示例#1
0
	//When the program starts, log needs to be a singleton
	void Awake(){
		if (_instance != null) {
			Debug.Log ("Instance already exists!");
			return;
		}
		_instance = this;

		logfile = "DataFile/" + sName + "Log.txt"; //NOTE: THIS FOLDER MUST EXIST
		eyeLogfile = "DataFile/" + sName + "EyeLog.txt";
		experimentLog.fileName = logfile;
		eyeLog.fileName = eyeLogfile;
	}
示例#2
0
 private static AutomationElementCollection UiaGetMenuItems(BaseProdControl control)
 {
     try
     {
         AutomationElementCollection retVal  = control.UIAElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.MenuItem));
         Collection <object>         retColl = InternalUtilities.AutomationCollToObjectList(retVal);
         LogController.ReceiveLogMessage(new LogMessage(string.Join("Items", retColl)));
         return(retVal);
     }
     catch (ArgumentNullException err)
     {
         throw new ProdOperationException(err);
     }
     catch (ElementNotAvailableException err)
     {
         throw new ProdOperationException(err);
     }
     catch (InvalidOperationException err)
     {
         throw new ProdOperationException(err);
     }
 }
 private static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
 {
     try
     {
         Exception ex = (Exception)e.ExceptionObject;
         LogException(ex);
     }
     catch
     {
         try
         {
             LogController.GetInstance().LogData(LogController.
                                                 GetInstance().LogFormat.
                                                 GetNavigationLine("CD UNHANDLED EXCEPTION: " +
                                                                   "Fatal exception happend inside UnhadledExceptionHandler"));
             RunCrashApp();
             Process.GetCurrentProcess().Kill();
         }
         finally
         { }
     }
 }
 private static void UIThreadException(object sender, ThreadExceptionEventArgs t)
 {
     try
     {
         Exception ex = t.Exception;
         LogException(ex);
     }
     catch
     {
         try
         {
             LogController.GetInstance().LogData(LogController.
                                                 GetInstance().LogFormat.
                                                 GetNavigationLine("UIT UNHANDLED EXCEPTION: " +
                                                                   "Fatal exception happend inside UnhadledExceptionHandler"));
             RunCrashApp();
             Process.GetCurrentProcess().Kill();
         }
         finally
         { }
     }
 }
        public static bool ArithmeticDeleteTreeNode(Guid applicationId,
                                                    List <Guid> treeNodeIds, Guid?treeOwnerId, bool?removeHierarchy, Guid currentUserId)
        {
            string spName = GetFullyQualifiedName("ArithmeticDeleteTreeNode");

            try
            {
                if (treeOwnerId == Guid.Empty)
                {
                    treeOwnerId = null;
                }

                return(ProviderUtil.succeed(ProviderUtil.execute_reader(spName, applicationId,
                                                                        ProviderUtil.list_to_string <Guid>(ref treeNodeIds), ',',
                                                                        treeOwnerId, removeHierarchy, currentUserId, DateTime.Now)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.DCT);
                return(false);
            }
        }
        public static bool MoveTreeNode(Guid applicationId,
                                        List <Guid> treeNodeIds, Guid?parentTreeNodeId, Guid currentUserId, ref string errorMessage)
        {
            string spName = GetFullyQualifiedName("MoveTreeNode");

            try
            {
                if (parentTreeNodeId == Guid.Empty)
                {
                    parentTreeNodeId = null;
                }

                return(ProviderUtil.succeed(ProviderUtil.execute_reader(spName, applicationId,
                                                                        ProviderUtil.list_to_string <Guid>(ref treeNodeIds), ',', parentTreeNodeId,
                                                                        currentUserId, DateTime.Now), ref errorMessage));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.DCT);
                return(false);
            }
        }
示例#7
0
        //====================================================================================================
        //
        public static void houseKeep_App_Daily_RemoveVisitRecords(CoreController core, DateTime DeleteBeforeDate)
        {
            try {
                //
                int    TimeoutSave         = 0;
                string SQL                 = null;
                string DeleteBeforeDateSQL = null;
                string appName             = null;
                string SQLTablePeople      = null;
                //
                // Set long timeout (30 min) needed for heavy work on big tables
                TimeoutSave = core.db.sqlCommandTimeout;
                core.db.sqlCommandTimeout = 1800;
                //
                SQLTablePeople = MetadataController.getContentTablename(core, "People");
                //
                appName             = core.appConfig.name;
                DeleteBeforeDateSQL = DbController.encodeSQLDate(DeleteBeforeDate);
                //
                // Visits older then archive age
                //
                LogController.logInfo(core, "Deleting visits before [" + DeleteBeforeDateSQL + "]");
                core.db.deleteTableRecordChunks("ccVisits", "(DateAdded<" + DeleteBeforeDateSQL + ")", 1000, 10000);
                //
                // Viewings with visits before the first
                //
                LogController.logInfo(core, "Deleting viewings with visitIDs lower then the lowest ccVisits.ID");
                core.db.deleteTableRecordChunks("ccviewings", "(visitid<(select min(ID) from ccvisits))", 1000, 10000);

                //
                // restore sved timeout
                //
                core.db.sqlCommandTimeout = TimeoutSave;
                return;
                //
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
        }
示例#8
0
        private ClassMInfo BindInfo(IDataReader dr)
        {
            ClassMInfo myInfo = new ClassMInfo();

            try
            {
                if (!dr["id"].Equals(DBNull.Value))
                {
                    myInfo.Id = dr["id"].ToString();
                }
                if (!dr["name"].Equals(DBNull.Value))
                {
                    myInfo.Name = dr["name"].ToString();
                }
            }
            catch (Exception ex)
            {
                LogController.WriteLog("ClassMDB.BindInfo", ex.ToString());
                throw (ex);
            }
            return(myInfo);
        }
示例#9
0
文件: Utils.cs 项目: jamesvdm/MemPlus
 /// <summary>
 /// Run the application using Administrative rights
 /// </summary>
 internal static void RunAsAdministrator(LogController logController)
 {
     try
     {
         Process proc = new Process
         {
             StartInfo =
             {
                 FileName        = Assembly.GetExecutingAssembly().Location,
                 UseShellExecute = true,
                 Verb            = "runas"
             }
         };
         proc.Start();
         Application.Current.Shutdown();
     }
     catch (Exception ex)
     {
         logController.AddLog(new ApplicationLog(ex.Message));
         MessageBox.Show(ex.Message, "MemPlus", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 public IDictionary <string, Entity> GetOrLoadEntitiesForImport(LogController logController)
 {
     if (FolderContainingPackage == null)
     {
         throw new NullReferenceException($"Cannot load files {nameof(FolderContainingPackage)} property is null");
     }
     if (_loadedEntities == null)
     {
         foreach (var childFolder in Directory.GetDirectories(FolderContainingPackage.FolderPath))
         {
             if (new DirectoryInfo(childFolder).Name == "Data")
             {
                 _loadedEntities = ImportXmlService.LoadEntitiesFromXmlFiles(childFolder, logController);
             }
         }
     }
     if (_loadedEntities == null)
     {
         _loadedEntities = new Dictionary <string, Entity>();
     }
     return(_loadedEntities);
 }
示例#11
0
        /// <inheritdoc />
        /// <summary>
        /// Initialize a new LogWindow object
        /// </summary>
        /// <param name="logController">The LogController object that can be used to add and view logs</param>
        /// <param name="logType">The LogType that is currently being monitored. Can be null if all logs should be monitored</param>
        internal LogWindow(LogController logController, LogType?logType)
        {
            _logController = logController;
            _logController.AddLog(new ApplicationLog("Initializing LogWindow"));

            _logType = logType;

            InitializeComponent();
            ChangeVisualStyle();
            LoadProperties();

            FillLogView();

            _logController.LogAddedEvent       += LogAddedEvent;
            _logController.LogsClearedEvent    += LogsClearedEvent;
            _logController.LogDeletedEvent     += LogDeletedEvent;
            _logController.LogTypeClearedEvent += LogTypeClearedEvent;

            _autoScroll = true;

            _logController.AddLog(new ApplicationLog("Done initializing LogWindow"));
        }
示例#12
0
 public static void housekeep(CoreController core, HouseKeepEnvironmentModel env)
 {
     try {
         //
         LogController.logInfo(core, "Housekeep, memberrules");
         //
         //
         // -- delete rows with invalid columns
         core.db.executeNonQuery("delete from ccMemberRules where groupid is null or memberid is null");
         //
         // MemberRules with bad MemberID
         //
         LogController.logInfo(core, "Deleting Member Rules with bad MemberID.");
         string sql = "delete ccmemberrules"
                      + " From ccmemberrules"
                      + " LEFT JOIN ccmembers on ccmembers.ID=ccmemberrules.memberId"
                      + " WHERE (ccmembers.ID is null)";
         core.db.executeNonQuery(sql);
         //
         // MemberRules with bad GroupID
         //
         LogController.logInfo(core, "Deleting Member Rules with bad GroupID.");
         sql = "delete ccmemberrules"
               + " From ccmemberrules"
               + " LEFT JOIN ccgroups on ccgroups.ID=ccmemberrules.GroupID"
               + " WHERE (ccgroups.ID is null)";
         core.db.executeNonQuery(sql);
         //
         // -- delete duplicates (very slow query)
         sql = "delete from ccmemberrules where id in ("
               + " select distinct b.id"
               + " from ccmemberrules a, ccmemberrules b"
               + " where ((a.memberid=b.memberid)and(a.groupid=b.groupid)and(a.id<b.id))"
               + ")";
         core.db.executeNonQuery(sql);
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
示例#13
0
        /// <summary>
        /// Список файлов в данном каталоге
        /// </summary>
        /// <param name="dirUri">Путь к каталогу на сервере.</param>
        public async Task <List <DirectoryItem> > ListAsync(Uri dirUri)
        {
            List <DirectoryItem> list = new List <DirectoryItem>();

            Progress_Start();

            try
            {
                using (WebDavSession session = new WebDavSession(Server, httpClientHandler, version))
                {
                    IList <WebDavSessionItem> items = await session.ListAsync(dirUri);

                    foreach (WebDavSessionItem item in items)
                    {
                        // обработка списка
                        DirectoryItem dirItem = new DirectoryItem
                        {
                            Name           = item.Name,
                            Uri            = item.Uri,
                            LastModified   = item.LastModified,
                            ContentLength  = item.ContentLength,
                            QuotaUsedBytes = item.QuotaUsedBytes,
                            IsFolder       = item.IsFolder
                        };
                        list.Add(dirItem);
                    }
                    LogController.Info(logger, $"Получено содержимое каталога {dirUri}");
                }
                await LoadQuotaAsync();
            }
            catch (Exception e)
            {
                LogController.Error(logger, e, $"Ошибка, не удалось получить содержимое каталога {dirUri}");
            }

            Progress_Stop();

            return(list);
        }
示例#14
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            jQuery.RequestDnnPluginsRegistration();

            btnClear.Click  += BtnClearClick;
            btnDelete.Click += BtnDeleteClick;
            btnEmail.Click  += BtnEmailClick;
            ddlLogType.SelectedIndexChanged        += DdlLogTypeSelectedIndexChanged;
            ddlPortalid.SelectedIndexChanged       += DdlPortalIDSelectedIndexChanged;
            ddlRecordsPerPage.SelectedIndexChanged += DdlRecordsPerPageSelectedIndexChanged;

            if (Request.QueryString["CurrentPage"] != null)
            {
                _pageIndex = Convert.ToInt32(Request.QueryString["CurrentPage"]);
            }

            var logController = new LogController();

            _logTypeDictionary = logController.GetLogTypeInfoDictionary();
        }
 //
 public static string get(CoreController core)
 {
     try {
         var result_guid = new StringBuilderLegacyController();
         result_guid.add(AdminUIController.getHeaderTitleDescription("Create GUID", "Use this tool to create a GUID. This is useful when creating new Addons."));
         //
         // Process the form
         string Button = core.docProperties.getText("button");
         if (Button.Equals(ButtonCancel))
         {
             return(string.Empty);
         }
         //
         result_guid.add(HtmlController.inputText_Legacy(core, "GUID", GenericController.getGUID(), 1, 80));
         //
         // Display form
         return(AdminUIController.getToolForm(core, result_guid.text, ButtonCancel + "," + ButtonCreateGUId));
     } catch (Exception ex) {
         LogController.logError(core, ex);
         return(string.Empty);
     }
 }
示例#16
0
        public MainWindow()
        {
            _logController = new LogController();
            LoadApplicationModule();
            _applicationModule?.AddData("DeviceLog is currently initializing...");

            InitializeComponent();
            StringVariables stringVariables = new StringVariables
            {
                CancelButtonText      = "Cancel",
                DownloadButtonText    = "Download",
                InformationButtonText = "Information",
                NoNewVersionText      = "You are running the latest version!",
                TitleText             = "DeviceLog",
                UpdateNowText         = "Would you like to update the application now?"
            };

            _updateManager = new UpdateManager.Classes.UpdateManager(Assembly.GetExecutingAssembly().GetName().Version, "https://codedead.com/Software/DeviceLog/update.xml", stringVariables);

            LoadKeyBoardModule();
            LoadClipboardModule();
            LoadFileSystemModule();

            LoadTheme();

            try
            {
                if (Properties.Settings.Default.AutoUpdate)
                {
                    _updateManager.CheckForUpdate(false, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "DeviceLog", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            _applicationModule?.AddData("DeviceLog is done initializing.");
        }
示例#17
0
        public async Task CreateApp()
        {
            AppController appController = new AppController();

            var a = await appController.Put(new LogServer.Web.Models.App
            {
                Name     = "Sample",
                Platform = "iOS"
            });

            LogController logController = new LogController();

            //Assert.AreNotEqual(appController.DIScope, logController.DIScope);

            await logController.Put(a.AppID, a.AppPushKey, new LogInfo
            {
                Application = "Sample",

                Title  = "Title",
                Detail = "Description",
                Device = "Log",
                User   = "******"
            });

            await logController.Put(a.AppID, a.AppPushKey, new LogInfo
            {
                Application = "Sample",

                Title  = "Title",
                Detail = "Description",
                Device = "Log",
                User   = "******"
            });

            await logController.Clean();

            Assert.Equal(a.AppID, 1);
        }
示例#18
0
        public void shoud_get_all_logs()
        {
            var logServiceMock = new Mock <ILogService>();
            var mapperMock     = new Mock <IMapper>();

            var logList = new List <Log>()
            {
                new Log()
                {
                    Id          = 1,
                    Name        = "Log_Name",
                    Description = "Log_Description",
                    Environment = "dev",
                    Type        = "Error",
                    UserId      = 1
                },
                new Log()
                {
                    Id          = 2,
                    Name        = "Log_Name",
                    Description = "Log_Description",
                    Environment = "dev",
                    Type        = "Dev",
                    UserId      = 2
                }
            };

            logServiceMock.Setup(x => x.GetAll(It.IsAny <string?>(), It.IsAny <string?>(), It.IsAny <int?>())).Returns(logList);

            var logController = new LogController(logServiceMock.Object, mapperMock.Object);

            var expectedLogList = logController.GetAll(It.IsAny <string?>(), It.IsAny <string?>(), It.IsAny <int?>());

            var result = expectedLogList.Result as OkObjectResult;

            Assert.NotNull(result);
            Assert.Equal(200, result.StatusCode);
        }
示例#19
0
        public void GetDeliveryStatus(BatchMessage batchMessage)
        {
            try
            {
                if (string.IsNullOrEmpty(batchMessage.Receivers.First().ReturnID) || batchMessage.Receivers.First().DeliveryGetTime > DateTime.Now)
                {
                    return;
                }

                foreach (InProgressSms receiver in batchMessage.Receivers)
                {
                    LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("{0}->{1}->returnId:{2}{3}", receiver.RecipientNumber, receiver.DeliveryStatus, receiver.ReturnID, Environment.NewLine));
                }

                Cls_SMS.ClsStatus sms     = new Cls_SMS.ClsStatus();
                ArrayList         Arr_Res = new ArrayList();
                Arr_Res = sms.StatusSMS(batchMessage.Username, batchMessage.Password, batchMessage.SendLink, batchMessage.Domain, batchMessage.Domain + "+" + batchMessage.Receivers.First().ReturnID);
                string str = string.Empty;
                for (int i = 0; i < Arr_Res.Count; i++)
                {
                    Cls_SMS.ClsStatus.STC_SMSStatus tt = (Cls_SMS.ClsStatus.STC_SMSStatus)Arr_Res[i];
                    LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("{0}{1}{2}", tt.ReceiveNumber, tt.DeliveryStatus, Environment.NewLine));

                    batchMessage.Receivers.Where(receiver => receiver.RecipientNumber == Helper.GetLocalMobileNumber(tt.ReceiveNumber)).FirstOrDefault().DeliveryStatus = (int)GetDeliveryStatus(tt.DeliveryStatus);
                    //numberStatus.Where(item => item.RecipientNumber == Helper.GetLocalMobileNumber(tt.ReceiveNumber)).First().DeliveryStatus = GetDeliveryStatus(tt.DeliveryStatus);
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\n<--<--<--<--<--<--<--<--<--<--<--"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\nGetDeleviry : StackTrace : {0}", ex.StackTrace));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\nGetDeleviry : Message : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.DeliverySms, string.Format("\r\n<--<--<--<--<--<--<--<--<--<--<--"));
            }
        }
示例#20
0
        private void CalculateGiveBackMessages(Guid guid, string id, SendStatus sendStatus)
        {
            try
            {
                switch (sendStatus)
                {
                case SendStatus.Stored:
                case SendStatus.WatingForSend:
                case SendStatus.IsBeingSent:
                    Facade.Outbox.CheckReceiverCount(guid);
                    break;

                case SendStatus.Sent:
                    Facade.Outbox.GiveBackBlackListAndFailedSend(guid);
                    //Facade.Outbox.AddBlackListNumbersToTable(guid);
                    break;

                case SendStatus.SentAndGiveBackCredit:
                    Facade.Outbox.ArchiveNumbers(guid);
                    break;

                case SendStatus.Archiving:
                    //ArchiveSendReportFile(id);
                    Facade.OutboxNumber.DeleteNumbers(guid);
                    break;
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.GiveBackCredit, string.Format("\r\n-------------------------------------------------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.GiveBackCredit, string.Format("\r\n CalculateGiveBackMessages : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.GiveBackCredit, string.Format("\r\n CalculateGiveBackMessages : {0}", ex.StackTrace));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.GiveBackCredit, string.Format("\r\n-------------------------------------------------------------------------"));
            }
        }
示例#21
0
        /// <summary>
        /// 下载研发预留单
        /// </summary>
        /// <param name="OrgCode"></param>
        /// <param name="billNo"></param>
        /// <returns></returns>
        public virtual Result DownloadYfBill(string OrgCode, string factory, string billNo)
        {
            Result rs = new Result();

            try
            {
                var list = DownloadYfWipIssueBill(OrgCode, factory, billNo);
                if (billNo.IsNotEmpty() && list.Count() <= 0)
                {
                    rs.Success = false;
                    rs.Message = "找不到研发预留单:" + billNo;
                    return(rs);
                }
                foreach (var bill in list)
                {
                    try
                    {
                        SaveOrUpdateYfbill(bill);
                    }
                    catch (Exception ex)
                    {
                        LogController.Error("研发预留单下载异常: ", "预留单号:[{0}]".FormatArgs(bill.No), ex.GetBaseException().Message);
                        if (billNo.IsNotEmpty())//单个下载 把异常抛出到界面
                        {
                            throw ex;
                        }
                    }
                }
                rs.Success = true;
                return(rs);
            }
            catch (Exception ex)
            {
                rs.Success = false;
                rs.Message = ex.Message;
                return(rs);
            }
        }
示例#22
0
        public static long GetCommentsCount(Guid applicationId, Guid?postId, Guid?senderUserId)
        {
            string spName = GetFullyQualifiedName("GetCommentsCount");

            try
            {
                if (postId == Guid.Empty)
                {
                    postId = null;
                }
                if (senderUserId == Guid.Empty)
                {
                    senderUserId = null;
                }

                return(ProviderUtil.succeed_long(ProviderUtil.execute_reader(spName, applicationId, postId, senderUserId)));
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.SH);
                return(-1);
            }
        }
示例#23
0
        protected override void OnStop()
        {
            try
            {
                if (deliveryThread != null)
                {
                    deliveryThread.Stop();
                }

                if (gcThread != null)
                {
                    gcThread.Stop();
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.SendSms, string.Format("\r\n------------------OnStop-------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.SendSms, string.Format("On Stop GetDeliverySmsService : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.SendSms, string.Format("\r\n--------------------------------------------------------"));
            }
        }
 /// <summary>
 /// Determines whether the specified item text is selected.
 /// </summary>
 /// <param name="controlHandle">The control handle.</param>
 /// <param name="itemText">The item text.</param>
 /// <returns>
 ///   <c>true</c> if the specified item text is selected; otherwise, <c>false</c>.
 /// </returns>
 /// <exception cref="ProdOperationException">Examine inner exception</exception>
 public static bool TabIsSelected(IntPtr controlHandle, string itemText)
 {
     try
     {
         AutomationElement   control = CommonUIAPatternHelpers.Prologue(SelectionPattern.Pattern, controlHandle);
         AutomationElement[] element = SelectionPatternHelper.GetSelection(control);
         bool retVal = (SelectionItemPatternHelper.FindItemByText(control, itemText).Current.FrameworkId == element[0].Current.FrameworkId);
         LogController.ReceiveLogMessage(new LogMessage(retVal.ToString()));
         return(retVal);
     }
     catch (InvalidOperationException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ElementNotAvailableException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
     catch (ArgumentException err)
     {
         throw new ProdOperationException(err.Message, err);
     }
 }
示例#25
0
        private static void _remove_all_docs(Guid applicationId)
        {
            try
            {
                IndexWriter writer;
                //Delete from Ram
                if (RaaiVanSettings.IndexUpdate.Ram(applicationId))
                {
                    writer = _create_writer(applicationId, true);
                    writer.DeleteAll();
                    _close_writer(applicationId, ref writer);
                }

                //Delete from Hard
                writer = _create_writer(applicationId, false);
                writer.DeleteAll();
                _close_writer(applicationId, ref writer);
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, "RemoveAllIndexDocuments", ex, ModuleIdentifier.SRCH);
            }
        }
示例#26
0
        public static void GetThreads(Guid applicationId, ref List <ThreadInfo> threads, Guid userId, int?count, int?lastId)
        {
            string spName = GetFullyQualifiedName("GetThreads");

            try
            {
                if (lastId <= 0)
                {
                    lastId = null;
                }
                if (count <= 0)
                {
                    count = null;
                }

                IDataReader reader = ProviderUtil.execute_reader(spName, applicationId, userId, count, lastId);
                _parse_threads(ref reader, ref threads);
            }
            catch (Exception ex)
            {
                LogController.save_error_log(applicationId, null, spName, ex, ModuleIdentifier.MSG);
            }
        }
        protected override void OnStop()
        {
            try
            {
                if (exportThread != null)
                {
                    exportThread.Stop();
                }

                if (gcThread != null)
                {
                    gcThread.Stop();
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.ExportData, string.Format("\r\n------------------OnStop-------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.ExportData, string.Format("On Stop ExportDataService : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.ExportData, string.Format("\r\n--------------------------------------------------------"));
            }
        }
        protected override void OnStop()
        {
            try
            {
                if (aradSendThread != null)
                {
                    aradSendThread.Stop();
                }

                if (gcThread != null)
                {
                    gcThread.Stop();
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.Arad, string.Format("\r\n------------------OnStop-------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.Arad, string.Format("On Stop AradSmsSenderService : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.Arad, string.Format("\r\n--------------------------------------------------------"));
            }
        }
示例#29
0
        /// <summary>
        /// Set value of control
        /// </summary>
        /// <param name="controlHandle">NativeWindowHandle to the target control</param>
        /// <param name="value">The value to set the slider to.</param>
        /// <exception cref="ProdOperationException">Examine inner exception</exception>
        /// <remarks>
        /// Invalid for WPF controls
        /// </remarks>
        public static void SliderSetValue(IntPtr controlHandle, double value)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(RangeValuePattern.Pattern, controlHandle);
                StaticEvents.RegisterEvent(RangeValuePattern.ValueProperty, control);

                RangeValuePatternHelper.SetValue(control, value);
                LogController.ReceiveLogMessage(new LogMessage(control.Current.Name));
            }
            catch (InvalidOperationException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
示例#30
0
        /// <summary>
        /// Gets the control-specific large-change value which is added to or subtracted from the Value property
        /// </summary>
        /// <param name="controlHandle">The target controls handle.</param>
        /// <returns>
        /// The large-change value or null if the element does not support LargeChange
        /// </returns>
        /// <exception cref="ProdOperationException">Examine inner exception</exception>
        public static double SliderGetLargeChange(IntPtr controlHandle)
        {
            try
            {
                AutomationElement control = CommonUIAPatternHelpers.Prologue(RangeValuePattern.Pattern, controlHandle);

                double retVal = RangeValuePatternHelper.GetLargeChange(control);
                LogController.ReceiveLogMessage(new LogMessage(control.Current.Name + " Value: " + retVal));
                return(retVal);
            }
            catch (InvalidOperationException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ElementNotAvailableException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
            catch (ArgumentException err)
            {
                throw new ProdOperationException(err.Message, err);
            }
        }
示例#31
0
        protected override void OnStop()
        {
            try
            {
                if (parserThread != null)
                {
                    parserThread.Stop();
                }

                if (gcThread != null)
                {
                    gcThread.Stop();
                }
            }
            catch (Exception ex)
            {
                LogController <ServiceLogs> .LogInFile(ServiceLogs.SmsParser, string.Format("\r\n------------------OnStop-------------------------------"));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.SmsParser, string.Format("On Stop MessageParserService : {0}", ex.Message));

                LogController <ServiceLogs> .LogInFile(ServiceLogs.SmsParser, string.Format("\r\n--------------------------------------------------------"));
            }
        }
        /// <summary>
        /// Uses a PIR motion sensor, a Proximity sensor and a Photovoltaic sensor
        /// </summary>
        /// <param name="bathroom">The bathroom where the device is implanted</param>
        private static void ProcessDeviceMethod1(Bathroom bathroom)
        {
            Device device = bathroom.PhotonDevice;
            // Milliseconds elapsed since the last time the PIR sensor reported status change
            TimeSpan PIRSpan;
            int PIRMs;
            // Milliseconds elapsed since the last time the Photo sensor reported status change
            TimeSpan PhotoSpan;
            int PhotoMs;
            // Milliseconds elapsed since the last time the Proximity sensor reported status change
            TimeSpan ProximitySpan;
            int ProximityMs;

            int PIRSecondsRequiredToOccupy = int.Parse(ConfigurationManager.AppSettings[Constants.PIRSecondsRequiredToOccupy]);
            int PIRSecondsRequiredToFree = int.Parse(ConfigurationManager.AppSettings[Constants.PIRSecondsRequiredToFree]);
            int lightOnThreshold = int.Parse(ConfigurationManager.AppSettings[Constants.LightOnThreshold]);
            int proximityThreshold = int.Parse(ConfigurationManager.AppSettings[Constants.ProximityThreshold]);
            LogController lC = new LogController();

            while (true)
            {
                PIRSpan = DateTime.Now - device.LastPIRReportTime;
                PIRMs = (int)PIRSpan.TotalMilliseconds;

                PhotoSpan = DateTime.Now - device.LastPhotoReportTime;
                PhotoMs = (int)PhotoSpan.TotalMilliseconds;

                ProximitySpan = DateTime.Now - device.LastProximityReportTime;
                ProximityMs = (int)ProximitySpan.TotalMilliseconds;

                // If there is a person close the proximity sensor, the bath is occupied
                if (device.ProximityValue < proximityThreshold)
                {
                    if (!bathroom.IsOccupied && ProximityMs > 3000)
                    {
                        lC.LogStateChange(bathroom.ID, true);
                    }
                }
                // If the Proximity Sensor was not helpful to determine the bath status
                else
                {
                    // Avoid changing the state when the user is moving from the WC area to the basin area
                    if (ProximityMs > 5000)
                    {
                        // If there is movement and the light was turned on a few seconds ago, the bath is occupied
                        if (device.PIRSensorValue == 1 && device.PhotoSensorValue >= lightOnThreshold && PhotoMs < 3000)
                        {
                            if (!bathroom.IsOccupied)
                            {
                                lC.LogStateChange(bathroom.ID, true);
                            }
                        }
                        // If there is not movement and the light is off, the bath is free
                        else if (device.PIRSensorValue == 0 && device.PhotoSensorValue < lightOnThreshold)
                        {
                            if (bathroom.IsOccupied)
                            {
                                lC.LogStateChange(bathroom.ID, false);
                            }
                        }
                        // If the PhotoSensor was not helpful to determine the bath status
                        else
                        {
                            // If the device is reporting '1' and the bathroom is free
                            if (device.PIRSensorValue == 1 && !bathroom.IsOccupied)
                            {
                                // Avoid logging the state change more than once in a row
                                if (device.LastPIRReportTime > bathroom.LastOccupiedTime)
                                {
                                    // If some seconds have passed with uninterrupted 'true' state
                                    if (PIRMs > PIRSecondsRequiredToOccupy * 1000)
                                    {
                                        lC.LogStateChange(bathroom.ID, true);
                                    }
                                }
                            }
                            // If the device is reporting '0' and the bathroom is occupied
                            else if (device.PIRSensorValue == 0 && bathroom.IsOccupied)
                            {
                                // Avoid logging the state change more than once in a row
                                if (device.LastPIRReportTime > bathroom.LastFreedTime)
                                {
                                    // If some seconds have passed with a uninterrupted 'false' state
                                    if (PIRMs > PIRSecondsRequiredToFree * 1000)
                                    {
                                        lC.LogStateChange(bathroom.ID, false);
                                    }
                                }
                            }
                        }
                    }
                }

                Thread.Sleep(2000);
            }
        }
 private void InitializeController()
 {
     _logController = new LogController(_mockLogBusiness.Object, _mockSetBusiness.Object);
 }