/// <summary> /// 保存组织架构到本地数据库 /// </summary> /// <param name="strUserID"></param> private void SaveOrganizationByLocal(string strUserID) { List <V_CompanyInfo> vLocalCompanys = new List <V_CompanyInfo>(); List <V_DepartmentInfo> vLocalDepartments = new List <V_DepartmentInfo>(); List <V_PostInfo> vLocalPosts = new List <V_PostInfo>(); foreach (var item in allCompanysView) { if (string.IsNullOrWhiteSpace(item.COMPANYID)) { continue; } V_CompanyInfo info = item.CloneObject <V_CompanyInfo>(new V_CompanyInfo()); info.UserModuleID = System.Guid.NewGuid().ToString(); info.UserID = strUserID; vLocalCompanys.Add(info); if (allDepartmentsView != null) { if (allDepartmentsView.Count() > 0) { foreach (var p in allDepartmentsView) { V_DepartmentInfo departmentInfo = item.CloneObject <V_DepartmentInfo>(new V_DepartmentInfo()); departmentInfo.UserModuleID = info.UserModuleID; departmentInfo.UserID = strUserID; vLocalDepartments.Add(departmentInfo); } } } if (allPostsView != null) { if (allPostsView.Count() > 0) { foreach (var d in allPostsView) { V_PostInfo postInfo = item.CloneObject <V_PostInfo>(new V_PostInfo()); postInfo.UserModuleID = info.UserModuleID; postInfo.UserID = strUserID; vLocalPosts.Add(postInfo); } } } } V_CompanyInfoVM.SaveV_CompanyInfo(strUserID, vLocalCompanys); V_DepartmentInfoVM.SaveV_DepartmentInfo(strUserID, vLocalDepartments); V_PostInfoVM.SaveV_PostInfo(strUserID, vLocalPosts); }
public static void DeleteSelectedV_DepartmentInfo(string strUserID, string strDepartmentID) { V_DepartmentInfo deleteV_DepartmentInfo = (from o in SterlingService.Current.Database.Query <V_DepartmentInfo, string>() where o.LazyValue.Value.UserID == strUserID && o.LazyValue.Value.DEPARTMENTID == strDepartmentID select o.LazyValue.Value).FirstOrDefault(); if (deleteV_DepartmentInfo != null) { SterlingService.Current.Database.Delete(deleteV_DepartmentInfo); SterlingService.Current.Database.Flush(); } GetAllV_DepartmentInfo(strUserID); }
public static void SaveV_DepartmentInfo(string strUserID, List <V_DepartmentInfo> ents) { V_DepartmentInfo newV_DepartmentInfo = new V_DepartmentInfo(); var tmps = (from o in SterlingService.Current.Database.Query <V_DepartmentInfo, string>() where o.LazyValue.Value.UserID == strUserID select o.LazyValue.Value).ToList(); if (tmps != null) { if (tmps.Count() > 0) { DeleteAllV_DepartmentInfo(strUserID); } } foreach (var o in ents) { SterlingService.Current.Database.Save(o); } SterlingService.Current.Database.Flush(); }