/// <summary> /// The method returns the value corresponding to the DCO field specified, from the current DCO for the field. /// <param name="DCOTree">DCO Expression in the format [DCO].[document_type].[page_type].[field_name]</param> /// <returns>The value corresponding to the DCO field specified, from the current DCO.</returns> /// </summary> public virtual string getDCOValueForField(string DCOTree) { // DCO reference in the template file should adhere to a 4 part string [DCO].[document_type].[page_type].[field_name] // Parse the DCO reference and extract the page_type and field_name which can then be used to look up in the // current document that is being processed DCOTree = DCOTree.Replace("[", "").Replace("]", ""); char[] sep = { '.' }; string[] dcoArray = DCOTree.Split(sep, 4, StringSplitOptions.None); TDCOLib.DCO page = CurrentDCO.Parent(); string pageID = page.ID; TDCOLib.DCO document = page.Parent(); string documentID = document.ID; string output = ""; try { // this is to pick up the field from the right page type if ((dcoArray[3] == CurrentDCO.ID && (dcoArray[1] == document.Type || page.Parent().ObjectType() == Constants.Batch) && dcoArray[2] == page.Type)) { output = CurrentDCO.Text; } else { ExportCore.WriteLog(" Current field " + CurrentDCO.ID + " is different from required field which is" + DCOTree); } } catch (Exception exp) { // There could be reference in the template for the documents that are not processed in the current batch // Template in TravelDocs can have reference to a field under Flight but the current batch doesn't have // any flight related input. Alternatively, Flight and Car Rental gets processed but for the Car Rental // data output, there cannot be any Flight reference ExportCore.WriteErrorLog(" Unable to find DCO reference for the field : " + DCOTree); ExportCore.WriteErrorLog(" Error while reading DCO reference: " + exp.ToString()); } return(output); }
/// <summary> /// The method returns the value corresponding to the DCO expression specified from the current DCO. /// <param name="DCOTree">DCO Expression in the format [DCO].[document_type].[page_type].[field_name]</param> /// <param name="pageID">Page ID from where the value needs to be extracted</param> /// <returns>The value corresponding to the DCO expression specified from the current DCO.</returns> /// </summary> public string getDCOValueForPage(string DCOTree, string pageID) { // DCO reference in the template file should adhere to a 4 part string [DCO.<doc_type>.<page_type>.<field_name>] // Parse the DCO reference and extract the page_type and field_name which can then be used to look up in the // current document that is being processed DCOTree = DCOTree.Replace("[", "").Replace("]", ""); char[] sep = { '.' }; string[] dcoArray = DCOTree.Split(sep, 4, StringSplitOptions.None); string output = ""; try { TDCOLib.DCO page = DCO.FindChild(pageID); if (dcoArray.Length == 2 && DCOTree == "page.name") { output = page.ID + " - " + page.Type; } // Validate DCOTree expression against the current DCO // match page type and parent type of page else if ((dcoArray[1] == page.Parent().Type || page.Parent().ObjectType() == Constants.Batch) && dcoArray[2] == page.Type) { output = page.FindChild(dcoArray[3]).Text; } else { ExportCore.WriteLog(" The expression " + DCOTree + " is not valid for page " + pageID); } } catch (Exception exp) { // There could be reference in the template for the documents that are not processed in the current batch // Template in TravelDocs can have reference to a field under Flight but the current batch doesn't have // any flight related input. Alternatively, Flight and Car Rental gets processed but for the Car Rental // data output, there cannot be any Flight reference ExportCore.WriteErrorLog(" Unable to find DCO reference for the page with ID: " + pageID); ExportCore.WriteErrorLog(" Error while reading DCO reference: " + exp.ToString()); } return(output); }
/// <summary> /// The method value of the DCO expression from the current file. /// <param name="DCOTree" >DCO expression that refers to a field in the file.</param> /// </summary> public string getDCOValueForFile(string DCOTree) { string filename = (string)Globals.Instance.GetData(Constants.forLoopString.CURRENTFILE); Dictionary <string, List <string> > filePageMap = (Dictionary <string, List <string> >)Globals.Instance.GetData(Constants.FILE_PAGE_MAP); List <string> pages = (List <string>)filePageMap[filename]; string output = ""; DCOTree = DCOTree.Replace("[", "").Replace("]", ""); char[] sep = { '.' }; string[] dcoArray = DCOTree.Split(sep); if (CurrentDCO.ObjectType() != Constants.Batch) { throw new SmartExportException("getDCOValueForFile(" + DCOTree + ") can be used at batch level only. "); } foreach (string pageID in pages) { TDCOLib.DCO page = CurrentDCO.FindChild(pageID); // Validate DCOTree expression against the current DCO // match page type and parent type of page if (page.Parent().ObjectType() == Constants.Batch && dcoArray[1] == page.Type) { output += page.FindChild(dcoArray[2]).Text; if (!string.IsNullOrEmpty(output)) { break; } } else { ExportCore.WriteLog(" The expression " + DCOTree + " is not valid for page " + pageID); } } return(output); }