예제 #1
0
        /// <summary>
        /// Gets the statistics from every registered logger.
        /// </summary>
        /// <returns>Retrieved statistics.</returns>
        private CommunicationStatistics GetStatistics()
        {
            CommunicationStatistics stats = new CommunicationStatistics();

            Logging.LogMessage msg;
            if (this.ExecutorLogger != null)
            {
                msg = this.ExecutorLogger.PopLastMessage();
                if (msg != null)
                {
                    stats.LastExecutionMessage = new MessageData(msg.Message, msg.MessageTime);
                }

                stats.LastExecutionTime = (DateTime?)this.ExecutorLogger.GetProperty("LastExecutionTime");
            }

            if (this.ReceiverLogger != null)
            {
                msg = this.ReceiverLogger.PopLastMessage();
                if (msg != null)
                {
                    stats.LastReceiveMessage = new MessageData(msg.Message, msg.MessageTime);
                }
            }

            if (this.SenderLogger != null)
            {
                msg = this.SenderLogger.PopLastMessage();
                if (msg != null)
                {
                    stats.LastSendMessage = new MessageData(msg.Message, msg.MessageTime);
                }
            }

            using (IUnitOfWork uow = Manager.CreateUnitOfWork())
            {
                uow.MapperFactory = this.mapperFactory;

                CommunicationPackageRepository repo = new CommunicationPackageRepository(uow);
                stats.PackagesToExecute = repo.GetUnprocessedPackagesQuantity();
                stats.PackagesToSend    = repo.GetUndeliveredPackagesQuantity();

                if (String.IsNullOrEmpty(this.Manager.TransmitterConfiguration.AdditionalDataStoreProcedure) == false)
                {
                    string newData = repo.GetAdditionalData(this.Manager.TransmitterConfiguration.AdditionalDataStoreProcedure).ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                    if (newData != this.additionalData)
                    {
                        stats.AdditionalData = repo.GetAdditionalData(this.Manager.TransmitterConfiguration.AdditionalDataStoreProcedure).ToString(System.Xml.Linq.SaveOptions.DisableFormatting);
                        this.additionalData  = newData;
                    }
                }
            }

            return(stats);
        }
예제 #2
0
        /// <summary>
        /// Retrives new portion of unprocessed packages.
        /// </summary>
        private void GetNewXmlPackages()
        {
            if (this.XmlList.Count == 0)
            {
                using (IUnitOfWork uow = Manager.CreateUnitOfWork())
                {
                    uow.MapperFactory = this.mapperFactory;

                    CommunicationPackageRepository repo = new CommunicationPackageRepository(uow);
                    this.XmlList = repo.FindUnprocessedPackages(Manager.ExecutorConfiguration.MaxTransactionCount);

                    if (this.XmlList.Count > 0)
                    {
                        this.WaitingPackages = repo.GetUnprocessedPackagesQuantity();
                    }
                    else
                    {
                        this.WaitingPackages = 0;
                    }
                }
            }
        }