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); }
private void WriteConfigSection(XmlWriter writer, AppConfigSection appConfigSection) { writer.WriteStartElement("section"); writer.WriteAttributeString("name", appConfigSection.Name); writer.WriteAttributeString("type", appConfigSection.Type); writer.WriteEndElement(); }
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); } } }
/// <summary> /// Creates an instance of master service with the specified generator and begins to accept slaves /// </summary> /// <param name="generator">Class that generates id for user</param> public UserServiceMaster(IGenerator generator) { this.IdGenerator = generator; this.collection = new List <User>(); this.formatter = new BinaryFormatter(); this.removedServices = new List <TcpClient>(); this.activeServices = new List <TcpClient>(); AppConfigSection config = AppConfigSection.GetConfigSection(); this.TuneLogger(config); this.GetRegisteredServices(config); this.listener = new TcpListener(new IPEndPoint(IPAddress.Parse(config.MasterEndPoint.Hostname), int.Parse(config.MasterEndPoint.Port))); this.listener.Start(); ThreadPool.SetMaxThreads(int.Parse(config.ThreadPool.Max), int.Parse(config.ThreadPool.Max)); ThreadPool.SetMinThreads(int.Parse(config.ThreadPool.Min), int.Parse(config.ThreadPool.Min)); new Thread(this.Listen) { IsBackground = true }.Start(); var t = new Timer(this.CheckConnection, null, 600000, 600000); }
private void GetRegisteredServices(AppConfigSection config) { int count = config.EndPoints.Count; this.registeredServices = new string[count]; for (int i = 0; i < count; i++) { this.registeredServices[i] = config.EndPoints[i].Hostname + ":" + config.EndPoints[i].Port; } }
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; } } }
private void TuneLogger(AppConfigSection config) { bool logging = string.Equals(config.Logging.Value, "true", StringComparison.InvariantCultureIgnoreCase); if (logging) { this.logAction = delegate(string str) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Info(str); }; } }
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); }
/// <summary> /// Creates a new xml storage /// </summary>> public UserStorageXml() { AppConfigSection config = AppConfigSection.GetConfigSection(); this.path = config.FilePath.Value + ".xml"; }