Beispiel #1
0
        public JsonResult AddChildWithDefAttr(string Children)
        {
            var    dic       = JsonHelper.ToObject(Children);
            string parentIDs = dic["ParentIDs"].ToString();
            string children  = dic["childNodes"].ToString();
            string type      = dic["Type"].ToString();
            var    list      = BaseConfigFO.GetWBSAttrList(type);

            foreach (var parentID in parentIDs.TrimEnd(',').Split(','))
            {
                var parent = this.GetEntityByID <S_D_WBSTemplateNode>(parentID);
                if (parent == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }
                foreach (var item in children.Split(','))
                {
                    var attrDefine = list.FirstOrDefault(d => d.Code == item);
                    if (attrDefine == null)
                    {
                        continue;
                    }
                    var wbs = new S_D_WBSTemplateNode();
                    wbs.WBSType   = dic["Type"].ToString();
                    wbs.Name      = attrDefine.Name;
                    wbs.SortIndex = attrDefine.SortIndex;
                    wbs.WBSValue  = item;
                    parent.AddChild(wbs);
                }
            }
            this.entities.SaveChanges();
            return(Json(""));
        }
Beispiel #2
0
        public ActionResult MajorList()
        {
            var projectInfoID = this.GetQueryString("ProjectInfoID");
            var projectInfo   = this.GetEntityByID <S_I_ProjectInfo>(projectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("找不到指定的项目信息,请确认ID为【" + projectInfoID + "】项目是否存在");
            }
            ViewBag.ProjectInfo   = JsonHelper.ToJson(projectInfo);
            ViewBag.ProjectInfoID = projectInfo.ID;
            ViewBag.SpaceCode     = this.GetQueryString("SpaceCode");
            ViewBag.AuthType      = this.GetQueryString("AuthType");
            ViewBag.FuncType      = this.GetQueryString("FuncType");
            ViewBag.FuncTitle     = "设计输入资料";
            ViewBag.FlowTitle     = "设计输入评审";
            var spaceCode = this.GetQueryString("SpaceCode");

            if (!String.IsNullOrEmpty(spaceCode))
            {
                var major = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major).FirstOrDefault(d => d.Code == spaceCode);
                if (major != null)
                {
                    ViewBag.FuncTitle = major.Name + "-设计输入资料";
                    ViewBag.FlowTitle = major.Name + "-设计输入评审";
                }
            }
            return(View());
        }
Beispiel #3
0
        public JsonResult AddChildWithDefAttr(string Children)
        {
            var    dic       = JsonHelper.ToObject(Children);
            string parentIDs = dic["ParentIDs"].ToString();
            string children  = string.Empty;

            if (dic.ContainsKey("childNodes"))
            {
                children = dic["childNodes"].ToString();
            }
            if (dic.ContainsKey("allChildNodes"))
            {
                children = dic["allChildNodes"].ToString();
            }
            string type   = dic["Type"].ToString();
            var    list   = BaseConfigFO.GetWBSAttrList(type);
            var    result = new List <S_W_WBS>();
            //EPCWBS信息
            var epcEntities = FormulaHelper.GetEntities <EPCEntities>();

            foreach (var parentID in parentIDs.TrimEnd(',').Split(','))
            {
                var parent = this.GetEntityByID <S_W_WBS>(parentID);
                if (parent == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }
                var epcParentWBSNode = epcEntities.Set <S_I_WBS>().Find(parentID);
                if (epcParentWBSNode == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }
                foreach (var item in children.Split(','))
                {
                    var attrDefine = list.FirstOrDefault(d => d.Code == item);
                    if (attrDefine == null)
                    {
                        continue;
                    }
                    var wbs = new S_W_WBS();
                    wbs.WBSType   = dic["Type"].ToString();
                    wbs.Name      = attrDefine.Name;
                    wbs.SortIndex = attrDefine.SortIndex;
                    wbs.WBSValue  = item;
                    result.Add(parent.AddChild(wbs));
                    var epcWBS = new S_I_WBS();
                    epcWBS.NodeType  = dic["Type"].ToString();
                    epcWBS.Name      = attrDefine.Name;
                    epcWBS.SortIndex = attrDefine.SortIndex;
                    epcWBS.Value     = item;
                    epcWBS.ID        = wbs.ID;
                    epcParentWBSNode.AddChild(epcWBS, true, true);
                }
            }
            this.entities.SaveChanges();
            epcEntities.SaveChanges();
            return(Json(result));
        }
Beispiel #4
0
        /// <summary>
        /// 设置出图信息
        /// </summary>
        public string SetPublishInfo()
        {
            var entities      = FormulaHelper.GetEntities <ProjectEntities>();
            var publishEntity = new S_E_PublishInfo();

            //publishEntity.A0 = this.A0;
            //publishEntity.A1 = this.A1;
            //publishEntity.A2 = this.A2;
            //publishEntity.A3 = this.A3;
            //publishEntity.A4 = this.A4;
            if (this.ApplyDate != null)
            {
                publishEntity.PublishDate = Convert.ToDateTime(this.ApplyDate);
            }
            if (publishEntity.PublishDate != null)
            {
                publishEntity.BelongYear    = publishEntity.PublishDate.Year;
                publishEntity.BelongMonth   = publishEntity.PublishDate.Month;
                publishEntity.BelongQuarter = (int)((publishEntity.PublishDate.Month - 1) / 3) + 1;
            }
            if (!string.IsNullOrEmpty(this.MajorCode))
            {
                var majors    = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);
                var majorAttr = majors.SingleOrDefault(d => d.Code == this.MajorCode);
                if (majorAttr == null)
                {
                    throw new Formula.Exceptions.BusinessException("【" + this.MajorCode + "】专业未定义,无法进行出图操作");
                }
                publishEntity.MajorValue = this.MajorCode;
                publishEntity.MajorName  = majorAttr.Name;
            }
            publishEntity.ProjectInfoCode = this.ProjectCode;
            publishEntity.ProjectInfoID   = this.ProjectInfoID;
            publishEntity.ProjectInfoName = this.ProjectName;
            //publishEntity.PublishType = this.FileType;
            publishEntity.RelateInfoID = this.ID;
            publishEntity.SummaryCost  = this.RealCostAmount;

            var a0 = publishEntity.A0.HasValue ? publishEntity.A0.Value : 0m;
            var a1 = publishEntity.A1.HasValue ? publishEntity.A1.Value : 0m;
            var a2 = publishEntity.A2.HasValue ? publishEntity.A2.Value : 0m;
            var a3 = publishEntity.A3.HasValue ? publishEntity.A3.Value : 0m;
            var a4 = publishEntity.A4.HasValue ? publishEntity.A4.Value : 0m;

            var toA1 = a0 * 2 + a1 + a2 * 0.5m + a3 * 0.25m + a4 * 0.125m;

            publishEntity.ToA1     = this.ToA1;
            publishEntity.UniPrice = this.Price;
            publishEntity.ID       = FormulaHelper.CreateGuid();
            entities.Set <S_E_PublishInfo>().Add(publishEntity);
            SetPublishInfoDetail(publishEntity.ID);
            return(publishEntity.ID);
        }
        public ActionResult MileStoneTrack()
        {
            var configentities  = FormulaHelper.GetEntities <BaseConfigEntities>();
            var ProjectModeCode = GetQueryString("ProjectModeCode");

            S_T_ProjectMode pm;

            if (string.IsNullOrEmpty(ProjectModeCode))
            {
                pm = configentities.Set <S_T_ProjectMode>().FirstOrDefault();
            }
            else
            {
                pm = BaseConfigFO.GetMode(ProjectModeCode);
            }
            if (pm == null)
            {
                throw new Formula.Exceptions.BusinessException("找不到编号为【" + ProjectModeCode + "】的项目模式");
            }

            ViewBag.ProjectMode = pm;

            var phaseInfo = pm.S_T_MileStone.Where(d => d.MileStoneType == MileStoneType.Normal.ToString())
                            .Select(d => d.PhaseValue).ToList();

            var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase).Where(d => phaseInfo.Count(c => c.Contains(d.Code)) > 0).
                            OrderBy(d => d.SortIndex).ToList();

            var MileStoneList = pm.S_T_MileStone.Where(d => d.MileStoneType == MileStoneType.Normal.ToString()).
                                OrderBy(d => d.SortIndex).ToList();

            ViewBag.MileStoneList = JsonHelper.ToJson(MileStoneList);
            var phaseArray = phaseList.Select(d => new { value = d.Code, text = d.Name }).ToList();

            ViewBag.PhaseArray = JsonHelper.ToJson(phaseArray);
            ViewBag.PhaseList  = JsonHelper.ToJson(phaseList);
            var defaultPhase = phaseList.FirstOrDefault();

            if (defaultPhase != null)
            {
                ViewBag.PhaseValue = defaultPhase.Code;
            }
            else
            {
                ViewBag.PhaseValue = "";
            }
            ViewBag.PhaseMultiSelect = true;
            if (this.GetQueryString("PhaseMultiSelect") == false.ToString().ToLower())
            {
                ViewBag.PhaseMultiSelect = false;
            }
            return(View());
        }
Beispiel #6
0
        public override JsonResult GetList(QueryBuilder qb)
        {
            string projectInfoID = this.Request["ProjectInfoID"];
            string sql           = @"select distinct UserID,UserName,RoleCode,RoleName,MajorValue from S_W_OBSUser  where ProjectInfoID='{0}'";

            qb.SortField = "UserName";
            var sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Project);

            if (!String.IsNullOrEmpty(this.GetQueryString("MajorValue")))
            {
                qb.Add("MajorValue", QueryMethod.Equal, this.GetQueryString("MajorValue"));
            }

            var dt   = sqlHelper.ExecuteDataTable(String.Format(sql, projectInfoID), (SearchCondition)qb);
            var data = (from DataRow vRow in dt.Rows
                        select new
            {
                UserID = vRow["UserID"].ToString(),
                UserName = vRow["UserName"].ToString(),
                MajorValue = vRow["MajorValue"].ToString()
            }).Distinct();
            var result       = new List <Dictionary <string, object> >();
            var majorDefList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);

            foreach (var user in data)
            {
                var item = new Dictionary <string, object>();
                item.SetValue("UserID", user.UserID);
                item.SetValue("UserName", user.UserName);
                if (!string.IsNullOrEmpty(user.MajorValue))
                {
                    item.SetValue("MajorValue", user.MajorValue);
                    var major = majorDefList.FirstOrDefault(d => d.Code == user.MajorValue);
                    if (major != null)
                    {
                        item.SetValue("MajorName", major.Name);
                    }
                }
                var    roleRows = dt.Select("UserID='" + user.UserID + "' and MajorValue='" + user.MajorValue + "'");
                string roleCodes = string.Empty; string roleNames = string.Empty;
                foreach (var roleRow in roleRows)
                {
                    roleCodes += roleRow["RoleCode"].ToString() + ",";
                    roleNames += roleRow["RoleName"].ToString() + ",";
                }
                item.SetValue("RoleCode", roleCodes.TrimEnd(','));
                item.SetValue("RoleName", roleNames.TrimEnd(','));
                result.Add(item);
            }
            return(Json(result));
        }
Beispiel #7
0
        /// <summary>
        /// 同步错误信息
        /// </summary>
        public void SynchMistake()
        {
            var projectEntities = this.GetDbContext <ProjectEntities>();
            var mistakes        = this.T_EXE_Audit_AdviceDetail;
            var majorEnum       = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major).ToList().FirstOrDefault(d => d.Code == this.MajorCode);
            var projectInfo     = projectEntities.S_I_ProjectInfo.Find(this.ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("");
            }
            if (mistakes != null && mistakes.Count() > 0)
            {
                foreach (var mistake in mistakes)
                {
                    var entity = projectEntities.Set <S_AE_Mistake>().Create();
                    if (string.IsNullOrEmpty(entity.ID))
                    {
                        entity.ID = FormulaHelper.CreateGuid();
                    }
                    entity.ProjectInfoID     = this.ProjectInfoID;
                    entity.AuditID           = this.ID;
                    entity.MistakeContent    = mistake.MsitakeContent;
                    entity.AuditActivityType = mistake.Step;
                    entity.MistakeLevel      = mistake.MistakeType;
                    if (mistake.MistakeType == "" || mistake.MistakeType == null)
                    {
                        entity.MistakeLevel = "OtherForNull";
                    }
                    entity.MajorCode = this.MajorCode;
                    if (majorEnum != null)
                    {
                        entity.MajorName = majorEnum.Name;
                    }
                    entity.DesignerID    = this.Designer;
                    entity.Designer      = this.DesignerName;
                    entity.CreateUserID  = mistake.CreateUser;
                    entity.CreateUser    = mistake.CreateUserName;
                    entity.CreateDate    = mistake.CreateDate == null ? DateTime.Now : Convert.ToDateTime(mistake.CreateDate);
                    entity.MistakeYear   = mistake.CreateDate.Value.Year;
                    entity.MistakeMonth  = mistake.CreateDate.Value.Month;
                    entity.MistakeSeason = (mistake.CreateDate.Value.Month + 2) / 3;
                    entity.Measure       = mistake.ResponseContent;
                    entity.DrawingNO     = mistake.ProductCode;
                    entity.DeptID        = projectInfo.ChargeDeptID;
                    entity.DeptName      = projectInfo.ChargeDeptName;
                    //图号等信息
                    projectEntities.Set <S_AE_Mistake>().Add(entity);
                }
            }
        }
Beispiel #8
0
        public ActionResult WBSAdd()
        {
            string childType = this.Request["Type"];

            if (String.IsNullOrEmpty(childType))
            {
                throw new Formula.Exceptions.BusinessException("未指定需要增加的WBS节点类型,无法增加节点");
            }
            var list = BaseConfigFO.GetWBSAttrList(childType);

            if (list.Count > 0)
            {
                this.ViewBag.IsAttrDefine = true.ToString();
            }
            else
            {
                this.ViewBag.IsAttrDefine = false.ToString();
            }
            return(this.View());
        }
Beispiel #9
0
        public JsonResult GetMenu(string ID)
        {
            var wbs = this.GetEntityByID <S_D_WBSTemplateNode>(ID);

            if (wbs == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + ID + "】的WBS对象");
            }
            if (wbs.StructNodeInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("WBS节点未定义类别,无法显示菜单");
            }
            var childNodeCodes = wbs.StructNodeInfo.ChildCode.Split(',');
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();

            foreach (var item in childNodeCodes)
            {
                var menuItem = new Dictionary <string, object>();
                var name     = EnumBaseHelper.GetEnumDescription(typeof(WBSNodeType), item);

                menuItem["name"]    = item;
                menuItem["text"]    = "增加" + name;
                menuItem["iconCls"] = "icon-add";
                menuItem["onClick"] = "addNode";
                var attrDefineList = BaseConfigFO.GetWBSAttrList(item);
                if (attrDefineList.Count > 0)
                {
                    menuItem["attrDefine"] = "true";
                }
                else
                {
                    menuItem["attrDefine"] = "false";
                }
                result.Add(menuItem);
            }
            string json = JsonHelper.ToJson(result);

            return(Json(result));
        }
Beispiel #10
0
        private S_I_ProjectInfo AddProject(T_CP_TaskNotice entity, S_I_Engineering engineering, T_CP_TaskNotice_PhaseDetail singlePhase = null)
        {
            var marketEntities = FormulaHelper.GetEntities <Market.Logic.Domain.MarketEntities>();

            S_I_ProjectInfo projectInfo = entity.Push();

            projectInfo.ModifyDate   = projectInfo.CreateDate;
            projectInfo.ModifyUser   = projectInfo.CreateUser;
            projectInfo.ModifyUserID = projectInfo.CreateUserID;

            //重新修改phaseValue、phaseName、Name、Code等信息
            if (singlePhase != null)
            {
                projectInfo.PhaseValue        = singlePhase.Phase;
                projectInfo.WBSRoot.PhaseCode = singlePhase.Phase;
                var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
                var phaseItem = phaseList.FirstOrDefault(d => projectInfo.PhaseValue == d.Code);
                projectInfo.PhaseName      = phaseItem.Name;
                projectInfo.Name           = singlePhase.Name;
                projectInfo.Code           = singlePhase.Code;
                projectInfo.ChargeDeptID   = singlePhase.ChargeDept ?? entity.ChargeDept;
                projectInfo.ChargeDeptName = singlePhase.ChargeDeptName ?? entity.ChargeDeptName;
                projectInfo.ChargeUserID   = singlePhase.ChargeUser ?? entity.ChargeUser;
                projectInfo.ChargeUserName = singlePhase.ChargeUserName ?? entity.ChargeUserName;
                projectInfo.OtherDeptID    = singlePhase.OtherDept ?? entity.OtherDept;
                projectInfo.OtherDeptName  = singlePhase.OtherDeptName ?? entity.OtherDeptName;
                projectInfo.PlanStartDate  = singlePhase.PlanStartDate ?? entity.PlanStartDate;
                projectInfo.PlanFinishDate = singlePhase.PlanFinishDate ?? entity.PlanFinishDate;
            }

            projectInfo.ModifyDate   = projectInfo.CreateDate;
            projectInfo.ModifyUser   = projectInfo.CreateUser;
            projectInfo.ModifyUserID = projectInfo.CreateUserID;
            #region  步创建经营库的项目信息
            S_I_Project project    = null;
            var         marketClue = marketEntities.S_P_MarketClue.Find(entity.RelateID);
            project = marketEntities.S_I_Project.FirstOrDefault(d => d.TasKNoticeID == entity.ID);
            if (project != null)
            {
                throw new Formula.Exceptions.BusinessException("任务单已经下达过项目,无法重复下达");
            }
            project                    = new S_I_Project();
            project.ID                 = projectInfo.ID;
            project.TasKNoticeID       = entity.ID;
            project.TasKNoticeTmplCode = entity.TmplCode;
            project.Name               = projectInfo.Name;
            project.Code               = projectInfo.Code;
            project.Phase              = projectInfo.PhaseValue;
            project.ProjectClass       = projectInfo.ProjectClass;
            project.Customer           = projectInfo.CustomerID;
            project.CustomerName       = projectInfo.CustomerName;
            project.CreateDate         = DateTime.Now;
            project.EngineeringInfo    = entity.EngineeringID;
            project.ChargerDept        = projectInfo.ChargeDeptID;
            project.ChargerDeptName    = projectInfo.ChargeDeptName;
            project.ChargerUser        = projectInfo.ChargeUserID;
            project.ChargerUserName    = projectInfo.ChargeUserName;
            project.Country            = projectInfo.Country;
            project.Province           = projectInfo.Province;
            project.Area               = projectInfo.Area;
            project.City               = projectInfo.City;
            project.State              = projectInfo.State;
            project.ProjectScale       = entity.ProjectLevel;
            if (marketClue != null)
            {
                project.MakertClueID = marketClue.ID;
                marketClue.State     = Market.Logic.ClueState.Succeed.ToString();
            }
            marketEntities.S_I_Project.Add(project);
            entity.MarketProjectID = project.ID;
            #endregion

            #region  步绑定合同

            if (!String.IsNullOrEmpty(entity.ContractInfo))
            {
                var contract = marketEntities.Set <S_C_ManageContract>().Include("S_C_ManageContract_ProjectRelation")
                               .Include("S_C_ManageContract_ReceiptObj").FirstOrDefault(d => d.ID == entity.ContractInfo);
                if (contract != null)
                {
                    var relation = contract.S_C_ManageContract_ProjectRelation.FirstOrDefault(a => a.ProjectID == project.ID);
                    if (relation == null)
                    {
                        relation                      = new S_C_ManageContract_ProjectRelation();
                        relation.ID                   = FormulaHelper.CreateGuid();
                        relation.ProjectID            = project.ID;
                        relation.S_C_ManageContractID = contract.ID;
                        relation.ProjectCode          = project.Code;
                        relation.ProjectName          = project.Name;
                        if (contract.S_C_ManageContract_ProjectRelation.Count == 0)
                        {
                            if (entity.ContractValue.HasValue && contract.ContractRMBAmount > 0)
                            {
                                if (contract.ContractRMBAmount > 0)
                                {
                                    relation.Scale = entity.ContractValue.Value / contract.ContractRMBAmount * 100;
                                }
                                else
                                {
                                    relation.Scale = 0;
                                }
                                relation.ProjectValue = entity.ContractValue;
                                relation.TaxRate      = contract.TaxRate;
                                relation.TaxValue     = relation.ProjectValue / (1 + contract.TaxRate) * contract.TaxRate;
                                relation.ClearValue   = relation.ProjectValue - relation.TaxValue;
                            }
                            else
                            {
                                relation.Scale        = 100;
                                relation.ProjectValue = contract.ContractRMBAmount;
                                var taxRate    = contract.TaxRate.HasValue ? contract.TaxRate.Value : 0;
                                var taxValue   = contract.ContractRMBAmount / (1 + taxRate) * taxRate;
                                var clearVlaue = contract.ContractRMBAmount - taxValue;
                                relation.TaxRate    = taxRate;
                                relation.TaxValue   = taxValue;
                                relation.ClearValue = contract.ContractRMBAmount - taxValue;
                            }
                            foreach (var item in contract.S_C_ManageContract_ReceiptObj.ToList())
                            {
                                item.ProjectInfo     = project.ID;
                                item.ProjectInfoName = project.Name;
                                relation.TaxRate     = contract.TaxRate;
                            }
                        }
                        else
                        {
                            if (entity.ContractValue.HasValue && contract.ContractRMBAmount > 0)
                            {
                                if (contract.ContractRMBAmount > 0)
                                {
                                    relation.Scale = entity.ContractValue.Value / contract.ContractRMBAmount * 100;
                                }
                                else
                                {
                                    relation.Scale = 0;
                                }
                                relation.ProjectValue = entity.ContractValue;
                                relation.TaxRate      = contract.TaxRate;
                                relation.TaxValue     = relation.ProjectValue / (1 + contract.TaxRate) * contract.TaxRate;
                                relation.ClearValue   = relation.ProjectValue - relation.TaxValue;
                            }
                            else
                            {
                                relation.Scale        = 0;
                                relation.ProjectValue = 0;
                                relation.TaxRate      = contract.TaxRate;
                            }
                        }
                        contract.S_C_ManageContract_ProjectRelation.Add(relation);
                        if (String.IsNullOrEmpty(contract.EngineeringInfo) && engineering != null)
                        {
                            contract.EngineeringInfo     = engineering.ID;
                            contract.EngineeringInfoName = engineering.Name;
                        }
                    }
                }
            }
            else
            {
                var contractList = marketEntities.Set <S_C_ManageContract>().Include("S_C_ManageContract_ProjectRelation")
                                   .Include("S_C_ManageContract_ReceiptObj").Where(d => d.EngineeringInfo == entity.EngineeringID).ToList();
                foreach (var contract in contractList)
                {
                    var relation = contract.S_C_ManageContract_ProjectRelation.FirstOrDefault(a => a.ProjectID == project.ID);
                    if (relation == null)
                    {
                        relation                      = new S_C_ManageContract_ProjectRelation();
                        relation.ID                   = FormulaHelper.CreateGuid();
                        relation.ProjectID            = project.ID;
                        relation.S_C_ManageContractID = contract.ID;
                        relation.ProjectCode          = project.Code;
                        relation.ProjectName          = project.Name;
                        if (contract.S_C_ManageContract_ProjectRelation.Count == 0)
                        {
                            relation.Scale        = 100;
                            relation.ProjectValue = contract.ContractRMBAmount;
                            foreach (var item in contract.S_C_ManageContract_ReceiptObj.ToList())
                            {
                                item.ProjectInfo     = project.ID;
                                item.ProjectInfoName = project.Name;
                            }
                        }
                        else
                        {
                            relation.Scale        = 0;
                            relation.ProjectValue = 0;
                        }
                        contract.S_C_ManageContract_ProjectRelation.Add(relation);
                    }
                }
            }


            #endregion

            projectInfo.MarketProjectInfoID = project.ID;

            #region 默认创建EPS结构
            var group = this.BusinessEntities.Set <S_I_ProjectGroup>().FirstOrDefault(d => d.RelateID == entity.EngineeringID && d.Type == "Engineering");
            if (group == null)
            {
                group                      = new S_I_ProjectGroup();
                group.ID                   = Formula.FormulaHelper.CreateGuid();
                group.Name                 = engineering.Name;
                group.Code                 = engineering.Code;
                group.City                 = engineering.City;
                group.Country              = engineering.Country;
                group.Province             = engineering.Province;
                group.Area                 = engineering.Area;
                group.ProjectClass         = engineering.Class;
                group.Investment           = engineering.Investment;
                group.Proportion           = engineering.Proportion;
                group.PhaseContent         = engineering.PhaseContent;
                group.Address              = engineering.Address;
                group.DeptID               = engineering.MainDept;
                group.DeptName             = engineering.MainDeptName;
                group.RelateID             = engineering.ID;
                group.EngineeringSpaceCode = ProjectMode.Standard.ToString();
                group.CreateDate           = DateTime.Now;
                var fo = Formula.FormulaHelper.CreateFO <EPSFO>();
                fo.BuildEngineering(group);
            }
            group.BindingProject(projectInfo);
            entity.GroupID     = group.ID;
            group.PhaseContent = engineering.PhaseContent;
            group.PhaseValue   = engineering.PhaseValue;
            #endregion

            projectInfo.InitDeisgnInputTemplate(true);

            //把设总放进RBS中
            if (projectInfo != null && !string.IsNullOrEmpty(entity.DesignManager))
            {
                projectInfo.WBSRoot.SetUsers(ProjectRole.DesignManager.ToString(), entity.DesignManager.Split(','), true, true, true, true);
            }

            var customer = marketEntities.Set <S_F_Customer>().FirstOrDefault(a => a.ID == entity.Customer);
            if (customer != null)
            {
                if (string.IsNullOrEmpty(entity.Country))
                {
                    project.Country     = customer.Country;
                    projectInfo.Country = customer.Country;
                }
                if (string.IsNullOrEmpty(entity.Province))
                {
                    project.Province     = customer.Province;
                    projectInfo.Province = customer.Province;
                }
                if (string.IsNullOrEmpty(entity.City))
                {
                    project.City     = customer.City;
                    projectInfo.City = customer.City;
                }
                if (string.IsNullOrEmpty(entity.Area))
                {
                    project.Area     = customer.Area;
                    projectInfo.Area = customer.Area;
                }
            }

            return(projectInfo);
        }
Beispiel #11
0
        protected override void OnFlowEnd(T_CP_TaskNotice entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity == null)
            {
                throw new Formula.Exceptions.BusinessException("没有找到指定的任务单,立项失败");
            }
            var marketEntities = FormulaHelper.GetEntities <Market.Logic.Domain.MarketEntities>();

            var projectList = new List <S_I_ProjectInfo>();

            if (!String.IsNullOrEmpty(entity.ProjectInfoID) &&
                this.BusinessEntities.Set <S_I_ProjectInfo>().Any(a => a.ID == entity.ProjectInfoID))
            {
                #region 任务单升版
                S_I_ProjectInfo projectInfo = null;
                S_I_Project     project     = null;
                projectInfo             = entity.UpGrade();
                project                 = marketEntities.S_I_Project.FirstOrDefault(d => d.ID == projectInfo.MarketProjectInfoID);
                project.Name            = entity.ProjectInfo;
                project.Code            = entity.SerialNumber;
                project.Phase           = entity.Phase;
                project.ProjectClass    = entity.ProjectClass;
                project.Customer        = entity.Customer;
                project.CustomerName    = entity.CustomerName;
                project.CreateDate      = DateTime.Now;
                project.EngineeringInfo = entity.EngineeringID;
                project.ChargerDept     = string.IsNullOrEmpty(entity.ChargeDept) ? entity.DesignDept : entity.ChargeDept;
                project.ChargerDeptName = string.IsNullOrEmpty(entity.ChargeDeptName) ? entity.DesignDeptName : entity.ChargeDeptName;
                project.ChargerUser     = entity.ChargeUser;
                project.ChargerUserName = entity.ChargeUserName;
                project.Country         = entity.Country;
                project.Province        = entity.Province;
                project.Area            = entity.Area;

                if (string.IsNullOrEmpty(project.Area))
                {
                    //获取省份对应的地区(SubCategory)
                    var enumItem = EnumBaseHelper.GetEnumDef("System.Province").EnumItem.FirstOrDefault(a => a.Code == entity.Province);
                    if (enumItem != null)
                    {
                        project.Area = enumItem.SubCategory;
                    }
                }
                project.City             = entity.City;
                project.ProjectScale     = entity.ProjectLevel;
                projectInfo.ModifyDate   = DateTime.Now;
                projectInfo.ModifyUser   = entity.CreateUser;
                projectInfo.ModifyUserID = entity.CreateUserID;

                //修改经营库项目名称冗余字段
                if (!string.IsNullOrEmpty(projectInfo.MarketProjectInfoID))
                {
                    if (entity.ContractValue.HasValue && String.IsNullOrEmpty(entity.ContractInfo))
                    {
                        marketEntities.S_C_ManageContract_ProjectRelation.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID &&
                                                                                a.S_C_ManageContractID == entity.ContractInfo).Update(a => a.ProjectValue = entity.ContractValue);
                    }
                    marketEntities.S_C_ManageContract_ProjectRelation.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName  = entity.ProjectInfo);
                    marketEntities.S_C_ManageContract_ReceiptObj.Where(a => a.ProjectInfo == projectInfo.MarketProjectInfoID).Update(a => a.ProjectInfoName = entity.ProjectInfo);
                    marketEntities.S_C_PlanReceipt.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName             = entity.ProjectInfo);
                    marketEntities.S_FC_CostInfo.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName               = entity.ProjectInfo);
                    marketEntities.S_SP_SupplierContract.Where(a => a.ProjectInfo == projectInfo.MarketProjectInfoID).Update(a => a.ProjectInfoName = entity.ProjectInfo);
                }
                projectList.Add(projectInfo);
                #endregion
            }
            else
            {
                #region 新建任务单立项

                #region 如果工程信息为空,则默认创建工程
                var  engineering = marketEntities.S_I_Engineering.Find(entity.EngineeringID);
                bool newEngineer = false;
                if (engineering == null)
                {
                    engineering    = new S_I_Engineering();
                    engineering.ID = FormulaHelper.CreateGuid();
                    marketEntities.S_I_Engineering.Add(engineering);
                    newEngineer = true;
                }
                engineering.Name = String.IsNullOrEmpty(entity.EngineeringName) ? entity.ProjectInfo : entity.EngineeringName;
                if (!String.IsNullOrEmpty(entity.Customer))
                {
                    engineering.CustomerInfo     = entity.Customer;
                    engineering.CustomerInfoName = entity.CustomerName;
                }
                engineering.Code = String.IsNullOrEmpty(entity.EngineeringCode) ? entity.SerialNumber : entity.EngineeringCode;
                if (!string.IsNullOrEmpty(entity.MainDeptInfo))
                {
                    engineering.MainDept     = entity.MainDeptInfo;
                    engineering.MainDeptName = entity.MainDeptInfoName;
                }
                else if (string.IsNullOrEmpty(engineering.MainDept))
                {
                    engineering.MainDept     = entity.ChargeDept;
                    engineering.MainDeptName = entity.ChargeDeptName;
                }
                engineering.OtherDept       = String.IsNullOrEmpty(entity.EngineeringOtherDept) ? entity.OtherDept : entity.EngineeringOtherDept;
                engineering.OtherDeptName   = String.IsNullOrEmpty(entity.EngineeringOtherDeptName) ? entity.OtherDeptName : entity.EngineeringOtherDeptName;
                engineering.ChargerUser     = String.IsNullOrEmpty(entity.EngineeringChargeUser) ? entity.ChargeUser : entity.EngineeringChargeUser;
                engineering.ChargerUserName = String.IsNullOrEmpty(entity.EngineeringChargeUserName) ? entity.ChargeUserName : entity.EngineeringChargeUserName;
                engineering.Country         = entity.Country;
                engineering.Province        = entity.Province;
                engineering.City            = entity.City;
                engineering.Area            = entity.Area;
                engineering.Proportion      = entity.BuildArea;
                engineering.Address         = entity.BuildAddress;
                engineering.LandingArea     = entity.LandArea;
                engineering.CreateDate      = DateTime.Now;
                if (!String.IsNullOrEmpty(entity.Investment))
                {
                    engineering.Investment = Convert.ToDecimal(entity.Investment);
                }
                if (newEngineer)
                {
                    entity.EngineeringID             = engineering.ID;
                    entity.EngineeringName           = engineering.Name;
                    entity.EngineeringCode           = engineering.Code;
                    entity.EngineeringChargeUser     = engineering.ChargerUser;
                    entity.EngineeringChargeUserName = engineering.ChargerUserName;
                    entity.MainDeptInfo             = engineering.MainDept;
                    entity.MainDeptInfoName         = engineering.MainDeptName;
                    entity.EngineeringOtherDept     = engineering.OtherDept;
                    entity.EngineeringOtherDeptName = engineering.OtherDeptName;
                }

                var phaseName       = "";
                var phaseList       = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
                var entityPhaseList = phaseList.Where(d => entity.Phase.Contains(d.Code)).ToList();
                foreach (var item in entityPhaseList)
                {
                    phaseName += item.Name + ",";
                }
                engineering.PhaseContent = phaseName.TrimEnd(',');
                engineering.PhaseValue   = entity.Phase;
                #endregion

                if (!string.IsNullOrEmpty(entity.MultiProjMode) && entity.MultiProjMode.ToLower() == "1")
                {
                    var list = entity.Phase.Split(',');
                    if (list.Length == 0)
                    {
                        throw new Formula.Exceptions.BusinessException("没有指定阶段");
                    }

                    string projIds = "";
                    foreach (var item in entity.T_CP_TaskNotice_PhaseDetail)
                    {
                        var prj = AddProject(entity, engineering, item);
                        projIds           += prj.ID + ",";
                        item.ProjectInfoID = prj.ID;
                        projectList.Add(prj);
                    }
                    entity.ProjectInfoID = projIds.TrimEnd(',');
                }
                else
                {
                    var prj = AddProject(entity, engineering);
                    projectList.Add(prj);
                }

                #endregion
            }

            this.BusinessEntities.SaveChanges();
            marketEntities.SaveChanges();


            #region 自动同步核算项目
            Expenses.Logic.CBSInfoFO.SynCBSInfo(FormulaHelper.ModelToDic <T_CP_TaskNotice>(entity), Expenses.Logic.SetCBSOpportunity.TaskNoticeComplete);
            #endregion
        }
Beispiel #12
0
        public JsonResult GetMenu(string ID, string ShowDeleteBtn)
        {
            var wbs = this.GetEntityByID <S_W_WBS>(ID);

            if (wbs == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + ID + "】的WBS对象");
            }
            if (wbs.StructNodeInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("WBS节点未定义类别,无法显示菜单");
            }
            var structList     = wbs.StructNodeInfo.S_T_ProjectMode.S_T_WBSStructInfo.ToList();
            var childNodeCodes = wbs.StructNodeInfo.ChildCode.Split(',');
            List <Dictionary <string, object> > result = new List <Dictionary <string, object> >();
            var majorStruct          = structList.FirstOrDefault(c => c.Code == WBSNodeType.Major.ToString());
            var canAddChildNodeCodes = "";

            setChildNodeCodes(structList, majorStruct, ref canAddChildNodeCodes);

            foreach (var item in childNodeCodes)
            {
                if (!canAddChildNodeCodes.Split(',').Contains(item))
                {
                    continue;
                }
                var menuItem = new Dictionary <string, object>();
                if (String.IsNullOrEmpty(item))
                {
                    continue;
                }
                var childStructNode = structList.FirstOrDefault(c => c.Code == item);
                if (childStructNode == null)
                {
                    continue;
                }
                var name = childStructNode.Name;
                menuItem["name"]    = item;
                menuItem["text"]    = "增加" + name;
                menuItem["iconCls"] = "icon-add";
                menuItem["onClick"] = "addNode";
                var attrDefineList = BaseConfigFO.GetWBSAttrList(item);
                if (attrDefineList.Count > 0)
                {
                    menuItem["attrDefine"] = "true";
                }
                else
                {
                    menuItem["attrDefine"] = "false";
                }
                result.Add(menuItem);
            }
            if (canAddChildNodeCodes.Split(',').Contains(WBSNodeType.Work.ToString()) ||
                canAddChildNodeCodes.Split(',').Contains(WBSNodeType.CooperationPackage.ToString()))
            {
                var menuItem = new Dictionary <string, object>();
                menuItem["name"]    = "importPackage";
                menuItem["text"]    = "从工作包词典导入";
                menuItem["iconCls"] = "icon-add";
                menuItem["onClick"] = "importPackage";
            }
            if (wbs.WBSType == WBSNodeType.CooperationPackage.ToString())
            {
                var relateItem = new Dictionary <string, object>();
                relateItem["name"]    = "relateMileStone";
                relateItem["text"]    = "关联计划";
                relateItem["iconCls"] = "icon-edit";
                relateItem["onClick"] = "relateMileStone";
                result.Add(relateItem);
            }
            if (wbs.WBSType != WBSNodeType.Project.ToString() && canAddChildNodeCodes.Split(',').Contains(wbs.StructNodeInfo.Code) &&
                ShowDeleteBtn.ToLower() != false.ToString().ToLower())
            {
                var delItem = new Dictionary <string, object>();
                delItem["name"]    = "delete";
                delItem["text"]    = "删除";
                delItem["iconCls"] = "icon-remove";
                delItem["onClick"] = "delWBS";
                result.Add(delItem);
            }

            string json = JsonHelper.ToJson(result);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public void Push(Dictionary <string, string> dic)
        {
            var projectEntities = FormulaHelper.GetEntities <ProjectEntities>();
            var projectInfo     = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息");
            }
            var rootWBS = projectInfo.WBSRoot;

            if (rootWBS == null)
            {
                throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。");
            }
            if (!String.IsNullOrEmpty(this.Code))
            {
                projectInfo.Code = this.Code;
            }

            if (this.PlanStartDate.HasValue)
            {
                projectInfo.PlanStartDate = this.PlanStartDate;
            }
            if (this.PlanFinishDate.HasValue)
            {
                projectInfo.PlanFinishDate = this.PlanFinishDate;
            }

            this.SynchRBSUser(dic);
            var selectMajorList = this.Major.Split(',');

            #region 更新预留工时、管理工时CBS
            var cbsRoot      = projectInfo.CBSRoot;
            var nodeType     = CBSNodeType.Category.ToString();
            var categoryType = CBSCategoryType.Reserve.ToString();
            var enums        = EnumBaseHelper.GetEnumDef(typeof(CBSCategoryType));
            //预留工时
            var reserveCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType);
            if (reserveCBS == null)
            {
                reserveCBS              = new S_C_CBS();
                reserveCBS.Name         = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name;
                reserveCBS.Code         = categoryType;
                reserveCBS.NodeType     = nodeType;
                reserveCBS.CBSType      = CBSType.LabourExpense.ToString();
                reserveCBS.SortIndex    = 0;
                reserveCBS.CreateUserID = this.CreateUserID;
                reserveCBS.CreateUser   = this.CreateUser;
                cbsRoot.AddChild(reserveCBS);
            }
            reserveCBS.Quantity   = this.ReserveWorkload ?? 0;
            reserveCBS.TotalPrice = reserveCBS.Quantity.Value * reserveCBS.UnitPrice.Value;
            //管理工时
            categoryType = CBSCategoryType.Manage.ToString();
            var manageCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType);
            if (manageCBS == null)
            {
                manageCBS              = new S_C_CBS();
                manageCBS.Name         = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name;
                manageCBS.Code         = categoryType;
                manageCBS.NodeType     = nodeType;
                manageCBS.CBSType      = CBSType.LabourExpense.ToString();
                manageCBS.SortIndex    = 1;
                manageCBS.CreateUserID = this.CreateUserID;
                manageCBS.CreateUser   = this.CreateUser;
                cbsRoot.AddChild(manageCBS);
            }
            //删除不存在的
            var subManageWorkloadList = this.T_SC_ElectricalPowerProjectScheme_ManageWorkloadList.ToList();
            var removeManageList      = manageCBS.Children.Where(d => !subManageWorkloadList.Select(a => a.Item).Contains(d.Code)).ToList();
            foreach (var item in removeManageList)
            {
                item.Delete();
            }
            foreach (var item in subManageWorkloadList)
            {
                var _mcbs = manageCBS.Children.FirstOrDefault(a => a.Code == item.Item);
                if (_mcbs == null)
                {
                    _mcbs              = new S_C_CBS();
                    _mcbs.Name         = item.ItemName;
                    _mcbs.Code         = item.Item;
                    _mcbs.NodeType     = CBSNodeType.CBS.ToString();
                    _mcbs.CBSType      = CBSType.LabourExpense.ToString();
                    _mcbs.SortIndex    = item.SortIndex;
                    _mcbs.CreateUserID = this.CreateUserID;
                    _mcbs.CreateUser   = this.CreateUser;
                    manageCBS.AddChild(_mcbs);
                }
                else
                {
                    _mcbs.ModifyUserID = this.CreateUserID;
                    _mcbs.ModifyUser   = this.CreateUser;
                    _mcbs.ModifyDate   = DateTime.Now;
                }
                _mcbs.Quantity   = item.ManageWorkload ?? 0;
                _mcbs.TotalPrice = _mcbs.Quantity.Value * _mcbs.UnitPrice.Value;
            }
            manageCBS.SummayQuantity();
            #endregion

            var ProjectTaskWorkList = new List <S_W_TaskWork>();
            var DetailTaskWorkList  = this.T_SC_ElectricalPowerProjectScheme_TaskWorkList.ToList();
            #region  除卷册
            if (!string.IsNullOrEmpty(this.TaskWorkList))
            {
                var selectids = DetailTaskWorkList.Select(a => a.TaskWorkID).ToList();
                ProjectTaskWorkList = projectEntities.Set <S_W_TaskWork>().Where(a => a.ProjectInfoID == projectInfo.ID).ToList();
                var deleteList = ProjectTaskWorkList.Where(a => !selectids.Contains(a.ID)).ToList();
                foreach (var item in deleteList)
                {
                    item.Delete();
                    ProjectTaskWorkList.Remove(item);
                }
            }
            #endregion

            #region 回写专业信息,专业工时CBS
            //移除未选中的专业
            var removeMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString() &&
                                                            !selectMajorList.Contains(d.WBSValue)).ToList();
            foreach (var item in removeMajorList)
            {
                item.Delete();
            }

            #region 专业工时

            categoryType = CBSCategoryType.Product.ToString();
            var productCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType);
            if (productCBS == null)
            {
                productCBS              = new S_C_CBS();
                productCBS.Name         = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name;
                productCBS.Code         = categoryType;
                productCBS.NodeType     = nodeType;
                productCBS.CBSType      = CBSType.LabourExpense.ToString();
                productCBS.SortIndex    = 2;
                productCBS.CreateUserID = this.CreateUserID;
                productCBS.CreateUser   = this.CreateUser;
                cbsRoot.AddChild(productCBS);
            }
            //删除不存在的
            var removeMajorWorkloadList = productCBS.Children.Where(d => !selectMajorList.Contains(d.Code)).ToList();
            foreach (var item in removeMajorWorkloadList)
            {
                item.Delete();
            }
            #endregion

            var roleDefineList = BaseConfigFO.GetRoleDefineList();
            var majorAttrList  = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);
            if (!string.IsNullOrEmpty(this.MajorList))
            {
                var majorNodes = JsonHelper.ToList(this.MajorList);
                foreach (var item in majorNodes)
                {
                    var majorCode = item.GetValue("MajorCode");
                    var majorName = item.GetValue("MajorName");
                    var attr      = majorAttrList.FirstOrDefault(d => d.Code == majorCode);
                    if (attr == null)
                    {
                        throw new Formula.Exceptions.BusinessException("未定义专业【" + majorCode + "】" + majorName + ",操作失败");
                    }
                    var major = projectInfo.S_W_WBS.FirstOrDefault(d => d.WBSValue == majorCode && d.WBSType == WBSNodeType.Major.ToString());
                    if (major == null)
                    {
                        major           = new S_W_WBS();
                        major.Name      = attr.Name;
                        major.Code      = attr.WBSCode;
                        major.WBSValue  = attr.Code;
                        major.WBSType   = WBSNodeType.Major.ToString();
                        major.SortIndex = attr.SortIndex;
                        projectInfo.WBSRoot.AddChild(major);
                    }
                    //if (!string.IsNullOrEmpty(item.MajorPrinciple))
                    //    major.SetUsers(ProjectRole.MajorPrinciple.ToString(), item.MajorPrinciple.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.MajorEngineer))
                    //    major.SetUsers(ProjectRole.MajorEngineer.ToString(), item.MajorEngineer.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Designer))
                    //    major.SetUsers(ProjectRole.Designer.ToString(), item.Designer.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Collactor))
                    //    major.SetUsers(ProjectRole.Collactor.ToString(), item.Collactor.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Auditor))
                    //    major.SetUsers(ProjectRole.Auditor.ToString(), item.Auditor.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Approver))
                    //    major.SetUsers(ProjectRole.Approver.ToString(), item.Approver.Split(','), true, true, true, true);
                    var roleList = roleDefineList.Where(a => item.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(item.GetValue(a.RoleCode)));
                    foreach (var roleDef in roleList)
                    {
                        major.SetUsers(roleDef.RoleCode, item.GetValue(roleDef.RoleCode).Split(','), true, true, true, true);
                    }

                    #region 卷册
                    if (!string.IsNullOrEmpty(this.TaskWorkList))
                    {
                        var list = DetailTaskWorkList.Where(a => a.Major == major.WBSValue).ToList();
                        foreach (var detail in list)
                        {
                            var task = ProjectTaskWorkList.FirstOrDefault(a => a.ID == detail.TaskWorkID);
                            if (task == null)
                            {
                                task       = new S_W_TaskWork();
                                task.State = TaskWorkState.Plan.ToString();
                            }
                            task.Name       = detail.Name;
                            task.Code       = detail.Code;
                            task.MajorValue = detail.Major;
                            task.PhaseValue = detail.Phase;
                            if (string.IsNullOrEmpty(task.ID))
                            {
                                task.ID = detail.TaskWorkID;
                                //根据专业同步人员
                                task.FillWBSUser(major);
                                major.AddTaskWork(task);
                            }
                            else
                            {
                                task.Save();
                            }
                            task.DossierCode       = detail.DossierCode;
                            task.DossierName       = detail.DossierName;
                            task.S_W_WBS.PhaseCode = task.PhaseValue;
                            //修改成果的阶段、专业、卷号
                            foreach (var product in task.S_W_WBS.S_E_Product.ToList())
                            {
                                product.PhaseValue  = task.PhaseValue;
                                product.MajorValue  = task.MajorValue;
                                product.MonomerCode = task.DossierCode;
                                product.MonomerInfo = task.DossierName;
                                product.PackageCode = task.Code;
                                product.PackageName = task.Name;
                            }
                            if (task.Version == null)
                            {
                                task.Version = 1;
                            }
                        }
                    }
                    #endregion

                    #region 专业工时CBS数据
                    var _mcbs = productCBS.Children.FirstOrDefault(a => a.Code == majorCode);
                    if (_mcbs == null)
                    {
                        _mcbs           = new S_C_CBS();
                        _mcbs.Name      = majorName;
                        _mcbs.Code      = majorCode;
                        _mcbs.NodeType  = CBSNodeType.Major.ToString();
                        _mcbs.CBSType   = CBSType.LabourExpense.ToString();
                        _mcbs.SortIndex = 0;
                        if (!string.IsNullOrEmpty(item.GetValue("SortIndex")))
                        {
                            _mcbs.SortIndex = Convert.ToDouble(item.GetValue("SortIndex"));
                        }
                        _mcbs.CreateUserID = this.CreateUserID;
                        _mcbs.CreateUser   = this.CreateUser;
                        productCBS.AddChild(_mcbs);
                    }
                    else
                    {
                        _mcbs.ModifyUserID = this.CreateUserID;
                        _mcbs.ModifyUser   = this.CreateUser;
                        _mcbs.ModifyDate   = DateTime.Now;
                    }
                    _mcbs.Quantity = 0;
                    if (!string.IsNullOrEmpty(item.GetValue("MajorWorkload")))
                    {
                        _mcbs.Quantity = Convert.ToDecimal(item.GetValue("MajorWorkload"));
                    }
                    _mcbs.TotalPrice = _mcbs.Quantity.Value * _mcbs.UnitPrice.Value;

                    #endregion
                }
            }

            productCBS.SummayQuantity();

            var wbsMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString()).
                               Select(d => new { Name = d.Name, Value = d.WBSValue, SortIndex = d.SortIndex }).OrderBy(c => c.SortIndex).ToList();
            projectInfo.Major = JsonHelper.ToJson(wbsMajorList);
            var wonomerList = projectInfo.WBSRoot.S_W_Monomer.ToList();
            var userInfo    = FormulaHelper.GetUserInfo();
            if (wonomerList.Count == 0)
            {
                var wonomer = new S_W_Monomer();
                wonomer.ID              = FormulaHelper.CreateGuid();
                wonomer.Name            = projectInfo.Name;
                wonomer.ProjectInfoID   = this.ProjectInfoID;
                wonomer.Code            = "";
                wonomer.CreateDate      = DateTime.Now;
                wonomer.CreateUser      = userInfo.UserName;
                wonomer.CreateUserID    = userInfo.UserID;
                wonomer.SchemeFormSubID = this.ID;
                projectInfo.WBSRoot.S_W_Monomer.Add(wonomer);
            }
            #endregion

            var detailMileStoneList = this.T_SC_ElectricalPowerProjectScheme_MileStoneList.ToList();
            #region  除里程碑
            var selectCodes         = detailMileStoneList.Select(a => a.Code).ToList();
            var deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList();
            foreach (var item in deleteMileStoneList)
            {
                item.Delete();
            }
            #endregion
            #region 更新进度计划
            for (int i = 0; i < detailMileStoneList.Count; i++)
            {
                var item      = detailMileStoneList.ToList()[i];
                var mileStone = projectEntities.S_P_MileStone.FirstOrDefault(d => d.Code == item.Code && d.WBSID == projectInfo.WBSRoot.ID &&
                                                                             d.ProjectInfoID == this.ProjectInfoID);
                if (mileStone == null)
                {
                    mileStone                   = new S_P_MileStone();
                    mileStone.ID                = FormulaHelper.CreateGuid();
                    mileStone.Name              = item.Name;
                    mileStone.Code              = item.Code;
                    mileStone.MileStoneValue    = item.Code;
                    mileStone.WBSID             = projectInfo.WBSRoot.ID;
                    mileStone.ProjectInfoID     = projectInfo.ID;
                    mileStone.OrlPlanFinishDate = item.PlanEndDate;
                    mileStone.S_I_ProjectInfo   = projectInfo;
                }
                if (mileStone.State == ProjectCommoneState.Finish.ToString())
                {
                    continue;
                }
                mileStone.PlanFinishDate = item.PlanEndDate;
                mileStone.Weight         = item.Weight;
                mileStone.MajorValue     = item.Major;
                mileStone.TemplateID     = item.TemplateID;
                mileStone.MileStoneType  = item.MileStoneType;
                mileStone.Name           = item.Name;
                if (projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_MsDataIsFromLastVertion") == TrueOrFalse.True.ToString())
                {
                    mileStone.SortIndex = Convert.ToInt32(item.SortIndex.HasValue ? Convert.ToDecimal(item.SortIndex) * 100 : i);
                }
                else
                {
                    var template = projectInfo.ProjectMode.S_T_MileStone.FirstOrDefault(d => d.ID == item.TemplateID);
                    if (template != null)
                    {
                        mileStone.SortIndex = template.SortIndex;
                    }
                    if (!mileStone.SortIndex.HasValue)
                    {
                        mileStone.SortIndex = item.SortIndex.HasValue ? Convert.ToInt32(item.SortIndex) : i;
                    }
                }
                mileStone.Description = item.Remark;
                mileStone.Save();
                if (mileStone.MileStoneType == MileStoneType.Cooperation.ToString())
                {
                    mileStone.OutMajorValue = item.InMajor;
                    var cooperationPlan = projectEntities.S_P_CooperationPlan.FirstOrDefault(d => d.SchemeWBSID == projectInfo.WBSRoot.ID &&
                                                                                             d.CooperationValue == mileStone.MileStoneValue);
                    if (cooperationPlan == null)
                    {
                        cooperationPlan = new S_P_CooperationPlan();
                        cooperationPlan.InMajorValue       = item.InMajor;
                        cooperationPlan.OutMajorValue      = item.OutMajor;
                        cooperationPlan.MileStoneID        = mileStone.ID;
                        cooperationPlan.ID                 = FormulaHelper.CreateGuid();
                        cooperationPlan.CooperationContent = mileStone.Name;
                        cooperationPlan.CooperationValue   = mileStone.MileStoneValue;
                        cooperationPlan.OrPlanFinishDate   = item.PlanEndDate;
                        cooperationPlan.PlanFinishDate     = item.PlanEndDate;
                    }
                    if (!cooperationPlan.OrPlanFinishDate.HasValue)
                    {
                        cooperationPlan.OrPlanFinishDate = item.PlanEndDate;
                    }
                    cooperationPlan.PlanFinishDate = item.PlanEndDate;
                    if (projectInfo.WBSRoot != null)
                    {
                        projectInfo.WBSRoot.SaveCooperationPlan(cooperationPlan);
                    }
                }
            }
            #endregion

            //根据RBS更新OBS
            projectInfo.ResetOBSUserFromRBS();
            projectInfo.State = ProjectCommoneState.Execute.ToString();
        }
Beispiel #14
0
        public S_I_ProjectInfo UpGrade()
        {
            var projectEntities = this.GetDbContext <ProjectEntities>();
            var projectInfo     = projectEntities.S_I_ProjectInfo.FirstOrDefault(d => d.ID == this.ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("没有找到指定的项目信息,任务单无法升版");
            }
            projectInfo.Name       = this.ProjectInfo;
            projectInfo.Code       = this.SerialNumber;
            projectInfo.Name       = this.ProjectInfo;
            projectInfo.PhaseValue = this.Phase;
            var phaseName = "";
            var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
            var list      = phaseList.Where(d => projectInfo.PhaseValue.Contains(d.Code)).ToList();

            foreach (var item in list)
            {
                phaseName += item.Name + ",";
            }
            projectInfo.PhaseName             = phaseName.TrimEnd(',');
            projectInfo.WorkContent           = this.WorkContent;
            projectInfo.ChargeUserName        = this.ChargeUserName;
            projectInfo.ChargeUserID          = this.ChargeUser;
            projectInfo.ChargeDeptID          = this.ChargeDept;
            projectInfo.ChargeDeptName        = this.ChargeDeptName;
            projectInfo.OtherDeptID           = this.OtherDept;
            projectInfo.OtherDeptName         = this.OtherDeptName;
            projectInfo.PlanStartDate         = this.PlanStartDate;
            projectInfo.PlanFinishDate        = this.PlanFinishDate;
            projectInfo.CustomerID            = this.Customer;
            projectInfo.CustomerName          = this.CustomerName;
            projectInfo.CustomerSub           = this.CustomerSub;
            projectInfo.CustomerSubName       = this.CustomerSubName;
            projectInfo.ProjectClass          = this.ProjectClass;
            projectInfo.ProjectSpecialty      = this.ProjectSpecialty;
            projectInfo.Country               = this.Country;
            projectInfo.Province              = this.Province;
            projectInfo.CustomerRequireInfoID = this.CustomerRequestReview;
            projectInfo.City           = this.City;
            projectInfo.CoopUnitID     = this.CoopUnitID;
            projectInfo.CoopUnitIDName = this.CoopUnitIDName;
            projectInfo.Lat            = this.Lat;
            projectInfo.Long           = this.Long;
            projectInfo.District       = this.District;
            SyncExtention(projectInfo);
            projectInfo.WBSRoot.Name      = this.ProjectInfo;
            projectInfo.WBSRoot.PhaseCode = projectInfo.PhaseValue;
            if (!string.IsNullOrEmpty(this.ChargeUser))
            {
                projectInfo.WBSRoot.SetUsers(ProjectRole.ProjectManager.ToString(), this.ChargeUser.Split(','), true, true);
            }
            if (projectInfo.CBSRoot != null)
            {
                projectInfo.CBSRoot.Quantity  = this.Workload ?? 0;
                projectInfo.CBSRoot.UnitPrice = this.WorkloadUnitPrice ?? 1;
                if (projectInfo.CBSRoot.Quantity.HasValue && projectInfo.CBSRoot.UnitPrice.HasValue)
                {
                    projectInfo.CBSRoot.TotalPrice = projectInfo.CBSRoot.Quantity.Value * projectInfo.CBSRoot.UnitPrice.Value;
                }
            }

            if (!String.IsNullOrEmpty(this.BuildArea))
            {
                projectInfo.Proportion = Convert.ToDecimal(this.BuildArea);
            }

            projectInfo.GroupInfo.Name           = projectInfo.Name;
            projectInfo.GroupInfo.Code           = projectInfo.Code;
            projectInfo.GroupInfo.ChargeUser     = projectInfo.ChargeUserID;
            projectInfo.GroupInfo.ChargeUserName = projectInfo.ChargeUserName;
            projectInfo.GroupInfo.DeptID         = projectInfo.ChargeDeptID;
            projectInfo.GroupInfo.DeptName       = projectInfo.ChargeDeptName;
            projectInfo.GroupInfo.Province       = projectInfo.Province;
            projectInfo.GroupInfo.City           = projectInfo.City;
            projectInfo.GroupInfo.PhaseValue     = projectInfo.PhaseValue;
            projectInfo.GroupInfo.PhaseContent   = projectInfo.PhaseName;
            return(projectInfo);
        }
Beispiel #15
0
        void setMajorNodes(DataRow subProjectNode, DataTable wbsDt, DataTable rbsDt, List <S_D_RoleDefine> roleDefineList, string rbsList, StringBuilder sqlCommand,
                           List <S_T_WBSStructInfo> structList, IList <UserInfo> allUser)
        {
            var fo = FormulaHelper.CreateFO <ProjectInfoFO>();
            var db = SQLHelper.CreateSqlHelper(ConnEnum.Project);

            if (subProjectNode == null)
            {
                throw new Formula.Exceptions.BusinessException("传入的WBS节点为空。");
            }
            var majorList = "";

            if (!string.IsNullOrEmpty(rbsList))
            {
                majorList = rbsList;
            }
            else
            {
                majorList = this.MajorList;
            }
            #region  除不需要的专业
            var delMajors = wbsDt.AsEnumerable().Where(c => c["ParentID"] != DBNull.Value &&
                                                       c["ParentID"].ToString() == subProjectNode["ID"].ToString() &&
                                                       !this.Major.Contains(c["WBSValue"].ToString())).ToList(); //parentNode.Children.Where(d => !this.Major.Contains(d.WBSValue)).ToList();
            foreach (var item in delMajors)
            {
                fo.DeleteWBSNodeWithADO(item, wbsDt, "", sqlCommand);
            }
            #endregion

            if (!String.IsNullOrEmpty(majorList))
            {
                var majorNodes    = JsonHelper.ToList(majorList);
                var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);
                var majorWBSType  = WBSNodeType.Major.ToString();
                foreach (var majorNode in majorNodes)
                {
                    if (majorNode.GetValue("Valid") == "0")
                    {
                        var thisMajorValue = majorNode.GetValue("MajorCode");
                        var thisMajorNode  = wbsDt.AsEnumerable().FirstOrDefault(c => c["ParentID"] != DBNull.Value &&
                                                                                 c["ParentID"] != null && c["ParentID"].ToString() == subProjectNode["ID"].ToString() &&
                                                                                 c["WBSValue"].ToString() == thisMajorValue);
                        if (thisMajorNode != null)
                        {
                            fo.DeleteWBSNodeWithADO(thisMajorNode, wbsDt, this.ProjectInfoID, sqlCommand);
                        }
                        continue;
                    }
                    var value     = majorNode.GetValue("MajorCode");
                    var majorAttr = majorAttrList.SingleOrDefault(c => c.Code == value);
                    if (majorAttr == null)
                    {
                        continue;
                    }
                    var childNode = wbsDt.AsEnumerable().FirstOrDefault(c => c["ParentID"] != DBNull.Value &&
                                                                        c["ParentID"] != null && c["ParentID"].ToString() == subProjectNode["ID"].ToString() &&
                                                                        c["WBSValue"].ToString() == value);
                    if (!this.Major.Split(',').Contains(value))
                    {
                        if (childNode != null)
                        {
                            fo.DeleteWBSNodeWithADO(childNode, wbsDt, this.ProjectInfoID, sqlCommand);
                        }
                        continue;
                    }
                    if (childNode == null)
                    {
                        childNode                   = wbsDt.NewRow();
                        childNode["ID"]             = FormulaHelper.CreateGuid();
                        childNode["WBSType"]        = majorWBSType;
                        childNode["Name"]           = majorAttr.Name;
                        childNode["WBSValue"]       = majorAttr.Code;
                        childNode["Code"]           = majorAttr.WBSCode;
                        childNode["SortIndex"]      = majorAttr.SortIndex;
                        childNode["ChargeUserID"]   = majorNode.GetValue("MajorPrinciple");;
                        childNode["ChargeUserName"] = majorNode.GetValue("MajorPrincipleName");
                        fo.AddWBSChildWithAdo(subProjectNode, childNode, wbsDt, structList);
                    }
                    else
                    {
                        childNode["SortIndex"] = majorAttr.SortIndex;
                        sqlCommand.AppendLine(String.Format("update S_W_WBS set ChargeUserID='{0}',ChargeUserName='******' where ID='{2}'",
                                                            majorNode.GetValue("MajorPrinciple"), majorNode.GetValue("MajorPrincipleName"), childNode["ID"]));
                        sqlCommand.AppendLine(String.Format("DELETE FROM S_W_RBS WHERE WBSID='{0}' ", childNode["ID"]));
                    }
                    var roleList = roleDefineList.Where(a => majorNode.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(majorNode.GetValue(a.RoleCode)));
                    foreach (var roleDef in roleList)
                    {
                        var userIDs = majorNode.GetValue(roleDef.RoleCode).Split(',');
                        foreach (var userID in userIDs)
                        {
                            var userInfo = allUser.SingleOrDefault(c => c.UserID == userID);
                            if (userInfo == null)
                            {
                                continue;
                            }
                            addRbsDt(userInfo, rbsDt, childNode, roleDef);
                        }
                    }
                }
            }
        }
        private S_I_ProjectInfo AddProject(S_I_WBS designNode, T_CP_TaskNotice entity, T_CP_TaskNotice_PhaseDetail singlePhase = null)
        {
            entity.ProjectInfoID = designNode.ID;
            S_I_ProjectInfo projectInfo = entity.Push();

            projectInfo.ModifyDate   = projectInfo.CreateDate;
            projectInfo.ModifyUser   = projectInfo.CreateUser;
            projectInfo.ModifyUserID = projectInfo.CreateUserID;

            //重新修改phaseValue、phaseName、Name、Code等信息
            if (singlePhase != null)
            {
                projectInfo.PhaseValue        = singlePhase.Phase;
                projectInfo.WBSRoot.PhaseCode = singlePhase.Phase;
                var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
                var phaseItem = phaseList.FirstOrDefault(d => projectInfo.PhaseValue == d.Code);
                projectInfo.PhaseName      = phaseItem.Name;
                projectInfo.Name           = singlePhase.Name;
                projectInfo.Code           = singlePhase.Code;
                projectInfo.ChargeDeptID   = singlePhase.ChargeDept ?? entity.ChargeDept;
                projectInfo.ChargeDeptName = singlePhase.ChargeDeptName ?? entity.ChargeDeptName;
                projectInfo.ChargeUserID   = singlePhase.ChargeUser ?? entity.ChargeUser;
                projectInfo.ChargeUserName = singlePhase.ChargeUserName ?? entity.ChargeUserName;
                projectInfo.OtherDeptID    = singlePhase.OtherDept ?? entity.OtherDept;
                projectInfo.OtherDeptName  = singlePhase.OtherDeptName ?? entity.OtherDeptName;
                projectInfo.PlanStartDate  = singlePhase.PlanStartDate ?? entity.PlanStartDate;
                projectInfo.PlanFinishDate = singlePhase.PlanFinishDate ?? entity.PlanFinishDate;
            }
            projectInfo.ModifyDate          = projectInfo.CreateDate;
            projectInfo.ModifyUser          = projectInfo.CreateUser;
            projectInfo.ModifyUserID        = projectInfo.CreateUserID;
            projectInfo.MarketProjectInfoID = projectInfo.ID;

            #region 默认创建EPS结构
            var group = this.BusinessEntities.Set <S_I_ProjectGroup>().FirstOrDefault(d => d.RelateID == entity.EngineeringID && d.Type == "Engineering");
            if (group == null)
            {
                group                      = new S_I_ProjectGroup();
                group.ID                   = Formula.FormulaHelper.CreateGuid();
                group.Name                 = designNode.S_I_Engineering.Name;
                group.Code                 = designNode.S_I_Engineering.SerialNumber;
                group.City                 = designNode.S_I_Engineering.City;
                group.Province             = designNode.S_I_Engineering.Province;
                group.Area                 = designNode.S_I_Engineering.Area;
                group.ProjectClass         = designNode.S_I_Engineering.ProjectClass;
                group.Investment           = designNode.S_I_Engineering.Investment;
                group.PhaseContent         = designNode.S_I_Engineering.PhaseValue;
                group.DeptID               = designNode.S_I_Engineering.ChargerDept;
                group.DeptName             = designNode.S_I_Engineering.ChargerDeptName;
                group.RelateID             = designNode.S_I_Engineering.ID;
                group.EngineeringSpaceCode = ProjectMode.Standard.ToString();
                group.CreateDate           = DateTime.Now;
                var fo = Formula.FormulaHelper.CreateFO <EPSFO>();
                fo.BuildEngineering(group);
            }
            group.BindingProject(projectInfo);
            entity.GroupID   = group.ID;
            group.PhaseValue = designNode.S_I_Engineering.PhaseValue;
            #endregion

            projectInfo.InitDeisgnInputTemplate(true);

            //把设总放进RBS中
            if (projectInfo != null && !string.IsNullOrEmpty(entity.DesignManager))
            {
                projectInfo.WBSRoot.SetUsers(ProjectRole.DesignManager.ToString(), entity.DesignManager.Split(','), true, true, true, true);
            }
            return(projectInfo);
        }
Beispiel #17
0
        public JsonResult AddChild(string parentIDs, string Children, string WBSType)
        {
            var result           = new List <S_W_WBS>();
            var list             = JsonHelper.ToList(Children);
            var majorType        = WBSNodeType.Major.ToString();
            var majorWBSAttrList = BaseConfigFO.GetWBSAttrList(majorType);
            //EPCWBS信息
            var epcEntities = FormulaHelper.GetEntities <EPCEntities>();

            foreach (var parentID in parentIDs.TrimEnd(',').Split(','))
            {
                var parent = this.GetEntityByID <S_W_WBS>(parentID);
                if (parent == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }

                var epcParentWBSNode = epcEntities.Set <S_I_WBS>().Find(parentID);
                if (epcParentWBSNode == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }

                var rbsList = parent.S_W_RBS.ToList();
                foreach (var item in list)
                {
                    var wbs = new S_W_WBS();
                    this.UpdateEntity <S_W_WBS>(wbs, item);
                    var subEntityNode = parent.AddChild(wbs, true, true);
                    result.Add(subEntityNode);

                    var epcWBS = new S_I_WBS();
                    this.UpdateEntity <S_I_WBS>(epcWBS, item);
                    epcWBS.NodeType = WBSNodeType.SubProject.ToString();
                    epcWBS.ID       = wbs.ID;
                    var epcSubProjectNode = epcParentWBSNode.AddChild(epcWBS, true, false);

                    var majorCodes = item.GetValue("MajorCode");
                    if (!string.IsNullOrWhiteSpace(majorCodes))
                    {
                        foreach (var majorCode in majorCodes.Split(','))
                        {
                            var majorAttrDefine = majorWBSAttrList.FirstOrDefault(d => d.Code == majorCode);
                            if (majorAttrDefine == null)
                            {
                                continue;
                            }

                            var majorWBSNode = new S_W_WBS();
                            majorWBSNode.WBSType   = majorType;
                            majorWBSNode.Name      = majorAttrDefine.Name;
                            majorWBSNode.SortIndex = majorAttrDefine.SortIndex;
                            majorWBSNode.WBSValue  = majorCode;
                            result.Add(subEntityNode.AddChild(majorWBSNode));

                            var epcMajorWBSNode = new S_I_WBS();
                            epcMajorWBSNode.NodeType  = majorType;
                            epcMajorWBSNode.Name      = majorAttrDefine.Name;
                            epcMajorWBSNode.SortIndex = majorAttrDefine.SortIndex;
                            epcMajorWBSNode.Value     = majorCode;
                            epcMajorWBSNode.ID        = majorWBSNode.ID;
                            epcSubProjectNode.AddChild(epcMajorWBSNode, true, true);
                        }
                    }

                    if (!string.IsNullOrEmpty(parent.MajorCode))
                    {
                        if (wbs.StructNodeInfo.S_T_WBSStructRole.Count > 0)
                        {
                            var roleDefines = wbs.StructNodeInfo.S_T_WBSStructRole.Where(c => c.SychWBS != true.ToString()).ToList();
                            foreach (var roleDefine in roleDefines)
                            {
                                var users = rbsList.Where(a => a.RoleCode == roleDefine.RoleCode).Select(a => a.UserID).ToArray();
                                if (users.Length > 0)
                                {
                                    wbs.SetUsers(roleDefine.RoleCode, users, false, true, false, true);
                                }
                            }
                        }
                    }
                }
            }
            this.entities.SaveChanges();
            epcEntities.SaveChanges();
            return(Json(result));
        }
        public void Push(Dictionary <string, string> dic)
        {
            var projectEntities = FormulaHelper.GetEntities <ProjectEntities>();
            var projectInfo     = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息");
            }
            var rootWBS = projectInfo.WBSRoot;

            if (rootWBS == null)
            {
                throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。");
            }
            if (!String.IsNullOrEmpty(this.Code))
            {
                projectInfo.Code = this.Code;
            }

            if (this.PlanStartDate.HasValue)
            {
                projectInfo.PlanStartDate = this.PlanStartDate;
            }
            if (this.PlanFinishDate.HasValue)
            {
                projectInfo.PlanFinishDate = this.PlanFinishDate;
            }

            this.SynchRBSUser(dic);
            var selectMajorList = this.Major.Split(',');

            #region 回写专业信息
            //移除未选中的专业
            var removeMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString() &&
                                                            !selectMajorList.Contains(d.WBSValue)).ToList();
            foreach (var item in removeMajorList)
            {
                item.Delete();
            }

            var roleDefineList = BaseConfigFO.GetRoleDefineList();
            var majorAttrList  = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);

            if (!string.IsNullOrEmpty(this.MajorList))
            {
                var majorNodes = JsonHelper.ToList(this.MajorList);
                foreach (var item in majorNodes)
                {
                    var majorCode = item.GetValue("MajorCode");
                    var attr      = majorAttrList.FirstOrDefault(d => d.Code == majorCode);
                    if (attr == null)
                    {
                        throw new Formula.Exceptions.BusinessException("未定义专业【" + majorCode + "】" + item.GetValue("MajorName") + ",操作失败");
                    }
                    var major = projectInfo.S_W_WBS.FirstOrDefault(d => d.WBSValue == majorCode && d.WBSType == WBSNodeType.Major.ToString());
                    if (major == null)
                    {
                        major           = new S_W_WBS();
                        major.Name      = attr.Name;
                        major.Code      = attr.WBSCode;
                        major.WBSValue  = attr.Code;
                        major.MajorCode = attr.Code;
                        major.WBSType   = WBSNodeType.Major.ToString();
                        major.SortIndex = attr.SortIndex;
                        projectInfo.WBSRoot.AddChild(major);
                    }
                    else
                    {
                        major.PhaseCode = projectInfo.PhaseValue;
                    }
                    //if (!string.IsNullOrEmpty(item.MajorPrinciple))
                    //    major.SetUsers(ProjectRole.MajorPrinciple.ToString(), item.MajorPrinciple.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.MajorEngineer))
                    //    major.SetUsers(ProjectRole.MajorEngineer.ToString(), item.MajorEngineer.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Designer))
                    //    major.SetUsers(ProjectRole.Designer.ToString(), item.Designer.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Collactor))
                    //    major.SetUsers(ProjectRole.Collactor.ToString(), item.Collactor.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Auditor))
                    //    major.SetUsers(ProjectRole.Auditor.ToString(), item.Auditor.Split(','), true, true, true, true);
                    //if (!string.IsNullOrEmpty(item.Approver))
                    //    major.SetUsers(ProjectRole.Approver.ToString(), item.Approver.Split(','), true, true, true, true);
                    var roleList = roleDefineList.Where(a => item.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(item.GetValue(a.RoleCode)));
                    foreach (var roleDef in roleList)
                    {
                        major.SetUsers(roleDef.RoleCode, item.GetValue(roleDef.RoleCode).Split(','), true, true, true, true);
                    }
                }
            }
            var wbsMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString()).
                               Select(d => new { Name = d.Name, Value = d.WBSValue, SortIndex = d.SortIndex }).OrderBy(c => c.SortIndex).ToList();
            projectInfo.Major = JsonHelper.ToJson(wbsMajorList);
            var wonomerList = projectInfo.WBSRoot.S_W_Monomer.ToList();
            var userInfo    = FormulaHelper.GetUserInfo();
            if (wonomerList.Count == 0)
            {
                var wonomer = new S_W_Monomer();
                wonomer.ID              = FormulaHelper.CreateGuid();
                wonomer.Name            = projectInfo.Name;
                wonomer.ProjectInfoID   = this.ProjectInfoID;
                wonomer.Code            = "";
                wonomer.CreateDate      = DateTime.Now;
                wonomer.CreateUser      = userInfo.UserName;
                wonomer.CreateUserID    = userInfo.UserID;
                wonomer.SchemeFormSubID = this.ID;
                projectInfo.WBSRoot.S_W_Monomer.Add(wonomer);
            }
            #endregion

            var detailMileStoneList = this.T_SC_SingleProjectScheme_MileStoneList.ToList();
            #region  除里程碑
            var selectCodes         = detailMileStoneList.Select(a => a.Code).ToList();
            var deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList();
            foreach (var item in deleteMileStoneList)
            {
                item.Delete();
            }
            #endregion
            #region 更新进度计划
            for (int i = 0; i < detailMileStoneList.Count; i++)
            {
                var item      = detailMileStoneList.ToList()[i];
                var mileStone = projectEntities.S_P_MileStone.FirstOrDefault(d => d.Code == item.Code && d.WBSID == projectInfo.WBSRoot.ID &&
                                                                             d.ProjectInfoID == this.ProjectInfoID);
                if (mileStone == null)
                {
                    mileStone                   = new S_P_MileStone();
                    mileStone.ID                = FormulaHelper.CreateGuid();
                    mileStone.Name              = item.Name;
                    mileStone.Code              = item.Code;
                    mileStone.MileStoneValue    = item.Code;
                    mileStone.WBSID             = projectInfo.WBSRoot.ID;
                    mileStone.ProjectInfoID     = projectInfo.ID;
                    mileStone.OrlPlanFinishDate = item.PlanEndDate;
                    mileStone.S_I_ProjectInfo   = projectInfo;
                }
                if (mileStone.State == ProjectCommoneState.Finish.ToString())
                {
                    continue;
                }
                mileStone.PlanFinishDate = item.PlanEndDate;
                mileStone.Weight         = item.Weight;
                mileStone.MajorValue     = item.Major;
                mileStone.TemplateID     = item.TemplateID;
                mileStone.MileStoneType  = item.MileStoneType;
                mileStone.Name           = item.Name;
                if (projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_MsDataIsFromLastVertion") == TrueOrFalse.True.ToString())
                {
                    mileStone.SortIndex = Convert.ToInt32(item.SortIndex.HasValue ? Convert.ToDecimal(item.SortIndex) * 100 : i);
                }
                else
                {
                    var template = projectInfo.ProjectMode.S_T_MileStone.FirstOrDefault(d => d.ID == item.TemplateID);
                    if (template != null)
                    {
                        mileStone.SortIndex = template.SortIndex;
                    }
                    if (!mileStone.SortIndex.HasValue)
                    {
                        mileStone.SortIndex = item.SortIndex.HasValue ? Convert.ToInt32(item.SortIndex) : i;
                    }
                }
                mileStone.Description = item.Remark;
                mileStone.Save();
                if (mileStone.MileStoneType == MileStoneType.Cooperation.ToString())
                {
                    mileStone.OutMajorValue = item.InMajor;
                    var cooperationPlan = projectEntities.S_P_CooperationPlan.FirstOrDefault(d => d.SchemeWBSID == projectInfo.WBSRoot.ID &&
                                                                                             d.CooperationValue == mileStone.MileStoneValue);
                    if (cooperationPlan == null)
                    {
                        cooperationPlan = new S_P_CooperationPlan();
                        cooperationPlan.InMajorValue       = item.InMajor;
                        cooperationPlan.OutMajorValue      = item.OutMajor;
                        cooperationPlan.MileStoneID        = mileStone.ID;
                        cooperationPlan.ID                 = FormulaHelper.CreateGuid();
                        cooperationPlan.CooperationContent = mileStone.Name;
                        cooperationPlan.CooperationValue   = mileStone.MileStoneValue;
                        cooperationPlan.OrPlanFinishDate   = item.PlanEndDate;
                        cooperationPlan.PlanFinishDate     = item.PlanEndDate;
                    }
                    if (!cooperationPlan.OrPlanFinishDate.HasValue)
                    {
                        cooperationPlan.OrPlanFinishDate = item.PlanEndDate;
                    }
                    cooperationPlan.PlanFinishDate = item.PlanEndDate;
                    if (projectInfo.WBSRoot != null)
                    {
                        projectInfo.WBSRoot.SaveCooperationPlan(cooperationPlan);
                    }
                }
            }
            #endregion
            //根据RBS更新OBS
            projectInfo.ResetOBSUserFromRBS();
            projectInfo.State = ProjectCommoneState.Execute.ToString();
        }
Beispiel #19
0
        /// <summary>
        /// 根据阶段、子项信息、专业信息同步WBS节点
        /// </summary>
        public void SynchWBSNode(Dictionary <string, string> dic, S_W_WBS rootWBS = null)
        {
            var enumService     = FormulaHelper.GetService <IEnumService>();
            var userInfo        = FormulaHelper.GetUserInfo();
            var projectEntities = FormulaHelper.GetEntities <ProjectEntities>();
            var projectInfo     = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息");
            }
            if (rootWBS == null)
            {
                //获取项目信息
                rootWBS = projectInfo.WBSRoot;
                if (rootWBS == null)
                {
                    throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。");
                }
            }
            var detailList = this.T_SC_SchemeForm_OEM_Szsow_SubProjectList.OrderBy(d => d.SortIndex).ToList();

            var roleDefineList = BaseConfigFO.GetRoleDefineList();
            var phaseWBSes     = rootWBS.Children.ToList();
            var phaseAttrs     = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);

            foreach (var phaseValue in projectInfo.PhaseValue.Split(','))
            {
                #region 阶段节点

                var phaseName = enumService.GetEnumText("Project.Phase", phaseValue);
                var attr      = phaseAttrs.FirstOrDefault(a => a.Code == phaseValue);
                if (attr == null)
                {
                    throw new Formula.Exceptions.BusinessException("未定义阶段【" + phaseValue + "】" + phaseName + ",操作失败");
                }
                var phaseWBSNode = phaseWBSes.FirstOrDefault(d => d.WBSValue == phaseValue &&
                                                             d.WBSType == WBSNodeType.Phase.ToString());
                if (phaseWBSNode == null)
                {
                    phaseWBSNode          = new S_W_WBS();
                    phaseWBSNode.ID       = FormulaHelper.CreateGuid();
                    phaseWBSNode.WBSType  = WBSNodeType.Phase.ToString();
                    phaseWBSNode.Name     = phaseName;
                    phaseWBSNode.Code     = attr.WBSCode;
                    phaseWBSNode.WBSValue = attr.Code;
                    rootWBS.AddChild(phaseWBSNode);
                }
                else
                {
                    phaseWBSNode.Name     = phaseName;
                    phaseWBSNode.Code     = attr.WBSCode;
                    phaseWBSNode.WBSValue = attr.Code;
                    phaseWBSNode.Save();
                    phaseWBSes.Remove(phaseWBSNode);
                }
                #endregion

                #region 子项节点
                var subwbses = phaseWBSNode.Children.ToList();
                foreach (var subProject in detailList.Where(a => a.PhaseValue.Split(',').Contains(phaseValue)).ToList())
                {
                    var subWBSNode = subwbses.FirstOrDefault(d => d.WBSValue == subProject.Code && d.WBSType == WBSNodeType.SubProject.ToString());
                    if (subWBSNode == null)
                    {
                        subWBSNode           = new S_W_WBS();
                        subWBSNode.ID        = FormulaHelper.CreateGuid();
                        subWBSNode.WBSType   = WBSNodeType.SubProject.ToString();
                        subWBSNode.Name      = subProject.Name;
                        subWBSNode.Code      = "";
                        subWBSNode.WBSValue  = subProject.Code;
                        subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : "";
                        subWBSNode.ExtField2 = subProject.Unit;
                        phaseWBSNode.AddChild(subWBSNode);
                    }
                    else
                    {
                        subWBSNode.Name      = subProject.Name;
                        subWBSNode.WBSValue  = subProject.Code;
                        subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : "";
                        subWBSNode.ExtField2 = subProject.Unit;
                        subWBSNode.Save();
                        subwbses.Remove(subWBSNode);
                    }
                    subProject.PhaseWBSID = phaseWBSNode.ID;
                    #region 新增单体
                    var wonomerList = subWBSNode.S_W_Monomer.ToList();
                    if (String.IsNullOrEmpty(subProject.Unit))
                    {
                        var wonomer = wonomerList.FirstOrDefault(d => d.Name == subProject.Name);
                        if (wonomer == null)
                        {
                            wonomer                 = new S_W_Monomer();
                            wonomer.ID              = FormulaHelper.CreateGuid();
                            wonomer.Name            = subProject.Name;
                            wonomer.ProjectInfoID   = this.ProjectInfoID;
                            wonomer.Code            = "";
                            wonomer.CreateDate      = DateTime.Now;
                            wonomer.CreateUser      = userInfo.UserName;
                            wonomer.CreateUserID    = userInfo.UserID;
                            wonomer.SchemeFormSubID = this.ID;
                            subWBSNode.S_W_Monomer.Add(wonomer);
                        }
                    }
                    else if (!string.IsNullOrEmpty(subProject.Name))
                    {
                        foreach (var item in subProject.Unit.Replace(",", ",").Split(','))
                        {
                            var wonomer = subWBSNode.S_W_Monomer.FirstOrDefault(d => d.Name == item);
                            if (wonomer == null)
                            {
                                wonomer                 = new S_W_Monomer();
                                wonomer.ID              = FormulaHelper.CreateGuid();
                                wonomer.Name            = item;
                                wonomer.ProjectInfoID   = this.ProjectInfoID;
                                wonomer.Code            = "";
                                wonomer.CreateDate      = DateTime.Now;
                                wonomer.CreateUser      = userInfo.UserName;
                                wonomer.CreateUserID    = userInfo.UserID;
                                wonomer.SchemeFormSubID = this.ID;
                                subWBSNode.S_W_Monomer.Add(wonomer);
                            }
                            else
                            {
                                wonomerList.Remove(wonomer);
                            }
                        }
                    }
                    foreach (var delWonomer in wonomerList)   //移除不需要的单体
                    {
                        projectEntities.S_W_Monomer.Remove(delWonomer);
                    }

                    #endregion

                    //增加名称判断逻辑
                    if (string.IsNullOrEmpty(subProject.Name))
                    {
                        //将空名子项的专业挂到阶段下
                        SynchMajorWBSNode(roleDefineList, subWBSNode.Parent, subProject.RBSJson);
                        //删除空名子项
                        subWBSNode.Delete();

                        //排除在阶段下的专业
                        var rbsDicList = JsonHelper.ToList(subProject.RBSJson ?? MajorList);
                        subwbses.RemoveAll(a => rbsDicList.Any(b => a.WBSValue == b.GetValue("MajorCode")));
                    }
                    else
                    {
                        subProject.SubProjectWBSID = subWBSNode.ID;
                        SynchMajorWBSNode(roleDefineList, subWBSNode, subProject.RBSJson);
                    }
                    //this.InitMileStone(subWBSNode);
                }
                #endregion

                //删除阶段节点下多余的子项和专业
                subwbses.ForEach(t =>
                {
                    if (t.WBSType == WBSNodeType.Major.ToString())
                    {
                        //删除阶段下层专业时,同时删除挂在阶段下的专业计划、发图计划
                        projectEntities.Set <S_P_MileStone>().Delete(d => d.WBSID == phaseWBSNode.ID && d.MajorValue == t.WBSValue);
                    }
                    t.Delete();
                });
            }
            phaseWBSes.ForEach(t => t.Delete());  //删除多余的阶段

            this.SubProjectList = JsonHelper.ToJson <List <T_SC_SchemeForm_OEM_Szsow_SubProjectList> >(detailList);
        }
Beispiel #20
0
        /// <summary>
        /// 多阶段只立一个项目
        /// </summary>
        /// <returns></returns>
        public S_I_ProjectInfo Push()
        {
            var    context     = this.GetDbContext <ProjectEntities>();
            string projectCode = this.SerialNumber;
            var    projectInfo = new S_I_ProjectInfo
            {
                ID                    = string.IsNullOrEmpty(this.ProjectInfoID) ? FormulaHelper.CreateGuid() : this.ProjectInfoID,
                Name                  = this.ProjectInfo,
                Code                  = projectCode,
                PhaseValue            = this.Phase,
                WorkContent           = this.WorkContent,
                State                 = ProjectCommoneState.Plan.ToString(),
                ChargeUserName        = this.ChargeUserName,
                ChargeUserID          = this.ChargeUser,
                ChargeDeptID          = string.IsNullOrEmpty(this.ChargeDept) ? this.DesignDept : this.ChargeDept,
                ChargeDeptName        = string.IsNullOrEmpty(this.ChargeDeptName) ? this.DesignDeptName: this.ChargeDeptName,
                OtherDeptID           = this.OtherDept,
                OtherDeptName         = this.OtherDeptName,
                PlanStartDate         = this.PlanStartDate,
                PlanFinishDate        = this.PlanFinishDate,
                CustomerID            = this.Customer,
                CustomerName          = this.CustomerName,
                CustomerSub           = this.CustomerSub,
                CustomerSubName       = this.CustomerSubName,
                CompletePercent       = 0,
                ProjectClass          = this.ProjectClass,
                ProjectSpecialty      = this.ProjectSpecialty,
                Country               = this.Country,
                Province              = this.Province,
                Area                  = this.Area,
                CustomerRequireInfoID = this.CustomerRequestReview,
                City                  = this.City,
                CoopUnitID            = this.CoopUnitID,
                CoopUnitIDName        = this.CoopUnitIDName,
                Long                  = this.Long,
                Lat                   = this.Lat,
                Address               = this.Address,
                District              = this.District
            };

            SyncExtention(projectInfo);
            if (!String.IsNullOrEmpty(this.BuildArea))
            {
                decimal d;
                if (Decimal.TryParse(this.BuildArea, out d))
                {
                    projectInfo.Proportion = d;
                }
            }

            var majorEnumTable = BaseConfigFO.GetWBSEnum(WBSNodeType.Major);

            if (!string.IsNullOrEmpty(this.Major))
            {
                var major = this.Major.Split(',').Select(
                    c => new
                {
                    Name  = majorEnumTable.Select("value='" + c + "'")[0]["text"],
                    Value = c,
                }
                    );
                projectInfo.Major = JsonHelper.ToJson(major);
            }
            var phaseName = "";
            var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
            var list      = phaseList.Where(d => projectInfo.PhaseValue.Contains(d.Code)).ToList();

            foreach (var item in list)
            {
                phaseName += item.Name + ",";
            }
            projectInfo.PhaseName           = phaseName.TrimEnd(',');
            projectInfo.MarketProjectInfoID = this.MarketProjectID;
            projectInfo.Build();
            projectInfo.ProjectLevel = String.IsNullOrEmpty(this.ProjectLevel) ? 10 : Convert.ToInt32(this.ProjectLevel);
            if (projectInfo.CBSRoot != null)
            {
                projectInfo.CBSRoot.Quantity  = this.Workload ?? 0;
                projectInfo.CBSRoot.UnitPrice = this.WorkloadUnitPrice ?? 1;
                if (projectInfo.CBSRoot.Quantity.HasValue && projectInfo.CBSRoot.UnitPrice.HasValue)
                {
                    projectInfo.CBSRoot.TotalPrice = projectInfo.CBSRoot.Quantity.Value * projectInfo.CBSRoot.UnitPrice.Value;
                }
            }
            context.SaveChanges();
            if (String.IsNullOrEmpty(this.MultiProjMode) || this.MultiProjMode.ToLower() != "1")
            {
                this.ProjectInfoID = projectInfo.ID;
            }
            context.SaveChanges();
            return(projectInfo);
        }
Beispiel #21
0
        /// <summary>
        /// 根据专业同步WBS
        /// </summary>
        /// <param name="parentNode"></param>
        public void SynchMajorWBSNode(List <S_D_RoleDefine> roleDefineList, S_W_WBS parentNode, string rbsList = "")
        {
            var projectEntities = FormulaHelper.GetEntities <ProjectEntities>();

            if (parentNode == null)
            {
                throw new Formula.Exceptions.BusinessException("传入的WBS节点为空。");
            }
            var majorList = "";

            if (!string.IsNullOrEmpty(rbsList))
            {
                majorList = rbsList;
            }
            else
            {
                majorList = this.MajorList;
            }

            #region  除不需要的专业
            //sll edit 2018-8-8
            //改前var delMajors = parentNode.Children.Where(d => !this.Major.Contains(d.WBSValue)).ToList();
            var delMajors = parentNode.Children.Where(d => !this.Major.Contains(d.WBSValue) && d.WBSType == WBSNodeType.Major.ToString()).ToList();
            foreach (var item in delMajors)
            {
                item.Delete();
                parentNode.Children.Remove(item);
            }
            #endregion

            if (!string.IsNullOrEmpty(majorList))
            {
                var majorNodes    = JsonHelper.ToList(majorList);
                var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major);
                var majorWBSType  = WBSNodeType.Major.ToString();
                foreach (var majorNode in majorNodes)
                {
                    if (majorNode.GetValue("Valid") == "0")
                    {
                        var thisMajorValue = majorNode.GetValue("MajorCode");
                        var thisMajorNode  = parentNode.Children.SingleOrDefault(c => c.WBSValue == thisMajorValue);
                        if (thisMajorNode != null)
                        {
                            thisMajorNode.Delete();
                        }
                        continue;
                    }
                    var value     = majorNode.GetValue("MajorCode");
                    var majorAttr = majorAttrList.SingleOrDefault(c => c.Code == value);
                    if (majorAttr == null)
                    {
                        continue;
                    }
                    var childNode = parentNode.Children.SingleOrDefault(c => c.WBSValue == value);
                    if (!this.Major.Split(',').Contains(value))
                    {
                        if (childNode != null)
                        {
                            childNode.Delete();
                        }
                        continue;
                    }
                    if (childNode == null)
                    {
                        childNode = projectEntities.Set <S_W_WBS>().Create();
                        if (string.IsNullOrEmpty(childNode.ID))
                        {
                            childNode.ID = FormulaHelper.CreateGuid();
                        }
                        childNode._state    = EntityState.Added.ToString();
                        childNode.WBSType   = majorWBSType;
                        childNode.Name      = majorAttr.Name;
                        childNode.WBSValue  = majorAttr.Code;
                        childNode.MajorCode = majorAttr.Code;
                        childNode.Code      = majorAttr.WBSCode;
                    }
                    childNode.SortIndex      = majorAttr.SortIndex;
                    childNode.ChargeUserID   = majorNode.GetValue("MajorPrinciple");
                    childNode.ChargeUserName = majorNode.GetValue("MajorPrincipleName");
                    if (childNode._state == EntityState.Added.ToString())
                    {
                        parentNode.AddChild(childNode);
                    }

                    #region  步设校审人员信息
                    var roleList = roleDefineList.Where(a => majorNode.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(majorNode.GetValue(a.RoleCode)));
                    foreach (var roleDef in roleList)
                    {
                        childNode.SetUsers(roleDef.RoleCode, majorNode.GetValue(roleDef.RoleCode).Split(','), true, false, true, true);
                    }
                    #endregion
                }
            }
        }
Beispiel #22
0
        public void BuildMajorWBS(S_W_WBS majorParentWBS, List <Dictionary <string, object> > majorList)
        {
            if (majorList == null || majorList.Count <= 0)
            {
                return;
            }
            var majorEnum = BaseConfigFO.GetWBSEnum(WBSNodeType.Major)
                            .AsEnumerable()
                            .Select(c => new DicItem
            {
                Text  = c["text"].ToString(),
                Value = c["value"].ToString()
            }).ToList();
            var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major.ToString());

            foreach (var major in majorList)
            {
                var     mCode    = major.GetValue("Major").ToString();
                S_W_WBS majorwbs = majorParentWBS.AllChildren.FirstOrDefault(c => c.WBSValue == mCode);
                if (majorwbs == null)
                {
                    #region 新增
                    majorwbs = new S_W_WBS
                    {
                        WBSType  = WBSNodeType.Major.ToString(),
                        Name     = majorEnum.FirstOrDefault(c => c.Value == mCode).Text,
                        WBSValue = mCode
                                   //Code = mCode,
                    };
                    var attrDefine = majorAttrList.FirstOrDefault(d => d.Code == majorwbs.WBSValue);
                    if (attrDefine != null)
                    {
                        majorwbs.SortIndex = attrDefine.SortIndex;
                    }
                    majorParentWBS.AddChild(majorwbs);
                    #endregion
                }
                else
                {
                    majorwbs.Name = majorEnum.FirstOrDefault(c => c.Value == mCode).Text;
                    var attrDefine = majorAttrList.FirstOrDefault(d => d.Code == majorwbs.WBSValue);
                    if (attrDefine != null)
                    {
                        majorwbs.SortIndex = attrDefine.SortIndex;
                    }
                }

                if (!String.IsNullOrEmpty(major.GetValue("MajorPrincipleID")))
                {
                    majorwbs.SetUsers(ProjectRole.MajorPrinciple.ToString(), major.GetValue("MajorPrincipleID").ToString().Split(','));
                }
                if (!String.IsNullOrEmpty(major.GetValue("DesignID")))
                {
                    majorwbs.SetUsers(ProjectRole.Designer.ToString(), major.GetValue("DesignID").Split(','));
                }
                if (!String.IsNullOrEmpty(major.GetValue("CollactorID")))
                {
                    majorwbs.SetUsers(ProjectRole.Collactor.ToString(), major.GetValue("CollactorID").Split(','));
                }
                if (!String.IsNullOrEmpty(major.GetValue("AuditorID")))
                {
                    majorwbs.SetUsers(ProjectRole.Auditor.ToString(), major.GetValue("AuditorID").Split(','));
                }
                if (!String.IsNullOrEmpty(major.GetValue("CheckID")))
                {
                    majorwbs.SetUsers(ProjectRole.Approver.ToString(), major.GetValue("CheckID").Split(','));
                }
            }
        }