public IList <CreateOrEditDataChamCongDto> GetDataChamCongAll() { IList <CreateOrEditDataChamCongDto> result = new List <CreateOrEditDataChamCongDto>(); var configs = AppConfigSection.GetInstance(); if (configs.Device.Enable) { LogUtils.WirteLogInfo("Schedule Get Data From Device Start"); AbriDoorSDK.Instance.Connect_Net(configs.Device.DeviceAddress, configs.Device.Port); int dwTMachineNumber = 0, dwEnrollNumber = 0, dwEMachineNumber = 0, dwVerifyMode = 0, dwInOutMode = 0, dwYear = 0, dwMonth = 0, dwDay = 0, dwHour = 0, dwMinute = 0; AbriDoorSDK.Instance.ReadAllGLogData(); while (AbriDoorSDK.Instance.GetAllGLogData(ref dwTMachineNumber, ref dwEnrollNumber, ref dwEMachineNumber, ref dwVerifyMode, ref dwInOutMode, ref dwYear, ref dwMonth, ref dwDay, ref dwHour, ref dwMinute)) { var timekeepingDate = new DateTime(dwYear, dwMonth, dwDay, dwHour, dwMinute, 0); var dataChamCong = new CreateOrEditDataChamCongDto(); dataChamCong.MaChamCong = dwEnrollNumber; dataChamCong.TimeCheck = timekeepingDate.ToString(BaseConfig.FormatDate); result.Add(dataChamCong); } AbriDoorSDK.Instance.Disconnect(); LogUtils.WirteLogInfo($"Schedule Get Data From Device End - Count: {result.Count}"); } return(result); }
public void StartAsync() { var configs = AppConfigSection.GetInstance(); if (configs.Scheduler.Enable) { TimeSpan time; if (TimeSpan.TryParse(configs.Scheduler.TimeStartJob, out time)) { // construct a scheduler factory ISchedulerFactory schedulerFactory = new StdSchedulerFactory(); // get a scheduler, start the schedular before triggers or anything else scheduler = schedulerFactory.GetScheduler(); scheduler.Start(); IJobDetail job = JobBuilder.Create <DeviceJob>() .WithIdentity("DeviceJob", "DeviceChamCong") .Build(); ITrigger trigger = TriggerBuilder.Create() .WithIdentity("DeviceTrigger", "DeviceChamCong") .StartAt(DateBuilder.TodayAt(time.Hours, time.Minutes, time.Seconds)) .WithSimpleSchedule(schedule => { schedule.RepeatForever() .WithIntervalInHours(configs.Scheduler.HoursRepeat); }) .Build(); scheduler.ScheduleJob(job, trigger); } } }
static async Task Main() { var config = AppConfigSection.GetInstance(); if (config.AppMode) { // Kiểm tra xem đã có instance nào đang chạy hay không string current = Process.GetCurrentProcess().ProcessName; Process[] procs = Process.GetProcessesByName(current); if (procs.Length > 1) { Application.ExitThread(); Application.Exit(); SchedulerUtils.Instance.ShutdownAsync(); return; } AppDomain.CurrentDomain.UnhandledException += AppDomain_UnhandledException; Application.ThreadException += Application_ThreadException; try { SchedulerUtils.Instance.StartAsync(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain()); } catch (Exception ex) { Cursor.Current = Cursors.Default; HandleException(ex); return; } } else { try { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new AbrivisionDeviceService() }; ServiceBase.Run(ServicesToRun); } catch (Exception ex) { HandleException(ex); return; } } }
public ResultModel GetList(string url, int pageIndex, params ParameterModel[] parameter) { var request = new RestRequest($"{url}"); request.AddParameter("MaxResultCount", configs.WebApi.MaxResultCount.ToString()); request.AddParameter("SkipCount", (pageIndex * AppConfigSection.GetInstance().WebApi.MaxResultCount).ToString()); foreach (var param in parameter) { if (param.Value != null) { request.AddParameter(param.FieldName, param.Value); } } request.AddHeader("Content-Type", "application/json"); request.AddHeader("Accept", "application/json"); request.Method = Method.GET; Task <IRestResponse <ResultModel> > response = client.ExecuteGetTaskAsync <ResultModel>(request); response.Wait(); if (response.Result.ResponseStatus == ResponseStatus.Completed) { if (response.Result.Data.Success) { return(response.Result.Data); } else { throw new HandleException(response.Result.Data.Error); } } else { throw new HandleException(0, response.Result.Content.ToString()); } }
public WebApiHelper() { configs = AppConfigSection.GetInstance(); client = new RestClient(configs.WebApi.ServerAddress); }