예제 #1
0
        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));
        }