public string PostDelete([FromBody] XmDistributeModel data) { var rundata = QtXmDistributeService.Find(x => x.FProjcode == data.FProjcode).Data.ToList(); SavedResult <Int64> savedresult = new SavedResult <Int64>(); foreach (var a in rundata) { a.PersistentState = PersistentState.Deleted; } savedresult = QtXmDistributeService.Save <Int64>(rundata, ""); return(DataConverterHelper.SerializeObject(savedresult)); }
public string PostXmFF([FromBody] XmDistributeModel data) { var selectdata = QtXmDistributeService.Find(x => x.FProjcode == data.FProjcode).Data.ToList(); var orglist = new List <Int64>(); var rundata = new List <QtXmDistributeModel>(); if (selectdata != null && selectdata.Count > 0) { //既然能选到 数据库必有数据 var data1 = QtXmDistributeService.Find(x => x.FProjcode == data.FProjcode).Data.ToList(); orglist = (data1 != null && data1.Count > 0) ? data1.Select(x => x.Orgid).ToList() : new List <long>(); } var AddOrg = (data.EnableOrgList != null && data.EnableOrgList.Count > 0) ? data.EnableOrgList.Except(orglist).ToList():null; var deleteOrg = (data.EnableOrgList != null && data.EnableOrgList.Count > 0)?orglist.Except(data.EnableOrgList).ToList(): orglist; SavedResult <Int64> savedresult = new SavedResult <Int64>(); if (deleteOrg != null && deleteOrg.Count > 0) { rundata = QtXmDistributeService.Find(x => x.FProjcode == data.FProjcode && deleteOrg.Contains(x.Orgid)).Data.ToList(); foreach (var b in rundata) { b.PersistentState = PersistentState.Deleted; } } if (AddOrg != null && AddOrg.Count > 0) { var orglist1 = CorrespondenceSettingsService.GetOrgCodeList(AddOrg); foreach (var a in AddOrg) { QtXmDistributeModel model = new QtXmDistributeModel(); model.FProjcode = data.FProjcode; model.FProjname = data.FProjname; model.FBusiness = data.FBusiness; model.Orgid = a; model.Orgcode = orglist1.Find(x => x.PhId == a).OCode; model.Distributeorgid = data.orgid; model.Distributeuserid = data.userid; model.PersistentState = PersistentState.Added; rundata.Add(model); } } savedresult = QtXmDistributeService.Save <Int64>(rundata, ""); return(DataConverterHelper.SerializeObject(savedresult)); }
public string GetQtXmDistributeList([FromUri] long OrgPhid) { if (OrgPhid == 0) { return(DCHelper.ErrorMessage("组织ID为空!")); } List <XmDistributeModel> result = new List <XmDistributeModel>(); var syssets = QTSysSetService.Find(x => x.DicType == "Business" && x.Orgid == OrgPhid).Data.ToList(); //取有权限修改的 var data1 = QtXmDistributeService.Find(x => x.Distributeorgid == OrgPhid, "FProjcode").Data.ToList(); if (data1 != null && data1.Count > 0) { var data2 = new List <QtXmDistributeModel>(); var FProjcodeList1 = data1.Select(x => x.FProjcode).Distinct().ToList(); foreach (var code in FProjcodeList1) { data2 = data1.FindAll(x => x.FProjcode == code); XmDistributeModel a = new XmDistributeModel(); a.CanFF = true; a.FProjcode = code; a.FProjname = data2[0].FProjname; a.FBusiness = data2[0].FBusiness; if (!string.IsNullOrEmpty(a.FBusiness) && syssets != null) { if (syssets.Find(x => x.TypeCode == a.FBusiness) != null) { a.FBusiness_EXName = syssets.Find(x => x.TypeCode == a.FBusiness).TypeName; } } a.EnableOrgList = data2.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList(); if (a.EnableOrgList != null && a.EnableOrgList.Count > 0) { a.EnableOrgList2 = new List <object>(); foreach (var o in a.EnableOrgList) { var disabled = data2.Find(x => x.Orgid == o).Isactive == 0 ? false : true; a.EnableOrgList2.Add(new { phid = o, disabled = disabled }); } a.EnableOrgStr = CorrespondenceSettingsService.GetOrgStr(a.EnableOrgList); } if (data2.FindAll(x => x.Isactive == 1).Count > 0) { a.CanUpdate = false; } else { a.CanUpdate = true; } result.Add(a); } } //取没分发权限的 var data3 = QtXmDistributeService.Find(x => x.Distributeorgid != OrgPhid && x.Orgid == OrgPhid).Data.ToList(); if (data3 != null && data3.Count > 0) { var data4 = new List <QtXmDistributeModel>(); var FProjcodeList2 = data3.Select(x => x.FProjcode).Distinct().ToList(); foreach (var code in FProjcodeList2) { data4 = QtXmDistributeService.Find(x => x.FProjcode == code).Data.ToList(); XmDistributeModel b = new XmDistributeModel(); b.CanFF = false; b.FProjcode = code; b.FProjname = data4[0].FProjname; b.FBusiness = data4[0].FBusiness; if (!string.IsNullOrEmpty(b.FBusiness) && syssets != null) { if (syssets.Find(x => x.TypeCode == b.FBusiness) != null) { b.FBusiness_EXName = syssets.Find(x => x.TypeCode == b.FBusiness).TypeName; } } b.EnableOrgList = data4.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList(); if (b.EnableOrgList != null && b.EnableOrgList.Count > 0) { b.EnableOrgList2 = new List <object>(); foreach (var o in b.EnableOrgList) { var disabled = data4.Find(x => x.Orgid == o).Isactive == 0 ? false : true; b.EnableOrgList2.Add(new { phid = o, disabled = disabled }); } //b.EnableOrgList = data4.OrderBy(x => x.Orgcode).Select(x => x.Orgid).ToList(); b.EnableOrgStr = CorrespondenceSettingsService.GetOrgStr(b.EnableOrgList); } b.CanUpdate = false; result.Add(b); } } result = result.OrderBy(x => x.FProjcode).ToList(); return(DCHelper.ModelListToJson <XmDistributeModel>(result, (Int32)result.Count)); }