Забанили ресурс по SharePoint
http://sharepoint.infoyen.com/
забанен по решению Россиского государства. Приехали.
http://sharepoint.infoyen.com/
забанен по решению Россиского государства. Приехали.
some SharePoint ideas
public class LinqToSPSecurity { public static void RunWithElevatedPriveledges(SPWeb web, Action<SPWeb> action) { Guid webId = web.ID; Guid siteId = web.Site.ID; HttpContext backupCtxt = HttpContext.Current; try { if (SPContext.Current != null) HttpContext.Current = null; SPSecurity.RunWithElevatedPrivileges(() => { using (SPSite elevatedSite = new SPSite(siteId)) { using (SPWeb elevatedWeb = elevatedSite.OpenWeb(webId)) { HttpRequest httpRequest = new HttpRequest("", elevatedWeb.Url, ""); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(new System.IO.StringWriter())); SPControl.SetContextWeb(HttpContext.Current, elevatedWeb); action(elevatedWeb); } } }); } finally { if (SPContext.Current != null) HttpContext.Current = backupCtxt; } } public static void RunWithElevatedPriveledges(Action<SPWeb> action) { RunWithElevatedPriveledges(SPContext.Current.Web, action); } }
/// <summary> /// Сохранение орг. звена /// </summary> /// <param name="orgUnit">Орг. звено</param> /// <param name="newchildren">Список идентификаторов добавляемых дочерних орг. единиц</param> /// <param name="deletechildren">Список идентификаторов удаляемых дочерних орг. единиц</param> /// <param name="newcustomers">Список идентификаторов добавляемых заказчиков</param> /// <param name="deletecustomers">Список идентификаторов удаляемых заказчиков</param> /// <param name="newemployees">Список идентификаторов добавляемых сотрудников</param> /// <param name="deleteemployees">Список идентификаторов удаляемых сотрудников</param> public void Save(OrgUnit orgUnit, List<int> newchildren, List<int> deletechildren, List<int> newcustomers, List<int> deletecustomers, List<int> newemployees, List<int> deleteemployees) { if (newchildren == null) newchildren = new List<int>(); if (newcustomers == null) newcustomers = new List<int>(); if (newemployees == null) newemployees = new List<int>(); if (deletechildren == null) deletechildren = new List<int>(); if (deletecustomers == null) deletecustomers = new List<int>(); if (deleteemployees == null) deleteemployees = new List<int>(); if (orgUnit.OrgUnitID == 0) // новая - создать { L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title); DataContext.OrgUnits.InsertOnSubmit(orgUnit); } foreach (int id in newemployees) { OUBind oldbins = App.DataContext.OUBinds.FirstOrDefault(b => b.EmployeeID == id && b.EndDate == null && b.BindType == 'M'); if (oldbins != null) oldbins.EndDate = DateTime.Now; oldbins = App.DataContext.OUBinds.FirstOrDefault(b => b.EmployeeID == id && b.EndDate == null && b.BindType == 'E'); if (oldbins != null) oldbins.EndDate = DateTime.Now; OUBind eou = new OUBind(); eou.OrgUnit = orgUnit; eou.EmployeeID = id; eou.BeginDate = DateTime.Now; eou.BindType = 'M'; App.DataContext.OUBinds.InsertOnSubmit(eou); if (App.DataContext.EmployeeRoles.Count(r => r.EmployeeID == id && r.RoleCode == RoleEnum.Employee.ToString()) == 0) { EmployeeRole er = new EmployeeRole { EmployeeID = id, RoleCode = RoleEnum.Employee.ToString() }; App.DataContext.EmployeeRoles.InsertOnSubmit(er); } } if (deleteemployees.Count > 0) { List<OUBind> eoudel = DataContext.OUBinds.Where( eou => deleteemployees.Contains(eou.EmployeeID) && eou.OrgUnitID == orgUnit.OrgUnitID).ToList(); foreach (var b in eoudel) b.EndDate = DateTime.Now; } if (orgUnit.BranchID == null) // сохранение филиалов { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.BranchID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID.HasValue && !ou.FuncDirectionID.HasValue && !ou.ActivityCategoryID.HasValue && !ou.RegionID.HasValue && !ou.DepartmentID.HasValue && !ou.GroupID.HasValue && deletechildren.Contains(ou.BranchID ?? 0) ).ToList(); foreach (var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } } else if (orgUnit.FuncDirectionID == null) // сохранение функциональных направлений { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.Branch = orgUnit.Branch; o.FuncDirectionID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID == orgUnit.BranchID && ou.FuncDirectionID.HasValue && !ou.ActivityCategoryID.HasValue && !ou.RegionID.HasValue && !ou.DepartmentID.HasValue && !ou.GroupID.HasValue && deletechildren.Contains(ou.FuncDirectionID ?? 0) ).ToList(); foreach (var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } } else if (orgUnit.ActivityCategoryID == null) // сохранение видов деятельности { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.Branch = orgUnit.Branch; o.FuncDirection = orgUnit.FuncDirection; o.ActivityCategoryID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID == orgUnit.BranchID && ou.FuncDirectionID == orgUnit.FuncDirectionID && ou.ActivityCategoryID.HasValue && !ou.RegionID.HasValue && !ou.DepartmentID.HasValue && !ou.GroupID.HasValue && deletechildren.Contains(ou.ActivityCategoryID ?? 0) ).ToList(); foreach (var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } } else if (orgUnit.RegionID == null) // сохранение регионов { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.Branch = orgUnit.Branch; o.FuncDirection = orgUnit.FuncDirection; o.ActivityCategory = orgUnit.ActivityCategory; o.RegionID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID == orgUnit.BranchID && ou.FuncDirectionID == orgUnit.FuncDirectionID && ou.ActivityCategoryID == orgUnit.ActivityCategoryID && ou.RegionID.HasValue && !ou.DepartmentID.HasValue && !ou.GroupID.HasValue && deletechildren.Contains(ou.RegionID ?? 0) ).ToList(); foreach (var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } foreach (int id in newcustomers) { CustomerOrgUnit cou = new CustomerOrgUnit(); cou.OrgUnitID = orgUnit.OrgUnitID; cou.CustomerID = id; DataContext.CustomerOrgUnits.InsertOnSubmit(cou); } if (deletecustomers.Count > 0) { List<CustomerOrgUnit> coudel = DataContext.CustomerOrgUnits.Where( cou => deletecustomers.Contains(cou.CustomerID) && cou.OrgUnitID == orgUnit.OrgUnitID).ToList(); DataContext.CustomerOrgUnits.DeleteAllOnSubmit(coudel); } } else if (orgUnit.DepartmentID == null) // сохранение отделов { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.Branch = orgUnit.Branch; o.FuncDirection = orgUnit.FuncDirection; o.ActivityCategory = orgUnit.ActivityCategory; o.Region = orgUnit.Region; o.DepartmentID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID == orgUnit.BranchID && ou.FuncDirectionID == orgUnit.FuncDirectionID && ou.ActivityCategoryID == orgUnit.ActivityCategoryID && ou.RegionID == orgUnit.RegionID && ou.DepartmentID.HasValue && !ou.GroupID.HasValue && deletechildren.Contains(ou.DepartmentID ?? 0) ).ToList(); foreach (var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } } else if (orgUnit.GroupID == null) // сохранение групп { foreach (int id in newchildren) { OrgUnit o = new OrgUnit(); o.Affiliation = orgUnit.Affiliation; o.Branch = orgUnit.Branch; o.FuncDirection = orgUnit.FuncDirection; o.ActivityCategory = orgUnit.ActivityCategory; o.Region = orgUnit.Region; o.Department = orgUnit.Department; o.GroupID = id; o.IsActive = true; L_UserActivityController.Write("Орг.звено", "Создание", orgUnit.Title + " / " + GetAdminUnit(id).Title); DataContext.OrgUnits.InsertOnSubmit(o); } if (deletechildren.Count > 0) { List<OrgUnit> oudel = DataContext.OrgUnits.Where(ou => ou.AffiliationID == orgUnit.AffiliationID && ou.BranchID == orgUnit.BranchID && ou.FuncDirectionID == orgUnit.FuncDirectionID && ou.ActivityCategoryID == orgUnit.ActivityCategoryID && ou.RegionID == orgUnit.RegionID && ou.DepartmentID == orgUnit.DepartmentID && ou.GroupID.HasValue && deletechildren.Contains(ou.GroupID ?? 0) ).ToList(); foreach(var ou in oudel) { L_UserActivityController.Write("Орг.звено", "Удаление", ou.Title); ou.IsActive = false; DeleteChild(ou); } } } DataContext.SubmitChanges(); RedirectTo<OrgUnitController>(c => c.Edit(orgUnit.OrgUnitID)); }
Пример двухмерного клеточного автомата из 6 состояний (0-5) и с начальным состоянием "1" в топ-центре сетки. Каждому состоянию ...