private void SetPublishInfoDetail(string S_E_PublishInfoID) { var entities = FormulaHelper.GetEntities <ProjectEntities>(); var products = this.T_EXE_PublishApply_Products.ToList(); var pids = products.Select(a => a.ProductID).Distinct().ToList(); var productList = entities.Set <S_E_Product>().Where(a => pids.Contains(a.ID)).ToList(); var versionList = entities.Set <S_E_ProductVersion>().Where(a => pids.Contains(a.ProductID)).ToList(); foreach (var applyProduct in products) { S_E_PublishInfoDetail detail = new S_E_PublishInfoDetail(); detail.S_E_PublishInfoID = S_E_PublishInfoID; detail.ProductID = applyProduct.ID; detail.ProductCode = applyProduct.ProductCode; detail.ProductName = applyProduct.ProductName; detail.ProductVersion = applyProduct.ProductVersion; detail.ProjectInfoName = this.ProjectName; detail.ProjectCode = this.ProjectCode; detail.ProjectManager = this.ProjectManager; detail.MajorCode = this.MajorCode; detail.StepName = this.StepName; detail.SerialNumber = this.SerialNumber; //detail.PublishDate = this.PublishDate; S_I_ProjectInfo proj = entities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (proj == null) { throw new Formula.Exceptions.BusinessException("未找到ID为" + this.ProjectInfoID + "的S_I_ProjectInfo表"); } detail.ChargeDeptName = proj.ChargeDeptName; var p = productList.FirstOrDefault(a => a.ID == applyProduct.ProductID && a.Version == applyProduct.ProductVersion); if (p != null) { detail.PdfFile = p.PdfFile; detail.PlotFile = p.PlotFile; } else { var version = versionList.FirstOrDefault(a => a.ProductID == applyProduct.ProductID && a.Version == applyProduct.ProductVersion); if (version != null) { { detail.PdfFile = version.PdfFile; detail.PlotFile = version.PlotFile; } } } //TODO //detail.DesingerName detail.Printed = false; detail.ID = FormulaHelper.CreateGuid(); entities.Set <S_E_PublishInfoDetail>().Add(detail); } }
//同步扩展字段至项目 public void SyncExtention(S_I_ProjectInfo project) { project.Extention1 = this.Extention1; project.Extention2 = this.Extention2; project.Extention3 = this.Extention3; project.Extention4 = this.Extention4; project.Extention5 = this.Extention5; project.Extention6 = this.Extention6; project.Extention7 = this.Extention7; project.Extention8 = this.Extention8; project.Extention9 = this.Extention9; project.Extention10 = this.Extention10; }
/// <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); }
/// <summary> /// 绑定管理单元 /// </summary> /// <param name="projectInfo">管理单元项目对象</param> public void BindingProject(S_I_ProjectInfo projectInfo) { var baseConfigEntities = this.GetDbContext <BaseConfigEntities>(); var projectEntities = this.GetDbContext <ProjectEntities>(); if (!String.IsNullOrEmpty(projectInfo.GroupID)) { var groupInfo = projectEntities.S_I_ProjectGroup.FirstOrDefault(d => d.ID == projectInfo.GroupID); if (groupInfo != null) { throw new Formula.Exceptions.BusinessException("已经绑定了EPS的项目不能进行重复绑定"); } } projectInfo.EngineeringInfoID = this.RelateID; var type = EngineeringSpaceType.UnderEngineering.ToString(); var epsDefines = baseConfigEntities.Set <S_D_EPSDef>().Where(d => d.Type == type).OrderBy(d => d.FullID).ToList(); if (this.Children.Count == 0 || epsDefines.Count == 0) { var project = new S_I_ProjectGroup(); project.ID = FormulaHelper.CreateGuid(); project.Name = projectInfo.Name; project.Code = projectInfo.Code; project.DeptID = projectInfo.ChargeDeptID; project.DeptName = projectInfo.ChargeDeptName; project.City = this.City; project.ProjectClass = string.IsNullOrEmpty(this.ProjectClass) ? projectInfo.ProjectClass : this.ProjectClass; project.Address = this.Address; project.Country = this.Country; project.Proportion = this.Proportion; project.Province = this.Province; project.RelateID = this.RelateID; project.Type = EngineeringSpaceType.Project.ToString(); project.ChargeUserName = projectInfo.ChargeUserName; project.ChargeUser = projectInfo.ChargeUserID; project.PhaseContent = projectInfo.PhaseName; project.PhaseValue = projectInfo.PhaseValue; project.State = projectInfo.State; this.AddChild(project); projectInfo.GroupID = project.ID; projectInfo.GroupRootID = project.RootID; projectInfo.GroupFullID = project.FullID; } else { var list = new List <S_I_ProjectGroup>(); foreach (var item in epsDefines) { #region var propertyInfoValue = projectInfo.GetPropertyString(item.GroupField); var eps = projectEntities.S_I_ProjectGroup.FirstOrDefault(d => d.DefineID == item.ID && d.Name == propertyInfoValue && d.FullID.StartsWith(this.FullID)); if (eps == null) { eps = projectEntities.S_I_ProjectGroup.Create(); eps.Type = EngineeringSpaceType.UnderEngineering.ToString(); eps.ID = FormulaHelper.CreateGuid(); eps.Name = propertyInfoValue; eps.DefineID = item.ID; if (item.Parent == null) { throw new Formula.Exceptions.BusinessException(); } if (item.Parent.Type == EngineeringSpaceType.Engineering.ToString()) { eps.RelateID = this.RelateID; eps.Type = EngineeringSpaceType.UnderEngineering.ToString(); this.AddChild(eps); } else { var parentValue = projectInfo.GetPropertyString(item.Parent.GroupField); var parentEps = list.FirstOrDefault(d => d.DefineID == item.ParentID && d.Name == parentValue); if (parentEps != null) { parentEps.AddChild(eps); } } } list.Add(eps); if (item.Children.Count == 0) { var project = new S_I_ProjectGroup(); project.ID = FormulaHelper.CreateGuid(); project.Name = projectInfo.Name; project.Code = projectInfo.Code; project.DeptID = projectInfo.ChargeDeptID; project.DeptName = projectInfo.ChargeDeptName; project.City = this.City; project.ProjectClass = this.ProjectClass; project.Address = this.Address; project.Country = this.Country; project.Proportion = this.Proportion; project.Province = this.Province; project.RelateID = this.RelateID; project.Type = EngineeringSpaceType.Project.ToString(); project.ChargeUserName = project.ChargeUserName; project.ChargeUserName = projectInfo.ChargeUserName; project.ChargeUser = projectInfo.ChargeUserID; project.PhaseValue = projectInfo.PhaseValue; project.State = projectInfo.State; eps.AddChild(project); projectInfo.GroupID = project.ID; projectInfo.GroupRootID = project.RootID; projectInfo.GroupFullID = project.FullID; } #endregion } } }