public void RunGC()
        {
            this.CancelGCPass();
            PerfLogger.Reset();
            IEnumerator enumerator = this.PawnGCPass().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object obj = enumerator.Current;
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            float num = PerfLogger.Duration() * 1000f;

            PerfLogger.Flush();
            Log.Message(string.Format("World pawn GC run complete in {0} ms", num), false);
        }
示例#2
0
 public async Task HandleAsync(T message)
 {
     using (PerfLogger.Create(message.GetType().Name))
     {
         await _decorated.HandleAsync(message).ConfigureAwait(false);
     }
 }
示例#3
0
 public UserPlaylist GetUserPlaylist(Guid userId, string playlistName)
 {
     using (PerfLogger.Create("GetUserPlaylist", () => new { smartPlaylistName = playlistName }))
     {
         return(_decorated.GetUserPlaylist(userId, playlistName));
     }
 }
示例#4
0
 public async Task <Domain.SmartPlaylist[]> GetAllUpdateableSmartPlaylistsAsync()
 {
     using (PerfLogger.Create("GetAllUpdateableSmartPlaylists"))
     {
         return(await _decorated.GetAllUpdateableSmartPlaylistsAsync().ConfigureAwait(false));
     }
 }
 public void Delete(Guid userId, string smartPlaylistId)
 {
     using (PerfLogger.Create("DeleteSmartPlaylist"))
     {
         _decorated.Delete(userId, smartPlaylistId);
     }
 }
示例#6
0
        public void RunGC()
        {
            CancelGCPass();
            PerfLogger.Reset();
            IEnumerator enumerator = PawnGCPass().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object current = enumerator.Current;
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            float num = PerfLogger.Duration() * 1000f;

            PerfLogger.Flush();
            Log.Message($"World pawn GC run complete in {num} ms");
        }
 public void Save(SmartPlaylistDto smartPlaylist)
 {
     using (PerfLogger.Create("SaveSmartPlaylist", () => new { smartPlaylistName = smartPlaylist.Name }))
     {
         _decorated.Save(smartPlaylist);
     }
 }
 public async Task <SmartPlaylistDto[]> GetAllSmartPlaylistsAsync()
 {
     using (PerfLogger.Create("GetAllSmartPlaylistsFromStore"))
     {
         return(await _decorated.GetAllSmartPlaylistsAsync().ConfigureAwait(false));
     }
 }
 public async Task <SmartPlaylistDto[]> LoadPlaylistsAsync(Guid userId)
 {
     using (PerfLogger.Create("LoadPlaylistsFromStore"))
     {
         return(await _decorated.LoadPlaylistsAsync(userId).ConfigureAwait(false));
     }
 }
示例#10
0
        public override void Initialize()
        {
            base.Initialize();
            crmListener = new HttpListener();
            string text = ConfigurationValueReader.ConfigurationReader().ReadAppSettings("GenericListener");

            if (string.IsNullOrEmpty(text))
            {
                text = "http://localhost:5000/";
            }
            crmListener.Prefixes.Add(text);
            crmListener.Start();
            crmRequestWorker = new Thread(RequestWorker);
            crmRequestWorker.IsBackground = true;
            crmRequestWorker.Start();
            PerfLogger.LogData("UII_HOSTED_APP_LOAD_" + GetHashCode(), new Dictionary <string, string>
            {
                {
                    "AppID",
                    base.ApplicationID.ToString()
                },
                {
                    "Name",
                    base.ApplicationName
                }
            });
        }
        public async Task UpdateAsync(UserPlaylist playlist, BaseItem[] newItems)
        {
            using (PerfLogger.Create("UpdatePlaylistItems",
                                     () => new { playlistName = playlist.Name, newItemsCount = newItems.Length }))

            {
                await _decorated.UpdateAsync(playlist, newItems).ConfigureAwait(false);
            }
        }
示例#12
0
        public async Task <Domain.SmartPlaylist> GetSmartPlaylistAsync(Guid smartPlaylistId)
        {
            Domain.SmartPlaylist smartPlaylist = null;
            using (PerfLogger.Create("GetSmartPlaylistFromProvider", () => new { smartPlaylistName = smartPlaylist?.Name }))
            {
                smartPlaylist = await _decorated.GetSmartPlaylistAsync(smartPlaylistId).ConfigureAwait(false);

                return(smartPlaylist);
            }
        }
示例#13
0
        static public void RunGC(WorldPawnGC __instance)
        {
            __instance.CancelGCPass();
            PerfLogger.Reset();
            PawnGCPass(__instance).ExecuteEnumerable();
            float num = PerfLogger.Duration() * 1000f;

            PerfLogger.Flush();
            Log.Message(string.Format("World pawn GC run complete in {0} ms", num));
        }
        public IEnumerable <BaseItem> GetItems(User user, string[] itemTypes)
        {
            var items = new BaseItem[0];

            using (PerfLogger.Create("GetUserItems", () => new { userName = user.Name, itemsCount = items.Length }))
            {
                items = _decorated.GetItems(user, itemTypes).ToArray();
                return(items);
            }
        }
        public async Task <SmartPlaylistDto> GetSmartPlaylistAsync(Guid smartPlaylistId)
        {
            SmartPlaylistDto smartPlaylistDto = null;

            using (PerfLogger.Create("GetSmartPlaylistFromStore", () => new { smartPlaylistName = smartPlaylistDto?.Name }))
            {
                smartPlaylistDto = await _decorated.GetSmartPlaylistAsync(smartPlaylistId).ConfigureAwait(false);

                return(smartPlaylistDto);
            }
        }
示例#16
0
        public void RunGC()
        {
            this.CancelGCPass();
            PerfLogger.Reset();
            foreach (object current in this.PawnGCPass())
            {
            }
            float num = PerfLogger.Duration() * 1000f;

            PerfLogger.Flush();
            Log.Message(string.Format("World pawn GC run complete in {0} ms", num));
        }
示例#17
0
        private async Task GetTasks(Domain.SmartPlaylist smartPlaylist, BaseItem[] items)
        {
            BaseItem[] newItems;
            var        playlist = _playlistRepository.GetUserPlaylist(smartPlaylist.UserId, smartPlaylist.Name);

            using (PerfLogger.Create("FilterPlaylistItems",
                                     () => new { playlistName = playlist.Name, itemsCount = items.Length }))
            {
                newItems = smartPlaylist.FilterPlaylistItems(playlist, items).ToArray();
            }

            await _playlistItemsUpdater.UpdateAsync(playlist, newItems).ConfigureAwait(false);
        }
示例#18
0
        static void Main(string[] args)
        {
            var sum = 0.0;

            using (PerfLogger.Measure("100M for iterations"))
                for (var i = 0; i < 100000000; i++)
                {
                    sum += i;
                }
            using (PerfLogger.Measure("100M LINQ iterations"))
                sum -= Enumerable.Range(0, 100000000).Sum(i => (double)i);
            Console.WriteLine(sum);
        }
示例#19
0
        public void RunGC()
        {
            CancelGCPass();
            PerfLogger.Reset();
            foreach (object item in PawnGCPass())
            {
                _ = item;
            }
            float num = PerfLogger.Duration() * 1000f;

            PerfLogger.Flush();
            Log.Message($"World pawn GC run complete in {num} ms");
        }
示例#20
0
        public async Task HandleAsync(UpdateSmartPlaylistCommand message)
        {
            var smartPlaylist = await _smartPlaylistProvider.GetSmartPlaylistAsync(message.SmartPlaylistId)
                                .ConfigureAwait(false);

            var playlist = _playlistRepository.GetUserPlaylist(smartPlaylist.UserId, smartPlaylist.Name);

            var items = _userItemsProvider.GetItems(playlist.User, Const.SupportedItemTypeNames).ToArray();

            BaseItem[] newItems;
            using (PerfLogger.Create("FilterPlaylistItems",
                                     () => new { playlistName = playlist.Name, itemsCount = items.Length }))
            {
                newItems = smartPlaylist.FilterPlaylistItems(playlist, items).ToArray();
            }

            await _playlistItemsUpdater.UpdateAsync(playlist, newItems).ConfigureAwait(false);

            if (smartPlaylist.IsShuffleUpdateType)
            {
                smartPlaylist.UpdateLastShuffleTime();
                _smartPlaylistStore.Save(smartPlaylist.ToDto());
            }
        }
        public new void Complete(bool treatWarningsAsErrors)
        {

            using (var logger = new PerfLogger(this.GetType(), "Complete", MinDurationToLog))
            {
                //if (treatWarningsAsErrors)
                //{
                //    this.SeverityLimit = ErrorSeverity.Information;
                //}
                //else
                //{
                //    this.SeverityLimit = ErrorSeverity.Warning;
                //}

                // Validate before performing any transactional operations
                //this.Validate(ValidationMode.Full);
                this.CheckResults(ProcessInvocationPoint.Validation, ErrorSeverity.Fatal);
                this.CheckResults(TransactionInvocationPoint.PreValidate, ErrorSeverity.Fatal);
                this.CheckResults(TransactionInvocationPoint.PostValidate, ErrorSeverity.Fatal);

                // begin transaction to update data
                using (var ts = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = TransactionIsolationLevel }))
                {

                    //var prop = typeof(AbstractBusinessTransaction).GetProperty("ProcessHandler");
                    //var processHandler = (IBusinessProcessHandler)prop.GetValue(this, null);
                    //base.ProcessHandler.PreComplete(this);
                    //this.CheckResults(TransactionInvocationPoint.PreComplete, this.SeverityLimit);

                    this.DoSave();
                    this.CheckResults(TransactionInvocationPoint.Save, this.SeverityLimit);

                    this.DoComplete();
                    this.CheckResults(TransactionInvocationPoint.Complete, this.SeverityLimit);

                    // Code running in PostComplete must not attempt to update any data in the object context
                    //this.ProcessHandler.PostComplete(this);

                    this.CheckResults(ErrorSeverity.Fatal);

                    if (_Logger.IsWarnEnabled && Transaction.Current != null)
                    {
                        Guid identifier = Transaction.Current.TransactionInformation.DistributedIdentifier;
                        if (identifier != Guid.Empty)
                        {
                            _Logger.Warn("FlattenedTransaction promoted to DTC with DistributedIdentifier " + identifier);
                        }
                    }

                    // Commits the changes
                    ts.Complete();
                    //this._isActive = false;
                    //this._isExecuted = false;
                }

                // FlattenedTransaction has been committed so even if an error occurs the transaction is done with and needs to be removed
                try
                {
                    this.DoPostCommit();
                    this.CheckResults(TransactionInvocationPoint.PostCommit, ErrorSeverity.Fatal);
                }
                finally
                {
                    // Remove the business transaction object from cache.
                    // which has been added from BusinessTransactionFactory 
                    XiapTransactionEvents.RaiseOnTransactionEnd(this.Context.TransactionId);
                }
            }
        }
示例#22
0
        /// <summary>
        /// When a file comes into a folder, method will be called, process the file data
        /// </summary>
        /// <param name="sender">Object sender</param>
        /// <param name="e">File System EventArgs</param>
        private void ProcessFiles(object sender, FileSystemEventArgs e)
        {
            string logFileName = this.serviceManager.LogFilePath;
            string statusMessage = null;
            string trasactionStatus = null;
            if (_Logger.IsInfoEnabled)
            {
                _Logger.Info(String.Format(Constants.INFOMESSAGE_PROCESSING_CALLED, e.Name));
            }

            string  logFilePath = logFileName + "\\" + e.Name.Replace(".txt", string.Empty) + "_" + DateTime.Now.ToString("dd-MM-yyyy_hh-mm-ss tt") + ".txt";

            string archivePath = this.serviceManager.ArchivePath;
            int maxNoofRetries = this.serviceManager.NumberOfFileAccessRetries.HasValue ? this.serviceManager.NumberOfFileAccessRetries.Value : 3;
            int durationOfSleep = this.serviceManager.DurationOfSleepForFileAccessRetries.HasValue ? this.serviceManager.DurationOfSleepForFileAccessRetries.Value : 1000; 
            int numberOfRetires = 0;

            using (PerfLogger _LG = new PerfLogger(typeof(ProcessFile), "ProcessFile"))
            {
                while (true)
                {
                    try
                    {
                        if (_Logger.IsInfoEnabled)
                        {
                            _Logger.Info("Before File Stream");
                        }

                        this.ReadFileAndProcess(e, logFileName, logFilePath, out statusMessage, out trasactionStatus);
                        break;
                    }
                    catch (IOException exc)
                    {
                        numberOfRetires++;
                        if (numberOfRetires < maxNoofRetries)
                        {
                            Thread.Sleep(durationOfSleep);
                            if (_Logger.IsInfoEnabled)
                            {
                                _Logger.Info(string.Format("Unable to access File {0} retrying {1} time(s)", e.FullPath, numberOfRetires + 1));
                                _Logger.Info(exc.Message);
                                _Logger.Info(exc.StackTrace);
                            }

                            continue;
                        }

                        this.HandleError(e, trasactionStatus, exc, statusMessage, logFilePath, e.Name, archivePath);
                        break;
                    }
                    catch (Exception exc)
                    {
                        this.HandleError(e, trasactionStatus, exc, statusMessage, logFilePath, e.Name, archivePath);
                        break;
                    }
                }
            }
        }
示例#23
0
        /// <summary>
        /// Process on the PostComplete point.
        /// If Create Claim,CloseClaim,ReopenClaim,AmendClaim,Copy,Delete ,CancelPayment,ReserveAuthorisation,PaymentAuthorisation,RecoveryReceiptAuthorisation
        /// </summary>
        /// <param name="businessTransaction">Processing ClaimTransactionHeader</param>
        /// <param name="point">it is invocation(PostComplete)</param>
        /// <param name="PluginId">Plugin ID</param>
        /// <param name="parameters">Process transaction Parameters if any </param>
        /// <returns>return Result Collection</returns>
        public ProcessResultsCollection ProcessTransaction(IBusinessTransaction businessTransaction, TransactionInvocationPoint point, int PluginId, params object[] parameters)
        {
            ClaimHeader claimHeader = null;
            using (PerfLogger _LG = new PerfLogger(typeof(AXAClaimTransferPlugin), "AXAClaimTransferPlugin"))
            {
                if (point == TransactionInvocationPoint.PostComplete)
                {
                    if (businessTransaction.Component != null)
                    {
                        if (businessTransaction.Component is ClaimTransactionHeader)
                        {
                            claimHeader = businessTransaction.Component.Parent as ClaimHeader;
                        }
                        else
                        {
                            claimHeader = businessTransaction.Component as ClaimHeader;
                        }
                    }

                    // Get invalid Header Status codes from the application configuration
                    // No claims of this header status code will be transferred.
                    string invalidClaimHeaderStatusCodes = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(ClaimConstants.APP_SETTING_KEY_HEADERSTATUSESFORINVALIDCLAIMTRANSFER);
                    if (claimHeader != null && ClaimsBusinessLogicHelper.CheckValidHeaderStatus(claimHeader, invalidClaimHeaderStatusCodes))
                    {
                        if (_Logger.IsDebugEnabled)
                        {
                            _Logger.Debug(claimHeader.ClaimReference + " : has valid claim header status code.");
                        }

                        // If header status of claim has been changed to Abandoned then if previous header status was valid then insert entry in claim transfer control log table.
                        if (claimHeader.ClaimHeaderStatusCode == ClaimConstants.CLAIM_HEADER_STATUS_ABANDONED)
                        {
                            if (claimHeader.OriginalTransitionStatus == ClaimConstants.CLAIM_HEADER_STATUS_NO_ESTIMATE
                                || claimHeader.OriginalTransitionStatus == ClaimConstants.CLAIM_HEADER_STATUS_ESTIMATE_MADE
                                || claimHeader.OriginalTransitionStatus == ClaimConstants.CLAIM_HEADER_STATUS_PAYMENT_MADE)
                            {
                                this.AddClaimTransferControlLogEntry(businessTransaction);
                            }

                            // No further processing of an abandoned claim
                            return null;
                        }

                        // Check if status is moved from invalid to valid then write out all ClaimTransactions to Transfer log which were added when claim status was invalid.
                        List<string> invalidClaimHeaderStatusesList = invalidClaimHeaderStatusCodes.Split(',').ToList<string>();
                        if (!string.IsNullOrEmpty(invalidClaimHeaderStatusCodes)
                            && claimHeader.OriginalTransitionStatus != claimHeader.ClaimHeaderStatusCode
                            && invalidClaimHeaderStatusesList.Contains(claimHeader.OriginalTransitionStatus.ToString())
                            && !invalidClaimHeaderStatusesList.Contains(claimHeader.ClaimHeaderStatusCode.ToString()))
                        {
                            // If there is status transition from invalid to valid then this won't insert records for financial transactions instead 
                            // Stored Procedure will insert all the finanical transactions.
                            this.AddClaimTransferControlLogEntry(businessTransaction, false);
                            if (_Logger.IsDebugEnabled)
                            {
                                _Logger.Debug(claimHeader.ClaimReference + " : Using SP to to Inserting financial records that were made when claim was having invalid header status code into ClaimTransferControlLog table.");
                            }

                            // Use Stored Procedure to retroactively insert the necessary financial recors.
                            IAXAClaimsQuery query = ObjectFactory.Resolve<IAXAClaimsQuery>();
                            query.ExecuteClaimTransferControlLogSP(claimHeader.ClaimReference.ToString());
                        }
                        else
                        {
                            if (_Logger.IsDebugEnabled)
                            {
                                _Logger.Debug(claimHeader.ClaimReference + " : Inserting financial records of claim having valid header status code, into ClaimTransferControlLog table.");
                            }

                            // This will insert records for create/update claim and financial transaction if exist.
                            this.AddClaimTransferControlLogEntry(businessTransaction, true);
                        }
                    }
                }
            }

            return null;
        }