/// <summary> /// Processes the json object. /// Don't think your clever enought to optimise this function /// </summary> /// <param name="jsonObject">The json object.</param> private void ProcessJsonObject(JsonBE jsonObject) { DeliveryInfoBE deliveryInfo = new DeliveryInfoBE(); deliveryInfo.AppQuadri = jsonObject.Step1.ApplicationQuadri; deliveryInfo.NewVersion = jsonObject.Step1.NewVersion; deliveryInfo.OldVersion = jsonObject.Step1.OldVersion; //determine on which environment the deployment will be made deliveryInfo.isINT = jsonObject.Step1.Environments.Where(env => env.Equals("INT")).Any(); deliveryInfo.isUAT = jsonObject.Step1.Environments.Where(env => env.Equals("UAT")).Any(); deliveryInfo.isSTA = jsonObject.Step1.Environments.Where(env => env.Equals("STA")).Any(); deliveryInfo.isPROD = jsonObject.Step1.Environments.Where(env => env.Equals("PROD")).Any(); //determine the deliverables deliveryInfo.isDelvWEB = jsonObject.Step1.Deliverables.Where(env => env.Equals("WEB")).Any(); #warning k2 ws also deliveryInfo.isDelvWS = jsonObject.Step1.Deliverables.Where(env => env.Equals("WS")).Any(); deliveryInfo.isDelvDB = jsonObject.Step1.Deliverables.Where(env => env.Equals("DB")).Any(); deliveryInfo.isDelvK2PROCESS = jsonObject.Step1.Deliverables.Where(env => env.Equals("K2PROCESS")).Any(); deliveryInfo.isDelvREPORT = jsonObject.Step1.Deliverables.Where(env => env.Equals("REPORT")).Any(); deliveryInfo.isDelvBATCH = jsonObject.Step1.Deliverables.Where(env => env.Equals("BATCH")).Any(); #warning should modify this logic if (jsonObject.Step1.NewVersion != jsonObject.Step1.OldVersion) { deliveryInfo.isModifWebConfig = true; } //get the application that we are making the deployment for ApplicationBE app = ApplicationDA.GetApplication(jsonObject.Step1.ApplicationQuadri); deliveryInfo.RootDirectoryPath = ConstantBE.OUTPUTPATH + '\\' + app.FolderName; deliveryInfo.ITFNo = jsonObject.Step1.ITFNumber; //if we are delivering on STAGING or PROD //we need to fetch the next external directory if (deliveryInfo.isSTA || deliveryInfo.isPROD) { deliveryInfo.NextExternalDirectory = DirectoryManagementDA.GetTheNextExternalDirectory(app, jsonObject.Step1.DeltaOrFull); } //we create the directory structure DirectoryManagementDA.CreateDirectoryStructure(deliveryInfo); String outputPath = String.Empty; #region BL Generation if (deliveryInfo.isINT || deliveryInfo.isUAT) { outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Internals" + '\\' + "ITF" + deliveryInfo.ITFNo + '\\'; BonDeLivraisonDA.GenerateBL(GetBLFromJsonObject(jsonObject, "Internals", deliveryInfo.NextExternalDirectory), outputPath); } if (deliveryInfo.isSTA || deliveryInfo.isPROD) { outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Externals" + '\\' + deliveryInfo.NextExternalDirectory + '\\'; BonDeLivraisonDA.GenerateBL(GetBLFromJsonObject(jsonObject, "Externals", deliveryInfo.NextExternalDirectory), outputPath); } #endregion #region RFC Generation foreach (String item in jsonObject.Step1.Environments) { ApplicationConfigBE appConfig = ApplicationDA.GetApplicationConfig(jsonObject.Step1.ApplicationQuadri, item); RequestForChangeDA.GenerateRFC(GetRFCFromJsonObject(jsonObject, item, jsonObject.Step1.ApplicationQuadri, deliveryInfo), deliveryInfo, item, appConfig); } #endregion #region MCOP Generation foreach (String item in jsonObject.Step1.Environments) { ApplicationConfigBE appConfig = ApplicationDA.GetApplicationConfig(jsonObject.Step1.ApplicationQuadri, item); if (deliveryInfo.isDelvWEB) { McopDA.GenerateMcopFileForSetup(GetMCOPFromJsonObject(appConfig, deliveryInfo, "WEB", true, item), deliveryInfo, item, "WEB"); McopDA.GenerateMcopFileForRollBack(GetMCOPFromJsonObject(appConfig, deliveryInfo, "WEB", false, item), deliveryInfo, item, "WEB"); } if (deliveryInfo.isDelvWS) { McopDA.GenerateMcopFileForSetup(GetMCOPFromJsonObject(appConfig, deliveryInfo, "WS", true, item), deliveryInfo, item, "WS"); McopDA.GenerateMcopFileForRollBack(GetMCOPFromJsonObject(appConfig, deliveryInfo, "WS", false, item), deliveryInfo, item, "WS"); } if (deliveryInfo.isDelvBATCH) { McopDA.GenerateMcopFileForSetup(GetMCOPFromJsonObject(appConfig, deliveryInfo, "BATCH", true, item), deliveryInfo, item, "BATCH"); McopDA.GenerateMcopFileForRollBack(GetMCOPFromJsonObject(appConfig, deliveryInfo, "BATCH", false, item), deliveryInfo, item, "BATCH"); } } #endregion }
private McopBE GetMCOPFromJsonObject(ApplicationConfigBE appConfig, DeliveryInfoBE deliveryInfo, String deliverable, bool isSetup, String environment) { McopBE mcop = new McopBE(); #region Servers Collection<String> serversCol = new Collection<string>(); if (deliverable == "WEB") { foreach (WebServer item in appConfig.WebServers) { serversCol.Add(item.Name); } } else if (deliverable == "WS") { foreach (WebServiceServer item in appConfig.WebServiceServers) { serversCol.Add(item.Name); } } else { foreach (BatchServer item in appConfig.BatchServers) { serversCol.Add(item.Name); } } //set the server path mcop.ServersCol = serversCol; #endregion //set long date format to be true //you can change the format by putting //it to false mcop.isLongIsoDateDefault = true; //setup or rollback if (isSetup) { mcop.FirstAction = "Copy"; mcop.SecondAction = "Copy"; mcop.isNewFirstAction = true; mcop.isNewSecondAction = true; mcop.isOverWriteFirstAction = true; mcop.isOverWriteSecondAction = true; mcop.PhysicalPath = "\\\\{s}" + appConfig.WEBPhysicalLocation; mcop.BackupPath = DirectoryManagementDA.GetDirectoryPathForMCOP(deliveryInfo, environment, deliverable, false) + "\\{s}"; mcop.DeliverablePath = DirectoryManagementDA.GetDirectoryPathForMCOP(deliveryInfo, environment, deliverable, true); } else { mcop.FirstAction = "Del"; mcop.SecondAction = "Copy"; mcop.isNewFirstAction = false; mcop.isNewSecondAction = false; mcop.isOverWriteFirstAction = false; mcop.isOverWriteSecondAction = true; mcop.PhysicalPath = "\\\\{s}" + appConfig.WEBPhysicalLocation; mcop.BackupPath = DirectoryManagementDA.GetDirectoryPathForMCOP(deliveryInfo, environment, deliverable, false) + "\\{s}"; mcop.DeliverablePath = DirectoryManagementDA.GetDirectoryPathForMCOP(deliveryInfo, environment, deliverable, true); } return mcop; }
/// <summary> /// Gets the RFC from json object. /// </summary> /// <param name="jsonObject">The json object.</param> /// <returns></returns> private RequestForChangeBE GetRFCFromJsonObject(JsonBE jsonObject, String environment, String appQuadri, DeliveryInfoBE deliveryInfo) { RequestForChangeBE rfc = new RequestForChangeBE(); //the IS Entity //rfc.Entity = jsonObject.Step3.ISEntity; #warning should be crosschecked if ((environment == "INT") || (environment == "UAT")) { rfc.Entity = "C2IL"; } else { rfc.Entity = "COS"; } //who submitted the rfc rfc.SubmittedBy = TransversalDA.GetPersonDetailsByID(jsonObject.Step3.SubmittedBy).name; //the submitted date rfc.SubmittedDate = DateTime.Parse(jsonObject.Step3.SubmittedDate); //qualification fo request rfc.QualificationOfRequest = jsonObject.Step3.QualificationOfRequest; //priority rfc.Priority = jsonObject.Step3.Priority; //regulated environment rfc.RegulatedEnvironment = jsonObject.Step3.RegulatedEnvironment; //only set the expected date / time for //INT and UAT environment if (environment == "INT" || environment == "UAT") { rfc.ExpectedDate = DateTime.Parse(jsonObject.Step3.ExpectedDate).ToString("dd/MM/yy"); rfc.ExpectedStartTime = jsonObject.Step3.ExpectedStartTime; rfc.ExpectedDuration = jsonObject.Step3.ExpectedDuration; } else { rfc.ExpectedDate = "To be set"; rfc.ExpectedStartTime = "To be set"; rfc.ExpectedDuration = jsonObject.Step3.ExpectedDuration; } //change reason rfc.ChangeReason = jsonObject.Step3.ChangeReason + " on " + environment ; //the deployment environment rfc.Environment = environment; //HPSD ID String[] splitChangeAndQCItem = jsonObject.Step2.ChangeQCAndDescription.Split(';'); rfc.HPSDTicketID = splitChangeAndQCItem[0].Replace("|", " / "); //fetch the application configs base on the environment ApplicationConfigBE applicationConfigurations = ApplicationDA.GetApplicationConfig(appQuadri, environment); //initilise the string builder for the servers environments StringBuilder strBuilderEnvironment = new StringBuilder(); if (deliveryInfo.isDelvWEB) { strBuilderEnvironment.Append("WEB :"); foreach (WebServer item in applicationConfigurations.WebServers) { //not he last item in the collection if (item != applicationConfigurations.WebServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } if (deliveryInfo.isDelvWS) { strBuilderEnvironment.Append("WS :"); foreach (WebServiceServer item in applicationConfigurations.WebServiceServers) { //not he last item in the collection if (item != applicationConfigurations.WebServiceServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } if (deliveryInfo.isDelvDB) { strBuilderEnvironment.Append("DB :"); foreach (DatabaseServer item in applicationConfigurations.DatabaseServers) { //not he last item in the collection if (item != applicationConfigurations.DatabaseServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } if (deliveryInfo.isDelvK2PROCESS) { strBuilderEnvironment.Append("K2 :"); foreach (WorkflowServer item in applicationConfigurations.WorkflowServers) { //not he last item in the collection if (item != applicationConfigurations.WorkflowServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } if (deliveryInfo.isDelvREPORT) { strBuilderEnvironment.Append("REPORT :"); foreach (ReportingServer item in applicationConfigurations.ReportingServers) { //not he last item in the collection if (item != applicationConfigurations.ReportingServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } if (deliveryInfo.isDelvBATCH) { strBuilderEnvironment.Append("BATCH :"); foreach (BatchServer item in applicationConfigurations.BatchServers) { //not he last item in the collection if (item != applicationConfigurations.BatchServers.Last()) { strBuilderEnvironment.Append(" ").Append(item.Name).Append(" / "); } else { strBuilderEnvironment.Append(" ").Append(item.Name); } } strBuilderEnvironment.Append("|"); } rfc.ServerInformation = strBuilderEnvironment.ToString(); return rfc; }
/// <summary> /// Generates the mcop file for setup. /// </summary> /// <param name="mcop">The mcop file settings</param> public static void GenerateMcopFileForSetup(McopBE mcop, DeliveryInfoBE deliveryInfo, String environment, String deliverable) { //create the xmldocument XmlDocument mcopXml = new XmlDocument(); //set the declaration to "<?xml version="1.0" encoding="utf-8"?>" XmlDeclaration xmlDeclaration = mcopXml.CreateXmlDeclaration("1.0", "utf-8", null); //create the rootnode and append it to the document <maspCopy> XmlElement rootNode = mcopXml.CreateElement("maspCopy"); mcopXml.InsertBefore(xmlDeclaration, mcopXml.DocumentElement); mcopXml.AppendChild(rootNode); #region Servers //create the parent node <servers> XmlElement parentNodeServers = mcopXml.CreateElement("servers"); //<servers pattern="{s}"> XmlAttribute attributeServerPattern = mcopXml.CreateAttribute("pattern"); attributeServerPattern.Value = "{s}"; parentNodeServers.Attributes.Append(attributeServerPattern); foreach (String item in mcop.ServersCol) { //<add> XmlElement childNodeServerAdd = mcopXml.CreateElement("add"); //<add name='MYSERVER'> XmlAttribute attributeAdd = mcopXml.CreateAttribute("name"); attributeAdd.Value = item; childNodeServerAdd.Attributes.Append(attributeAdd); parentNodeServers.AppendChild(childNodeServerAdd); } #endregion #region DateTimeFormats //create the parent node <dateTimeFormats> XmlElement parentNodeDateTimeFormats = mcopXml.CreateElement("dateTimeFormats"); //<dateTimeFormats pattern="{d}"> XmlAttribute attributeDateTimeFormatsPattern = mcopXml.CreateAttribute("pattern"); attributeDateTimeFormatsPattern.Value = "{d}"; parentNodeDateTimeFormats.Attributes.Append(attributeDateTimeFormatsPattern); //<add> XmlElement childNodeLongIsoDateAdd = mcopXml.CreateElement("add"); //<add name="longisodate" value="yyyy_MM_dd HH mm" default="true" /> //<add name="longisodate" value="yyyy_MM_dd HH mm" default="false" /> XmlAttribute attributeLongIsoDateName = mcopXml.CreateAttribute("name"); attributeLongIsoDateName.Value = "longisodate"; childNodeLongIsoDateAdd.Attributes.Append(attributeLongIsoDateName); XmlAttribute attributeLongIsoDateValue = mcopXml.CreateAttribute("value"); attributeLongIsoDateValue.Value = "yyyy_MM_dd HH mm"; childNodeLongIsoDateAdd.Attributes.Append(attributeLongIsoDateValue); XmlAttribute attributeLongIsoDateDefault = mcopXml.CreateAttribute("default"); //<add> XmlElement childNodeShortIsoDateAdd = mcopXml.CreateElement("add"); //<add name="shortisodate" value="yyyy_MM_dd" default="true" /> //<add name="shortisodate" value="yyyy_MM_dd" default="false" /> XmlAttribute attributeShortIsoDateName = mcopXml.CreateAttribute("name"); attributeShortIsoDateName.Value = "shortisodate"; childNodeShortIsoDateAdd.Attributes.Append(attributeShortIsoDateName); XmlAttribute attributeShortIsoDateValue = mcopXml.CreateAttribute("value"); attributeShortIsoDateValue.Value = "yyyy_MM_dd"; childNodeShortIsoDateAdd.Attributes.Append(attributeShortIsoDateValue); XmlAttribute attributeShortIsoDateDefault = mcopXml.CreateAttribute("default"); if (mcop.isLongIsoDateDefault) { attributeLongIsoDateDefault.Value = "true"; attributeShortIsoDateDefault.Value = "false"; } else { attributeLongIsoDateDefault.Value = "false"; attributeShortIsoDateDefault.Value = "true"; } childNodeLongIsoDateAdd.Attributes.Append(attributeLongIsoDateDefault); childNodeShortIsoDateAdd.Attributes.Append(attributeShortIsoDateDefault); parentNodeDateTimeFormats.AppendChild(childNodeLongIsoDateAdd); parentNodeDateTimeFormats.AppendChild(childNodeShortIsoDateAdd); #endregion #region Actions //create the parent node <actions> XmlElement parentNodeActions = mcopXml.CreateElement("actions"); #region Backup //add a comment to the file for humans :) XmlComment commentBackupAdd = mcopXml.CreateComment("backup"); parentNodeActions.AppendChild(commentBackupAdd); //<add> XmlElement childNodeAddBackup = mcopXml.CreateElement("add"); //src XmlAttribute attributeBackupSRC = mcopXml.CreateAttribute("src"); attributeBackupSRC.Value = mcop.PhysicalPath; childNodeAddBackup.Attributes.Append(attributeBackupSRC); //dst XmlAttribute attributeBackupDST = mcopXml.CreateAttribute("dst"); attributeBackupDST.Value = mcop.BackupPath; childNodeAddBackup.Attributes.Append(attributeBackupDST); //do XmlAttribute attributeBackupDO = mcopXml.CreateAttribute("do"); attributeBackupDO.Value = mcop.FirstAction; childNodeAddBackup.Attributes.Append(attributeBackupDO); //new XmlAttribute attributeBackupNEW = mcopXml.CreateAttribute("new"); attributeBackupNEW.Value = mcop.isNewFirstAction.ToString().ToLower(); childNodeAddBackup.Attributes.Append(attributeBackupNEW); //overwrite XmlAttribute attributeBackupOverWrite = mcopXml.CreateAttribute("overwrite"); attributeBackupOverWrite.Value = mcop.isOverWriteFirstAction.ToString().ToLower(); childNodeAddBackup.Attributes.Append(attributeBackupOverWrite); //append it to the parent node parentNodeActions.AppendChild(childNodeAddBackup); #endregion #region Setup //add a comment to the file for humans :) XmlComment commentSetupAdd = mcopXml.CreateComment("setup"); parentNodeActions.AppendChild(commentSetupAdd); //<add> XmlElement childNodeAddSetup = mcopXml.CreateElement("add"); //src XmlAttribute attributeSetupSRC = mcopXml.CreateAttribute("src"); attributeSetupSRC.Value = mcop.DeliverablePath; childNodeAddSetup.Attributes.Append(attributeSetupSRC); //dst XmlAttribute attributeSetupDST = mcopXml.CreateAttribute("dst"); attributeSetupDST.Value = mcop.PhysicalPath; childNodeAddSetup.Attributes.Append(attributeSetupDST); //do XmlAttribute attributeSetupDO = mcopXml.CreateAttribute("do"); attributeSetupDO.Value = mcop.SecondAction; childNodeAddSetup.Attributes.Append(attributeSetupDO); //new XmlAttribute attributeSetupNEW = mcopXml.CreateAttribute("new"); attributeSetupNEW.Value = mcop.isNewSecondAction.ToString().ToLower(); childNodeAddSetup.Attributes.Append(attributeSetupNEW); //overwrite XmlAttribute attributeSetupOverWrite = mcopXml.CreateAttribute("overwrite"); attributeSetupOverWrite.Value = mcop.isOverWriteSecondAction.ToString().ToLower(); childNodeAddSetup.Attributes.Append(attributeSetupOverWrite); //append it to the parent node parentNodeActions.AppendChild(childNodeAddSetup); #endregion #endregion //appending all the parent nodes to the root node rootNode.AppendChild(parentNodeServers); rootNode.AppendChild(parentNodeDateTimeFormats); rootNode.AppendChild(parentNodeActions); String mcopFileName = GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(true, false), deliverable, "SETUP"); String mcopSavePath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, environment, deliverable, "SETUP"); mcopXml.Save(mcopSavePath + '\\' + mcopFileName); }
public static void GenerateRFC(RequestForChangeBE rfc, DeliveryInfoBE deliveryInfo, String delvEnvironment, ApplicationConfigBE appConfig) { //path to the RFC template String rfcTemplatePath = ConstantBE.TEMPLATEPATH + '\\' + deliveryInfo.AppQuadri + ".docx"; String rfcNewName = String.Empty; String outputPath = String.Empty; String directoryPath = String.Empty; String filename = String.Empty; #region RFC Name Formatting And Output Path if (delvEnvironment == "INT") { //RFC_IPRI_ITF594_2.2.0_20120328_INT rfcNewName = String.Format(ConstantBE.RFCFORMATINTANDUAT, deliveryInfo.AppQuadri, "ITF" + deliveryInfo.ITFNo, deliveryInfo.GetVersion(true, false), rfc.SubmittedDate.ToString("yyyyMMdd"), "INT"); outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Internals" + '\\' + "ITF" + deliveryInfo.ITFNo + '\\' + "RFC\\" + rfcNewName + ".docx"; } else if (delvEnvironment == "UAT") { //RFC_IPRI_ITF594_2.2.0_20120328_INT rfcNewName = String.Format(ConstantBE.RFCFORMATINTANDUAT, deliveryInfo.AppQuadri, "ITF" + deliveryInfo.ITFNo, deliveryInfo.GetVersion(true, false), rfc.SubmittedDate.ToString("yyyyMMdd"), "UAT"); outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Internals" + '\\' + "ITF" + deliveryInfo.ITFNo + '\\' + "RFC\\" + rfcNewName + ".docx"; } else if (delvEnvironment == "STA") { //get the integer path from the string String integerPart = Regex.Match(deliveryInfo.NextExternalDirectory, @"\d+").Value; //RFC_IPRI_Liv_2_STA rfcNewName = String.Format(ConstantBE.RFCFORMATSTAANDPROD, deliveryInfo.AppQuadri, "Liv", integerPart, "STA"); outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Externals" + '\\' + deliveryInfo.NextExternalDirectory + '\\' + "DOCUMENTATION\\" + rfcNewName + ".docx"; } else { //get the integer path from the string String integerPart = Regex.Match(deliveryInfo.NextExternalDirectory, @"\d+").Value; //RFC_IPRI_Liv_2_PROD rfcNewName = String.Format(ConstantBE.RFCFORMATSTAANDPROD, deliveryInfo.AppQuadri, "Liv", integerPart, "PROD"); outputPath = deliveryInfo.RootDirectoryPath + '\\' + "Externals" + '\\' + deliveryInfo.NextExternalDirectory + '\\' + "DOCUMENTATION\\" + rfcNewName + ".docx"; } #endregion DirectoryManagementDA.CopyFileAndRename(rfcTemplatePath, outputPath); //open the copied file in its new location for modification using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(outputPath, true)) { //get the document body MainDocumentPart mainDocPart = wordDoc.MainDocumentPart; #region Change Identification #region Requestor Information //get only the change identification body from the document SdtBlock rfcBody = OpenXmlHelpers.GetContentControl(mainDocPart, ConstantBE.CHANGEIDENTIFICATIONBODY); //Get the table in the change identification tag Table rfcBodyTable = rfcBody.Descendants<Table>().Single(); //Entity rfcBodyTable.Elements<TableRow>().ElementAt(3).Elements<SdtCell>() .ElementAt(0).Descendants<Text>().Single().Text = rfc.Entity; //Submitted by rfcBodyTable.Elements<TableRow>().ElementAt(3).Elements<SdtCell>() .ElementAt(1).Descendants<Text>().Single().Text = rfc.SubmittedBy; //Sumitted date rfcBodyTable.Elements<TableRow>().ElementAt(3).Elements<SdtCell>() .ElementAt(2).Descendants<Text>().Single().Text = rfc.SubmittedDate.ToString("dd/MM/yy"); #endregion #region Qualification Of Request Checkbox Paragraph qualOfRequestPara = new Paragraph(); //based on the qualification of request we get the corresponding //element switch (rfc.QualificationOfRequest) { case "Major": qualOfRequestPara = rfcBodyTable.Elements<TableRow>().ElementAt(5) .Elements<TableCell>().ElementAt(0).Elements<Paragraph>().FirstOrDefault(); break; case "Medium": qualOfRequestPara = rfcBodyTable.Elements<TableRow>().ElementAt(5) .Elements<TableCell>().ElementAt(1).Elements<Paragraph>().FirstOrDefault(); break; default: qualOfRequestPara = rfcBodyTable.Elements<TableRow>().ElementAt(5) .Elements<TableCell>().ElementAt(2).Elements<Paragraph>().FirstOrDefault(); break; } CheckBox qualOfRequestCB = qualOfRequestPara.Descendants<CheckBox>().FirstOrDefault(); if (qualOfRequestCB != null) { //get the checkbox DefaultCheckBoxFormFieldState dcb = qualOfRequestCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) dcb.Val = true; } #endregion #region Priority Checkbox Paragraph priorityPara = new Paragraph(); //based on the priority we get the corresponding //element switch (rfc.Priority) { case "1": priorityPara = rfcBodyTable.Elements<TableRow>().ElementAt(7) .Elements<TableCell>().ElementAt(0).Elements<Paragraph>().FirstOrDefault(); break; case "2": priorityPara = rfcBodyTable.Elements<TableRow>().ElementAt(7) .Elements<TableCell>().ElementAt(1).Elements<Paragraph>().FirstOrDefault(); break; default: priorityPara = rfcBodyTable.Elements<TableRow>().ElementAt(7) .Elements<TableCell>().ElementAt(2).Elements<Paragraph>().FirstOrDefault(); break; } CheckBox priorityCB = priorityPara.Descendants<CheckBox>().FirstOrDefault(); if (priorityCB != null) { //get the checkbox DefaultCheckBoxFormFieldState dcb = priorityCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) dcb.Val = true; } #endregion #region Regulated Environment Checkbox Paragraph regulatedEnvPara = new Paragraph(); //based on the regulated environment we get the corresponding //element switch (rfc.RegulatedEnvironment) { case "GxPImpact": regulatedEnvPara = rfcBodyTable.Elements<TableRow>().ElementAt(9) .Elements<TableCell>().ElementAt(0).Elements<Paragraph>().FirstOrDefault(); break; case "SOAImpact": regulatedEnvPara = rfcBodyTable.Elements<TableRow>().ElementAt(9) .Elements<TableCell>().ElementAt(1).Elements<Paragraph>().FirstOrDefault(); break; default: regulatedEnvPara = rfcBodyTable.Elements<TableRow>().ElementAt(9) .Elements<TableCell>().ElementAt(2).Elements<Paragraph>().FirstOrDefault(); break; } CheckBox regulatedEnvCB = regulatedEnvPara.Descendants<CheckBox>().FirstOrDefault(); if (regulatedEnvCB != null) { //get the checkbox DefaultCheckBoxFormFieldState dcb = regulatedEnvCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) dcb.Val = true; } #endregion #region Expected Finish //Expected finish date rfcBodyTable.Elements<TableRow>().ElementAt(12).Elements<SdtCell>() .ElementAt(0).Descendants<Text>().Single().Text = rfc.ExpectedDate; //Expected finish hour rfcBodyTable.Elements<TableRow>().ElementAt(12).Elements<SdtCell>() .ElementAt(1).Descendants<Text>().Single().Text = rfc.ExpectedStartTime; //Expecte finish duration rfcBodyTable.Elements<TableRow>().ElementAt(12).Elements<SdtCell>() .ElementAt(2).Descendants<Text>().Single().Text = rfc.ExpectedDuration; #endregion #region Change Region //we get the change reason table cell TableCell changeResonTableCell = rfcBodyTable.Elements<TableRow>().ElementAt(14) .Elements<TableCell>().ElementAt(0); //Change reason changeResonTableCell.Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.CHANGEREASON).Single() .Descendants<Text>().Single().Text = rfc.ChangeReason; //Environment changeResonTableCell.Elements<Paragraph>().ElementAt(3) .Elements<SdtRun>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.ENVIRONMENT).Single() .Descendants<Text>().Single().Text = rfc.Environment; //ServerInformation /*changeResonTableCell.Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ContantsBE.SERVERINFORMATION).Single() .Descendants<Text>().Single().Text = rfc.ServerInformation; */ String[] splitedServerInformation = rfc.ServerInformation.Split('|'); foreach (String item in splitedServerInformation) { //only if have item if (!String.IsNullOrEmpty(item)) { Paragraph newPara = new Paragraph(); Run newRun = new Run(); //add a new line and the append the item //newRun.AppendChild(new Break()); newRun.AppendChild(new Text(item)); newPara.Append(newRun); changeResonTableCell.Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.SERVERINFORMATION).Single().Append(newPara); } } //Impact on service changeResonTableCell.Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.IMPACTONSERVICE).Single() .Descendants<Text>().Single().Text = rfc.ImpactOnService; #endregion #endregion #region Backup And Maintenance SdtBlock descReqBackBody = OpenXmlHelpers.GetContentControl(mainDocPart, ConstantBE.DESCRIPTIONREQUESTBODY); //Get the table in the description body tag Table descReqBackTable = descReqBackBody.Descendants<Table>().Single(); //if we are not delivering WEB we remove the backup directive if (!deliveryInfo.isDelvWEB) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBBACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBBACKUPDIRECTIVE).Single().Remove(); } } //if we are not delivering WS we remove the backup directive if (!deliveryInfo.isDelvWS) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSBACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSBACKUPDIRECTIVE).Single().Remove(); } } //if we are not delivering DB we remove the backup directive if (!deliveryInfo.isDelvDB) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEBACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEBACKUPDIRECTIVE).Single().Remove(); } } else { #warning this logic should be modified descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEBACKUPDIRECTIVE).Single() .Descendants<Text>().ElementAt(1).Text = "Please do a backup of the schema " + appConfig.DatabaseServers[0].InstanceName + " before proceeding."; } //if we are not delivering K2 we remove the backup directive if (!deliveryInfo.isDelvK2PROCESS) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.K2BACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.K2BACKUPDIRECTIVE).Single().Remove(); } } //if we are not delivering REPORT we remove the backup directive if (!deliveryInfo.isDelvREPORT) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTBACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTBACKUPDIRECTIVE).Single().Remove(); } } //if we are not delivering BATCH we remove the backup directive if (!deliveryInfo.isDelvBATCH) { //check if the tag exists before removing else //it will cause an exception //and we don't want it to crash here!! if (descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHBACKUPDIRECTIVE).Any()) { descReqBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHBACKUPDIRECTIVE).Single().Remove(); } } #endregion #region Deployment SdtBlock descReqDeployBody = OpenXmlHelpers.GetContentControl(mainDocPart, ConstantBE.SETUPDESCRIPTIONBODY); //Get the table in the description body tag Table descReqDeployTable = descReqDeployBody.Descendants<Table>().Single(); #region WEB //check if we are delivering WEB else remove the tag if (deliveryInfo.isDelvWEB) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WEB", "SETUP"); //set the path to the setup file descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(true, false), "WEB", "SETUP"); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WEB", "LOGS"); //append the log path descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBDEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBDEPLOYMENT).Single().Remove(); } } #endregion #region WS //check if we are delivering WS else remove the tag if (deliveryInfo.isDelvWS) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WS", "SETUP"); //set the path to the setup file descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(true, false), "WS", "SETUP"); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WS", "LOGS"); //append the log path descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSDEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSDEPLOYMENT).Single().Remove(); } } #endregion #region DB //check if we are delivering DB else remove the tag if (deliveryInfo.isDelvDB) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "DB", "SETUP"); //set the path to the setup file descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = "Enter your script name"; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "DB", "LOGS"); //append the log path descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEDEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEDEPLOYMENT).Single().Remove(); } } #endregion #region K2PROCESS //check if we are delivering K2 else remove the tag if (deliveryInfo.isDelvK2PROCESS) { } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.K2DEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.K2DEPLOYMENT).Single().Remove(); } } #endregion #region REPORT //check if we are delivering REPORT else remove the tag if (deliveryInfo.isDelvREPORT) { } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTDEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTDEPLOYMENT).Single().Remove(); } } #endregion #region BATCH //check if we are delivering BATCH else remove the tag if (deliveryInfo.isDelvBATCH) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "BATCH", "SETUP"); //set the path to the setup file descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(true, false), "BATCH", "SETUP"); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "BATCH", "LOGS"); //append the log path descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHDEPLOYMENT).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHDEPLOYMENT).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHDEPLOYMENT).Single().Remove(); } } #endregion #region WEB.CONFIG //check if we are modifying the web.config else remove the tag if (deliveryInfo.isModifWebConfig) { foreach (String item in ApplicationDA.GetApplicationWebConfig(appConfig)) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, item)); } descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<Paragraph>().ElementAt(5).Descendants<SdtRun>().FirstOrDefault() .Descendants<Text>().Single().Text = deliveryInfo.GetVersion(true, true); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<Paragraph>().ElementAt(9).Descendants<SdtRun>().ElementAt(0) .Descendants<Text>().Single().Text = ApplicationDA.GetWebConfigFullEnvironmentCode(delvEnvironment); descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<Paragraph>().ElementAt(9).Descendants<SdtRun>().ElementAt(1) .Descendants<Text>().Single().Text = deliveryInfo.GetVersion(true, true); } else { //check if it exist in the document before removing if (descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).Any()) { descReqDeployTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBCONFIGMODIF).Single().Remove(); } } #endregion #endregion #region RollBack SdtBlock rollBackBody = OpenXmlHelpers.GetContentControl(mainDocPart, ConstantBE.TESTINGROLLBACKBODY); //Get the table in the rollback body tag Table rollBackTable = rollBackBody.Descendants<Table>().Single(); #region Required Testing rollBackTable.Elements<TableRow>().ElementAt(1) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REQUIREDTESTINGURL).FirstOrDefault() .Descendants<Paragraph>().FirstOrDefault().Descendants<Text>().Single().Text = appConfig.AppTestUrl; #endregion #region WEB //check if we are delivering WEB else remove the tag if (deliveryInfo.isDelvWEB) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WEB", "ROLLBACK"); //set the path to the setup file rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(false, false), "WEB", "ROLLBACK"); rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WEB", "LOGS"); //append the log path rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBROLLBACK).Any()) { rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WEBROLLBACK).Single().Remove(); } } #endregion #region WS //check if we are delivering WS else remove the tag if (deliveryInfo.isDelvWS) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WS", "ROLLBACK"); //set the path to the setup file rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(false, false), "WS", "ROLLBACK"); rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "WS", "LOGS"); //append the log path rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSROLLBACK).Any()) { rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.WSROLLBACK).Single().Remove(); } } #endregion #region DB //check if we are delivering DB else remove the tag if (deliveryInfo.isDelvDB) { //we can add some logic here also :) } else { //check if it exist in the document before removing if (rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEROLLBACK).Any()) { rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.DATABASEROLLBACK).Single().Remove(); } } #endregion #region REPORT //check if we are delivering REPORT else remove the tag if (deliveryInfo.isDelvREPORT) { } else { //check if it exist in the document before removing if (rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTROLLBACK).Any()) { rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.REPORTROLLBACK).Single().Remove(); } } #endregion #region BATCH //check if we are delivering BATCH else remove the tag if (deliveryInfo.isDelvBATCH) { //setup directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "BATCH", "ROLLBACK"); //set the path to the setup file rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOFILE).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); filename = McopDA.GetMcopName(deliveryInfo.AppQuadri, deliveryInfo.GetVersion(false, false), "BATCH", "ROLLBACK"); rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.FILENAME).FirstOrDefault() .Descendants<Text>().Single().Text = filename; //logs directory path directoryPath = DirectoryManagementDA.GetDirectoryPath(deliveryInfo, delvEnvironment, "BATCH", "LOGS"); //append the log path rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHROLLBACK).FirstOrDefault() .Elements<SdtContentBlock>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.PATHTOSTORERESULT).FirstOrDefault() .SdtContentBlock.Append(OpenXmlHelpers.GenerateParagraphWithHyperLink(mainDocPart, directoryPath)); } else { //check if it exist in the document before removing if (rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHROLLBACK).Any()) { rollBackTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(0) .Elements<SdtBlock>().Where (r => r.SdtProperties.GetFirstChild<Tag>().Val == ConstantBE.BATCHROLLBACK).Single().Remove(); } } #endregion #endregion #region Information Body SdtBlock informationBody = OpenXmlHelpers.GetContentControl(mainDocPart, ConstantBE.INFORMATIONBODY); //Get the table in the information body tag Table informationTable = informationBody.Descendants<Table>().Single(); #region System Impact Checkbox //if we are delivering DB if (deliveryInfo.isDelvDB) { Paragraph databaseSystemImpactPara = new Paragraph(); databaseSystemImpactPara = informationTable.Elements<TableRow>().ElementAt(3) .Elements<TableCell>().ElementAt(2).Elements<Paragraph>().FirstOrDefault(); CheckBox databaseSysImpCB = databaseSystemImpactPara.Descendants<CheckBox>().FirstOrDefault(); if (databaseSysImpCB != null) { //get the checkbox DefaultCheckBoxFormFieldState dbCB = databaseSysImpCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) dbCB.Val = true; } } #warning check if true for all deliverables ex report !! if ((deliveryInfo.isDelvWEB) || (deliveryInfo.isDelvWS) || (deliveryInfo.isDelvBATCH) || (deliveryInfo.isDelvREPORT)) { Paragraph appSystemImpactPara = new Paragraph(); appSystemImpactPara = informationTable.Elements<TableRow>().ElementAt(5) .Elements<TableCell>().ElementAt(0).Elements<Paragraph>().FirstOrDefault(); CheckBox appSysImpCB = appSystemImpactPara.Descendants<CheckBox>().FirstOrDefault(); if (appSysImpCB != null) { //get the checkbox DefaultCheckBoxFormFieldState appCB = appSysImpCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) appCB.Val = true; } } if (deliveryInfo.isDelvK2PROCESS) { Paragraph othersSystemImpactPara = new Paragraph(); othersSystemImpactPara = informationTable.Elements<TableRow>().ElementAt(5) .Elements<TableCell>().ElementAt(2).Elements<Paragraph>().FirstOrDefault(); //set the text to K2 Server othersSystemImpactPara.Descendants<SdtRun>().FirstOrDefault() .Descendants<Text>().Single().Text = "K2 Server"; CheckBox othersSysImpCB = othersSystemImpactPara.Descendants<CheckBox>().FirstOrDefault(); if (othersSysImpCB != null) { //get the checkbox DefaultCheckBoxFormFieldState othersCB = othersSysImpCB.Elements<DefaultCheckBoxFormFieldState>() .FirstOrDefault(); //set it to true (Checked) othersCB.Val = true; } } #endregion //set values for HPSD ticket ID informationTable.Elements<TableRow>().ElementAt(12).Elements<SdtCell>() .ElementAt(0).Descendants<Text>().Single().Text = rfc.HPSDTicketID; #endregion //save the changes to the document mainDocPart.Document.Save(); //write the changes to disk using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create))) { sw.Write(mainDocPart); } } }
public static String GetDirectoryPathForMCOP(DeliveryInfoBE delvInfo, String delvEnvironment, String deliverable, bool isSetup) { String directoryPath = delvInfo.RootDirectoryPath; #region Delivery Environment if ((delvEnvironment == "INT") || (delvEnvironment == "UAT")) { directoryPath += '\\' + "Internals" + '\\' + "ITF" + delvInfo.ITFNo; } else { directoryPath += '\\' + "Externals" + '\\' + delvInfo.NextExternalDirectory; } #endregion #region WEB or WS or BATCH if (isSetup) { if (deliverable == "WEB") { directoryPath += '\\' + "WEB"; } else if (deliverable == "WS") { directoryPath += '\\' + "WS"; } else { directoryPath += '\\' + "BATCH"; } } else { if (deliverable == "WEB") { directoryPath += '\\' + "BACKUPS" + '\\' + "WEB" + '\\' + delvEnvironment; } else if (deliverable == "WS") { directoryPath += '\\' + "BACKUPS" + '\\' + "WS" + '\\' + delvEnvironment; } else { directoryPath += '\\' + "BACKUPS" + '\\' + "BATCH" + '\\' + delvEnvironment; } } #endregion return directoryPath; }
public static String GetDirectoryPath(DeliveryInfoBE delvInfo, String delvEnvironment, String deliverable, String delvType) { String directoryPath = delvInfo.RootDirectoryPath; #region Delivery Environment if ((delvEnvironment == "INT") || (delvEnvironment == "UAT")) { directoryPath += '\\' + "Internals" + '\\' + "ITF" + delvInfo.ITFNo; } else { directoryPath += '\\' + "Externals" + '\\' + delvInfo.NextExternalDirectory; } #endregion #region WEB or WS or BATCH if ((deliverable == "WEB") || (deliverable == "WS") || (deliverable == "BATCH")) { directoryPath += '\\' + "MCOP_FILES" + '\\' + delvEnvironment + '\\' + delvType; } #endregion #region DB if (deliverable == "DB") { if (delvType == "SETUP") { directoryPath += '\\' + "DB"; } else { directoryPath += '\\' + "DB" + '\\' + "LOGS" + '\\' + delvEnvironment; } } #endregion return directoryPath; }
/// <summary> /// Creates the directory structure for the deployment /// Prepare yourself to see many IF statements !! /// </summary> /// <param name="deliveryInfo">The create directory.</param> public static void CreateDirectoryStructure(DeliveryInfoBE deliveryInfo) { #warning should check structure for folder well. some deliverables don't have logs files String rootDirectoryPathInternals = String.Empty; String rootDirectoryPathExternals = String.Empty; #region Int and Uat if (deliveryInfo.isINT || deliveryInfo.isUAT) { rootDirectoryPathInternals = deliveryInfo.RootDirectoryPath + '\\' + "Internals" + '\\' + "ITF" + deliveryInfo.ITFNo; //check if folder exists and delete everything if (Directory.Exists(rootDirectoryPathInternals)) { //there no format drive function at the moment //i wrote this :) Directory.Delete(rootDirectoryPathInternals, true); } //create the root folder Directory.CreateDirectory(rootDirectoryPathInternals); #region Deliverables Directories //this folder should always be created else //where the hell are you going to save the generated documents ? Directory.CreateDirectory(rootDirectoryPathInternals + "\\RFC"); //create sub folders based on what is being delivered //this you can optimise :) if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\WS"); } if (deliveryInfo.isDelvDB) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\DB"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\DB\\LOGS"); if (deliveryInfo.isINT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\DB\\LOGS\\INT"); } if (deliveryInfo.isUAT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\DB\\LOGS\\UAT"); } } if (deliveryInfo.isDelvK2PROCESS) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\K2PROCESS"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\K2PROCESS\\LOGS"); if (deliveryInfo.isINT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\K2PROCESS\\LOGS\\INT"); } if (deliveryInfo.isUAT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\K2PROCESS\\LOGS\\UAT"); } } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\REPORT"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BATCH"); } #endregion #region Mcops Directories //only create the MCOP directory if the following are //being delivered WEB / WS / BATCH / REPORT if ((deliveryInfo.isDelvWEB) || (deliveryInfo.isDelvWS) || (deliveryInfo.isDelvBATCH)) { //create the root directory Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES"); if (deliveryInfo.isINT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\INT"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\INT\\SETUP"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\INT\\ROLLBACK"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\INT\\LOGS"); } if (deliveryInfo.isUAT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\UAT"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\UAT\\SETUP"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\UAT\\ROLLBACK"); Directory.CreateDirectory(rootDirectoryPathInternals + "\\MCOP_FILES\\UAT\\LOGS"); } } #endregion #region Backup Directories //only create the backup directories if the following are //being delivered WEB / WS / BATCH / REPORT if ((deliveryInfo.isDelvWEB) || (deliveryInfo.isDelvWS) || (deliveryInfo.isDelvBATCH) || (deliveryInfo.isDelvREPORT)) { //create the root directory Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS"); if (deliveryInfo.isINT) { //create the sub directories Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\INT"); if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\INT\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\INT\\WS"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\INT\\BATCH"); } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\INT\\REPORT"); } } if (deliveryInfo.isUAT) { //create the sub directories Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\UAT"); if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\UAT\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\UAT\\WS"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\UAT\\BATCH"); } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathInternals + "\\BACKUPS\\UAT\\REPORT"); } } } #endregion } #endregion #region Staging and Prod if (deliveryInfo.isSTA || deliveryInfo.isPROD) { rootDirectoryPathExternals = deliveryInfo.RootDirectoryPath + '\\' + "Externals" + '\\' + deliveryInfo.NextExternalDirectory; //check if folder exists and delete everything if (Directory.Exists(rootDirectoryPathExternals)) { //there no format drive function at the moment //i wrote this :) Directory.Delete(rootDirectoryPathExternals, true); } //create the root folder Directory.CreateDirectory(rootDirectoryPathExternals); #region Deliverables Directories #warning should check this line if it is documentation or documentations? //this folder should always be created else //where the hell are you going to save the generated documents ? Directory.CreateDirectory(rootDirectoryPathExternals + "\\DOCUMENTATION"); //create sub folders based on what is being delivered //this you can optimise :) if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\WS"); } if (deliveryInfo.isDelvDB) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\DB"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\DB\\LOGS"); if (deliveryInfo.isSTA) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\DB\\LOGS\\STA"); } if (deliveryInfo.isPROD) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\DB\\LOGS\\PROD"); } } if (deliveryInfo.isDelvK2PROCESS) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\K2PROCESS"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\K2PROCESS\\LOGS"); if (deliveryInfo.isSTA) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\K2PROCESS\\LOGS\\STA"); } if (deliveryInfo.isPROD) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\K2PROCESS\\LOGS\\PROD"); } } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\REPORT"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BATCH"); } #endregion #region Mcops Directories //only create the MCOP directory if the following are //being delivered WEB / WS / BATCH / REPORT if ((deliveryInfo.isDelvWEB) || (deliveryInfo.isDelvWS) || (deliveryInfo.isDelvBATCH)) { //create the root directory Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES"); if (deliveryInfo.isSTA) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\STA"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\STA\\SETUP"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\STA\\ROLLBACK"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\STA\\LOGS"); } if (deliveryInfo.isPROD) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\PROD"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\PROD\\SETUP"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\PROD\\ROLLBACK"); Directory.CreateDirectory(rootDirectoryPathExternals + "\\MCOP_FILES\\PROD\\LOGS"); } } #endregion #region Backup Directories //only create the backup directories if the following are //being delivered WEB / WS / BATCH / REPORT if ((deliveryInfo.isDelvWEB) || (deliveryInfo.isDelvWS) || (deliveryInfo.isDelvBATCH) || (deliveryInfo.isDelvREPORT)) { //create the root directory Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS"); if (deliveryInfo.isSTA) { //create the sub directories Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\STA"); if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\STA\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\STA\\WS"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\STA\\BATCH"); } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\STA\\REPORT"); } } if (deliveryInfo.isPROD) { //create the sub directories Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\PROD"); if (deliveryInfo.isDelvWEB) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\PROD\\WEB"); } if (deliveryInfo.isDelvWS) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\PROD\\WS"); } if (deliveryInfo.isDelvBATCH) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\PROD\\BATCH"); } if (deliveryInfo.isDelvREPORT) { Directory.CreateDirectory(rootDirectoryPathExternals + "\\BACKUPS\\PROD\\REPORT"); } } } #endregion } #endregion }