Ejemplo n.º 1
0
        public JsonResult ImportPackage(string DataSource, string TargetID, string WithUser)
        {
            var list = JsonHelper.ToList(DataSource);
            var wbs  = BusinessEntities.Set <S_W_WBS>().Find(TargetID);

            if (wbs == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + TargetID + "】的WBS节点,无法导入工作包");
            }
            foreach (var item in list)
            {
                var task = new S_W_TaskWork();
                task.Name = item.GetValue("Name");
                task.Code = item.GetValue("Code");
                if (!String.IsNullOrEmpty(item.GetValue("Workload")))
                {
                    task.Workload = Convert.ToDecimal(item.GetValue("Workload"));
                }
                task.PhaseValue = item.GetValue("PhaseCode");
                task.MajorValue = item.GetValue("MajorCode");
                if (WithUser == true.ToString())
                {
                    task.FillWBSUser(wbs);
                }
                wbs.AddTaskWork(task);
            }
            this.entities.SaveChanges();
            return(Json(""));
        }
Ejemplo n.º 2
0
        //public JsonResult GetDefaultTaskWorkDefaultRoleSet(string wbsNodeID)
        //{
        //    Dictionary<string, object> item = new Dictionary<string, object>();
        //    item.SetValue("ID", wbsNodeID);

        //    var wbs = BusinessEntities.Set<S_W_WBS>().Include("S_W_RBS").SingleOrDefault(d => d.ID == wbsNodeID);
        //    var CurrentUserInfo =  FormulaHelper.GetUserInfo();

        //    if (wbs != null)
        //    {
        //        item.SetValue("ProjectInfoID", wbs.ProjectInfoID);
        //        if (wbs.S_I_ProjectInfo.S_W_OBSUser.Count(d => d.UserID == CurrentUserInfo.UserID && d.MajorValue == wbs.WBSValue) > 0)
        //            item.SetValue("HasAuth", TrueOrFalse.True.ToString());
        //        else
        //            item.SetValue("HasAuth", TrueOrFalse.False.ToString());
        //        foreach (var stRole in wbs.StructNodeInfo.S_T_WBSStructRole.ToList())
        //        {
        //            string userID = string.Empty; string userName = string.Empty;
        //            foreach (var rbs in wbs.S_W_RBS.Where(d => d.RoleCode == stRole.RoleCode).ToList())
        //            {
        //                userID += rbs.UserID + ",";
        //                userName += rbs.UserName + ",";
        //            }
        //            item.SetValue(stRole.RoleCode + "UserID", userID.TrimEnd(','));
        //            item.SetValue(stRole.RoleCode + "UserName", userName.TrimEnd(','));
        //        }
        //    }

        //    string projectInfoID = wbs.ProjectInfoID;
        //    var projectInfo = wbs.S_I_ProjectInfo;
        //    if (projectInfo == null) throw new Formula.Exceptions.BusinessException("未能找到ID为【" + projectInfoID + "】的项目信息");
        //    var majorStruct = projectInfo.ProjectMode.S_T_WBSStructInfo.FirstOrDefault(d => d.Code == WBSNodeType.Major.ToString());
        //    if (majorStruct == null) throw new Formula.Exceptions.BusinessException("项目不存在专业节点定义,无法进行专业策划");
        //    var structRoles = majorStruct.S_T_WBSStructRole.Where(d => d.SychWBS != true.ToString()).OrderBy(d => d.SortIndex).ToList();
        //    ViewBag.StructRoles = structRoles;

        //    string sychField = "";
        //    foreach (var item1 in structRoles)
        //    {
        //        sychField += item1.RoleCode + "UserID,";
        //        sychField += item1.RoleCode + "UserName,";
        //    }
        //    ViewBag.SychField = sychField.TrimEnd(',');
        //    return Json(new { sychField = sychField, item = item });
        //}

        public JsonResult SaveWork(string TaskInfo, string ParentWBSID)
        {
            var list   = JsonHelper.ToList(TaskInfo);
            var parent = BusinessEntities.Set <S_W_WBS>().Find(ParentWBSID);

            if (parent == null)
            {
                throw new Formula.Exceptions.BusinessException("未获取到当前工作包的父节点,保存失败。");
            }
            foreach (var item in list)
            {
                S_W_TaskWork taskWork;
                if (item.GetValue("_state") == "removed")
                {
                    taskWork = BusinessEntities.Set <S_W_TaskWork>().Find(item.GetValue("ID"));
                    if (taskWork != null)
                    {
                        taskWork.Delete(false);
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(item.GetValue("ID")))
                    {
                        taskWork = new S_W_TaskWork();
                        this.UpdateEntity <S_W_TaskWork>(taskWork, item);
                        parent.AddTaskWork(taskWork);
                    }
                    else
                    {
                        taskWork = BusinessEntities.Set <S_W_TaskWork>().Find(item.GetValue("ID"));
                        this.UpdateEntity <S_W_TaskWork>(taskWork, item);
                        taskWork.Save();
                    }
                }
            }
            BusinessEntities.SaveChanges();
            return(Json(""));
        }
Ejemplo n.º 3
0
        public JsonResult ImportPackage(string DataSource, string TargetID, string ProjectInfoID)
        {
            var projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID);
            var list        = JsonHelper.ToList(DataSource);

            if (projectInfo == null)
            {
                throw new Formula.Exceptions.BusinessException("未能找到ID为【" + ProjectInfoID + "】的项目对象,导入工作包失败");
            }
            var majorList = projectInfo.GetMajorList();

            if (majorList.Count == 0)
            {
                throw new Formula.Exceptions.BusinessException("没有策划专业节点,无法进行工作包导入操作");
            }
            if (String.IsNullOrEmpty(TargetID))
            {
                foreach (var item in list)
                {
                    string majorValue = item.GetValue("MajorCode");
                    var    wbslist    = majorList.Where(d => d.WBSValue == majorValue).ToList();
                    foreach (var wbs in wbslist)
                    {
                        var task = new S_W_TaskWork();
                        task.MajorValue = majorValue;
                        task.Name       = item.GetValue("Name");
                        task.Code       = item.GetValue("Code");
                        if (!String.IsNullOrEmpty(item.GetValue("WorkLoad")))
                        {
                            task.Workload = Convert.ToDecimal(item.GetValue("WorkLoad"));
                        }
                        task.PhaseValue = item.GetValue("PhaseCode");
                        wbs.AddTaskWork(task);
                    }
                }
            }
            else
            {
                var wbs = this.GetEntityByID <S_W_WBS>(TargetID);
                if (wbs == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + TargetID + "】的WBS节点,导入工作包失败");
                }
                foreach (var item in list)
                {
                    string majorValue = item.GetValue("MajorCode");
                    var    task       = new S_W_TaskWork();
                    task.MajorValue = majorValue;
                    task.Name       = item.GetValue("Name");
                    task.Code       = item.GetValue("Code");
                    if (!String.IsNullOrEmpty(item.GetValue("WorkLoad")))
                    {
                        task.Workload = Convert.ToDecimal(item.GetValue("WorkLoad"));
                    }
                    task.PhaseValue = item.GetValue("PhaseCode");
                    wbs.AddTaskWork(task);
                }
            }
            this.entities.SaveChanges();
            return(Json(""));
        }
Ejemplo n.º 4
0
        protected override void OnFlowEnd(T_EXE_DesignChangeApply entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (!string.IsNullOrEmpty(entity.TaskWorkID))
            {
                //专业工作区内发起设计变更申请(单卷册)
                var task = this.GetEntityByID <S_W_TaskWork>(entity.TaskWorkID);
                if (task == null)
                {
                    throw new Formula.Exceptions.BusinessException("卷册【" + task.Name + "】不存在!");
                }
                if (task.Version == null)
                {
                    task.Version = 1;
                }
                else
                {
                    task.Version++;
                }
                task.ChangeState = TaskWorkChangeState.ApplyFinish.ToString();
                task.State       = TaskWorkState.Plan.ToString();
                task.FactEndDate = null;
                task.FactYear    = null;
                task.FactSeason  = null;
                task.FactMonth   = null;
            }
            else
            {
                //专业工作区外发起设计变更申请(多卷册)
                var majorWbs = this.BusinessEntities.Set <S_W_WBS>().FirstOrDefault(
                    a => a.ProjectInfoID == entity.ProjectInfoID && a.WBSValue == entity.MajorValue);
                var taskWorkList = this.BusinessEntities.Set <S_W_TaskWork>().Where(a => a.MajorValue == entity.MajorValue && a.ProjectInfoID == entity.ProjectInfoID).ToList();
                foreach (var detail in entity.T_EXE_DesignChangeApply_TaskWork.ToList())
                {
                    var task = taskWorkList.FirstOrDefault(a => a.ID == detail.TaskWorkID);
                    if (task == null)
                    {
                        task = new S_W_TaskWork();
                    }
                    task.Name        = detail.Name;
                    task.Code        = detail.Code;
                    task.MajorValue  = detail.Major;
                    task.PhaseValue  = detail.Phase;
                    task.DossierCode = detail.DossierCode;
                    task.DossierName = detail.DossierName;
                    task.PlanEndDate = detail.PlanEndDate;
                    task.Workload    = detail.Workload;
                    if (string.IsNullOrEmpty(task.ID))
                    {
                        task.ID = detail.TaskWorkID;
                        //根据专业同步人员
                        task.FillWBSUser(majorWbs);
                        majorWbs.AddTaskWork(task);
                        task.InitRoleRate();
                    }
                    else
                    {
                        task.Save();
                    }
                    task.ChangeState       = TaskWorkChangeState.ApplyFinish.ToString();
                    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;
                    }
                    else
                    {
                        task.Version++;
                    }

                    task.State       = TaskWorkState.Plan.ToString();
                    task.FactEndDate = null;
                    task.FactYear    = null;
                    task.FactSeason  = null;
                    task.FactMonth   = null;
                }
            }
            this.BusinessEntities.SaveChanges();
        }