public IList <PmsFlow> InsertPmsFlow(PmsFlow pmsFlow) { try { return(m_PMSSqlConnection.QueryForList <PmsFlow>("InsertPmsFlow", pmsFlow)); } catch (Exception ex) { m_Logger.Error("PmsFlowBiz/InsertPmsFlow:" + ex.ToString()); return(null); } }
public bool UpdatePmsFlow(PmsFlow pmsFlow) { try { m_PMSSqlConnection.Update("UpdatePmsFlow", pmsFlow); return(true); } catch (Exception ex) { m_Logger.Error("BasicInformationDetailBiz/pmsFlow:" + ex.ToString()); return(false); } }
protected PmsFlow getPmsFlow(string creator, DateTime createDate, string pmsID) { PmsFlow pmsFlow = new PmsFlow(); pmsFlow.Creator = creator; pmsFlow.CreateDate = createDate; PmsFlowTemplateBiz pmsFlowTemplateBiz = new PmsFlowTemplateBiz(); IList <PmsFlowTemplate> pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId("Service"); pmsFlow.FlowId = pmsFlowTemplateList[0].FlowId; pmsFlow.PmsId = pmsID; return(pmsFlow); }
/// <summary> /// Save Service Data /// </summary> /// <param name="pmsHead"></param> /// <param name="sdpDetail"></param> /// <param name="pmsFlow"></param> /// <param name="pmsDocuments"></param> /// <returns></returns> public int InsertServiceDataToDB(PmsHead pmsHead, SdpDetail sdpDetail, PmsFlow pmsFlow, PmsDocuments pmsDocuments) { int returnResult = 0; try { m_PMSSqlConnection.BeginTransaction(); // Insert PmsHead pmsHead.Vid = "PM"; pmsHead.Stage = 1; pmsHead.Pm = ""; pmsHead.Sd = ""; pmsHead.Se = ""; pmsHead.Qa = ""; // m_PMSSqlConnection.Insert("InsertPmsHead", pmsHead); // Insert SdpDetail SdpDetailBiz sdpDetailBiz = new SdpDetailBiz(); returnResult = sdpDetailBiz.InsertSdpDetailByTemplate(sdpDetail); if (returnResult == 0) { m_PMSSqlConnection.RollBackTransaction(); return(returnResult); } // Insert PmsFlow PmsFlowBiz pmsFlowBiz = new PmsFlowBiz(); pmsFlowBiz.InsertPmsFlow(pmsFlow); // Insert PmsDocuments if (pmsDocuments.FileName != string.Empty) { m_PMSSqlConnection.Insert("InsertPmsDocuments", pmsDocuments); } m_PMSSqlConnection.CommitTransaction(); } catch (Exception ex) { m_PMSSqlConnection.RollBackTransaction(); m_Logger.Error("PmsHeadBiz/InsertServiceDataToDB" + 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 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); }
protected void ButtonSave_Click(object sender, EventArgs e) { try { //get creator,createDate,pmsID,crID string creator = WSC.GlobalDefinition.Cookie_LoginUser.Replace(" ", "."); DateTime createDate; string pmsID = string.Empty; string crId = string.Empty; m_PmsCRCreatBiz.GetNewPmsIdTempCrId(out createDate, out pmsID, out crId); //get pmsHead,pmsflow,sdpDetail,getPmsChangeHistory,getPmsItarmMapping,getPmsFlow,itarmCrList PmsHead pmsHead = getPmsHead(creator, createDate, pmsID); SdpDetail sdpDetail = getSdpDetail(pmsID); PmsChangeHistory pmsChangeHistory = getPmsChangeHistory(creator, createDate, pmsID); PmsItarmMapping pmsItarmMapping = getPmsItarmMapping(creator, createDate, pmsID, crId); PmsFlow pmsFlow = getPmsFlow(creator, createDate, pmsID); ItarmCrList itarmCrList = getItarmCrList(creator, createDate, crId); IList <PmsDocuments> pmsDocuments = getPmsDocuments(creator, createDate, pmsID, crId); if (pmsHead == null) { Msgbox("Save failed"); return; } //Insert PmsHeadBiz pmsInsert = new PmsHeadBiz(); string errorInfo; int insertResult = pmsInsert.InsertPmsHeadAndDoc(pmsHead, sdpDetail, pmsChangeHistory, pmsItarmMapping, pmsFlow, itarmCrList, pmsDocuments, out errorInfo); if (insertResult == 0) { Msgbox(errorInfo); } else { //将TempFile文件夹里的文件移动到UploadFile下以CRNO命名的文件夹里并删除Temp里的文件。 MoveUploadFileDeleteTempFile(crId); LoginName.Replace(".", " "); pmsHead.UserName = LoginName; new MailBiz().SendCreateMail(pmsHead); // 更新Stage 自动把这个Cr推进到AssginMember int oldStage = (int)PmsCommonEnum.ProjectStage.PES; int newStage = (int)PmsCommonEnum.ProjectStage.AssignMember; string strAction = Enum.Parse(typeof(PmsCommonEnum.ProjectStage), oldStage.ToString()).GetDescription(); bool blResult = new BasicInformationDetailBiz().UpdateStages(pmsID, LoginName, oldStage, newStage, strAction); if (!blResult) { Msgbox("更新stage数据失败!"); return; } new MailBiz().SendPromoteMail(pmsHead, newStage); Msgbox("Create Successful!"); PageRegisterStartupScript("window.close();"); } } catch (Exception exception) { throw new Exception(exception.ToString()); } }
//private void BindDropDownListSiteAndImpactSite() //{ // try // { // PmsSys pmsSys = new PmsSys(); // pmsSys.Vid = "PM"; // pmsSys.Type = "Site"; // PmsSysBiz pmsSysBiz = new PmsSysBiz(); // IList<PmsSys> pmsSysList = pmsSysBiz.SelectData1ByType(pmsSys); // dropdownlistSite.DataSource = pmsSysList; // dropdownlistSite.DataTextField = "Data1"; // dropdownlistSite.DataValueField = "Data1"; // dropdownlistSite.DataBind(); // dropdownlistSite.Items.Insert(0, ""); // dropdownlistImpactSite.DataSource = pmsSysList; // dropdownlistImpactSite.DataTextField = "Data1"; // dropdownlistImpactSite.DataValueField = "Data1"; // dropdownlistImpactSite.DataBind(); // QWeb.SelectItem(dropdownlistImpactSite, "QCS"); // //dropdownlistSite.Items.Insert(0, new ListItem()); // //dropdownlistSite.Items[0].Text = ""; // //dropdownlistSite.Items[0].Value = ""; // //dropdownlistImpactSite.Items.Insert(0, new ListItem()); // //dropdownlistImpactSite.Items[0].Text = ""; // //dropdownlistImpactSite.Items[0].Value = ""; // } // catch // { // ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Bind ImpactSite failure');", true); // } //} #endregion #endregion protected void buttonSave_Click(object sender, EventArgs e) { try { //#region Define Variable ////string strSavePath = ""; ////int iTypeID = 0; //#endregion //检查控件中的值 if (!CheckControlValue()) { return; } //获取新的Pmsid,CrId以及他们的创建时间 DateTime dtCurDate; string strPmsID = string.Empty; string strCrId = string.Empty; m_PmsCRCreatBiz.GetNewPmsIdTempCrId(out dtCurDate, out strPmsID, out strCrId); #region Get StageID PmsFlowTemplateBiz pmsFlowTemplateBiz = new PmsFlowTemplateBiz(); IList <PmsFlowTemplate> pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId(dropdownlistType.SelectedValue.Trim()); int stageId = pmsFlowTemplateList[0].Stageid; #endregion #region For Insert PmsHead PmsHead pmsHeadInsert = new PmsHead(); pmsHeadInsert.Vid = "PM"; pmsHeadInsert.PmsId = strPmsID; pmsHeadInsert.PmsName = textboxPmsName.Text.Trim().Replace("'", ""); pmsHeadInsert.Type = dropdownlistType.SelectedItem.Text.Trim(); pmsHeadInsert.Description = textboxDescription.Text.Trim().Replace("'", ""); pmsHeadInsert.System = textboxSystem.Text.Trim().Replace("'", ""); pmsHeadInsert.Domain = dropdownlistDomain.SelectedItem.Text.Trim(); pmsHeadInsert.Priority = dropdownlistPriority.SelectedItem.Text.Trim(); pmsHeadInsert.Site = dropdownlistSite.SelectedValue; pmsHeadInsert.ImpactSite = dropdownlistImpactSite.SelectedItem.Text.Trim(); pmsHeadInsert.NeedSTP = RadioButtonNeedSTPYes.Checked ? "Y" : "N"; pmsHeadInsert.NeedSTC = RadioButtonNeedSTCYes.Checked ? "Y" : "N"; //要插VB2Net add by ITO.Abel.Li 2014-01-06 pmsHeadInsert.Category = RadioButtonVB2NetYes.Checked ? "Y" : "N"; pmsHeadInsert.NewVersion = textboxNewVersion.Text.Trim().Replace("'", ""); // pmsHeadInsert.OldVersion = textboxOldVersion.Text.Trim().Replace("'", ""); pmsHeadInsert.OldVersion = HiddenFieldOldVersion.Value.Trim().Replace("'", ""); pmsHeadInsert.DueDate = DateTime.Parse(dateTextBoxDueDate.Text.Trim()); pmsHeadInsert.PlanStartDate = DateTime.Parse(dateTextBoxPlanStartDate.Text.Trim()); //pmsHeadInsert.ReleaseDate = 0; //pmsHeadInsert.CloseDate = 0; pmsHeadInsert.Stage = stageId; pmsHeadInsert.Pm = textboxPM.Text.Trim().Replace("'", ""); pmsHeadInsert.Sd = ""; pmsHeadInsert.Se = ""; pmsHeadInsert.Qa = ""; pmsHeadInsert.AbnormalStage = 0; pmsHeadInsert.Rerver1 = ""; pmsHeadInsert.Rerver2 = ""; pmsHeadInsert.Rerver3 = ""; pmsHeadInsert.Rerver4 = ""; pmsHeadInsert.Rerver5 = ""; pmsHeadInsert.CreateDate = dtCurDate; pmsHeadInsert.Creator = LoginName; //pmsHeadInsert.MaintainDate = dtCurDate; pmsHeadInsert.MaintainUser = ""; pmsHeadInsert.OwnerDept = m_PmsCRCreatBiz.GetOwnerDept(LoginName) ?? string.Empty; pmsHeadInsert.RelatedCrNo = textboxRelatedCrNo.Text.Trim(); #endregion #region For Insert PMS_ITARM_Mapping PmsItarmMapping pmsItarmMapping = new PmsItarmMapping(); pmsItarmMapping.PmsId = strPmsID; pmsItarmMapping.CrId = strCrId; pmsItarmMapping.Creator = LoginName; pmsItarmMapping.CreateDate = dtCurDate; #endregion #region File(注释不用) #region Get Document Type //PmsDocumentType pmsDocType = new PmsDocumentType(); //pmsDocType.Vid = "PM"; //pmsDocType.TypeName = "PES"; //PmsDocumentTypeBiz pmsDocTypeBiz = new PmsDocumentTypeBiz(); //IList<PmsDocumentType> pmsDocTypeList = pmsDocTypeBiz.SelectPmsDocumentType(pmsDocType); //if (pmsDocTypeList != null && pmsDocTypeList.Count > 0) //{ // iTypeID = pmsDocTypeList[0].TypeId; //} #endregion #region Get UploadFilePath //PmsSys pmsSys = new PmsSys(); //pmsSys.Vid = "PM"; //pmsSys.Type = "UploadFilePath"; //PmsSysBiz pmsSysBiz = new PmsSysBiz(); //IList<PmsSys> pmsSysList = pmsSysBiz.SelectData1ByType(pmsSys); //if (pmsSysList != null && pmsSysList.Count > 0) //{ // strSavePath = pmsSysList[0].Data1.ToString().Trim(); //} //else //{ // ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('Please maintain UploadFilePath!');", true); // return; //} #endregion #region For Insert PmsDocuments //PmsDocuments pmsDocuments = new PmsDocuments(); //pmsDocuments.PmsId = strPmsID; //pmsDocuments.DocTypeId = iTypeID; //pmsDocuments.FileName = pesUpload.PostedFile.FileName.Substring(pesUpload.PostedFile.FileName.LastIndexOf("\\") + 1); //string strTmp = strSavePath + "\\" + strPmsID + "\\" + pmsDocuments.FileName; //if (strTmp.Length > 150) //{ // ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "alert('The length of SavePath is larger than 150!');", true); // pesUpload.Focus(); // return; //} //pmsDocuments.Path = strSavePath + "\\" + strPmsID + "\\" + pmsDocuments.FileName; //pmsDocuments.Size = pesUpload.PostedFile.ContentLength.ToString().Trim(); //pmsDocuments.Creator = LoginName; //pmsDocuments.CreateDate = dtCurDate; //#endregion //#region Upload PES File //if (pmsDocuments.FileName != "") //{ // strSavePath = strSavePath + "\\" + strPmsID; // if (!QFile.CheckFolderExist(strSavePath)) // { // QFile.CreateDirectory(strSavePath); // } // strSavePath = strSavePath + "\\" + pmsDocuments.FileName; // pesUpload.PostedFile.SaveAs(strSavePath); //} #endregion #endregion #region For Insert SdpDetail SdpDetail sdpDetail = new SdpDetail(); sdpDetail.Pmsid = strPmsID; sdpDetail.Type = dropdownlistType.SelectedValue.Trim(); #endregion #region For Insert PmsFlow //pmsFlowTemplateList = pmsFlowTemplateBiz.SelectPmsFlowTemplateByTypeId(dropdownlistType.SelectedValue.Trim()); PmsFlow pmsFlow = new PmsFlow(); pmsFlow.FlowId = pmsFlowTemplateList[0].FlowId; pmsFlow.PmsId = strPmsID; pmsFlow.Creator = LoginName; pmsFlow.CreateDate = dtCurDate; #endregion #region For Insert PMSChangeHistory PmsChangeHistory pmsChangeHistory = new PmsChangeHistory(); pmsChangeHistory.PmsId = strPmsID; pmsChangeHistory.ChangeContent = ""; pmsChangeHistory.Action = "CREATE"; pmsChangeHistory.CreateDate = dtCurDate; pmsChangeHistory.Creator = LoginName; #endregion #region For Insert Itarm_Cr_List ItarmCrList itarmCrList = new ItarmCrList(); itarmCrList.CrId = strCrId; itarmCrList.CrName = textboxPmsName.Text.Trim().Replace("'", ""); itarmCrList.Site = dropdownlistSite.SelectedValue; itarmCrList.Creator = LoginName; itarmCrList.CreateDate = dtCurDate; itarmCrList.Pm = textboxPM.Text.Trim().Replace("'", ""); itarmCrList.System = textboxSystem.Text.Trim().Replace("'", ""); #endregion #region Insert PmsHeadBiz pmsInsert = new PmsHeadBiz(); string errorInfo; int insertResult = pmsInsert.InsertPmsHeadAndDoc(pmsHeadInsert, sdpDetail, pmsChangeHistory, pmsItarmMapping, pmsFlow, itarmCrList, null, out errorInfo); if (insertResult == 0) { Msgbox("Save Fail!"); } else { #region 更新系统版本表 bool upVerResult = m_PmsCRCreatBiz.UpdateSysVersion(dropdownlistDomain.SelectedValue, textboxSystem.Text.Trim(), dropdownlistSite.SelectedValue, textboxNewVersion.Text.Trim()); if (!upVerResult) { Msgbox("Updated system version number fail!"); } #endregion // Session["InquiryPage_Refresh"] = "Y"; //发送创建成功的Mail LoginName.Replace(".", " "); pmsHeadInsert.UserName = LoginName; new MailBiz().SendCreateMail(pmsHeadInsert); Msgbox("Create Successful!"); PageRegisterStartupScript("window.close();"); } #endregion } catch (Exception exception) { Msgbox("Save Fail!"); } }