Пример #1
0
        public void StartFilesSearch(String profileName)
#endif
        {
            try
            {
                if (!String.IsNullOrEmpty(profileName))
                {
                    CCConfiguration.CCConfigurationData cfData = config.GetConfiguration(profileName);
                    if (cfData != null)
                    {
                        //-- Check if reset required --\\
                        if (timerSearch != null && String.Compare(profileName, timerSearch.CurrentProfile.Name, true) != 0)
                        {
                            //-- Reset --\\
                            timerSearch.Enabled = false;
                            timerSearch.Dispose();
                            timerSearch = null;
                        }

                        //-- Create a new timer search object if necessary --\\
                        if (timerSearch == null)
                        {
                            timerSearch = new CCTimerSearch(csmManager.GetCsm(String.IsNullOrEmpty(cfData.LoginApplication) ? profileName : cfData.LoginApplication, cfData.LoginStation, true), cfData);
                        }
                        timerSearch.Enabled = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
        }
Пример #2
0
        public int CreateCollection(String applicationName, bool copySourceFiles, String collectionDataPath, out int errCode, out String errMsg)
#endif
        {
            errCode = -1;
            errMsg  = null;

            try
            {
                //-- Create \ initilaize configuration data --\\
                CCConfiguration.CCConfigurationData cfg = CCConfiguration.CCConfigurationData.FromXml(applicationName);

                //-- Create a collection creator class --\\
                using (CCreator crt = new CCreator(cfg))
                {
                    crt.CurrentProfile.CopySourceFiles = copySourceFiles;

                    //-- Create the collection definition --\\
                    CCCollection coll = CCCollection.FromXml(collectionDataPath, !copySourceFiles);

                    if (coll == null)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0091;
                        errMsg  = String.Format("{0}, file name: [{1}], error code [{2}]", CCConstants.E0091, collectionDataPath ?? String.Empty, errCode);
                        throw new Exception(errMsg);
                    }


                    String[] resCols = crt.CreateCollections(null, out errCode, coll);
                    if (resCols == null || resCols.Length != 1)
                    {
                        errCode = errCode <= 0 ? (int)CCEnums.CCErrorCodes.E0092: errCode;
                        errMsg  = String.Format("{0}, {1}, Source file path [{1}], error code [{2}]", CCConstants.E0092, collectionDataPath ?? String.Empty, errCode);
                        throw new Exception(errMsg);
                    }
                    else
                    {
                        ILog.LogInfo("Done creating collection [{0}] from file [{1}] in eFlow system", resCols[0], collectionDataPath);
                        errCode = (int)CCEnums.CCErrorCodes.E0001;
                    }
                }
            }
            catch (Exception ex)
            {
                if (String.IsNullOrEmpty(errMsg))
                {
                    errMsg = ex.Message;
                }
                ILog.LogError(ex);
                if (currCfg == null || currCfg.ThrowAllExceptions)
                {
                    throw ex;
                }
            }
            return(errCode);
        }
Пример #3
0
        public CCTimerSearch(ITisClientServicesModule oCSM, String configPath, String profileName)
        {
            try
            {
                CSM = oCSM;
                CollectionsCreator = new CCreator();
                if (CSM != null)
                {
                    CSM.Session.OnMessage += StationMessage;
                    workDir = CSM.PathLocator.get_Path(CCEnums.CCFilesExt.TIF.ToString());
                }

                //-- Initialize profile --\\
                if (File.Exists(configPath ?? String.Empty))
                {
                    config = CCConfiguration.FromXml(configPath);
                }
                else
                {
                    config = CCConfiguration.FromCSM(CSM);
                }

                //-- Initialize profile --\\
                if (String.IsNullOrEmpty(profileName))
                {
                    profileName = CSM.Application.AppName;
                }
                currentProfile = config != null?config.GetConfiguration(profileName) : null;

                if (currentProfile == null)
                {
                    currentProfile = new CCConfiguration.CCConfigurationData();                        //-- create a default profile --\\
                }
                //-- Define collections creator settings --\\
                CollectionsCreator.CurrentProfile = currentProfile;

                //collectionsCreator.OnPostFileLock += PostFileLock;
                CollectionsCreator.OnCollectionCreated += CollectionCreated;

                if (SearchHandler == null)
                {
                    SearchHandler = new CCSearchFiles(currentProfile);
                }
                SearchHandler.OnPostFileLock += PostFileLock;
                SearchHandler.OnPreFileLock  += PreFileLock;

                PollingTimer.Enabled = currentProfile.SearchPaths != null && currentProfile.SearchPaths.Length > 0 && currentProfile.SearchExtensions != null && currentProfile.SearchExtensions.Length > 0;
                CreateEvent();//-- fire OnCreate  event --\
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
        }
Пример #4
0
 /// <summary>
 /// Convert the class data to a CCCOllection (the internal object used to create collections).
 /// </summary>
 /// <param name="cfg">The configuration to use.</param>
 /// <param name="errCode">Returns the erroro code for this function.</param>
 /// <param name="errMsg">Will contain all the errors that this function has encountered</param>
 /// <param name="copySourceFiles">Copy source files</param>
 /// <param name="createdFiles">A list of files created durning process. (like XML to PRD)</param>
 /// <returns>A CCCollection class when successfull, null when not.</returns>
 internal virtual CCCollection ToCCCollection(CCConfiguration.CCConfigurationData cfg, out int errCode, out String errMsg, bool copySourceFiles, ref String[] lstFiles)
 {
     if (Count > 0)
     {
         return(CCDataTable.FromDataTable(cfg, out errCode, out errMsg, copySourceFiles, out lstFiles, ToDataTable()));
     }
     else
     {
         errCode = (int)CCEnums.CCErrorCodes.E0040;
         errMsg  = "No header information";
         return(null);
     }
 }
Пример #5
0
 /// <summary>
 /// Search for files using the configuration specified as settings.
 /// </summary>
 /// <param name="cfgProfile">The application\profile to use it's settings for the search</param>
 /// <returns>A list of 'CCFileList'  objects when successfull and the search was successfull.</returns>
 public static CCFileList[] SearchFiles(CCConfiguration.CCConfigurationData cfgProfile)
 {
     try
     {
         if (cfgProfile != null)
         {
             using (CCSearchFiles ccs = new CCSearchFiles(cfgProfile))
             {
                 CCFileList[] result = ccs.SearchFiles();
                 return(result);
             }
         }
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(null);
 }
Пример #6
0
            /// <summary>
            /// From XMl function, deserializes a profile from XML
            /// </summary>
            /// <param name="xmlPath">The XML file path</param>
            /// <param name="profileName">the profile name to load.</param>
            /// <returns>CCConfigurationData</returns>
            public static CCConfigurationData FromXml(String xmlPath, String profileName)
            {
                CCConfiguration.CCConfigurationData result = null;

                try
                {
                    CCConfiguration cfg = CCConfiguration.FromXml(xmlPath);
                    return(cfg.GetConfiguration(profileName));
                }
                catch (Exception ex)
                {
                    ILog.LogError(ex);
                    if (result != null && result.ThrowAllExceptions)
                    {
                        throw ex;
                    }
                }
                return(result);
            }
Пример #7
0
        public CCTimerSearch(ITisClientServicesModule oCSM, CCConfiguration.CCConfigurationData dataCfg)
        {
            try
            {
                CSM = oCSM;
                CollectionsCreator = new CCreator();
                if (CSM != null)
                {
                    CSM.Session.OnMessage += StationMessage;
                    workDir = CSM.PathLocator.get_Path(CCEnums.CCFilesExt.TIF.ToString());
                }

                //-- Initialize profile --\\
                config = dataCfg.ParentConfiguration;

                //-- Initialize profile --\\
                currentProfile = dataCfg;

                //-- Define collections creator settings --\\
                CollectionsCreator.CurrentProfile       = currentProfile;
                CollectionsCreator.OnCollectionCreated += CollectionCreated;

                if (SearchHandler == null)
                {
                    SearchHandler = new CCSearchFiles(currentProfile);
                }
                SearchHandler.OnPostFileLock += PostFileLock;
                SearchHandler.OnPreFileLock  += PreFileLock;

                PollingTimer.Enabled = currentProfile.SearchPaths != null && currentProfile.SearchPaths.Length > 0 && currentProfile.SearchExtensions != null && currentProfile.SearchExtensions.Length > 0;
                CreateEvent();//-- fire OnCreate  event --\
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
        }
Пример #8
0
 /// <summary>
 /// Search an input folders for files of certain extension as key\trigger files then search and collect all other related attachments.
 /// </summary>
 /// <param name="rootPaths">The root paths to start the search from</param>
 /// <param name="subFolders">Inckude subfolders in te search when true.</param>
 /// <param name="dateSorted">Sort the files by date when true (alpha when false)</param>
 /// <param name="maxLock">The maximum key\trigger files to lock.</param>
 /// <param name="keyExtensions">The key\trigger extensions to look for.</param>
 /// <param name="subExtensions">The attachments extensions to look for once a key extension is found.</param>
 /// <returns>An array of FileCollection objects with all files of a collection, devided by extension</returns>
 public virtual CCFileList[] SearchFiles(CCConfiguration.CCConfigurationData cfg)
 {
     return(SearchFiles(cfg.SearchPaths, cfg.CopySourceFiles, cfg.SearchSubFolders, cfg.FilesSort, cfg.MaxFilesLock, cfg.SearchExtensions, cfg.AttachmentsExtensions));
 }
Пример #9
0
 public CCSearchFiles(CCConfiguration.CCConfigurationData config)
 {
     currentProfile = config;
 }
Пример #10
0
        /// <summary>
        /// Read collection definitions from DataTable and load into a CCCollection definition
        /// </summary>
        /// <param name="cfg">The configuration to use.</param>
        /// <param name="errCode">Returns the erroro code for this function.</param>
        /// <param name="errMsg">Will contain all the errors that this function has encountered</param>
        /// <param name="copySourceFiles">Copy source files</param>
        /// <param name="createdFiles">A list of files created durning process. (like XML to PRD)</param>
        /// <param name="dbCollectionData">The data table containing the data for the collection.</param>
        /// <returns>Return a CCCollection from the specified collection data.</returns>
        public static CCCollection FromDataTable(CCConfiguration.CCConfigurationData cfg, out int errCode, out String errMsg, bool copySourceFiles, out String[] createdFiles, DataTable dbCollectionData)
        {
            errCode      = -1;
            errMsg       = null;
            createdFiles = null;

            try
            {
                //-- Log DataTable --\\
                if (cfg != null && cfg.LogCollectionDataTable)
                {
                    try
                    {
                        ILog.LogInfo("{0} received DataTable [{1}], rows data (see next line\\s):\r\n[{2}], [{3}], [{4}], [{5}]\r\n{6}", "InputAPI", dbCollectionData.TableName ?? string.Empty,
                                     CCEnums.CCTableColumns.Level, CCEnums.CCTableColumns.DataType, CCEnums.CCTableColumns.Key, CCEnums.CCTableColumns.Data,
                                     Helpers.CCTDataRows.FromDataRows(dbCollectionData.Select()).ToString("\r\n", ", "));
                    }
                    catch { }
                }

                #region //-- Name table columns (if not named) --\\
                if (!chkLst.Contains(dbCollectionData.Columns[0].ColumnName.ToUpper()))
                {
                    dbCollectionData.Columns[0].ColumnName = CCEnums.CCTableColumns.Level.ToString();
                }

                if (!chkLst.Contains(dbCollectionData.Columns[1].ColumnName.ToUpper()))
                {
                    dbCollectionData.Columns[1].ColumnName = CCEnums.CCTableColumns.DataType.ToString();
                }

                if (!chkLst.Contains(dbCollectionData.Columns[2].ColumnName.ToUpper()))
                {
                    dbCollectionData.Columns[2].ColumnName = CCEnums.CCTableColumns.Key.ToString();
                }

                if (!chkLst.Contains(dbCollectionData.Columns[3].ColumnName.ToUpper()))
                {
                    dbCollectionData.Columns[3].ColumnName = CCEnums.CCTableColumns.Data.ToString();
                }
                #endregion

                //-- Process header data --\\
                int          pgCnt = 0;
                CCCollection res   = ReadHeaderData(cfg, out errCode, out errMsg, out pgCnt, dbCollectionData);

                if (res != null && errCode == (int)CCEnums.CCErrorCodes.E0001)
                {
                    //-- Process pages data --\\
                    createdFiles = ReadPagesData(cfg, out errCode, out errMsg, pgCnt, ref res, dbCollectionData);
                    if (errCode == (int)CCEnums.CCErrorCodes.E0001)
                    {
                        return(res);
                    }
                }
                else
                {
                    if (String.IsNullOrEmpty(errMsg))
                    {
                        errMsg = CCConstants.E0000;
                    }
                    throw new Exception(errMsg);
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex, false);
                throw ex;
            }
            return(null);
        }
Пример #11
0
        /// <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());
        }
Пример #12
0
        /// <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);
            }
        }
Пример #13
0
        public static int CreateCsmCollection(string nextStation, ITisClientServicesModule csm, CCConfiguration.CCConfigurationData dataCfg, bool copySourceFiles, String collectionDataPath, out int errCode, out String errMsg)
#endif
        {
            errCode = -1;
            errMsg  = null;

            try
            {
                #region //-- Validate profile and CSM --\\
                if (csm == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0210;
                    errMsg  = String.Format("{0}, error code [{1}]", CCConstants.E0210, "?Unknown?", errCode);
                    throw new Exception(errMsg);
                }

                if (dataCfg == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0102;
                    errMsg  = String.Format("{0}: [{1}], error code [{2}]", CCConstants.E0102, csm.Application.AppName, errCode);
                    throw new Exception(errMsg);
                }
                #endregion


                //-- Create a collection creator class --\\
                using (CCreator crt = new CCreator(dataCfg))
                {
                    crt.CurrentProfile.CopySourceFiles = copySourceFiles;

                    //-- Create the collection definition --\\
                    CCCollection coll = CCCollection.FromXml(collectionDataPath, !copySourceFiles);

                    if (coll == null)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0091;
                        errMsg  = String.Format("{0}, file name: [{1}], error code [{2}]", CCConstants.E0091, collectionDataPath ?? String.Empty, errCode);
                        throw new Exception(errMsg);
                    }


                    String[] resCols = crt.CreateCollections(nextStation, csm, out errCode, coll);
                    if (resCols == null || resCols.Length != 1)
                    {
                        errCode = errCode <= 0 ? (int)CCEnums.CCErrorCodes.E0092 : errCode;
                        errMsg  = String.Format("{0}, {1}, Source file path [{1}], error code [{2}]", CCConstants.E0092, collectionDataPath ?? String.Empty, errCode);
                        throw new Exception(errMsg);
                    }
                    else
                    {
                        ILog.LogInfo("Done creating collection [{0}] from file [{1}] in eFlow system", resCols[0], collectionDataPath);
                        errCode = (int)CCEnums.CCErrorCodes.E0001;
                    }
                }
            }
            catch (Exception ex)
            {
                if (String.IsNullOrEmpty(errMsg))
                {
                    errMsg = ex.Message;
                }
                ILog.LogError(ex);
                if (dataCfg == null || dataCfg.ThrowAllExceptions)
                {
                    throw ex;
                }
            }
            return(errCode);
        }
Пример #14
0
        /// <summary>
        /// Create an eFlow collection from the specified source file, using an existing\specified CSM object..
        /// </summary>
        /// <param name="nextStation">The name of the next station.</param>
        /// <param name="csm">ITisClientServicesModule object.</param>
        /// <param name="dataCfg">The InputApi profile to use to create the collection.</param>
        /// <param name="copySourceFiles">Copy the source file when true, move when false.</param>
        /// <param name="collectionDataPath">The path to the collection data file.</param>
        /// <param name="errCode">The output error code.</param>
        /// <param name="errMsg">The output error String</param>
        /// <returns>The error code, 1 when successfull, any other value when not.</returns>
#if INTERNAL && !EXPOSE_CCColection
        internal static int CreateCsmCollection(string nextStation, ITisClientServicesModule csm, CCConfiguration.CCConfigurationData dataCfg, bool copySourceFiles, String collectionDataPath, out int errCode, out String errMsg)
Пример #15
0
        /// <summary>
        /// Create an eFlow collection from the specified DataTable, using an existing\specified CSM object.
        /// </summary>
        /// <param name="nextStation">The name of the next station.</param>
        /// <param name="csm">ITisClientServicesModule object.</param>
        /// <param name="collectionData">The collection data in the a data table.</param>
        /// <param name="dataCfg">The InputApi profile to use to create the collection.</param>
        /// <param name="copySourceFiles">Copy the source file when true (as opposed to move).</param>
        /// <param name="errMsg">Will return the error message if any error occured.</param>
        /// <returns>The error code, 1 = sucsess.</returns>
        public static bool CreateCsmCollection(string nextStation, ITisClientServicesModule csm, DataTable collectionData, CCConfiguration.CCConfigurationData dataCfg, out int errCode, out String errMsg)
        {
            //-- Set returning values --\\
            errCode = (int)CCEnums.CCErrorCodes.E0000;
            errMsg  = null;
            String[] createdFiles = null;

            try
            {
                #region //-- Validate profile and CSM --\\
                if (csm == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0210;
                    errMsg  = String.Format("{0}, error code [{1}]", CCConstants.E0210, "?Unknown?", errCode);
                    throw new Exception(errMsg);
                }

                if (dataCfg == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0102;
                    errMsg  = String.Format("{0}: [{1}], error code [{2}]", CCConstants.E0102, csm.Application.AppName, errCode);
                    throw new Exception(errMsg);
                }
                #endregion

                //-- Create and define the Creator class --\\
                using (CCreator crt = new CCreator(dataCfg))
                {
                    //-- Load CCCollection from a data table (and validate all the data) --\\
                    CCCollection coll = CCDataTable.FromDataTable(dataCfg, out errCode, out errMsg, dataCfg.CopySourceFiles, out createdFiles, collectionData);

                    if (errCode != 1)
                    {
                        errMsg = String.Format("{0}, table name: [{1}], error code [{2}]", CCConstants.E0091, collectionData != null ? collectionData.TableName ?? String.Empty : String.Empty, errCode);
                        throw new Exception(errMsg);
                    }

                    if (coll == null)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0091;
                        errMsg  = String.Format("{0}, table name: [{1}], error code [{2}]", CCConstants.E0091, collectionData != null ? collectionData.TableName ?? String.Empty : String.Empty, errCode);
                        throw new Exception(errMsg);
                    }

                    try
                    {
                        //--<< Call eFlow to create the collection >>--\\
                        String[] resCols = crt.CreateCollections(nextStation, csm, out errCode, coll);
                        if (resCols == null || resCols.Length != 1)
                        {
                            errCode = errCode <= 0 ? (int)CCEnums.CCErrorCodes.E0092 : errCode;
                            errMsg  = crt.LastErrors;
                            throw new Exception(String.Format("{0}, {1}, error code [{2}]", CCConstants.E0092, errMsg, errCode));
                        }
                        else
                        {
                            ILog.LogInfo("Done creating collection [{0}] in eFlow system", resCols[0]);
                            errCode = (int)CCEnums.CCErrorCodes.E0001;
                            errMsg  = resCols[0];//-- Return the name of the created collection --\\
                        }
                    }
                    catch (Exception ec)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0092;
                        errMsg  = crt.LastErrors;
                        if (String.IsNullOrEmpty(errMsg))
                        {
                            errMsg = CCConstants.E0092 + "," + ec.Message;
                        }
                        throw new Exception(String.Format("{0}, {1}, {2}, error code [{3}]", CCConstants.E0092, errMsg, ec.Message, errCode));
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
                if (dataCfg == null || dataCfg.ThrowAllExceptions)
                {
                    throw ex;
                }
            }
            finally
            {
                //-- Delete files created by this method --\\ 
                if (dataCfg != null && dataCfg.CopySourceFiles && createdFiles != null && createdFiles.Length > 0)
                {
                    foreach (String sf in createdFiles)
                    {
                        try
                        {
                            if (File.Exists(sf ?? String.Empty))
                            {
                                File.SetAttributes(sf, FileAttributes.Normal);
                                File.Delete(sf);
                            }
                        }
                        catch (Exception ex)
                        {
                            ILog.LogError(ex);
                            throw ex;
                        }
                    }
                }
            }
            return(errCode == (int)CCEnums.CCErrorCodes.E0001);
        }
Пример #16
0
        /*
         * /// <summary>
         * /// Create an eFlow collection from the specified DataTable.
         * /// </summary>
         * /// <param name="collectionData">The collection data in the specified data table.</param>
         * /// <param name="applicationName">The eFlow application name to insert the collection to.</param>
         * /// <param name="copySourceFiles">Copy the source file when true (as opposed to move).</param>
         * /// <param name="errMsg">Will return the error message if any error occured.</param>
         * /// <returns>The error code, 1 = sucsess.</returns>
         * public bool TestCreateCollection(String filePath, String stationName, String applicationName)
         * {
         *  try
         *  {
         *      List<ITisPageParams> pages = new List<ITisPageParams>();
         *      ITisClientServicesModule csm = csmManager.GetCsm(applicationName, stationName, true);
         *      pages.Add(csm.Setup.get_FlowByIndex(0).get_FormByIndex(0).get_PageByIndex(0));
         *      CCCollection.CCPage pg = new CCCollection.CCPage(null, pages[0], "Demo");
         *      CCCollection col = new CCCollection();
         *      for (int i = 0; i < 7; i++)
         *      {
         *          col.AddForm(new CCCollection.CCForm(null, null, csm.Setup.get_FlowByIndex(0).get_FormByIndex(0).Name, pg));
         *      }
         *      col.ImagePath = filePath;// @"C:\Program Files\TIS\eFlow 4.5\Sample Applications\SimpleDemo\Office7Pages.TIF";
         *     // col.FlowType = "OfficeStore";
         *
         *      //-- Create and define the Creator class --\\
         *      using (CCreator crt = new CCreator())
         *      {
         *          crt.ValidatePagePerImagePage = false;
         *          crt.CurrentProfile = CCConfiguration.CCConfigurationData.FromXml("Default2");
         *          int errCode=0;
         *         String[] res= crt.CreateCollections(csm,  out errCode, col);
         *         if (res.Length > 0)
         *         {
         *             return true;
         *         }
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      ILog.LogError(ex);
         *  }
         *  return false;
         * }
         */

        /// <summary>
        /// Create an eFlow collection from the specified DataTable.
        /// </summary>
        /// <param name="collectionData">The collection data in the specified data table.</param>
        /// <param name="applicationName">The eFlow application name to insert the collection to.</param>
        /// <param name="copySourceFiles">Copy the source file\s when true (as opposed to move).</param>
        /// <param name="errMsg">Will return the error message if any error occured.</param>
        /// <returns>The error code, 1 = sucsess.</returns>
        public bool CreateCollection(DataTable collectionData, String applicationName, bool copySourceFiles, out int errCode, out String errMsg)
        {
            //-- Set returning values --\\
            errCode = (int)CCEnums.CCErrorCodes.E0000;
            errMsg  = null;
            String[]     createdFiles = null;
            CCCollection coll         = null;

            try
            {
                #region //-- Load and validate profile --\\
                if (config == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0101;
                    errMsg  = String.Format("{0}:, error code [{1}]", CCConstants.E0101, errCode);
                    throw new Exception(errMsg);
                }

                if (String.IsNullOrEmpty(applicationName))
                {
                    applicationName = CCEnums.CCNames.Default.ToString();
                }
                currCfg = config.GetConfiguration(applicationName);

                if (currCfg == null)
                {
                    errCode = (int)CCEnums.CCErrorCodes.E0102;
                    errMsg  = String.Format("{0}: [{1}], error code [{2}]", CCConstants.E0102, applicationName, errCode);
                    throw new Exception(errMsg);
                }
                #endregion

                //-- Create and define the Creator class --\\
                using (CCreator crt = new CCreator())
                {
                    crt.CurrentProfile.CopySourceFiles = copySourceFiles;
                    if (currCfg != null)
                    {
                        crt.CurrentProfile.LockExtension = currCfg.LockExtension;
                    }

                    ITisClientServicesModule csm = csmManager.GetCsm(String.IsNullOrEmpty(currCfg.LoginApplication) ? applicationName : currCfg.LoginApplication, currCfg.LoginStation, true);

                    if (csm == null)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0210;
                        errMsg  = String.Format("{0}, Application name: [{1}], Station name: [{2}] error code [{3}]", CCConstants.E0210, String.IsNullOrEmpty(currCfg.LoginApplication) ? applicationName ?? String.Empty : currCfg.LoginApplication ?? String.Empty, currCfg.LoginStation ?? String.Empty, errCode);
                        throw new Exception(errMsg);
                    }

                    //-- Load CCCollection from a data table (and validate all the data) --\\
                    coll = CCDataTable.FromDataTable(currCfg, out errCode, out errMsg, copySourceFiles, out createdFiles, collectionData);

                    if (errCode != 1)
                    {
                        errMsg = String.Format("{0}, table name: [{1}], error code [{2}]", CCConstants.E0091, collectionData != null ? collectionData.TableName ?? String.Empty : String.Empty, errCode);
                        throw new Exception(errMsg);
                    }

                    if (coll == null)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0091;
                        errMsg  = String.Format("{0}, table name: [{1}], error code [{2}]", CCConstants.E0091, collectionData != null ? collectionData.TableName ?? String.Empty : String.Empty, errCode);
                        throw new Exception(errMsg);
                    }

                    try
                    {
                        //--<< Call eFlow to create the collection >>--\\
                        String[] resCols = crt.CreateCollections(csm, out errCode, coll);
                        if (resCols == null || resCols.Length != 1)
                        {
                            errCode = errCode <= 0 ? (int)CCEnums.CCErrorCodes.E0092: errCode;
                            errMsg  = crt.LastErrors;
                            throw new Exception(String.Format("{0}, {1}, error code [{2}]", CCConstants.E0092, errMsg, errCode));
                        }
                        else
                        {
                            ILog.LogInfo("Done creating collection [{0}] in eFlow system", resCols[0]);
                            errCode = (int)CCEnums.CCErrorCodes.E0001;
                            errMsg  = resCols[0];//-- Return the name of the created collection --\\
                            //\\ return errCode == (int)CCEnums.CCErrorCodes.E0001;
                        }
                    }
                    catch (Exception ec)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0092;
                        errMsg  = crt.LastErrors;
                        if (String.IsNullOrEmpty(errMsg))
                        {
                            errMsg = CCConstants.E0092 + "," + ec.Message;
                        }
                        throw new Exception(String.Format("{0}, {1}, {2}, error code [{3}]", CCConstants.E0092, errMsg, ec.Message, errCode));
                    }
                }
            }
            catch (Exception ex)
            {
                //\\ if (errCode < (int)CCEnums.CCErrorCodes.E0000) errCode = (int)CCEnums.CCErrorCodes.E0000;
                ILog.LogError(ex);
                //-- Move collections to errror folder --\\
                if (coll != null && coll.Files.Length > 0 && currCfg != null && !String.IsNullOrEmpty(currCfg.ErrorFolderPath))
                {
                    CCFileList.MoveToFolder(currCfg.ErrorFolderPath, coll.Files);
                }
                if (currCfg == null || currCfg.ThrowAllExceptions)
                {
                    throw ex;
                }
            }
            finally
            {
                //-- Delete files created by this method --\\ 
                if (copySourceFiles && createdFiles != null && createdFiles.Length > 0)
                {
                    foreach (String sf in createdFiles)
                    {
                        try
                        {
                            if (File.Exists(sf ?? String.Empty))
                            {
                                File.SetAttributes(sf, FileAttributes.Normal);
                                File.Delete(sf);
                            }
                        }
                        catch (Exception ex)
                        {
                            ILog.LogError(ex);
                            throw ex;
                        }
                    }
                }
            }
            //\\  return false;
            return(errCode == (int)CCEnums.CCErrorCodes.E0001);
        }