Beispiel #1
0
        void GetCurrentMeters(IList <int> Installations)
        {
            try
            {
                LogManager.WriteLog("GetCurrentMeters Started", LogManager.enumLogLevel.Info);
                IMeterLife meterLife = MeterLifeBusinessObject.CreateInstance();
                meterLife.GetCurrentMeters(Installations,
                                           (i, j, k) =>
                {
                    this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate
                    {
                        lblStatus.SetValue(System.Windows.Controls.Label.ContentProperty, string.Format("Processing ... ({0:D} out of {1:D})", j, k));
                        pgBar.Value = j;
                    });
                });
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate
                {
                    lblStatus.SetValue(System.Windows.Controls.Label.ContentProperty, "Retrieving data from database...");
                });
                Thread.Sleep(SleepTime);
                LogManager.WriteLog("GetCurrentMeters Ended", LogManager.enumLogLevel.Info);
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate
                {
                    this.Close();
                });
            }
            finally
            {
                try
                {
                    if (_afterAction != null)
                    {
                        _afterAction();
                    }
                }
                catch { }

                Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart) delegate
                {
                    this.Close();
                });
            }
        }
        private void FetchDataAndBindGrid()
        {
            try
            {
                IMeterLife meterLife = MeterLifeBusinessObject.CreateInstance();
                LogManager.WriteLog("MeterLife: Get Current Meters for Installation No: " + InstallationNo.ToString() + "<START>", LogManager.enumLogLevel.Debug);
                meterLife.GetCurrentMeters(InstallationNo);

                LogManager.WriteLog("MeterLife: Database Fetching <START>", LogManager.enumLogLevel.Debug);
                DataSet dsMeterLife = meterLife.GetMeterLife(InstallationNo);
                LogManager.WriteLog("MeterLife: Database Fetching <END>", LogManager.enumLogLevel.Debug);

                if (_bindGrid != null)
                {
                    this.Dispatcher.Invoke(_bindGrid, dsMeterLife);
                }
                else
                {
                    LogManager.WriteLog("CMeterLife screen was disposed already. Skipped loading.", LogManager.enumLogLevel.Info);
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog("Error Occured in MeterLife: Get Current Meters for Installation No " + InstallationNo.ToString() + " : " + ex.Message, LogManager.enumLogLevel.Error);
                ExceptionManager.Publish(ex);
            }
            finally
            {
                if (_enableControls != null)
                {
                    this.Dispatcher.Invoke(_enableControls, null);
                }
                else
                {
                    LogManager.WriteLog("CMeterLife screen was disposed already. Skipped loading.", LogManager.enumLogLevel.Info);
                }
            }
        }