Esempio n. 1
0
        /// <summary>
        /// Load the queue according to the Policy.
        /// </summary>
        /// <param name="queueLoadingPolicy"></param>
        /// <returns>List<GTPQueue></returns>
        /// Called from Loader
        public static List <GTPQueue> GetAllGTPQueues(QueueLoadingPolicy queueLoadingPolicy = null)
        {
            //var value = (int)Enum.Parse(typeof(ContractEnum), contractPriority.ContractName);
            QueueStatesEnum contractEnum = (QueueStatesEnum)System.Enum.ToObject(typeof(QueueStatesEnum), 1);

            List <GTPQueue> listItemQueues = new List <GTPQueue>();

            try {
                ConnectionHelper.Connect(AutoCreateOption.None);
                Session session = new Session(XpoDefault.DataLayer);
                {
                    var queueItems = new XPQuery <Queue>(session).OrderBy(x => x.Priority).ToList();
                    foreach (var queuItem in queueItems)
                    {
                        var enumValue = (QueueStatesEnum)System.Enum.ToObject(typeof(QueueStatesEnum), queuItem.Status);
                        try
                        {
                            listItemQueues.Add(new GTPQueue()
                            {
                                DateCreation       = queuItem.DtCrea,
                                Id                 = queuItem.Id,
                                PriorityValue      = queuItem.Priority,
                                Interface          = queuItem.Interface,
                                SerizdIn           = queuItem.ObjectIn,
                                SerizdOut          = queuItem.ObjectOut,
                                ConcatIdsObjects   = queuItem.ObjectsIds,
                                Status             = queuItem.Status,
                                StatusEnum         = enumValue,
                                StatusEnumToString = enumValue.ToString()
                            });
                        }
                        catch (Exception ex)
                        {
                            log.Error(FormatMessages.getLogMessage(
                                          "GTPQueue",
                                          System.Reflection.MethodBase.GetCurrentMethod().Name,
                                          TokenKey.NoMethodParams,
                                          ex.ToString()));
                        }
                    }
                    session.DataLayer.Dispose();
                }
                return(listItemQueues);
            }
            catch (Exception ex)
            {
                log.Error(FormatMessages.getLogMessage(
                              "GTPQueue",
                              System.Reflection.MethodBase.GetCurrentMethod().Name,
                              TokenKey.NoMethodParams,
                              ex.ToString()));
                return(listItemQueues);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Load the que according to the Policy.
 /// </summary>
 /// <param name="queueLoadingPolicy"></param>
 /// <returns></returns>
 public static List <Queue> GetQueue(QueueLoadingPolicy queueLoadingPolicy = null)
 {
     // TODO: Load the queue according to the Policy -CSI
     ConnectionHelper.Connect(AutoCreateOption.None);
     Session session = new Session(XpoDefault.DataLayer);
     {
         //Default loading
         var resp = new XPQuery <Queue>(session).Where(x => x.Status != ((int)QueueStatesEnum.Traite)).ToList();
         session.DataLayer.Dispose();
         return(resp);
     }
 }