Пример #1
0
        /// <summary>
        /// Clone the current object to the specified target object.
        /// </summary>
        /// <param name="source">Source object</param>
        /// <param name="target">Traget object to clone source.</param>
        /// <returns>The cloned object same type of the source.</returns>
        public static object CloneTo(object source, object target)
        {
            try
            {
                if (source == null)
                {
                    return(null);
                }

                serializing = true;
                if (target == null)
                {
                    target = Activator.CreateInstance(source.GetType());
                }

                foreach (PropertyInfo pi in source.GetType().GetProperties())
                {
                    object obRet = pi.CanRead ? pi.GetValue(source, null) : null;
                    if (obRet is ICloneable)
                    {
                        if (pi.CanWrite && pi.CanRead)
                        {
                            pi.SetValue(target, (obRet as ICloneable).Clone(), null);
                        }
                    }
                    //else if (pi.GetType().IsClass)
                    //{
                    //    if (pi.CanWrite && pi.CanRead)
                    //    {
                    //        object clsSub = Activator.CreateInstance(pi.GetType());
                    //        CloneTo(pi.GetValue(source, null), clsSub);
                    //        pi.SetValue(target, clsSub, null);
                    //    }
                    //    else
                    //    {
                    //        CloneTo(pi.GetValue(source, null), target.GetType().GetProperty(pi.Name));
                    //    }
                    //}
                    else
                    {
                        if (pi.CanWrite && pi.CanRead)
                        {
                            pi.SetValue(target, obRet, null);
                        }
                    }
                }
                return(target);
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            finally
            {
                serializing = false;
            }
            return(null);
        }
Пример #2
0
        public CCEflowBaseObject FromEflowObject(CCreator creator, ITisDataLayerTreeNode eflowObject)
#endif
        {
            try
            {
                if (eflowObject is ITisFieldData)
                {
                    return(new CCCollection.CCField(creator, eflowObject as ITisFieldData));
                }
                else if (eflowObject is ITisFieldParams)
                {
                    return(new CCCollection.CCField(creator, eflowObject as ITisFieldParams));
                }
                else if (eflowObject is ITisFieldGroupData)
                {
                    return(new CCCollection.CCGroup(creator, eflowObject as ITisFieldGroupData));
                }
                else if (eflowObject is ITisFieldGroupParams)
                {
                    return(new CCCollection.CCGroup(creator, eflowObject as ITisFieldGroupParams));
                }
                else if (eflowObject is ITisFieldTableData)
                {
                    return(new CCCollection.CCTable(creator, eflowObject as ITisFieldTableData));
                }
                else if (eflowObject is ITisFieldTableParams)
                {
                    return(new CCCollection.CCTable(creator, eflowObject as ITisFieldTableParams));
                }
                else if (eflowObject is ITisFieldArrayData)
                {
                    return(new CCCollection.CCFieldArray(creator, eflowObject as ITisFieldArrayData));
                }
                else if (eflowObject is ITisPageData)
                {
                    return(new CCCollection.CCPage(creator, eflowObject as ITisPageData));
                }
                else if (eflowObject is ITisPageParams)
                {
                    ITisPageParams pg = eflowObject as ITisPageParams;
                    return(new CCCollection.CCPage(creator, pg, pg.NumberOfLinkedEFIs == 1 ? pg.get_LinkedEFIByIndex(0).Name : pg.ParentForm.ParentFlow.Process.DefaultEFI ?? String.Empty));
                }
                else if (eflowObject is ITisFormData)
                {
                    return(new CCCollection.CCForm(creator, eflowObject as ITisFormData));
                }
                else if (eflowObject is ITisFormParams)
                {
                    return(new CCCollection.CCForm(creator, eflowObject as ITisFormParams));
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(null);
        }
Пример #3
0
        /// <summary>
        /// Merge all tiff images (multi-page or not) to a multi-page tif.
        /// </summary>
        /// <param name="targetPath">The target path to save the merged images to.</param>
        /// <param name="deleteSource">Delete source files when flag is true.</param>
        /// <param name="filePaths">The image\s to merge.</param>
        /// <returns>true when successfull.</returns>
        public static bool MergeImages(String targetPath, bool deleteSource, params String[] filePaths)
        {
            try
            {
                if (filePaths.Length <= 0)
                {
                    throw new Exception("No files specified in method: " + MethodBase.GetCurrentMethod().Name);
                }
                else if (filePaths.Length == 1)
                {
                    // TODO: use 3rd pary software to make the image compatiable (dpi bw etc)
                    if (deleteSource)
                    {
                        File.SetAttributes(filePaths[0], FileAttributes.Normal);
                        File.Move(filePaths[0], targetPath);
                    }
                    else
                    {
                        File.Copy(filePaths[0], targetPath);
                        File.SetAttributes(targetPath, FileAttributes.Normal);
                    }
                }
                else
                {
                    FileOP fop = new FileOP();
                    fop.MergeImageFile(targetPath, filePaths);
                    // TODO: use 3rd pary software to make the image compatiable (dpi bw etc)

                    if (deleteSource)
                    {
                        foreach (String s in filePaths)
                        {
                            try
                            {
                                if (File.Exists(s))
                                {
                                    File.SetAttributes(s, FileAttributes.Normal);
                                    File.Delete(s);
                                }
                            }
                            catch (Exception ep)
                            {
                                ILog.LogError(ep);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
                return(false);
            }
        }
Пример #4
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);
        }
Пример #5
0
        /// <summary>
        /// Clone this object to another one just like it (copy all properties).
        /// </summary>
        /// <param name="source">The source object to clone it's properties.</param>
        /// <returns>The new cloned object same type of the source.</returns>
        public static object Clone(object source)
        {
            object res = null;

            try
            {
                if (source == null)
                {
                    return(res);
                }

                serializing = true;
                res         = Activator.CreateInstance(source.GetType());

                foreach (PropertyInfo pi in source.GetType().GetProperties())
                {
                    if (pi.GetType().GetInterface(typeof(ICloneable).Name) != null)
                    {
                        if (pi.CanWrite && pi.CanRead)
                        {
                            pi.SetValue(res, (pi.GetValue(source, null) as ICloneable).Clone(), null);
                        }
                    }
                    //else if (pi.GetType().IsClass)
                    //{
                    //    if (pi.CanWrite && pi.CanRead)
                    //    {
                    //        object clsSub = Activator.CreateInstance(pi.GetType());
                    //        CloneTo(pi.GetValue(source, null), clsSub);
                    //        pi.SetValue(res, clsSub, null);
                    //    }
                    //    else
                    //    {
                    //        CloneTo(pi.GetValue(source, null), res.GetType().GetProperty(pi.Name));
                    //    }
                    //}
                    else
                    {
                        if (pi.CanWrite && pi.CanRead)
                        {
                            pi.SetValue(res, pi.GetValue(source, null), null);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            finally
            {
                serializing = false;
            }
            return(res);
        }
Пример #6
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);
            }
        }
Пример #7
0
 /// <summary>
 /// Check a column data type to see if it is a string or not (requires '' or not...)
 /// </summary>
 /// <param name="dataTbl">The data table to check it's column.</param>
 /// <param name="columnIndex">The index of the column to check.</param>
 /// <returns>true if the column is a string</returns>
 internal static bool IsStringData(DataTable dataTbl, int columnIndex)
 {
     try
     {
         return(IsStringData(dataTbl.Columns[columnIndex]));
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(false);
 }
Пример #8
0
 /// <summary>
 /// Get the String that will represent this Station login key.
 /// </summary>
 /// <param name="appName">The name of the application.</param>
 /// <param name="stationName">The name of the station</param>
 /// <returns>The formatted key.</returns>
 protected virtual String GetCsmKey(String appName, String stationName)
 {
     try
     {
         return(String.Format("{0}_{1}", (appName ?? String.Empty).ToUpper(), (stationName ?? String.Empty).ToUpper()));
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(String.Empty);
 }
Пример #9
0
 /// <summary>
 /// Get the String that will represent this CSM key.
 /// </summary>
 /// <param name="csm">ITisClientServicesModule</param>
 /// <returns>The key being used to index this CSM instance.</returns>
 protected virtual String GetCsmKey(ITisClientServicesModule csm)
 {
     try
     {
         return(String.Format("{0}_{1}", csm.Application.AppName.ToUpper(), csm.Session.StationName.ToUpper()));
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(String.Empty);
 }
Пример #10
0
            public static TPage ToPRD(PageOcrData ocrData, String saveToPrdPath)
#endif
            {
                try
                {
                    if (ocrData != null)
                    {
                        TPage res = new TPage();

                        //-- iterate data lines --\\
                        foreach (LineOcrData lineOcr in ocrData.Lines)
                        {
                            TLine currentLine = new TLine();
                            //-- Itarate the line's words --\\
                            foreach (WordOcrData wordOcr in lineOcr.Words)
                            {
                                //-- Iterate the word's chars --\\
                                TWord wordPrd = new TWord();
                                foreach (CharOcrData charOcr in wordOcr.GetAsChars(true))
                                {
                                    wordPrd.AddChar(new TChar(charOcr.Value, (short)charOcr.Confidence, new TOCRRect(charOcr.Rect)));
                                }
                                currentLine.AddWord(wordPrd);
                            }

                            if (currentLine != null && currentLine.Words != null && currentLine.Words.Count > 0)
                            {
                                res.AddLine(currentLine);
                            }
                        }

                        //-- Save the contents to a PRD file if 'saveToPrdPath' is specified --\\
                        if (!String.IsNullOrEmpty(saveToPrdPath))
                        {
                            if (!Directory.Exists(Path.GetDirectoryName(saveToPrdPath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(saveToPrdPath));
                            }
                            TPage.SaveToPRD(res, saveToPrdPath);
                        }
                        return(res);
                    }
                    else
                    {
                        throw new Exception(String.Format("Invalid input PRD object in: [{0}]", MethodBase.GetCurrentMethod().Name));
                    }
                }
                catch (Exception ex)
                {
                    ILog.LogError(ex);
                }
                return(null);
            }
Пример #11
0
 /// <summary>
 /// Check a column data type to see if it is a string or not (requires '' or not...)
 /// </summary>
 /// <param name="dataCol">The data column to check it's type.</param>
 /// <returns>true if the column is a string</returns>
 internal static bool IsStringData(DataColumn dataCol)
 {
     try
     {
         return(dataCol.DataType == typeof(string));
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
     return(false);
 }
Пример #12
0
        /// <summary>
        /// Rollback files lock.
        /// </summary>
        /// <param name="extLock">The extension to rename from the file list</param>
        public virtual void RollbackLock(String extLock)
        {
            try
            {
                //-- Rollback reverse extension state \ rollback file ext.
                if (files != null && files.Count > 0)
                {
                    extLock = extLock.Trim('.', '*', ' ').ToUpper();
                    String fExt        = null;
                    String fileName    = null;
                    String newFileName = null;

                    //-- Keep the previous\original extension key --\\
                    foreach (KeyValuePair <String, List <String> > kvp in files)
                    {
                        try
                        {
                            if (kvp.Value != null)
                            {
                                for (int i = 0; i < kvp.Value.Count; i++)
                                {
                                    //-- Get file name and extension --\\
                                    fileName = kvp.Value[i];
                                    fExt     = Path.GetExtension(fileName).Trim('.', ' ', '*').ToUpper();

                                    //-- if it was locked --\\
                                    if (String.Compare(extLock, fExt, true) != 0)
                                    {
                                        fExt        = fExt.Replace(extLock, String.Empty);
                                        newFileName = Path.Combine(Path.GetDirectoryName(fileName), String.Format("{0}.{1}", Path.GetFileNameWithoutExtension(fileName), fExt));

                                        //-- if previous locked files esists exit --\\
                                        File.SetAttributes(fileName, FileAttributes.Normal);
                                        File.Move(fileName, newFileName);
                                    }
                                }
                            }
                        }
                        catch (Exception ec)
                        {
                            ILog.LogError(ec, false);
                            throw ec;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex, false);
                throw ex;
            }
        }
Пример #13
0
 /// <summary>
 /// Add or Set a Exception \SpecialTag item.
 /// </summary>
 /// <param name="key">The item Key</param>
 /// <param name="val">The item value.</param>
 /// <returns>true when added\updated, false when not.</returns>
 public virtual bool SetSpecialTag(String key, String val)
 {
     try
     {
         this.SpecialTags.NativeDictionary.Add(key, val);
         return(this.SpecialTags.NativeDictionary.ContainsKey(key));
     }
     catch (Exception ex)
     {
         ILog.LogError(ex, false);
         throw ex;
     }
 }
Пример #14
0
        public static new CollectionOcrData FromXml(String xmlFilePath)
#endif
        {
            try
            {
                return(FromXml(xmlFilePath, typeof(CollectionOcrData)) as CollectionOcrData);
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(null);
        }
Пример #15
0
            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);
                }
            }
Пример #16
0
            public CCGroup(CCreator parent, ITisFieldGroupParams group, bool createFields)
#endif
                : base(parent, group.Name, null, null, 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.NamedParent = group.ParentForm.Name;

                    if (createFields)
                    {
                        List <String> fieldNames = new List <String>();
                        foreach (ITisFieldParams fld in group.LinkedFields)
                        {
                            if (fieldNames.Contains(fld.Name.ToUpper()))
                            {
                                continue;
                            }
                            fields.Add(new CCField(this.ParentCreator, fld));
                            fieldNames.Add(fld.Name);
                        }

                        foreach (ITisFieldTableParams fldTbl in group.LinkedFieldTables)
                        {
                            tables.Add(new CCTable(this.ParentCreator, fldTbl));
                        }
                    }
                }
                catch (Exception ex)
                {
                    ILog.LogError(ex);
                }
            }
Пример #17
0
 /// <summary>
 /// The method that fires the 'OnPostFileLock' event if is assigned.
 /// </summary>
 /// <param name="fileName">the name of the file taht was locked.</param>
 protected void PostFileLock(String fileName)
 {
     try
     {
         if (OnPostFileLock != null)
         {
             OnPostFileLock(null, this, fileName);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #18
0
 /// <summary>
 /// The method that fires the 'OnPreCreateCollection' event
 /// </summary>
 protected virtual void PreCreateCollection()
 {
     try
     {
         if (OnPreCreateCollection != null)
         {
             OnPreCreateCollection(this, ref currentCollection);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #19
0
 /// <summary>
 /// The method that fires the 'OnDispose' event.
 /// </summary>
 protected virtual void DisposeEvent()
 {
     try
     {
         if (OnDispose != null)
         {
             OnDispose(this);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #20
0
 /// <summary>
 /// The method that fires the 'OnCreate' event.
 /// </summary>
 protected virtual void CreateEvent()
 {
     try
     {
         if (OnCreate != null)
         {
             OnCreate(this);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #21
0
 /// <summary>
 /// The method that fires the 'OnPreFileLock' event.
 /// </summary>
 /// <param name="cApi"></param>
 /// <param name="filesHandler"></param>
 /// <param name="fileName"></param>
 protected virtual void PreFileLock(CCTimerSearch cApi, object filesHandler, ref String fileName)
 {
     try
     {
         if (OnPreFileLock != null)
         {
             OnPreFileLock(this, filesHandler, ref fileName);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #22
0
        /// <summary>
        /// Deserialize any PRD file specified as Xml-Prd and return a path to the converted PRD file.
        /// </summary>
        /// <param name="errCode">Returns the error code from the function.</param>
        /// <param name="errMsg">Returns the error message\\s if any occured.</param>
        /// <param name="pageNumber">The page number to relate this PRD file to.</param>
        /// <param name="throwAllErrors">Throw all erros when true, log them when false.</param>
        /// <param name="xmlToPrdFilePath">The path of an XML file to deserialize as PRD.</param>
        /// <returns>a path to a prd file when successfull.</returns>
        public static String DeserializePRD(out int errCode, out String errMsg, int pageNumber, bool throwAllErrors, String xmlToPrdFilePath)
        {
            errCode = -1;
            errMsg  = null;

            try
            {
                //-- if XmlPRD files were defined convert them --\\
                if (!String.IsNullOrEmpty(xmlToPrdFilePath) && File.Exists(xmlToPrdFilePath))
                {
                    try
                    {
                        //-- Deserialize the XML file to a Prd memory object --\\
                        CollectionOcrData.PageOcrData poc = CollectionOcrData.PageOcrData.FromXml(xmlToPrdFilePath);
                        if (poc != null)
                        {
                            //-- Prepare target PRD file path --\\
                            String targetPRD = Path.Combine(Path.GetDirectoryName(xmlToPrdFilePath), String.Format("{0}_P{1}.{2}", Path.GetFileNameWithoutExtension(xmlToPrdFilePath), pageNumber.ToString("X").PadLeft(4, '0'), CCEnums.CCFilesExt.PRD));
                            poc.ToPRD(targetPRD);
                            if (File.Exists(targetPRD))
                            {
                                errCode = (int)CCEnums.CCErrorCodes.E0001;
                                return(targetPRD);
                            }
                        }
                    }
                    catch (Exception ec)
                    {
                        errCode = (int)CCEnums.CCErrorCodes.E0000;
                        errMsg  = String.Format("{0}, error code [{1}], error data: {2}", CCConstants.E0000, errCode, ec.Message);
                        ILog.LogError(ec);
                        if (throwAllErrors)
                        {
                            throw ec;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errCode = (int)CCEnums.CCErrorCodes.E0000;
                errMsg  = String.Format("{0}, error code [{1}], error data: {2}", CCConstants.E0000, errCode, ex.Message);
                ILog.LogError(ex);
                if (throwAllErrors)
                {
                    throw ex;
                }
            }
            return(null);
        }
Пример #23
0
 /// <summary>
 /// The method that fires the 'OnPostCreateCollection' event
 /// </summary>
 /// <param name="collectionName"></param>
 protected virtual void PostCreateCollection(String collectionName)
 {
     try
     {
         if (OnPostCreateCollection != null)
         {
             OnPostCreateCollection(this, collectionName);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #24
0
 /// <summary>
 /// The method that fires the 'OnCollectionCreated' event
 /// </summary>
 /// <param name="cApi"></param>
 /// <param name="creator"></param>
 /// <param name="csm"></param>
 /// <param name="collection"></param>
 /// <param name="canPut"></param>
 protected virtual void CollectionCreated(CCTimerSearch cApi, CCreator creator, ITisClientServicesModule csm, ITisCollectionData collection, ref bool canPut)
 {
     try
     {
         if (OnCollectionCreated != null)
         {
             OnCollectionCreated(this, creator, csm, collection, ref canPut);
         }
     }
     catch (Exception ex)
     {
         ILog.LogError(ex);
     }
 }
Пример #25
0
 /// <summary>
 /// Th emethod that fires the 'OnSearchedFiles' event.
 /// </summary>
 /// <param name="collectedFiles"></param>
 protected virtual void SearchedFiles(ref CCFileList[] collectedFiles)
 {
     try
     {
         if (OnSearchedFiles != null)
         {
             OnSearchedFiles(this, ref collectedFiles);
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #26
0
 /// <summary>
 /// The method that fired the 'OnTimer' event.
 /// </summary>
 protected virtual void TimerEvent()
 {
     try
     {
         if (OnTimer != null)
         {
             OnTimer(this, new EventArgs());
         }
     }
     catch (Exception ep)
     {
         ILog.LogError(ep);
     }
 }
Пример #27
0
        public void StopFilesSearch()
#endif
        {
            try
            {
                if (timerSearch != null && timerSearch.Enabled)
                {
                    timerSearch.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
        }
Пример #28
0
        public static String[] SortList(CCEnums.CompareTypeEnm sortType, params String[] filePaths)
#endif
        {
            try
            {
                List <String> files = new List <String>(filePaths);
                files.Sort(new FlexListComparer(sortType, false));
                return(files.ToArray());
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(new String[0]);
        }
Пример #29
0
            /// <summary>
            /// Add a field to the groups' List of fields.
            /// </summary>
            /// <param name="fieldName">The name of the Field to create.</param>
            /// <returns>A CCField when successfull, null when failed.</returns>
            public virtual CCField AddField(ITisFieldParams field, TIS_RECT fieldRect)
            {
                try
                {
                    if (fields == null)
                    {
                        fields = new List <CCField>();
                    }

                    //-- Add a new field --\\
                    foreach (CCField cf in fields)
                    {
                        if (String.Compare(cf.Name, field.Name, true) == 0)
                        {
                            return(cf);
                        }
                    }

                    if (field.ParentFieldTableExists)
                    {
                        // TODO: finish testing here.
                        //\\ bool createTable = true;
                        // CCTable = this.tables.IndexOf(
                        foreach (CCTable tbl in this.tables)
                        {
                            if (String.Compare(tbl.Name, field.ParentFieldTable.Name, true) == 0)
                            {
                                CCFieldArray cfa = tbl.AddFieldArray(field.Name);
                                cfa.AddField(field, fieldRect);
                            }
                        }
                    }
                    else
                    {
                        fields.Add(new CCField(this.ParentCreator, field.Name, String.Empty, 0, fieldRect, null, null, null));
                    }

                    fields[fields.Count - 1].CCParent = this;

                    this.SetParents();
                    return(fields[fields.Count - 1]);
                }
                catch (Exception ex)
                {
                    ILog.LogError(ex, false);
                    throw ex;
                }
            }
Пример #30
0
        /// <summary>
        /// Create the path to the default settings XML file path.
        /// </summary>
        /// <returns></returns>
        public static String GetSettingsFilePath()
        {
            try
            {
                string baseDllName = Path.Combine(DLL_NAME, String.Format("{0}-{1}.{2}", DLL_NAME, CCEnums.CCNames.Settings, CCEnums.CCFilesExt.XML));
                string baseName    = baseDllName;

                try
                {
                    baseName = Path.Combine(Application.ProductName, String.Format("{0}-{1}.{2}", Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().ManifestModule.Name), CCEnums.CCNames.Settings, CCEnums.CCFilesExt.XML));
                }
                catch (Exception ea)
                {
                    ILog.LogError(ea);
                }

                string pathTest = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), baseName);

                if (!File.Exists(pathTest))
                {
                    pathTest = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), baseDllName);
                }
                if (!File.Exists(pathTest))
                {
                    pathTest = Path.Combine(TisClientServicesModule.GetSingletoneInstance().BasicConfiguration.eFlowBinPath, Path.GetFileName(baseName));
                }
                if (!File.Exists(pathTest))
                {
                    pathTest = Path.Combine(TisClientServicesModule.GetSingletoneInstance().BasicConfiguration.eFlowBinPath, Path.GetFileName(baseDllName));
                }
                if (!File.Exists(pathTest))
                {
                    pathTest = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(baseName));
                }
                if (!File.Exists(pathTest))
                {
                    pathTest = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(baseDllName));
                }

                return(pathTest);
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
            }
            return(null);
        }