protected override void OnFlowEnd(T_SC_DesignPlanPetrifaction entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity != null)
            {
                List <S_P_MileStone> deleteMileStoneList = new List <S_P_MileStone>();
                var projectEntities     = FormulaHelper.GetEntities <ProjectEntities>();
                var projectInfo         = projectEntities.Set <S_I_ProjectInfo>().Find(entity.ProjectInfoID);
                var detailMileStoneList = entity.T_SC_DesignPlanPetrifaction_MilestoneList.ToList();
                var selectCodes         = detailMileStoneList.Select(a => a.Code).ToList();
                deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList();

                entity.Push();
                this.BusinessEntities.SaveChanges();
                //同步关联的收款项的里程碑信息:时间、状态
                var fo = new Basic.Controllers.MileStoneExecuteController();
                //找到删除的里程碑的所有收款项,在这些收款项中去除当前里程碑,在同步这些收款项的里程碑信息
                //foreach (var item in deleteMileStoneList)
                //{
                //    fo.UpdateReceiptObjByDelMeliStoneID(item.ID);
                //}
                //foreach (var item in projectInfo.S_P_MileStone.ToList())
                //{
                //    fo.SyncReceiptObj(item);
                //}
                //FormulaHelper.GetEntities<Market.Logic.Domain.MarketEntities>().SaveChanges();
            }
        }
        public JsonResult MileStoneSave(string MileStoneData, string ProjectInfoID, string WBSID)
        {
            string projectInfoID = this.Request["ProjectInfoID"];
            var    projectInfo   = this.GetEntityByID <S_I_ProjectInfo>(projectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + projectInfoID + "】的项目信息对象,无法保存里程碑信息");
            }
            var list     = JsonHelper.ToList(MileStoneData);
            var marketDB = SQLHelper.CreateSqlHelper(ConnEnum.Market);
            int Weight   = 0;

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();

            foreach (var item in list)
            {
                if (!string.IsNullOrEmpty(item.GetValue("Weight")))
                {
                    if (Weight < Convert.ToInt32(item.GetValue("Weight")))
                    {
                        Weight = Convert.ToInt32(item.GetValue("Weight"));
                    }
                }
                if (item.GetValue("_state") == "removed")
                {
                    continue;
                }
                S_P_MileStone mileStone;
                mileStone = this.GetEntityByID <S_P_MileStone>(item.GetValue("ID"));
                if (mileStone == null)
                {
                    mileStone = this.CreateEmptyEntity <S_P_MileStone>();
                }
                this.UpdateEntity(mileStone, item);
                mileStone.Save();

                //fo.SyncReceiptObj(mileStone);

                var receiptObjID = item.GetValue("ReceiptObjectID");
                if (!String.IsNullOrEmpty(receiptObjID))
                {
                    string sql = "update S_C_ManageContract_ReceiptObj set MileStoneID='{0}',MileStoneState='{1}' WHERE ID in ('{2}') ";
                    marketDB.ExecuteNonQuery(String.Format(sql, mileStone.ID, mileStone.State, receiptObjID.Replace(",", "','")));
                }
                else
                {
                    string sql = "update S_C_ManageContract_ReceiptObj set MileStoneID='',MileStoneState='' WHERE MileStoneID='{0}'  ";
                    marketDB.ExecuteNonQuery(String.Format(sql, mileStone.ID));
                }
            }
            if (Weight > 100)
            {
                throw new Formula.Exceptions.BusinessException("权重不能大于100%");
            }
            entities.SaveChanges();
            //FormulaHelper.GetEntities<Market.Logic.Domain.MarketEntities>().SaveChanges();
            return(Json(""));
        }
        public void Finish(string MileStoneData, string FinishDate)
        {
            var list = JsonHelper.ToList(MileStoneData);

            if (String.IsNullOrEmpty(FinishDate))
            {
                throw new Formula.Exceptions.BusinessException("必须指定延迟日期");
            }

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();

            foreach (var item in list)
            {
                var plan = this.GetEntityByID <S_P_MileStonePlan>(item.GetValue("ID"));
                if (plan == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + item.GetValue("ID") + "】的里程碑信息,无法进行变更操作");
                }
                var date = Convert.ToDateTime(FinishDate.Trim('\"'));
                plan.Finish(date);
                //fo.SyncReceiptObj(plan.S_P_MileStone);
            }
            this.entities.SaveChanges();
            //FormulaHelper.GetEntities<Market.Logic.Domain.MarketEntities>().SaveChanges();
        }
        protected override void OnFlowEnd(T_SC_SimpleProjectSchmea entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            string formData = Request["FormData"];
            Dictionary <string, string> dic = JsonHelper.ToObject <Dictionary <string, string> >(formData);
            var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(entity.ProjectInfoID);

            //var marketEntities = Formula.FormulaHelper.GetEntities<Market.Logic.Domain.MarketEntities>();
            // var marketProject = marketEntities.Set<Market.Logic.Domain.S_I_Project>().FirstOrDefault(d => d.ID == projectInfo.MarketProjectInfoID);
            if (projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_TemporaryMode") == TrueOrFalse.True.ToString())
            {
                var schemeDic = JsonHelper.ToObject <Dictionary <string, object> >(formData);
                var ignorKeys = new string[] { "CreateUserID", "CreateUser", "CreateDate", "State", "Major" };
                schemeDic.RemoveWhere(a => ignorKeys.Contains(a.Key));
                FormulaHelper.UpdateEntity(projectInfo, schemeDic);
                projectInfo.ReBuild();
                //marketProject.Phase = projectInfo.PhaseValue;
                //marketProject.Name = projectInfo.Name;
                //marketProject.Code = projectInfo.Code;
                //marketProject.Phase = projectInfo.PhaseValue;
                //marketProject.ProjectClass = projectInfo.ProjectClass;
                //marketProject.Customer = projectInfo.CustomerID;
                //marketProject.CustomerName = projectInfo.CustomerName;
                //marketProject.CreateDate = DateTime.Now;
                //marketProject.EngineeringInfo = projectInfo.EngineeringInfoID;
                //marketProject.ChargerDept = projectInfo.ChargeDeptID;
                //marketProject.ChargerDeptName = projectInfo.ChargeDeptName;
                //marketProject.ChargerUser = projectInfo.ChargeUserID;
                //marketProject.ChargerUserName = projectInfo.ChargeUserName;
                //marketProject.Country = projectInfo.Country;
                //marketProject.Province = projectInfo.Province;
                //marketProject.City = projectInfo.City;
                //marketProject.ProjectScale = projectInfo.ProjectLevel.HasValue ? projectInfo.ProjectLevel.Value.ToString() : "";
            }
            List <S_P_MileStone> deleteMileStoneList = new List <S_P_MileStone>();

            if (entity != null)
            {
                var selectCodes = entity.T_SC_SimpleProjectSchmea_MileStone.Select(a => a.Code).ToList();
                deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList();
                entity.Push(dic);
            }
            //if (marketProject != null)
            //    marketProject.State = ProjectCommoneState.Execute.ToString();
            //marketEntities.SaveChanges();
            this.BusinessEntities.SaveChanges();

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();
            //找到删除的里程碑的所有收款项,在这些收款项中去除当前里程碑,在同步这些收款项的里程碑信息
            //foreach (var item in deleteMileStoneList)
            //{
            //    fo.UpdateReceiptObjByDelMeliStoneID(item.ID);
            //}
            //foreach (var item in projectInfo.S_P_MileStone.ToList())
            //{
            //    fo.SyncReceiptObj(item);
            //}
            //marketEntities.SaveChanges();
        }
        /// <summary>
        /// 流程结束反写的业务逻辑
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="taskExec"></param>
        /// <param name="routing"></param>
        protected override void OnFlowEnd(T_EXE_MajorPutInfo entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity != null)
            {
                entity.Publish();
            }
            this.BusinessEntities.SaveChanges();

            if (!string.IsNullOrEmpty(entity.CoopPlanID))
            {
                var coopPlan = this.BusinessEntities.Set <S_P_CooperationPlan>().FirstOrDefault(c => c.ID == entity.CoopPlanID);
                if (coopPlan != null && !string.IsNullOrEmpty(coopPlan.MileStoneID))
                {
                    var mileStone = this.BusinessEntities.Set <S_P_MileStone>().FirstOrDefault(c => c.ID == coopPlan.MileStoneID);
                    //同步关联的收款项的里程碑信息:时间、状态
                    var fo = new Basic.Controllers.MileStoneExecuteController();
                    fo.SyncReceiptObj(mileStone);
                }
            }
        }
Exemple #6
0
        public JsonResult DeleteMileStone(string MileStoneData)
        {
            var list = JsonHelper.ToList(MileStoneData);
            var deleteMileStoneIDList = new List <string>();

            foreach (var item in list)
            {
                var ID = item.GetValue("ID");
                if (String.IsNullOrEmpty(ID))
                {
                    continue;
                }
                var mileStone = this.GetEntityByID <S_P_MileStone>(ID);
                if (mileStone == null)
                {
                    continue;
                }

                if (mileStone.State == MileStoneState.Finish.ToString())
                {
                    throw new Formula.Exceptions.BusinessException("里程碑【" + mileStone.Name + "】已经完成,无法删除");
                }
                this.entities.Set <S_P_MileStone>().Delete(d => d.ID == ID);
                deleteMileStoneIDList.Add(ID);
            }
            this.entities.SaveChanges();

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();

            //找到删除的里程碑的所有收款项,在这些收款项中去除当前里程碑,在同步这些收款项的里程碑信息
            foreach (var item in deleteMileStoneIDList)
            {
                fo.UpdateReceiptObjByDelMeliStoneID(item);
            }
            FormulaHelper.GetEntities <Market.Logic.Domain.MarketEntities>().SaveChanges();

            return(Json(""));
        }
        public JsonResult Delete()
        {
            var projectInfoID = this.Request["ProjectInfoID"];
            var listIDs       = this.Request["ListIDs"];
            var linkRoot      = false;

            if (this.Request["LinkRoot"] != null)
            {
                linkRoot = this.Request["LinkRoot"].ToLower() == bool.TrueString.ToLower();
            }
            var relateWBSs = this.entities.Set <S_W_WBS>().Where(a => a.ProjectInfoID == projectInfoID && !string.IsNullOrEmpty(a.RelateMileStone)).ToList();

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();

            foreach (var item in listIDs.Split(','))
            {
                var entity = this.GetEntityByID <S_P_CooperationPlan>(item);
                if (entity == null)
                {
                    continue;
                }
                entity.Delete(false, linkRoot);
                var relateWBSByThiss = relateWBSs.Where(a => a.RelateMileStone.Contains(entity.MileStoneID));

                //fo.UpdateReceiptObjByDelMeliStoneID(entity.MileStoneID);

                foreach (var w in relateWBSByThiss)
                {
                    var relateMileStone = JsonHelper.ToList(w.RelateMileStone);
                    var deleteItem      = relateMileStone.FirstOrDefault(a => a.GetValue("ID") == entity.MileStoneID);
                    if (deleteItem != null)
                    {
                        relateMileStone.Remove(deleteItem);
                    }
                    if (relateMileStone.Count > 0)
                    {
                        DateTime?bStart = DateTime.MinValue, bFinish = DateTime.MaxValue;
                        foreach (var mileS in relateMileStone)
                        {
                            if (mileS["PlanStart"] != null && bStart < (DateTime)mileS["PlanStart"])
                            {
                                bStart = (DateTime)mileS["PlanStart"];
                            }
                            if (mileS["PlanFinish"] != null && bFinish > (DateTime)mileS["PlanFinish"])
                            {
                                bFinish = (DateTime)mileS["PlanFinish"];
                            }
                        }
                        if (bStart != DateTime.MinValue)
                        {
                            w.BasePlanStartDate = bStart;
                        }
                        if (bFinish != DateTime.MaxValue)
                        {
                            w.BasePlanEndDate = bFinish;
                        }
                    }
                    else
                    {
                        w.BasePlanStartDate = null;
                        w.BasePlanEndDate   = null;
                    }
                    w.RelateMileStone = JsonHelper.ToJson(relateMileStone);
                }
            }
            this.entities.SaveChanges();
            //FormulaHelper.GetEntities<MarketEntities>().SaveChanges();
            return(Json(""));
        }
        public JsonResult SaveCoopPlan(string List)
        {
            var projectInfoID = this.Request["ProjectInfoID"];
            var subProjectID  = this.Request["SchemeWBSID"];
            var linkRoot      = false;

            if (this.Request["LinkRoot"] != null)
            {
                linkRoot = this.Request["LinkRoot"].ToLower() == bool.TrueString.ToLower();
            }
            var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(projectInfoID);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + projectInfoID + "】的项目信息对象,无法进行互提资料策划");
            }
            var relateWBSs = projectInfo.S_W_WBS.Where(a => !string.IsNullOrEmpty(a.RelateMileStone)).ToList();
            var wbs        = entities.Set <S_W_WBS>().FirstOrDefault(d => d.ID == subProjectID);

            if (wbs == null)
            {
                wbs = projectInfo.WBSRoot;
            }
            var CoopPlanList = UpdateList <S_P_CooperationPlan>(List);

            foreach (var item in CoopPlanList)
            {
                if (linkRoot && string.IsNullOrEmpty(item.WBSID))
                {
                    item.WBSID = projectInfo.WBSRoot.ID;
                }
                wbs.SaveCooperationPlan(item, true, linkRoot);
                //关联了这个提资计划的WBS
                var relateWBSByThiss = relateWBSs.Where(a => a.RelateMileStone.Contains(item.MileStoneID));
                foreach (var w in relateWBSByThiss)
                {
                    var relateMileStone = JsonHelper.ToList(w.RelateMileStone);
                    var m = relateMileStone.FirstOrDefault(a => a.GetValue("ID") == item.MileStoneID);
                    if (m != null)
                    {
                        m["Name"]       = item.CooperationContent;
                        m["PlanStart"]  = item.PlanStartDate;
                        m["PlanFinish"] = item.PlanFinishDate;
                    }
                    w.RelateMileStone = JsonHelper.ToJson(relateMileStone);
                    if (item.PlanStartDate != null)
                    {
                        if (w.BasePlanStartDate == null)
                        {
                            w.BasePlanStartDate = item.PlanStartDate;
                        }
                        else if (w.BasePlanStartDate < item.PlanStartDate)
                        {
                            w.BasePlanStartDate = item.PlanStartDate;
                        }
                        if (w.PlanStartDate == null)
                        {
                            w.PlanStartDate = item.PlanStartDate;
                        }
                        else if (w.PlanStartDate < item.PlanStartDate)
                        {
                            w.PlanStartDate = item.PlanStartDate;
                        }
                    }
                    if (item.PlanFinishDate != null)
                    {
                        if (w.BasePlanEndDate == null)
                        {
                            w.BasePlanEndDate = item.PlanFinishDate;
                        }
                        else if (w.BasePlanEndDate > item.PlanFinishDate)
                        {
                            w.BasePlanEndDate = item.PlanFinishDate;
                        }
                        if (w.PlanEndDate == null)
                        {
                            w.PlanEndDate = item.PlanFinishDate;
                        }
                        else if (w.PlanEndDate > item.PlanFinishDate)
                        {
                            w.PlanEndDate = item.PlanFinishDate;
                        }
                    }
                }
            }
            entities.SaveChanges();

            //同步关联的收款项的里程碑信息:时间、状态
            var fo = new Basic.Controllers.MileStoneExecuteController();

            foreach (var item in projectInfo.S_P_MileStone.ToList())
            {
                fo.SyncReceiptObj(item);
            }
            FormulaHelper.GetEntities <MarketEntities>().SaveChanges();
            return(Json(""));
        }