/// <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_CompanyInfo(string strUserID, string strCompanyID) { V_CompanyInfo deleteV_CompanyInfo = (from o in SterlingService.Current.Database.Query <V_CompanyInfo, string>() where o.LazyValue.Value.UserID == strUserID && o.LazyValue.Value.COMPANYID == strCompanyID select o.LazyValue.Value).FirstOrDefault(); if (deleteV_CompanyInfo != null) { SterlingService.Current.Database.Delete(deleteV_CompanyInfo); SterlingService.Current.Database.Flush(); } GetAllV_CompanyInfo(strUserID); }
public static void SaveV_CompanyInfo(string strUserID, List <V_CompanyInfo> ents) { V_CompanyInfo newV_CompanyInfo = new V_CompanyInfo(); var tmps = (from o in SterlingService.Current.Database.Query <V_CompanyInfo, string>() where o.LazyValue.Value.UserID == strUserID select o.LazyValue.Value).ToList(); if (tmps != null) { if (tmps.Count() > 0) { DeleteAllV_CompanyInfo(strUserID); } } foreach (var o in ents) { SterlingService.Current.Database.Save(o); } SterlingService.Current.Database.Flush(); }