예제 #1
0
        public static async void CacheTheError(Error error)
        {
            if (_errorSaverActionBlock == null ||
                _errorSaverActionBlock.Completion.IsFaulted)
            {
                #region Initile Action Block Again

                _errorSaverActionBlock = new ActionBlock <Error>(async e =>
                {
                    if (await SqlCompactEditionManager.InsertOrUpdateAsync(e)) // insert or update database and return cache check state
                    {
                        if (_errorSaverActionBlock.InputCount == 0 && !ErrorHandlingOption.AtSentState)
                        {
                            await CheckStateAsync();
                        }
                    }
                },
                                                                 new ExecutionDataflowBlockOptions
                {
                    MaxMessagesPerTask = 1
                });

                #endregion
            }

            await _errorSaverActionBlock.SendAsync(error);
        }
예제 #2
0
        public static async Task UploadCacheAsync()
        {
            if (SqlCompactEditionManager.ErrorIds.Count == 0)
            {
                ErrorHandlingOption.AtSentState = false;
                return;
            }

            IEnumerable <ProxyError> errors = SqlCompactEditionManager.GetErrors();

            if (errors == null || !errors.Any())
            {
                ErrorHandlingOption.AtSentState = false;
                return;
            }

            ErrorHandlingOption.AtSentState = true;

            foreach (var error in errors)
            {
                await ServerTransmitter.ErrorListenerTransformBlock.SendAsync(new ProxyError(error));

                if (!ErrorHandlingOption.EnableNetworkSending)
                {
                    break;
                }
            }
        }
예제 #3
0
        static CacheController()
        {
            #region Acknowledge Action Block

            AcknowledgeActionBlock = new ActionBlock <Tuple <ProxyError, bool> >(
                async ack =>
            {
                if (ack.Item2)     // Error Successful sent to server database
                {
                    //
                    // Remove Error from Log file:
                    await SqlCompactEditionManager.DeleteAsync(ack.Item1.Id);
                    //
                    // De-story error from Memory (RAM):
                    if (ack.Item1 != null)
                    {
                        ack.Item1.Dispose();
                    }
                }
            },
                new ExecutionDataflowBlockOptions
            {
                MaxMessagesPerTask = 1
            });

            #endregion
        }
예제 #4
0
        static CacheController()
        {
            // Create or Load log file path
            StorageRouter.CheckLogPathAndName();
            //
            // Create instance of SDF file manager object
            SdfManager = new SqlCompactEditionManager(ErrorHandlingOption.ErrorLogPath);

            #region Acknowledge Action Block

            AcknowledgeActionBlock = new ActionBlock <Tuple <IError, bool> >(
                async ack =>
            {
                if (ack.Item2)     // Error Successful sent to server database
                {
                    //
                    // Remove Error from Log file:
                    await SdfManager.DeleteAsync(ack.Item1.Id);
                    //
                    // De-story error from Memory (RAM):
                    var error = ack.Item1 as ProxyError;
                    if (error != null)
                    {
                        error.Dispose();
                    }
                }
            },
                new ExecutionDataflowBlockOptions
            {
                MaxMessagesPerTask = 1
            });

            #endregion
        }
        static CacheController()
        {
            // Create or Load log file path
            StorageRouter.CheckLogPathAndName();
            //
            // Create instance of SDF file manager object
            SdfManager = new SqlCompactEditionManager(ErrorHandlingOption.ErrorLogPath);

            #region Acknowledge Action Block

            AcknowledgeActionBlock = new ActionBlock<Tuple<ProxyError, bool>>(
                async ack =>
                {
                    if (ack.Item2) // Error Successful sent to server database
                    {
                        //
                        // Remove Error from Log file:
                        await SdfManager.DeleteAsync(ack.Item1.Id);
                        //
                        // De-story error from Memory (RAM):
                        if (ack.Item1 != null) ack.Item1.Dispose();
                    }
                },
                new ExecutionDataflowBlockOptions
                {
                    MaxMessagesPerTask = 1
                });

            #endregion
        }
예제 #6
0
        private static async void LoadLogPath()
        {
            ErrorHandlingOption.ErrorLogPath = Settings.Default.ErrorLogPath;

            CheckLogPath();

            await SqlCompactEditionManager.CreateSdfAsync(ErrorHandlingOption.ErrorLogPath);
        }
예제 #7
0
 public static async void ReadyCache()
 {
     if (File.Exists(ErrorHandlingOption.ErrorLogPath))
     {
         SqlCompactEditionManager.CheckSdf(ErrorHandlingOption.ErrorLogPath);
         SqlCompactEditionManager.LoadCacheIds();
     }
     else
     {
         await SqlCompactEditionManager.CreateSdfAsync(ErrorHandlingOption.ErrorLogPath);
     }
 }
예제 #8
0
 /// <summary>
 /// Check Cache State to Send Data to Server or Not ?
 /// </summary>
 public static async Task CheckStateAsync()
 {
     if (ConnectionManager.GetDefaultConnection().IsReady&& ErrorHandlingOption.EnableNetworkSending)
     {
         // if errors caching data was larger than limited size then send it to server
         // and if successful sent then clear them...
         if (ErrorHandlingOption.CacheFilled ||
             await SqlCompactEditionManager.GetTheFirstErrorHoursAsync() >= ErrorHandlingOption.ExpireHours ||
             ErrorHandlingOption.SentOnStartup ||
             ErrorHandlingOption.MaxQueuedError <= await SqlCompactEditionManager.CountAsync() ||
             ErrorHandlingOption.AtSentState)
         {
             await UploadCacheAsync();
         }
     }
 }
예제 #9
0
        private void btnRefreshGridView_Click(object sender, EventArgs e)
        {
            sdfManager = new SqlCompactEditionManager(txtCacheFilePath.Text);

            timer.Start();

            btnRefreshGridView.Enabled = false;
        }
 public static void LoadCacheIds()
 {
     SqlCompactEditionManager.ErrorIds = SqlCompactEditionManager.GetErrorsId();
 }