internal CCFieldArray(CCreator parent, ITisFieldArrayData fieldArray) : this(parent, fieldArray != null? fieldArray.Name:String.Empty, parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(fieldArray) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(fieldArray, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(fieldArray, true) : null) { this.EflowOwner = fieldArray; this.ParentCollection = fieldArray.ParentCollection; this.ParentForm = fieldArray.ParentForm; this.ParentPage = fieldArray.ParentPage; this.ParentGroup = fieldArray.ParentFieldGroup; this.ParentTable = fieldArray.ParentFieldTable; this.NamedParent = fieldArray.ParentFieldTable.Name; if (fields == null) { fields = new List <CCField>(); } else { fields.Clear(); } foreach (ITisFieldData fd in fieldArray.LinkedFields) { fields.Add(new CCField(this.ParentCreator, fd)); } }
public CCCollection(CCreator parent, ITisClientServicesModule csm, ITisCollectionData collection) #endif : base(parent, collection != null? collection.Name:String.Empty, parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(collection) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(collection, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(collection, true) : null) { try { Priority = WorkflowPriorityLevel.Normal; FlowType = String.Empty; TargetQueue = String.Empty; LoginApplication = String.Empty; LoginStation = String.Empty; ImagePath = String.Empty; if (forms == null) { forms = new List <CCForm>(); } else { forms.Clear(); } this.LoginStation = csm.Session.StationName; this.LoginApplication = csm.Application.AppName; this.ParentCollection = collection; this.FlowType = collection.FlowType; this.EflowOwner = collection; this.ImagePath = collection.GetAttachmentFileName(CCEnums.CCFilesExt.TIF.ToString()); #region remove the collection image path from the attachments. List <String> att = new List <string>(); att.AddRange(CCUtils.GetAttachments(csm, collection.AttachedFileManager)); for (int ia = att.Count - 1; ia >= 0; ia--) { if (String.Compare(Path.GetFileName(att[ia]), this.ImagePath, true) == 0) { att.RemoveAt(ia); } } #endregion this.Attachments = att.ToArray(); this.Priority = collection.PriorityLevel; //-- Create forms --\\ foreach (ITisFormData frm in collection.Forms) { forms.Add(new CCForm(this.ParentCreator, frm)); } } catch (Exception ex) { ILog.LogError(ex); } }
public CCTable(CCreator parent, ITisFieldTableData fieldTable) #endif : this(parent, fieldTable.Name, parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(fieldTable) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(fieldTable, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(fieldTable, true) : null) { this.EflowOwner = fieldTable; this.ParentCollection = fieldTable.ParentCollection; this.ParentForm = fieldTable.ParentForm; this.ParentPage = fieldTable.ParentPage; this.ParentGroup = fieldTable.ParentFieldGroup; this.NamedParent = fieldTable.ParentFieldGroupExists ? fieldTable.ParentFieldGroup.Name : String.Empty; List <CCFieldArray> fas = new List <CCFieldArray>(); if (fieldArrays == null) { fieldArrays = new List <CCFieldArray>(); } else { fieldArrays.Clear(); } foreach (ITisFieldArrayData fa in fieldTable.FieldArrays) { fieldArrays.Add(new CCFieldArray(this.ParentCreator, fa)); } }
public CCForm(CCreator parent, ITisFormData form) #endif : base(parent, form != null? form.Name:String.Empty, parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(form) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(form, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(form, true) : null) { try { if (pages == null) { pages = new List <CCPage>(); } else { pages.Clear(); } this.ParentCollection = form.ParentCollection; this.FormType = form.FormType; this.EflowOwner = form; this.NamedParent = form.ParentCollection.Name; foreach (ITisPageData pg in form.LinkedPages) { pages.Add(new CCPage(this.ParentCreator, pg)); } } catch (Exception ex) { ILog.LogError(ex); } }
public CollectionCreator(String settingsFile) #endif { try { csmManager = new CsmManager(); if (String.IsNullOrEmpty(settingsFile)) { settingsFile = CCUtils.GetSettingsFilePath(); } if (File.Exists(settingsFile)) { config = CCConfiguration.FromXml(settingsFile); } if (config == null) { String errMsg = String.Format("{0}: [{1}], error code [{2}]", CCConstants.E0100, settingsFile ?? String.Empty, (int)CCEnums.CCErrorCodes.E0100); throw new Exception(errMsg); } } catch (Exception ex) { ILog.LogError(ex); throw (ex); } }
public CCPage(CCreator parent, ITisPageData page) #endif : base(parent, page != null? page.Name:String.Empty, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(page, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(page, true) : null) { try { if (groups == null) { groups = new List <CCGroup>(); } else { groups.Clear(); } this.Attachments = CCUtils.GetAttachments(page); this.EflowOwner = page; this.ParentCollection = page.ParentCollection; this.ParentForm = page.ParentForm; this.PageID = page.PageId; this.NamedParent = page.ParentFormExists ? page.ParentForm.Name : String.Empty; List <String> grpNames = new List <String>(); foreach (ITisFieldData fld in page.LinkedFields) { if (grpNames.Contains(fld.ParentFieldGroup.Name.ToUpper())) { continue; } grpNames.Add(fld.ParentFieldGroup.Name.ToUpper()); groups.Add(new CCGroup(this.ParentCreator, fld.ParentFieldGroup)); } foreach (ITisFieldTableData fldTbl in page.LinkedFieldTables) { if (grpNames.Contains(fldTbl.ParentFieldGroup.Name.ToUpper())) { continue; } grpNames.Add(fldTbl.ParentFieldGroup.Name.ToUpper()); groups.Add(new CCGroup(this.ParentCreator, fldTbl.ParentFieldGroup)); } } catch (Exception ex) { ILog.LogError(ex); } }
public CCField(CCreator parent, ITisFieldData field) : #endif this(parent, field != null? field.Name:String.Empty, field != null? field.Contents:String.Empty, field != null? field.Confidence:short.MinValue, field != null? field.FieldBoundingRect:new TIS_RECT(), parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(field) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(field, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(field, true) : null) { this.EflowOwner = field; this.ParentCollection = field.ParentCollection; this.ParentForm = field.ParentForm; this.ParentPage = field.ParentPage; this.ParentGroup = field.ParentFieldGroup; this.ParentFieldArray = field.ParentFieldArray; this.Index = field.TableRepetitionIndex; this.ParentTable = field.ParentFieldTable; if (field.ParentFieldArrayExists) { this.NamedParent = field.ParentFieldArray.Name; } else if (field.ParentFieldGroupExists) { this.NamedParent = field.ParentFieldGroup.Name; } }
public CCGroup(CCreator parent, ITisFieldGroupData group) #endif : base(parent, group != null? group.Name:String.Empty, parent == null || !parent.CurrentProfile.IgnoreExceptions ? CCUtils.GetSpecialTags(group) : null, parent == null || !parent.CurrentProfile.IgnoreNamedUserTags ? CCUtils.GetNamedUserTags(group, false) : null, parent == null || !parent.CurrentProfile.IgnoreUserTags ? CCUtils.GetUserTags(group, true) : null) { try { if (fields == null) { fields = new List <CCField>(); } else { fields.Clear(); } if (tables == null) { tables = new List <CCTable>(); } else { tables.Clear(); } this.EflowOwner = group; this.ParentCollection = group.ParentCollection; this.ParentForm = group.ParentForm; this.NamedParent = group.ParentForm.Name; List <String> fieldNames = new List <String>(); foreach (ITisFieldData fld in group.LinkedFields) { if (fieldNames.Contains(fld.Name.ToUpper())) { continue; } if (this.ParentPage == null) { this.ParentPage = fld.ParentPage; } fields.Add(new CCField(this.ParentCreator, fld)); fieldNames.Add(fld.Name); } foreach (ITisFieldTableData fldTbl in group.LinkedFieldTables) { if (this.ParentPage == null) { this.ParentPage = fldTbl.ParentPage; } tables.Add(new CCTable(this.ParentCreator, fldTbl)); } } catch (Exception ex) { ILog.LogError(ex); } }
/// <summary> /// Search for files using the configuration specified as settings. /// </summary> /// <param name="profileName">The application\profile name to load from the configuration</param> /// <returns>A list of 'CCFileList' objects when successfull and the search was successfull.</returns> public static CCFileList[] SearchFiles(String profileName) { return(SearchFiles(!String.IsNullOrEmpty(profileName) ? CCConfiguration.CCConfigurationData.FromXml(CCUtils.GetSettingsFilePath(), profileName):null)); }
/// <summary> /// Get CCConfiguration from XML file, using the default path. /// </summary> /// <returns>The CCConfiguration as deserialized from XML.</returns> public static CCConfiguration FromXml() { return(FromXml(CCUtils.GetSettingsFilePath(), typeof(CCConfiguration)) as CCConfiguration); }
/// <summary> /// From XML function, deserializes a profile from XML, using the default path. /// </summary> /// <param name="profileName">the profile name to load.</param> /// <returns>CCConfigurationData</returns> public static new CCConfigurationData FromXml(String profileName) { return(FromXml(CCUtils.GetSettingsFilePath(), profileName)); }
/// <summary> /// Read and load pages data into the collection definition. /// </summary> /// <param name="cfg">The configuration profile to use.</param> /// <param name="errCode">Returns the error code of this operation.</param> /// <param name="errMsg">Returns the error string of this operation</param> /// <param name="expectedNumberOfPages">The expected nuumber of pages in the collection.</param> /// <param name="coll">The collection definition to add the data to.</param> /// <param name="colData">The data table containing the data for the collection.</param> /// <returns>An array oif file paths for files that were created in this method</returns> private static String[] ReadPagesData(CCConfiguration.CCConfigurationData cfg, out int errCode, out String errMsg, int expectedNumberOfPages, ref CCCollection coll, DataTable colData) { errCode = (int)CCEnums.CCErrorCodes.E0000; errMsg = null; List <String> result = new List <String>(); try { //-- Validate expected page count --\\ if (expectedNumberOfPages <= 0) { errCode = (int)CCEnums.CCErrorCodes.E0051; errMsg = String.Format("{0}, error code [{1}]", CCConstants.E0051, errCode); throw new Exception(errMsg); } int numberOfImagePages = CCUtils.GetImagePageCount(coll.ImagePath, null); //-- Validate page count --\\ if (numberOfImagePages <= 0) { errCode = (int)CCEnums.CCErrorCodes.E0061; errMsg = String.Format("{0}, file path [{1}], error code [{2}]", CCConstants.E0061, coll.ImagePath, errCode); throw new Exception(errMsg); } //-- Validate page count against expected page count --\\ if (numberOfImagePages != expectedNumberOfPages) { errCode = (int)CCEnums.CCErrorCodes.E0050; errMsg = String.Format("{4}. expected number of pages [{1}], actual image count [{2}], file path [{3}], error code [{0}]", errCode, expectedNumberOfPages, numberOfImagePages, coll.ImagePath, CCConstants.E0050); throw new Exception(errMsg); } List <CCCollection.CCForm> forms = new List <CCCollection.CCForm>(); for (int pageCount = 1; pageCount <= expectedNumberOfPages; pageCount++) { Dictionary <String, String> lstDct = new Dictionary <String, String>(); List <String> attachments = new List <String>(); DataRow[] pageRows = colData.Select(String.Format("{0}={1}", CCEnums.CCTableColumns.Level, IsStringData(colData.Columns[CCEnums.CCTableColumns.Level.ToString()]) ? "'" + pageCount.ToString() + "'" : pageCount.ToString())); if (pageRows == null || pageRows.Length <= 0) { pageRows = colData.Select(String.Format("{0}='{1}'", CCEnums.CCTableColumns.Level, pageCount)); } //-- Process pages data --\\ if (pageRows != null && pageRows.Length > 0) { List <int> pageNumbers = new List <int>(); String startDate = null; String endDate = null; //-- Iterate pages rows --\\ foreach (DataRow dr in pageRows) { //-- Get the page number the data is itntended to --\\ int pageNumber = CCUtils.StrToIntDef(dr[CCEnums.CCTableColumns.Level.ToString()].ToString(), -1); if (!pageNumbers.Contains(pageNumber)) { pageNumbers.Add(pageNumber); } //-- << Read pages data >>--\\ if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.PageType.ToString(), true) == 0) { //-- PageType --\\ CCUtils.AddSetDictionaryItem(CCEnums.CCPagesDataType.PageType.ToString(), dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.StartDate.ToString(), true) == 0) { //-- StartDate --\\ startDate = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); CCUtils.AddSetDictionaryItem(CCEnums.CCPagesDataType.StartDate.ToString(), startDate, excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.EndDate.ToString(), true) == 0) { //-- EndDate --\\ endDate = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); CCUtils.AddSetDictionaryItem(CCEnums.CCPagesDataType.EndDate.ToString(), endDate, excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.Attachments.ToString(), true) == 0) { //-- Attachments --\\ String val = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); if (!String.IsNullOrEmpty(val) && !File.Exists(val)) { errCode = (int)CCEnums.CCErrorCodes.E0065; errMsg = String.Format("{1}, file path[{2}], error code [{0}]", errCode, CCConstants.E0065, val ?? String.Empty); throw new Exception(errMsg); } else { if (!attachments.Contains(val)) { attachments.Add(val); } } } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.XmlPrdPath.ToString(), true) == 0) { //-- XmlPrdPath --\\ int errC = 0; String errS = null; String sourceXmlPath = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); //-- Convert XML to PRD and add as page attachment --\\ String prdPath = DeserializePRD(out errC, out errS, pageNumber, false, sourceXmlPath); if (!String.IsNullOrEmpty(prdPath)) { if (File.Exists(sourceXmlPath)) { //-- Lock PRD file --\\ String lockPrd = CCFileList.GetLockedFilePath(prdPath, cfg.LockExtension); if (String.Compare(lockPrd, prdPath, true) != 0) { if (File.Exists(lockPrd)) { File.SetAttributes(lockPrd, FileAttributes.Normal); File.Delete(lockPrd); } File.SetAttributes(prdPath, FileAttributes.Normal); File.Move(prdPath, lockPrd); } File.Delete(sourceXmlPath); if (!attachments.Contains(lockPrd)) { attachments.Add(lockPrd); } if (!result.Contains(lockPrd)) { result.Add(lockPrd); } } } } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCPagesDataType.MetaData.ToString(), true) == 0) { //-- Additional MetaData--\\ String tagName = dr[CCEnums.CCTableColumns.Key.ToString()] is DBNull || String.IsNullOrEmpty(dr[CCEnums.CCTableColumns.Key.ToString()].ToString()) ? null : dr[CCEnums.CCTableColumns.Key.ToString()].ToString(); if (!String.IsNullOrEmpty(tagName)) { CCUtils.AddSetDictionaryItem(tagName, dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } } } //-- Validate page dates --\\ if (!ValidateDates(startDate, endDate, out errCode, out errMsg)) { //-- Validate start and end time\date --\\ errCode = (int)CCEnums.CCErrorCodes.E0020; errMsg = String.Format("{0}, {1} [{2}],{3} [{4}], page number [{5}], error code [{6}]", CCConstants.E0020, CCEnums.CCPagesDataType.StartDate, startDate, CCEnums.CCPagesDataType.EndDate, endDate, pageCount, errCode); throw new Exception(errMsg); } } //-- Create a form and page, NF 2011-11-07 added support for multipage per form --\\ CCCollection.CCForm frm = cfg.MultiPagePerForm ? forms.Count > 0 ? forms[0] : new CCCollection.CCForm(null, null, null) : new CCCollection.CCForm(null, null, null); if (!cfg.MultiPagePerForm || (cfg.MultiPagePerForm && forms.Count <= 0)) { frm.NamedUserTags.NativeDictionary = lstDct; //-- Add page Named user tags to Form user tags --\\ } CCCollection.CCPage pg = new CCCollection.CCPage(); pg.Attachments = attachments.ToArray(); pg.NamedUserTags.NativeDictionary = lstDct; if (!cfg.MultiPagePerForm || forms.Count <= 0) { frm.Pages = new CCCollection.CCPage[] { pg }; } else { List <CCCollection.CCPage> pgs = new List <CCCollection.CCPage>(frm.Pages); pgs.Add(pg); frm.Pages = pgs.ToArray(); } if (!cfg.MultiPagePerForm || forms.Count <= 0) { forms.Add(frm); } } //-- Do some validations --\\ if (expectedNumberOfPages != forms.Count) { if (!cfg.MultiPagePerForm || forms.Count <= 0) { errCode = (int)CCEnums.CCErrorCodes.E0090; errMsg = String.Format("Error code [{0}], {1},expected number of pages [{2}], eflow form count [{3}]", errCode, CCConstants.E0090, expectedNumberOfPages, forms.Count); throw new Exception(errMsg); } else { if (forms[0].Pages.Length != expectedNumberOfPages) { errCode = (int)CCEnums.CCErrorCodes.E0090; errMsg = String.Format("Error code [{0}], {1},expected number of pages [{2}] in one form, eflow form count [{3}]", errCode, CCConstants.E0090, expectedNumberOfPages, forms.Count); throw new Exception(errMsg); } } } errCode = (int)CCEnums.CCErrorCodes.E0001; coll.Forms = forms.ToArray(); } catch (Exception ex) { ILog.LogError(ex, false); if (String.IsNullOrEmpty(errMsg)) { errMsg = CCConstants.E0000 + "," + ex.Message; } throw (ex); } return(result.ToArray()); }
/// <summary> /// Read header data. /// </summary> /// <param name="cfg">The configuration profile to use.</param> /// <param name="errCode">The return error code, 1 is OK, anything else not.</param> /// <param name="errMsg">Will contain the error data if any error occures.</param> /// <param name="expectedNumberOfPages">Returns the expected number of pages.</param> /// <param name="dbCollectionData">The data table with rows to get Hedaer info.</param> /// <returns>A CCCollection when successfull, null when failed,</returns> public static CCCollection ReadHeaderData(CCConfiguration.CCConfigurationData cfg, out int errCode, out String errMsg, out int expectedNumberOfPages, DataTable dbCollectionData) { errCode = -1; errMsg = null; expectedNumberOfPages = 0; try { if (dbCollectionData == null || dbCollectionData.Rows.Count <= 0 || dbCollectionData.Columns.Count < 4) { errCode = (int)CCEnums.CCErrorCodes.E0041; errMsg = String.Format("{0}, error code [{1}]", CCConstants.E0041, errCode); throw new Exception(errMsg); } //-- Get header rows --\\ DataRow[] headerRows = dbCollectionData.Select(String.Format("{0}={1}", CCEnums.CCTableColumns.Level, IsStringData(dbCollectionData.Columns[CCEnums.CCTableColumns.Level.ToString()]) ? "'0'":"0")); if (headerRows == null || headerRows.Length <= 0) { headerRows = dbCollectionData.Select(String.Format("{0}='0'", CCEnums.CCTableColumns.Level)); } //-- Process header data --\\ if (headerRows != null && headerRows.Length > 0) { CCCollection res = new CCCollection(); Dictionary <String, String> lstDct = new Dictionary <String, String>(); List <String> attachments = new List <String>(); String startDate = null; String endDate = null; bool hasFlow = false; foreach (DataRow dr in headerRows) { //-- Extract columns data --\\ if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.Name.ToString(), true) == 0) { //-- Name --\\ res.Name = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.FlowType.ToString(), true) == 0) { //-- FlowType --\\ hasFlow = true; res.FlowType = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.AbsolutePriority.ToString(), true) == 0) { //-- AbsolutePriority --\\ double absPrio = 0d; if (double.TryParse(dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), out absPrio)) { res.AbsolutePriority = absPrio; } } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.StartDate.ToString(), true) == 0) { //-- StartDate --\\ startDate = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.StartDate.ToString(), startDate, excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.EndDate.ToString(), true) == 0) { //-- EndDate --\\ endDate = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.EndDate.ToString(), endDate, excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.DeviceID.ToString(), true) == 0) { //-- DeviceID --\\ CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.DeviceID.ToString(), dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.UserID.ToString(), true) == 0) { //-- UserID --\\ CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.UserID.ToString(), dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.MachineID.ToString(), true) == 0) { //-- MachineID --\\ CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.MachineID.ToString(), dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.TotalPagesInBatch.ToString(), true) == 0) { //-- TotalPagesInBatch --\\ expectedNumberOfPages = CCUtils.StrToIntDef(dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), 0); CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.TotalPagesInBatch.ToString(), expectedNumberOfPages.ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.ImagePath.ToString(), true) == 0) { //-- ImagePath --\\ res.ImagePath = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.Attachments.ToString(), true) == 0) { //-- Attachments --\\ String val = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); if (!String.IsNullOrEmpty(val) && !File.Exists(val)) { errCode = (int)CCEnums.CCErrorCodes.E0065; errMsg = String.Format("{0}, file path [{1}], error code [{2}]", CCConstants.E0065, val ?? String.Empty, errCode); throw new Exception(errMsg); } else { if (!attachments.Contains(val)) { attachments.Add(val); } } } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.BatchType.ToString(), true) == 0) { //-- BatchType --\\ CCUtils.AddSetDictionaryItem(CCEnums.CCHedaerDataType.BatchType.ToString(), dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.Priority.ToString(), true) == 0) { //-- Priority --\\ String pr = dr[CCEnums.CCTableColumns.Data.ToString()].ToString().ToUpper(); if (!String.IsNullOrEmpty(pr) && !Regex.IsMatch(pr, CCConstants.RX_PRIORITY)) { errCode = (int)CCEnums.CCErrorCodes.E0070; errMsg = String.Format("{0}, specified value [{1}], error code [{2}]", CCConstants.E0070, pr, errCode); throw new Exception(errMsg); } else { res.Priority = pr == WorkflowPriorityLevel.AboveNormal.ToString().Substring(0, 1) || pr.Replace(" ", String.Empty) == WorkflowPriorityLevel.AboveNormal.ToString().ToUpper() ? WorkflowPriorityLevel.AboveNormal : pr == WorkflowPriorityLevel.High.ToString().Substring(0, 1) || pr == WorkflowPriorityLevel.High.ToString().ToUpper() ? WorkflowPriorityLevel.High : pr == WorkflowPriorityLevel.Low.ToString().Substring(0, 1) || pr == WorkflowPriorityLevel.Low.ToString().ToUpper() ? WorkflowPriorityLevel.Low : WorkflowPriorityLevel.Normal; } } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.ApplicationName.ToString(), true) == 0) { //-- ApplicationName --\\ res.LoginApplication = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.StationName.ToString(), true) == 0) { //-- StationName --\\ res.LoginStation = dr[CCEnums.CCTableColumns.Data.ToString()].ToString(); } else if (String.Compare(dr[CCEnums.CCTableColumns.DataType.ToString()].ToString(), CCEnums.CCHedaerDataType.MetaData.ToString(), true) == 0) { //-- Additional MetaData --\\ String tagName = dr[CCEnums.CCTableColumns.Key.ToString()] is DBNull || String.IsNullOrEmpty(dr[CCEnums.CCTableColumns.Key.ToString()].ToString()) ? null : dr[CCEnums.CCTableColumns.Key.ToString()].ToString(); if (!String.IsNullOrEmpty(tagName)) { CCUtils.AddSetDictionaryItem(tagName, dr[CCEnums.CCTableColumns.Data.ToString()].ToString(), excpetionOnDictDuplicates, ref lstDct); } } } if (!hasFlow && !String.IsNullOrEmpty(cfg.FlowType)) { //-- Take flow type from configuration, if defined --\\ res.FlowType = cfg.FlowType; } #region //-- Do some validations --\\ if (expectedNumberOfPages <= 0) { //-- Validate expected number of pages value --\\ errCode = (int)CCEnums.CCErrorCodes.E0051; errMsg = String.Format("{0}, error code [{1}]", CCConstants.E0051, errCode); throw new Exception(errMsg); } else if (!File.Exists(res.ImagePath)) { //-- Validate image path --\\ errCode = (int)CCEnums.CCErrorCodes.E0060; errMsg = String.Format("{0}, file path [{1}], error code [{2}]", CCConstants.E0060, res.ImagePath ?? String.Empty, errCode); throw new Exception(errMsg); } else if (!String.IsNullOrEmpty(res.Name) && !Regex.IsMatch(res.Name, CCConstants.RX_COLLECTION_NAME)) { //-- Validate collection name --\\ errCode = (int)CCEnums.CCErrorCodes.E0010; errMsg = String.Format("{0}, error code [{1}]", CCConstants.E0010, errCode); throw new Exception(errMsg); } else if (!ValidateDates(startDate, endDate, out errCode, out errMsg)) { //-- Validate start and end time\date --\\ errCode = (int)CCEnums.CCErrorCodes.E0020; errMsg = String.Format("{0}, {1} [{2}],{3} [{4}], error code [{5}]", CCConstants.E0020, CCEnums.CCHedaerDataType.StartDate, startDate, CCEnums.CCHedaerDataType.EndDate, endDate, errCode); throw new Exception(errMsg); } #endregion //-- Finish setting data --\\ res.Attachments = attachments.ToArray(); res.NamedUserTags.NativeDictionary = lstDct; //-- Done gathering data from all header rows --\\ errCode = (int)CCEnums.CCErrorCodes.E0001; return(res); } else { errCode = 999; errMsg = String.Format("{0}, error code [{1}]", CCConstants.E0040, errCode); throw new Exception(errMsg); } } catch (Exception ex) { ILog.LogError(ex, false); throw (ex); } }
public CCPage(CCreator parent, ITisPageParams page, String page_id) #endif : base(parent, page != null? page.Name:String.Empty, null, null) { try { if (groups == null) { groups = new List <CCGroup>(); } else { groups.Clear(); } this.EflowOwner = page; this.PageID = page_id; this.NamedParent = page.ParentForm.Name; bool hasEfi = false; CCGroup grp = null; List <CCTable> tables = new List <CCTable>(); if (!String.IsNullOrEmpty(page_id)) { //-- Get matched EFI --\\ ITisEFIParams efi = page.get_LinkedEFI(page_id); hasEfi = efi != null; if (hasEfi) { //-- Get all fields and field-groups that has ROIs --\\ foreach (ITisROIParams roi in efi.ROIs) { if (roi.Miscellaneous.OrderInField == 1) { ITisFieldParams fp = page.get_LinkedField(roi.Miscellaneous.FieldName); if (fp != null) { if (fp.ParentFieldGroupExists) { //-- A standard field --\\ grp = GetGroup(fp.ParentFieldGroup.Name); if (grp == null) { grp = new CCGroup(parent, fp.ParentFieldGroup, false); groups.Add(grp); } CCField cf = grp.GetField(fp.Name); //-- Create field and join sll ROIs --\\ if (cf == null) { cf = grp.AddField(fp.Name, String.Empty, 0, CCUtils.MergerRoisRect(CCUtils.GetLinkedRois(efi, fp.Name))); } else { cf.Rect = new FieldRect(CCUtils.MergerRoisRect(CCUtils.GetLinkedRois(efi, fp.Name))); } grp.AddField(cf); } else if (fp.ParentFieldTableExists) { //-- A table field --\\ grp = AddGroup(fp.ParentFieldTable.ParentFieldGroup.Name); CCTable tbl = grp.AddTable(fp.ParentFieldTable.Name); if (!tables.Contains(tbl)) { tables.Add(tbl); } CCFieldArray fldArr = tbl.AddFieldArray(fp.Name); fldArr.AddField(fp, CCUtils.MergerRoisRect(CCUtils.GetLinkedRois(efi, fp.Name))); //CCField cf = fldArr.AddField(fldArr.fp.Name); ////-- Create field and join sll ROIs --\\ //if (cf == null) cf = grp.AddField(fp.Name, String.Empty, 0, CCUtils.MergerRoisRect(CCUtils.GetLinkedRois(efi, fp.Name))); //else cf.Rect = new FieldRect(CCUtils.MergerRoisRect(CCUtils.GetLinkedRois(efi, fp.Name))); //CCFieldArray cfAr = tbl.AddFieldArray(fp.Name); //cfAr.AddField(cf); } } } } //-- Add rows if KeepEmptyRows is marked --\\ if (tables != null && tables.Count > 0) { foreach (CCTable tbl in tables) { ITisFieldTableParams efTable = page.get_LinkedFieldTable(tbl.Name); if (efTable != null && efTable.Table.KeepEmptyRows && efTable.Table.NumberOfRows > tbl.NumberOfRows) { tbl.AddRow(); } } } } } if (!hasEfi) { foreach (ITisFieldParams fld in page.LinkedFields) { if (fld.ParentFieldGroupExists) { grp = GetGroup(fld.ParentFieldGroup.Name); if (grp == null) { grp = new CCGroup(parent, fld.ParentFieldGroup, false); groups.Add(grp); } } else if (fld.ParentFieldTableExists) { grp = GetGroup(fld.ParentFieldTable.ParentFieldGroup.Name); if (grp == null) { grp = new CCGroup(parent, fld.ParentFieldTable.ParentFieldGroup, false); groups.Add(grp); } } } foreach (ITisFieldTableParams fldTbl in page.LinkedFieldTables) { grp = GetGroup(fldTbl.ParentFieldGroup.Name); if (grp == null) { grp = new CCGroup(parent, fldTbl.ParentFieldGroup, false); groups.Add(grp); } } } } catch (Exception ex) { ILog.LogError(ex); } }