public OperationResult<DateTime> GetMinJournalDateTime(Guid clientUID) { using (var dbService = new DbService()) { return dbService.JournalTranslator.GetMinDate(); } }
public JournalTranslator(DbService dbService) { DbService = dbService; Context = DbService.Context; JournalSynchroniser = new JounalSynchroniser(dbService); PassJournalSynchroniser = new PassJounalSynchroniser(dbService); }
public OperationResult<List<JournalItem>> GetFilteredJournalItems(Guid clientUID, JournalFilter filter) { using (var dbService = new RubezhDAL.DataClasses.DbService()) { return dbService.JournalTranslator.GetFilteredJournalItems(filter); } }
public static void EditUser(List<byte> bytes) { var imitatorUser = ImitatorUserFromBytes(bytes); var packNo = BytesHelper.SubstructShort(bytes, 255); using (var dbService = new DbService()) { dbService.ImitatorUserTraslator.Edit(imitatorUser); } }
public UsersViewModel() { Title = "Пользователи прибора"; using(var dbService = new DbService()) { var users = dbService.ImitatorUserTraslator.Get(); Users = new ObservableCollection<ImitatorUser>(users); } }
public static void Run() { try { Notifier.SetNotifier(new RubezhNotifier()); Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); ServiceBootstrapper.Run(); Logger.Trace(SystemInfo.GetString()); RubezhService.Service.RubezhService.ServerState = ServerState.Starting; LogPresenter.AddLog("Проверка лицензии"); if (!RubezhLicenseProcessor.TryLoadLicense()) LogPresenter.AddLog("Ошибка лицензии", true); LicensePresenter.Initialize(); LogPresenter.AddLog("Проверка соединения с БД"); using (var dbService = new DbService()) { if (dbService.CheckConnection().HasError) LogPresenter.AddLog("Ошибка соединения с БД", true); } LogPresenter.AddLog("Загрузка конфигурации"); ConfigurationCashHelper.Update(); if (UACHelper.IsAdministrator) { LogPresenter.AddLog("Открытие хоста"); RubezhServiceManager.Open(false); GKProcessor.Create(); LogPresenter.AddLog("Запуск ГК"); GKPresenter.Initialize(); GKProcessor.Start(); AutomationProcessor.Start(); ScheduleRunner.Start(); ServerTaskRunner.Start(); AutomationProcessor.RunOnApplicationRun(); ClientsManager.StartRemoveInactiveClients(TimeSpan.FromDays(1)); LogPresenter.AddLog("Готово"); } else LogPresenter.AddLog("Для запуска сервера требуются права администратора", true); RubezhService.Service.RubezhService.ServerState = ServerState.Ready; } catch (Exception e) { Logger.Error(e, "Исключение при вызове Bootstrapper.Run"); LogPresenter.AddLog("Ошибка при запуске сервера", true); Close(); } }
public SchedulesViewModel() { Title = "Графики работ прибора"; using (var dbService = new DbService()) { var schedules = dbService.ImitatorScheduleTranslator.Get(); schedules.ForEach(x => x.ImitatorSheduleIntervals = x.ImitatorSheduleIntervals.OrderBy(y => y.StartSeconds).ToList()); Schedules = new ObservableCollection<ImitatorSchedule>(schedules); } }
public OperationResult<bool> BeginGetJournal(JournalFilter filter, Guid clientUid, Guid journalClientUid) { ServerTaskRunner.Add(null, "Чтение журнала событий", () => { using (var dbService = new RubezhDAL.DataClasses.DbService()) { var result = dbService.JournalTranslator.GetFilteredJournalItems(filter); RubezhService.NotifyOperationResult_GetJournal(result, clientUid, journalClientUid); } }); return new OperationResult<bool>(true); }
public static void AddCommonJournalItems(List<JournalItem> journalItems, Guid? clientUID) { using (var databaseService = new RubezhDAL.DataClasses.DbService()) { databaseService.JournalTranslator.AddRange(journalItems); } RubezhService.NotifyJournalItems(journalItems, true); var user = clientUID.HasValue ? ConfigurationCashHelper.SecurityConfiguration.Users.FirstOrDefault(x => x.Login == GetLogin(clientUID.Value)) : null; foreach (var journalItem in journalItems) { AutomationProcessor.RunOnJournal(journalItem, user, clientUID ?? UID); } }
public static ImitatorJournalItem GetByGKNo(int gkNo) { ImitatorJournalItem imitatorJournalItem; lock (lockObject) { imitatorJournalItem = ImitatorJournalItems.FirstOrDefault(x => x.GkNo == gkNo); } if (imitatorJournalItem == null) { using (var dbService = new DbService()) { imitatorJournalItem = dbService.ImitatorJournalTranslator.GetByGKNo(gkNo); } } return imitatorJournalItem; }
static JournalCash() { ImitatorJournalItems = new List<ImitatorJournalItem>(); using (var dbService = new DbService()) { Count = dbService.ImitatorJournalTranslator.GetCount(); } for (int i = Math.Max(1, Count - 1000); i < Count; i++) { using (var dbService = new DbService()) { var imitatorJournalItem = dbService.ImitatorJournalTranslator.GetByGKNo(i); if (imitatorJournalItem != null) { ImitatorJournalItems.Add(imitatorJournalItem); } } } }
public static void EditShedule(List<byte> bytes) { var imitatorSchedule = new ImitatorSchedule(); imitatorSchedule.No = bytes[0]; imitatorSchedule.Name = BytesHelper.BytesToStringDescription(bytes, 1); imitatorSchedule.HolidayScheduleNo = bytes[33]; imitatorSchedule.PartsCount = BytesHelper.SubstructShort(bytes, 34); imitatorSchedule.TotalSeconds = BytesHelper.SubstructInt(bytes, 36); imitatorSchedule.WorkHolidayScheduleNo = bytes[40]; for (int i = 0; i < imitatorSchedule.PartsCount / 2; i++) { var imitatorSheduleInterval = new ImitatorSheduleInterval(); imitatorSheduleInterval.StartSeconds = BytesHelper.SubstructInt(bytes, 48 + i * 8); imitatorSheduleInterval.EndSeconds = BytesHelper.SubstructInt(bytes, 52 + i * 8); imitatorSchedule.ImitatorSheduleIntervals.Add(imitatorSheduleInterval); } using (var dbService = new DbService()) { dbService.ImitatorScheduleTranslator.AddOrEdit(imitatorSchedule); } }
private static bool IsInSchedule(DbService dbService, int scheduleNo) { var timeSpan = DateTime.Now - new DateTime(2000, 1, 1); var nowTotalSeconds = timeSpan.TotalSeconds; var schedule = dbService.ImitatorScheduleTranslator.GetByNo(scheduleNo); if (schedule != null) { foreach (var imitatorSheduleInterval in schedule.ImitatorSheduleIntervals) { var delta = 0; if (schedule.TotalSeconds > 0) { var periodsCount = (nowTotalSeconds - imitatorSheduleInterval.StartSeconds) / schedule.TotalSeconds; delta = (int)periodsCount * schedule.TotalSeconds; } if (nowTotalSeconds > imitatorSheduleInterval.StartSeconds + delta || nowTotalSeconds < imitatorSheduleInterval.EndSeconds + delta) { return true; } } } return false; }
public GKMetadataTranslator(DbService databaseService) { Context = databaseService.Context; }
public string Test(Guid clientUID, string arg) { using (var databaseService = new RubezhDAL.DataClasses.DbService()) { databaseService.PassJournalTranslator.InsertPassJournalTestData(); } return "Test"; }
public GKScheduleTranslator(DbService context) { DbService = context; Context = DbService.Context; }
public OperationResult<int> GetArchiveCount(Guid clientUID, JournalFilter filter) { using (var dbService = new RubezhDAL.DataClasses.DbService()) { return dbService.JournalTranslator.GetArchiveCount(filter); } }
public GKCardTranslator(DbService databaseService) { Context = databaseService.Context; }
public void AddJournalItem(ImitatorJournalItem journalItem) { journalItem.UNUSED_KauNo = 0; journalItem.UNUSED_KauAddress = 0; journalItem.GkObjectNo = GKBaseDescriptor.GetDescriptorNo(); journalItem.ObjectState = StatesToInt(); if (GKBaseDescriptor.GKBase is GKDevice) { journalItem.ObjectDeviceType = (short)(GKBaseDescriptor.GKBase as GKDevice).Driver.DriverTypeNo; journalItem.ObjectDeviceAddress = (short)(((GKBaseDescriptor.GKBase as GKDevice).ShleifNo - 1) * 256 + (GKBaseDescriptor.GKBase as GKDevice).IntAddress); } using (var dbService = new DbService()) { dbService.ImitatorJournalTranslator.Add(journalItem); } JournalCash.Add(journalItem); }
public CurrentConsumptionTranslator(DbService dbService) { DbService = dbService; }
public NightSettingTranslator(DbService context) { DbService = context; }
public ImitatorScheduleTranslator(DbService dbService) { DbService = dbService; }
public OperationResult<bool> ResetDB(Guid clientUID) { using (var databaseService = new RubezhDAL.DataClasses.DbService()) { return databaseService.ResetDB(); } }
public static void Run() { try { Notifier.SetNotifier(new RubezhNotifier()); ServiceBootstrapper.Run(); Environment.CurrentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Logger.Trace(SystemInfo.GetString()); Service.RubezhService.ServerState = ServerState.Starting; UILogger.Log("Проверка лицензии"); if (!RubezhLicenseProcessor.TryLoadLicense()) UILogger.Log("Ошибка лицензии", true); UILogger.Log("Проверка соединения с БД"); using (var dbService = new DbService()) { if (dbService.CheckConnection().HasError) UILogger.Log("Ошибка соединения с БД", true); } UILogger.Log("Загрузка конфигурации"); ConfigurationCashHelper.Update(); UILogger.Log("Открытие хоста"); RubezhServiceManager.Open(); //ServerLoadHelper.SetStatus(FSServerState.Opened); OpcDaHelper.Initialize(ConfigurationCashHelper.SystemConfiguration.AutomationConfiguration.OpcDaTsServers, ReadTagValue, WriteTagValue); GKProcessor.Create(); UILogger.Log("Запуск ГК"); GKProcessor.Start(); UILogger.Log("Запуск сервиса отчетов"); /*if (ReportServiceManager.Run()) { UILogger.Log("Сервис отчетов запущен: " + ConnectionSettingsManager.ReportServerAddress); MainView.Current.SetReportAddress(ConnectionSettingsManager.ReportServerAddress); } else { UILogger.Log("Ошибка при запуске сервиса отчетов", true); MainView.Current.SetReportAddress("<Ошибка>"); }*/ AutomationProcessor.Start(); ScheduleRunner.Start(); ServerTaskRunner.Start(); AutomationProcessor.RunOnApplicationRun(); ClientsManager.StartRemoveInactiveClients(TimeSpan.FromDays(1)); UILogger.Log("Запуск OPC DA"); OpcDaServersProcessor.Start(); UILogger.Log("Готово"); Service.RubezhService.ServerState = ServerState.Ready; } catch (Exception e) { Logger.Error(e, "Исключение при вызове Bootstrapper.Run"); UILogger.Log("Ошибка при запуске сервера", true); Close(); } }
public PassJounalSynchroniser(DbService dbService) { _context = dbService.Context; }
public TimeTrackDocumentTypeTranslator(DbService dbService) { Context = dbService.Context; }
public OperationResult<bool> BeginGetArchivePage(JournalFilter filter, int page, Guid clientUid, string userName) { ServerTaskRunner.Add(null, "Чтение архива", () => { using (var dbService = new RubezhDAL.DataClasses.DbService()) { var result = dbService.JournalTranslator.GetArchivePage(filter, page); RubezhService.NotifyOperationResult_GetArchivePage(result, clientUid, userName); } }); return new OperationResult<bool>(true); }
static Tuple<ImitatorUser, bool> GetUserAccess(uint currentCardNo, FormulaOperation formulaOperation, DescriptorViewModel descriptorViewModel) { var isAccess = false; var level = formulaOperation.FirstOperand; ImitatorUser user = null; var device = descriptorViewModel.GKBase as GKDevice; if (device != null && (device.Driver.IsCardReaderOrCodeReader)) { using (var dbService = new DbService()) { user = dbService.ImitatorUserTraslator.GetByNo(currentCardNo); if (user != null) { if (user.Level >= level) { if (IsInSchedule(dbService, user.ScheduleNo)) isAccess = true; } foreach (var imitatorUserDevice in user.ImitatorUserDevices) { if (imitatorUserDevice.DescriptorNo == formulaOperation.SecondOperand) { if (IsInSchedule(dbService, imitatorUserDevice.ScheduleNo)) isAccess = true; } } } } } return new Tuple<ImitatorUser, bool>(user, isAccess); }
public TimeTrackDocumentTranslator(DbService databaseService) { Context = databaseService.Context; }
public ImitatorUserTraslator(DbService dbService) { DbService = dbService; }