public bool Save(PmsHead pmsHead, string oldCrId, string newCrId, string loginName, string oldType, string newType) { try { m_PMSSqlConnection.BeginTransaction(); // add by Ename Wang on 20120321 #region 更新pms_flow表 PmsFlow pmsFlow = new PmsFlow(); PmsFlowTemplateBiz pmsFlowTemplateBiz = new PmsFlowTemplateBiz(); IList <PmsFlowTemplate> pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId(newType); pmsFlow.FlowId = pmsFlowTemplateList[0].FlowId; pmsFlow.PmsId = pmsHead.PmsId; pmsFlow.Creator = loginName; pmsFlow.CreateDate = System.DateTime.Now; if (!UpdatePmsFlow(pmsFlow)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } #endregion // end add // add by Ename Wang on 20120531 fix change CR to Small CR stage Bug IList <int> StageIds = new List <int>(); bool IsExist = true; foreach (PmsFlowTemplate pmsFlowTemplate in pmsFlowTemplateList) { StageIds.Add(pmsFlowTemplate.Stageid); } if (StageIds != null) { IsExist = StageIds.Contains(pmsHead.Stage); } if (IsExist == false) { switch (pmsHead.Stage) { case (int)PmsCommonEnum.ProjectStage.PIS_STP: pmsHead.Stage = (int)PmsCommonEnum.ProjectStage.Develop_Test; break; default: break; } } // end add if (!UpdatePmsHeadForOK(pmsHead)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } if (newType != oldType) { if (!new SdpDetailBiz().InsertSdpDetailByTemplateOnTypeChange(pmsHead.PmsId, oldType, newType)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } } if (oldCrId != newCrId) { //更新itarm_cr_list(删除旧的CRID,更新新的CRID) if (!DeleteItarmCrListAndCo(oldCrId)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } PmsItarmMappingBiz pmsItarmMappingBiz = new PmsItarmMappingBiz(); IList <PmsItarmMapping> pmsItarmMappingChange = pmsItarmMappingBiz.SelectPmsItarmMapping(newCrId, null); string changeContent = pmsItarmMappingChange.Aggregate("The following data is deleted:", (current, m) => current + m.CrId + ":" + m.PmsId + "."); // 已经存在SD的CR不能删除 if (pmsItarmMappingChange != null) { if (pmsItarmMappingChange.FirstOrDefault() != null) { string pmsId = pmsItarmMappingChange.FirstOrDefault().PmsId; PmsHeadBiz pmsHeadBiz = new PmsHeadBiz(); IList <PmsHead> ListPmsHead = pmsHeadBiz.SelectPmsHeadByPmsId(pmsId); if (ListPmsHead != null) { if (ListPmsHead.FirstOrDefault() != null) { if (ListPmsHead.FirstOrDefault().Sd == string.Empty) { if (!pmsItarmMappingBiz.DeletePmsItarmMappingCrId(newCrId)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } } } } } } if (!pmsItarmMappingBiz.UpdatePmsItarmMappingCrId(oldCrId, newCrId)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } //New CR 是ITARM创建的,它的SDP应及时删掉,防止和老CR的SDP重复 if (!new SdpDetailBiz().DeleteSDPForCRNoChange(newCrId)) { m_PMSSqlConnection.RollBackTransaction(); return(false); } //更新bugfree数据库中的表。账号权限不足,执行报错 //if (!UpdateBugfree(oldCrId, newCrId)) //{ // m_PMSSqlConnection.RollBackTransaction(); // return false; //} PmsChangeHistory pmsChangeHistory = new PmsChangeHistory(); pmsChangeHistory.PmsId = pmsHead.PmsId; pmsChangeHistory.Action = "Delete and Update CrId"; pmsChangeHistory.ChangeContent = changeContent + " CrId is changed from '" + oldCrId + "' to '" + newCrId + "'"; pmsChangeHistory.Creator = loginName; pmsChangeHistory.CreateDate = PmsSysBiz.GetDBDateTime(); new PmsChangeHistoryBiz().InsertPmsChangeHistory(pmsChangeHistory); } //更新pms_system_version #region 更新系统版本表 //TODO: oldType,newType为Service的情况。 if (oldType != PmsCommonEnum.ProjectTypeFlowId.Service.GetDescription()) { bool upVerResult = new PmsCRCreatBiz().UpdateSysVersion(pmsHead.Domain, pmsHead.System, pmsHead.Site, pmsHead.NewVersion); if (!upVerResult) { m_PMSSqlConnection.RollBackTransaction(); return(false); } } #endregion m_PMSSqlConnection.CommitTransaction(); return(true); } catch (Exception ex) { m_PMSSqlConnection.RollBackTransaction(); m_Logger.Error("BasicInformationDetailBiz/Save" + ex.Message.ToString()); return(false); } }
public int InsertPmsHeadAndDoc(PmsHead pmsHead, SdpDetail sdpDetail, PmsChangeHistory pmsChangeHistory, PmsItarmMapping pmsItarmMapping, PmsFlow pmsFlow, ItarmCrList itarmCrList, IList <PmsDocuments> listPmsDocuments, out string errorInfo) { errorInfo = string.Empty; int returnResult = 0; try { m_PMSSqlConnection.BeginTransaction(); #region Insert PmsHead //string type = pmsHead.PmsName.GetTypeCode; m_PMSSqlConnection.Insert("InsertPmsHead", pmsHead); #endregion #region Insert PmsItarmMapping PmsItarmMappingBiz pmsItarmMappingBiz = new PmsItarmMappingBiz(); pmsItarmMappingBiz.InsertPmsItarmMapping(pmsItarmMapping); #endregion #region Insert PmsDocuments if (listPmsDocuments != null) { foreach (PmsDocuments pmsDocuments in listPmsDocuments) { if (pmsDocuments.DocTypeId == 0) { errorInfo = "DocTypeId is Invalid!"; return(returnResult); } if (pmsDocuments.FileName == string.Empty) { errorInfo = "FileName is Empty!"; return(returnResult); } if (pmsDocuments.FileName != string.Empty) { m_PMSSqlConnection.Insert("InsertPmsDocuments", pmsDocuments); } } } #endregion #region Insert SdpDetail SdpDetailBiz sdpDetailBiz = new SdpDetailBiz(); returnResult = sdpDetailBiz.InsertSdpDetailByTemplate(sdpDetail); if (returnResult == 0) { m_PMSSqlConnection.RollBackTransaction(); return(returnResult); } #endregion #region Insert PmsChangeHistory PmsChangeHistoryBiz pmsChangeHistoryBiz = new PmsChangeHistoryBiz(); pmsChangeHistoryBiz.InsertPmsChangeHistory(pmsChangeHistory); #endregion #region Insert PmsFlow PmsFlowBiz pmsFlowBiz = new PmsFlowBiz(); pmsFlowBiz.InsertPmsFlow(pmsFlow); #endregion #region Insert ItarmCrList bool resultInsertItarm = new PmsCRCreatBiz().InsertItarmCrList(itarmCrList); if (!resultInsertItarm) { m_PMSSqlConnection.RollBackTransaction(); errorInfo = "Save Fail"; return(0); } #endregion m_PMSSqlConnection.CommitTransaction(); } catch (Exception ex) { m_PMSSqlConnection.RollBackTransaction(); errorInfo = "Save Fail"; m_Logger.Error("PmsHeadBiz/InsertPmsHeadAndDoc" + ex.Message.ToString()); } return(returnResult); }