Beispiel #1
0
        /// <summary>
        /// [Static] Batch.InternalPrioritizeHoldMany() --> Places collections on Hold.
        /// </summary>
        /// <param name="CollectionNames">Indicates the collection names.</param>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name.</param>
        /// <param name="toStationName">Indicates the station name where to move the collection.</param>
        /// <param name="priority">Is a Priority value, which indicates the collection's priority.</param>
        /// <param name="operation">Type of operation to execute: Hold / Prioritize.</param>
        /// <param name="hold">True indicates on Hold.</param>
        /// <returns>Returns true is successful, otherwise false.</returns>
        /// <example><code>Batch.InternalPrioritizeHoldMany("SimpleDemo", "Completion", "", new string[] { "000002349_0001", "000002349_0002" }, Batch.Priority.High, Constants.cStrHoldMethod, true);</code></example>
        protected static bool InternalPrioritizeHoldMany(string applicationName, string stationName, string toStationName, string[] CollectionNames,
                                                         Priority priority, string operation, bool hold)
        {
            bool result = false;

            ITisClientServicesModule csm = null;

            if (applicationName != String.Empty && stationName != String.Empty)
            {
                if (CollectionNames != null && CollectionNames.Length > 0)
                {
                    try
                    {
                        csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                        if (csm != null)
                        {
                            foreach (string CollectionName in CollectionNames)
                            {
                                if (CollectionName != String.Empty)
                                {
                                    CoreInternalPrioritizeHold(ref csm, stationName, toStationName, CollectionName, priority, operation, hold);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (csm != null)
                        {
                            csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + operation + Constants.cStrFailedWithException + e,
                                                         Constants.cStrLiteSdk, TIS_SEVERITY.TIS_ERROR, 0, 0);
                        }
                        else
                        {
                            throw new Exception(Constants.cStrLiteSdkBatch + operation + Constants.cStrFailedWithException + e);
                        }
                    }
                    finally
                    {
                        if (csm != null)
                        {
                            csm.Dispose();
                        }
                        result = true;
                    }
                }
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        /// [Static] Batch.InternalHistoryMany() --> Returns a list of the stations, the collections have gone through (when processed normally through the workflow).
        /// </summary>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name to log on to the CSM.</param>
        /// <param name="CollectionNames">Indicates the collection names to be checked.</param>
        /// <returns>Returns a multidimensional string array if the collections have any history, otherwise returns an empty sub array per collection.</returns>
        /// <example><code>string[][] history = Batch.HistoryMany("SimpleDemo", "Completion", new string[] { "000002349_0001", "000002349_0002" });</code></example>
        protected static string[][] InternalHistoryMany(string applicationName, string stationName, string[] CollectionNames)
        {
            List <string[]> result = new List <string[]>();

            ITisClientServicesModule csm = null;

            if (applicationName != String.Empty && stationName != String.Empty)
            {
                if (CollectionNames != null && CollectionNames.Length > 0)
                {
                    try
                    {
                        csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                        foreach (string CollectionName in CollectionNames)
                        {
                            if (CollectionName != String.Empty)
                            {
                                List <string> subresult = new List <string>();

                                CoreHistory(ref subresult, ref csm, CollectionName);

                                result.Add(subresult.ToArray());
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (csm != null)
                        {
                            csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + Constants.cStrHistoryMethod + Constants.cStrFailedWithException + e,
                                                         Constants.cStrLiteSdk, TIS_SEVERITY.TIS_ERROR, 0, 0);
                        }
                        else
                        {
                            throw new Exception(Constants.cStrLiteSdkBatch + Constants.cStrHistoryMethod + Constants.cStrFailedWithException + e);
                        }
                    }
                    finally
                    {
                        if (csm != null)
                        {
                            csm.Dispose();
                        }
                    }
                }
            }

            return(result.ToArray());
        }
Beispiel #3
0
 /// <summary>
 /// [Constructor] BatchInternals() --> Initializes a Batch object instance with the eFLOW application and station names.
 /// </summary>
 /// <param name="applicationName">Indicates the name of the eFLOW application to login to.</param>
 /// <param name="stationName">Indicates the name of the eFLOW station to login to.</param>
 /// <example><code>BatchInternals b = new BatchInternals("SimpleDemo", "Completion");</code></example>
 protected BatchInternals(string applicationName, string stationName)
 {
     try
     {
         oCSM = TisClientServicesModule.GetNewInstance(applicationName, stationName);
     }
     catch (Exception e)
     {
         throw new Exception(Constants.cStrLiteSdkBatch + " -> " + Constants.cStrFailedWithException, e);
     }
     finally
     {
         this.applicationName = applicationName;
         this.stationName     = stationName;
     }
 }
Beispiel #4
0
        /// <summary>
        /// [Static] Batch.InternalPutMany() --> Used by Put, Reject or Free collection.
        /// </summary>
        /// <param name="CollectionNames">Indicates the collection names to process.</param>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name to log on to the CSM.</param>
        /// <param name="put">A boolean - if true, indicates a Put collection operation, if false indicates a free collection operation.</param>
        /// <param name="method">The name of the method, either a Put, Reject or Free collection.</param>
        /// <returns>Returns true is successful (no exceptions occur), otherwise false.</returns>
        protected static bool InternalPutMany(string applicationName, string stationName, string[] CollectionNames, bool put, string method)
        {
            bool result = false;

            ITisClientServicesModule csm = null;

            if (applicationName != String.Empty && stationName != String.Empty)
            {
                if (CollectionNames != null && CollectionNames.Length > 0)
                {
                    try
                    {
                        csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                        foreach (string CollectionName in CollectionNames)
                        {
                            if (CollectionName != String.Empty)
                            {
                                CorePut(ref csm, CollectionName, method, put);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (csm != null)
                        {
                            csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + method + Constants.cStrFailedWithException + e,
                                                         Constants.cStrLiteSdk, Log.Severity.ERROR, 0, 0);
                        }
                        else
                        {
                            throw new Exception(Constants.cStrLiteSdkBatch + method + Constants.cStrFailedWithException + e);
                        }
                    }
                    finally
                    {
                        if (csm != null)
                        {
                            csm.Dispose();
                        }
                        result = true;
                    }
                }
            }

            return(result);
        }
Beispiel #5
0
        // Many
        #region "Batch.FromDynamic"
        /// <summary>
        /// [Static] Batch.FromDynamic() --> Imports collection(s) given by a file name.
        /// </summary>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name to logon to the CSM.</param>
        /// <param name="filename">Represents the file name from where the collection(s) will be imported.</param>
        /// <returns>Returns a string array if successful with the names of the imported collections, otherwise an empty array.</returns>
        /// <example><code>string[] collDatas = Batch.FromDynamic("SimpleDemo", "efInternal", @"c:\temp\test.dynamic");</code></example>
        public static string[] FromDynamic(string applicationName, string stationName, string filename)
        {
            List <ITisCollectionData> result       = new List <ITisCollectionData>();
            List <string>             returnResult = new List <string>();

            ITisClientServicesModule csm = null;

            if (filename != String.Empty && File.Exists(filename))
            {
                if (applicationName != String.Empty && stationName != String.Empty)
                {
                    try
                    {
                        csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                        CoreFromDynamic(ref result, ref csm, filename);
                    }
                    catch (Exception e)
                    {
                        if (csm != null)
                        {
                            csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + Constants.cStrFromDynamicMethod + Constants.cStrFailedWithException + e,
                                                         Constants.cStrLiteSdk, Log.Severity.ERROR, 0, 0);
                        }
                        else
                        {
                            throw new Exception(Constants.cStrLiteSdkBatch + Constants.cStrFromDynamicMethod + Constants.cStrFailedWithException + e);
                        }
                    }
                    finally
                    {
                        foreach (ITisCollectionData res in result)
                        {
                            returnResult.Add(res.Name);
                        }

                        if (csm != null)
                        {
                            csm.Dispose();
                        }
                    }
                }
            }

            return(returnResult.ToArray());
        }
Beispiel #6
0
        // Many
        #region "Batch.ToDynamic"
        /// <summary>
        /// [Static] Batch.ToDynamic() --> Exports the collections given by CollectionNames to a .dynamic file.
        /// </summary>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name to logon to the CSM.</param>
        /// <param name="filename">Represents the file name where the .dynamic will be exported to.</param>
        /// <param name="CollectionNames">Represents the names of the collections to export as a .dynamic file.</param>
        /// <returns>Returns true is successful, otherwise false.</returns>
        /// <example><code>bool result = Batch.ToDynamic("SimpleDemo", "efInternal", @"c:\temp\test.dynamic", new string[] { "000002349_0001", "000002349_0002" });</code></example>
        public static bool ToDynamic(string applicationName, string stationName, string filename, string[] CollectionNames)
        {
            bool result = false;

            ITisClientServicesModule csm = null;

            if (CollectionNames != null && CollectionNames.Length > 0)
            {
                if (filename != String.Empty && Directory.Exists(Path.GetDirectoryName(filename)))
                {
                    if (applicationName != String.Empty && stationName != String.Empty)
                    {
                        try
                        {
                            csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                            csm.DynamicImportExport.ExportCollectionsByName(filename, CollectionNames);
                        }
                        catch (Exception e)
                        {
                            if (csm != null)
                            {
                                csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + Constants.cStrToDynamicMethod + Constants.cStrFailedWithException + e,
                                                             Constants.cStrLiteSdk, Log.Severity.ERROR, 0, 0);
                            }
                            else
                            {
                                throw new Exception(Constants.cStrLiteSdkBatch + Constants.cStrToDynamicMethod + Constants.cStrFailedWithException + e);
                            }
                        }
                        finally
                        {
                            if (csm != null)
                            {
                                csm.Dispose();
                            }

                            result = true;
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #7
0
        /// <summary>
        /// [Static] Batch.InternalHistory() --> Returns a list of the stations a collection has gone through (when processed normally through the workflow).
        /// </summary>
        /// <param name="applicationName">Indicates the eFLOW application name.</param>
        /// <param name="stationName">Indicates the station name.</param>
        /// <param name="CollectionName">Indicates the collection name to be checked.</param>
        /// <example><code>string[] history = Batch.InternalHistory("SimpleDemo", "Completion", "000002349_0001");</code></example>
        protected static string[] InternalHistory(string applicationName, string stationName, string CollectionName)
        {
            List <string> result = new List <string>();

            ITisClientServicesModule csm = null;

            if (applicationName != String.Empty && stationName != String.Empty)
            {
                try
                {
                    csm = TisClientServicesModule.GetNewInstance(applicationName, stationName);

                    if (CollectionName != String.Empty)
                    {
                        CoreHistory(ref result, ref csm, CollectionName);
                    }
                }
                catch (Exception e)
                {
                    if (csm != null)
                    {
                        csm.Logger.RequestMessageLog(Constants.cStrLiteSdkBatch + Constants.cStrHistoryMethod + Constants.cStrFailedWithException + e,
                                                     Constants.cStrLiteSdk, Log.Severity.ERROR, 0, 0);
                    }
                    else
                    {
                        throw new Exception(Constants.cStrLiteSdkBatch + Constants.cStrHistoryMethod + Constants.cStrFailedWithException + e);
                    }
                }
                finally
                {
                    if (csm != null)
                    {
                        csm.Dispose();
                    }
                }
            }

            return(result.ToArray());
        }
Beispiel #8
0
        /// <summary>
        /// Batch->Login() --> Login to the CSM (if the Batch.ApplicationName and Batch.StationName properties have been previously set).
        /// </summary>
        /// <returns>Returns true is successful, otherwise false.</returns>
        /// <example><code>bool result = b.Login();</code></example>
        public bool Login()
        {
            bool result = false;

            if (this.applicationName != String.Empty && this.stationName != String.Empty)
            {
                try
                {
                    oCSM = TisClientServicesModule.GetNewInstance(this.applicationName, this.stationName);
                }
                catch (Exception e)
                {
                    throw new Exception(Constants.cStrLiteSdkBatch + Constants.cStrLoginMethod + Constants.cStrFailedToCreateCSMInstanceForApplicationName +
                                        this.applicationName + Constants.cStrAndStationName + this.stationName + Constants.cStrWithException +
                                        ((e.InnerException != null) ? e.InnerException.ToString() : e.ToString()));
                }
                finally
                {
                    result = true;
                }
            }

            return(result);
        }
Beispiel #9
0
        /// <summary>
        /// Get a CSM object based on the specified login credentials.
        /// </summary>
        /// <param name="appName">The eFlow application name.</param>
        /// <param name="stationName">The station that this CSM has to be logged to.</param>
        /// <returns>ITisClientServicesModule when successfull, null when failed.</returns>
        public virtual ITisClientServicesModule GetCsm(String appName, String stationName, bool canCreate)
        {
            ITisClientServicesModule res = null;

            try
            {
                //-- Create a key name --\\
                String keyname = GetCsmKey(appName, stationName);

                //-- Find in existing list --\\
                if (csms != null)
                {
                    if (csms.ContainsKey(keyname))
                    {
                        res       = csms[keyname];
                        canCreate = false;
                    }
                }

                //-- not foudn, create one if we can --\\
                if (canCreate && res == null)
                {
                    res     = TisClientServicesModule.GetNewInstance(appName, stationName);
                    keyname = GetCsmKey(res);//-- update --\\
                }


                if (res != null)
                {
                    //-- Update or set CSM result --\\
                    if (csms == null)
                    {
                        csms = new Dictionary <String, ITisClientServicesModule>();
                    }

                    //-- Update Last accessed time --\\
                    if (!csms.ContainsKey(keyname))
                    {
                        csms.Add(keyname, res);
                    }
                    if (lastAccessed == null)
                    {
                        lastAccessed = new Dictionary <String, DateTime>();
                        lastAccessed.Add(keyname, DateTime.Now);
                    }
                    else if (lastAccessed.ContainsKey(keyname))
                    {
                        lastAccessed[keyname] = DateTime.Now;
                    }
                    else
                    {
                        lastAccessed.Add(keyname, DateTime.Now);
                    }
                }
                else
                {
                    if (lastAccessed != null && !String.IsNullOrEmpty(keyname) && lastAccessed.ContainsKey(keyname))
                    {
                        lastAccessed.Remove(keyname);
                    }
                }
            }
            catch (Exception ex)
            {
                ILog.LogError(ex);
                throw (ex);
            }
            finally
            {
                if (res != null)
                {
                    //-- Hook to the CSM OnMessage event --\\
                    res.Session.OnMessage -= StationMessage;
                    res.Session.OnMessage += StationMessage;
                }

                //-- Freee and release orphaned csms --\\
                if (csms != null && res != null && !csms.ContainsKey(GetCsmKey(res)))
                {
                    try
                    {
                        res.LogoutApplication();
                        res.Dispose();
                        res = null;
                    }
                    catch (Exception ev)
                    {
                        ILog.LogError(ev);
                        throw ev;
                    }
                }
            }
            return(res);
        }