public bool GetCrID(string pmsId, out string crId) { crId = ""; try { PmsItarmMappingBiz pmsItarmMappingBiz = new PmsItarmMappingBiz(); IList <PmsItarmMapping> pmsItarmMappingList = pmsItarmMappingBiz.SelectPmsItarmMapping(null, pmsId); if (pmsItarmMappingList != null && pmsItarmMappingList.Count > 0) { crId = pmsItarmMappingList[0].CrId.Trim(); } return(true); } catch { return(false); } }
public bool GetNewPmsIdTempCrId(out DateTime creatDateTime, out string newPmsId, out string newTempCrId) { creatDateTime = PmsSysBiz.GetDBDateTime(); string creatDate = FormatDate(creatDateTime, "yyyyMMdd"); //获取PmsId string pmsIdPart = "PMS" + creatDate; PmsHeadBiz pmsHeadBiz = new PmsHeadBiz(); IList <PmsHead> pmsHeadListPmsId = pmsHeadBiz.SelectPmsHeadByPmsId(pmsIdPart); // pmsIdListCount = pmsHeadListPmsId.Count; if (pmsHeadListPmsId != null && pmsHeadListPmsId.Count > 0) { //目前不考虑“9999”的情况 //取最大的记录加1 int maxPmsIdNum = int.Parse(pmsHeadListPmsId[pmsHeadListPmsId.Count - 1].PmsId.Substring(11, 4)); int tempPmsIdNum; for (int i = 0; i < pmsHeadListPmsId.Count; i++) { tempPmsIdNum = int.Parse(pmsHeadListPmsId[i].PmsId.Substring(11, 4)); if (maxPmsIdNum < tempPmsIdNum) { maxPmsIdNum = tempPmsIdNum; } } maxPmsIdNum = maxPmsIdNum + 1; string pmsIdNum = maxPmsIdNum.ToString(); //不足四位补“0” while (pmsIdNum.Length < 4) { pmsIdNum = "0" + pmsIdNum; } ////不足四位补“0” //do //{ // pmsIdNum = "0" + pmsIdNum; //} while (pmsIdNum.Length < 4); newPmsId = pmsIdPart + pmsIdNum; } else { newPmsId = pmsIdPart + "0001"; } //获取CrId string tempCrIdPart = "T" + creatDate; //IList<PmsHead> pmsHeadListCrId = pmsHeadBiz.SelectPmsHeadByTempCrIdPart(tempCrIdPart); IList <PmsItarmMapping> pmsItarmMappingList = new PmsItarmMappingBiz().SelectPmsItarmMappingByTempCrIdPart(tempCrIdPart); if (pmsItarmMappingList != null && pmsItarmMappingList.Count > 0) { //目前不考虑“9999”的情况 //取最大的记录加1 int maxCrIdNum = int.Parse(pmsItarmMappingList[pmsItarmMappingList.Count - 1].CrId.Substring(9, 4)); int tempCrIdNum; for (int j = 0; j < pmsItarmMappingList.Count; j++) { tempCrIdNum = int.Parse(pmsItarmMappingList[j].CrId.Substring(9, 4)); if (maxCrIdNum < tempCrIdNum) { maxCrIdNum = tempCrIdNum; } } maxCrIdNum = maxCrIdNum + 1; string crIdNum = maxCrIdNum.ToString(); //不足四位补“0” while (crIdNum.Length < 4) { crIdNum = "0" + crIdNum; } //do //{ // crIdNum = "0" + crIdNum; //} while (crIdNum.Length < 4); newTempCrId = tempCrIdPart + crIdNum; } else { newTempCrId = tempCrIdPart + "0001"; } return(true); }
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); }
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 InsertFromItarmRequirement(string oldCrId, string newCrId) { ItarmCrList itarmCrListInsert = new ItarmCrList(); ItarmCrListCo itarmCrListCoInsert = new ItarmCrListCo(); ItarmCrListBiz itarmCrListBiz = new ItarmCrListBiz(); PmsItarmMappingBiz pmsItarmMappingBiz = new PmsItarmMappingBiz(); string creator = "Itarm"; DateTime createDate = System.DateTime.Now; int returnSerial = 0; try { #region Deal Requirement IList <SdpSys> sdpSysList = m_ITARMSqlConnection.QueryForList <SdpSys>("SelectRequirementList", newCrId); if (sdpSysList != null && sdpSysList.Count > 0) { // 插到itarm_CR_List m_PMSSqlConnection.BeginTransaction(); #region Insert itarm_cr_list if (sdpSysList[0].CrId.ToString().Trim().Length > 15) { itarmCrListInsert.CrId = sdpSysList[0].CrId.ToString().Trim().Substring(0, 15); } else { itarmCrListInsert.CrId = sdpSysList[0].CrId.ToString().Trim(); } if (sdpSysList[0].CRName.ToString().Trim().Length > 500) { itarmCrListInsert.CrName = sdpSysList[0].CRName.ToString().Trim().Substring(0, 500); } else { itarmCrListInsert.CrName = sdpSysList[0].CRName.ToString().Trim(); } if (sdpSysList[0].Site.ToString().Trim().Length > 20) { itarmCrListInsert.Site = sdpSysList[0].Site.ToString().Trim().Substring(0, 20); } else { itarmCrListInsert.Site = sdpSysList[0].Site.ToString().Trim(); } itarmCrListInsert.Creator = creator; itarmCrListInsert.CreateDate = createDate; if (sdpSysList[0].SystemName.ToString().Trim().Length > 100) { itarmCrListInsert.System = sdpSysList[0].SystemName.ToString().Trim().Substring(0, 100); } else { itarmCrListInsert.System = sdpSysList[0].SystemName.ToString().Trim(); } if (sdpSysList[0].PM.ToString().Trim().Length > 100) { itarmCrListInsert.Pm = sdpSysList[0].PM.ToString().Trim().Substring(0, 100); } else { itarmCrListInsert.Pm = sdpSysList[0].PM.ToString().Trim(); } int returnInsertResult = itarmCrListBiz.InsertItarmCrList(itarmCrListInsert); if (returnInsertResult <= 0) { m_PMSSqlConnection.RollBackTransaction(); return(returnSerial); } #endregion // 并更新PMS_Itarm_Mapping #region Update PMS_ITARM_Mapping bool mappingResult = pmsItarmMappingBiz.UpdatePmsItarmMappingCrId(oldCrId, newCrId); if (mappingResult == false) { m_PMSSqlConnection.RollBackTransaction(); return(returnSerial); } #endregion m_PMSSqlConnection.CommitTransaction(); returnSerial = 1; } #endregion } catch (Exception ex) { m_Logger.Error("ItArmCrListBiz/InsertFromItarmCr" + ex.ToString()); return(returnSerial); } try { #region Deal Requirement_Co IList <SdpSys> sdpSysList = m_ITARMSqlConnection.QueryForList <SdpSys>("SelectRequirementCoList", newCrId); if (sdpSysList != null && sdpSysList.Count > 0) { // 插到itarm_CR_List m_PMSSqlConnection.BeginTransaction(); #region Insert itarm_cr_list if (sdpSysList[0].CrId.ToString().Trim().Length > 15) { itarmCrListCoInsert.CrId = sdpSysList[0].CrId.ToString().Trim().Substring(0, 15); } else { itarmCrListCoInsert.CrId = sdpSysList[0].CrId.ToString().Trim(); } if (sdpSysList[0].CrId_co.ToString().Trim().Length > 15) { itarmCrListCoInsert.RelatedcrId = sdpSysList[0].CrId_co.ToString().Trim().Substring(0, 15); } else { itarmCrListCoInsert.RelatedcrId = sdpSysList[0].CrId_co.ToString().Trim(); } if (sdpSysList[0].CRName.ToString().Trim().Length > 500) { itarmCrListCoInsert.CrName = sdpSysList[0].CRName.ToString().Trim().Substring(0, 500); } else { itarmCrListCoInsert.CrName = sdpSysList[0].CRName.ToString().Trim(); } if (sdpSysList[0].CRName_co.ToString().Trim().Length > 100) { itarmCrListCoInsert.RelatedcrName = sdpSysList[0].CRName_co.ToString().Trim().Substring(0, 100); } else { itarmCrListCoInsert.RelatedcrName = sdpSysList[0].CRName_co.ToString().Trim(); } if (sdpSysList[0].Site.ToString().Trim().Length > 20) { itarmCrListCoInsert.RelatedSite = sdpSysList[0].Site.ToString().Trim().Substring(0, 20); } else { itarmCrListCoInsert.RelatedSite = sdpSysList[0].Site.ToString().Trim(); } itarmCrListCoInsert.Creator = creator; itarmCrListCoInsert.CreateDate = createDate; if (sdpSysList[0].SystemName.ToString().Trim().Length > 100) { itarmCrListCoInsert.System = sdpSysList[0].SystemName.ToString().Trim().Substring(0, 100); } else { itarmCrListCoInsert.System = sdpSysList[0].SystemName.ToString().Trim(); } if (sdpSysList[0].PM.ToString().Trim().Length > 100) { itarmCrListCoInsert.Pm = sdpSysList[0].PM.ToString().Trim().Substring(0, 100); } else { itarmCrListCoInsert.Pm = sdpSysList[0].PM.ToString().Trim(); } int returnInsertResult = itarmCrListBiz.InsertItarmCrListCo(itarmCrListCoInsert); if (returnInsertResult <= 0) { m_PMSSqlConnection.RollBackTransaction(); return(returnSerial); } #endregion // 并更新PMS_Itarm_Mapping #region Update PMS_ITARM_Mapping bool mappingResult = pmsItarmMappingBiz.UpdatePmsItarmMappingCrId(oldCrId, newCrId); if (mappingResult == false) { m_PMSSqlConnection.RollBackTransaction(); return(returnSerial); } #endregion m_PMSSqlConnection.CommitTransaction(); returnSerial = 1; } #endregion return(returnSerial); } catch (Exception ex) { m_Logger.Error("ItArmCrListBiz/InsertFromItarmCrCo" + ex.ToString()); return(returnSerial); } }