Ejemplo n.º 1
0
        public void Filter()
        {
            JournalRecords.Clear();

            using (var repo = new Repository()) {
                var records = repo.GetAllWhere <StudentStatusOnLesson>(s => s.Date >= SelectedDate && s.Date <= SelectedDate.AddDays(6) &&
                                                                       s.Student.Group.GroupName == SelectedGroup.GroupName &&
                                                                       s.ScheduleRecord.Subject.SubjectName == SelectedSubject.SubjectName);


                foreach (var r in records)
                {
                    JournalRecord journalRecord = JournalRecords.FirstOrDefault(j => j.Student.StudentId == r.StudentId);

                    if (journalRecord == null)
                    {
                        journalRecord         = new JournalRecord();
                        journalRecord.Student = r.Student;

                        //Заполнить статусы пустыми занчениями
                        journalRecord.Statuses =
                            new List <StudentStatusOnLesson>
                                (Enumerable.Repeat <StudentStatusOnLesson>(null, 6));
                    }

                    //Добавить статус в нужную ячейку
                    journalRecord.Statuses.Insert(r.ScheduleRecord.DayOfWeek - 1, r);

                    JournalRecords.Add(journalRecord);
                }
            }
        }
Ejemplo n.º 2
0
        private void journalRecordsButton_Click(object sender, EventArgs e)
        {
            JournalRecord journal = new JournalRecord(user, status);

            journal.Show();
            this.Hide();
        }
 public BORecordJournalEntry(Accountant accountant, JournalRecord data, BOContext context)
     : base(accountant, context)
 {
     mObjectID   = BOType.BORecordJournalEntry;
     mDataProxy  = data.Clone() as JournalRecord;
     mDataSource = data;
 }
Ejemplo n.º 4
0
        private IEnumerable <JournalRecord> GetJournalRecords()
        {
            var journalRecords = new List <JournalRecord>();

            using (var connection = new NpgsqlConnection(_provider.Settings.ConnectionString))
                using (var command = connection.CreateCommand())
                {
                    connection.Open();

                    command.CommandText = string.Format(
                        "SELECT id, written FROM {0} ORDER BY id ASC;",
                        _provider.Settings.Table);

                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var journalRecord = new JournalRecord((long)reader[0], (DateTime)reader[1], null);

                            journalRecords.Add(journalRecord);
                        }
                    }
                }

            return(journalRecords);
        }
Ejemplo n.º 5
0
        public IEnumerable <JournalRecord> GetRecords(long fromRecord = 0)
        {
            var endStreamCut = GetEndStreamCut();

            _lastEventReadHandler.Invoke(endStreamCut);

            var request = new ReadEventsRequest
            {
                Scope       = _scope,
                Stream      = _stream,
                ToStreamCut = endStreamCut
            };

            var recordNumber = 0;

            using var call = _client.ReadEvents(request, cancellationToken: _cancellationToken);

            var responseStream = call.ResponseStream;

            while (responseStream.MoveNext(_cancellationToken).GetAwaiter().GetResult())
            {
                if (recordNumber <= fromRecord)
                {
                    continue;
                }
                var @event      = responseStream.Current;
                var bytes       = @event.Event.ToByteArray();
                var savedRecord = (JournalRecord)_serializer.Deserialize(bytes);
                var record      = new JournalRecord(recordNumber++, savedRecord.Written, savedRecord.Command);
                yield return(record);
            }
        }
Ejemplo n.º 6
0
		public static void SetDeviceCatogoryAndDevieUID(JournalRecord journalRecord)
		{
			Guid deviceDatabaseUID = Guid.Empty;
			Guid.TryParse(journalRecord.DeviceDatabaseId, out deviceDatabaseUID);
			journalRecord.DeviceDatabaseUID = deviceDatabaseUID;

			Guid panelDatabaseUID = Guid.Empty;
			Guid.TryParse(journalRecord.PanelDatabaseId, out panelDatabaseUID);
			journalRecord.PanelDatabaseUID = panelDatabaseUID;

			Device device = null;
			if (ConfigurationCash.DeviceConfiguration.Devices != null)
			{
				if (journalRecord.DeviceDatabaseUID != Guid.Empty)
				{
					device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(x => x.UID == journalRecord.DeviceDatabaseUID);
				}
				else
				{
					device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(x => x.UID == journalRecord.PanelDatabaseUID);
				}
			}
			if (device != null)
			{
				journalRecord.DeviceCategory = (int)device.Driver.Category;
			}
			else
			{
				journalRecord.DeviceCategory = (int)DeviceCategoryType.None;
			}
		}
Ejemplo n.º 7
0
        public IJournalSubscription Subscribe(long @from, Action <JournalRecord> handler)
        {
            async Task MessageReceived(IStreamSubscription subscription, StreamMessage message,
                                       CancellationToken cancellationToken)
            {
                var command       = (Command)_serializer.FromString(await message.GetJsonData());
                var journalRecord = new JournalRecord(message.StreamVersion, message.CreatedUtc, command);

                handler.Invoke(journalRecord);
            }

            // pass null to subscribe from the beginning
            //or the version of the previous record
            int?version = null;

            if (from > 0)
            {
                version = (int)from - 1;
            }

            bool caughtUp = false;

            var sub = _streamStore.SubscribeToStream(
                _streamId,
                version,
                MessageReceived,
                SubscriptionDropped,
                hasCaughtUp => caughtUp = hasCaughtUp);

            sub.MaxCountPerRead = 100;

            return(new SqlStreamStoreSubscription(sub, () => caughtUp));
        }
Ejemplo n.º 8
0
        bool FilterRecord(JournalRecord journalRecord)
        {
            if (JournalFilter.Categories.IsNotNullOrEmpty())
            {
                Device device = null;
                if (string.IsNullOrWhiteSpace(journalRecord.DeviceDatabaseId) == false)
                {
                    device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == journalRecord.DeviceDatabaseId);
                }
                else
                {
                    device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == journalRecord.PanelDatabaseId);
                }

                if (device != null)
                {
                    if (JournalFilter.Categories.Any(daviceCategory => daviceCategory == device.Driver.Category) == false)
                        return false;
                }
            }

            if (JournalFilter.StateTypes.IsNotNullOrEmpty())
            {
                if (JournalFilter.StateTypes.Any(x => x == journalRecord.StateType) == false)
                    return false;
            }

            return true;
        }
Ejemplo n.º 9
0
        public JournalRecord CreateRecord(DateTime entryDate, int memberId, int commissionId, int roleId)
        {
            var journalRecordRepository = RepositoryFactory.GetJournalRecordRepository();

            var record = new JournalRecord
            {
                EntryDate        = entryDate,
                MemberId         = memberId,
                CommissionId     = commissionId,
                RoleCommissionId = roleId
            };

            journalRecordRepository.Create(record);

            try
            {
                UnitOfWork.PreSave();
            }
            catch (Exception ex)
            {
                throw new JournalServiceException(ex);
            }

            return(record);
        }
Ejemplo n.º 10
0
        public static bool AddJournalRecord(JournalRecord journalRecord)
        {
            try
            {
                using (var dataContext = ConnectionManager.CreateFiresecDataContext())
                {
                    var query =
                    "SELECT * FROM Journal WHERE " +
                    "\n SystemTime = '" + journalRecord.SystemTime.ToString("yyyy-MM-dd HH:mm:ss") + "'" +
                    "\n AND OldId = " + journalRecord.OldId.ToString();

                    var result = dataContext.ExecuteQuery<JournalRecord>(query);

                    if (result.Count() == 0)
                    {
                        dataContext.JournalRecords.InsertOnSubmit(journalRecord);
                        dataContext.SubmitChanges();
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                Logger.Error(e, "Исключение при вызове DatabaseHelper.AddJournalRecord");
            }
            return false;
        }
        public void HappyPath()
        {
            _typeMap["MyCommand"] = typeof(MyCommand);
            var command       = new MyCommand("the data");
            var now           = DateTimeOffset.Now;
            var journalRecord = new JournalRecord(32, now, command);
            var stream        = new MemoryStream();

            _target.WriteObject(stream, journalRecord);

            stream.Position = 0;
            var line = new StreamReader(stream).ReadLine();

            Console.WriteLine(line);
            Assert.AreEqual("32 " + now.ToString("o") + " " + command.Id + " MyCommand the data", line);
            stream.Position = 0;

            var clone = (JournalRecord)_target.ReadObject(stream);

            Assert.AreEqual(32, clone.RecordNumber);
            Assert.AreEqual(now, clone.Written);
            Assert.AreEqual(command.Id, clone.Command.Id);

            var clonedCommand = (MyCommand)clone.Command;

            Assert.AreEqual(command.Id, clonedCommand.Id);
            Assert.AreEqual(command.MyParameter, clonedCommand.MyParameter);
        }
Ejemplo n.º 12
0
 static void SetDeviceCatogory(JournalRecord journalRecord)
 {
     Device device = null;
     if (ConfigurationCash.DeviceConfiguration.Devices != null)
     {
         if (string.IsNullOrWhiteSpace(journalRecord.DeviceDatabaseId) == false)
         {
             device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(
                  x => x.DatabaseId == journalRecord.DeviceDatabaseId);
         }
         else
         {
             device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(
                    x => x.DatabaseId == journalRecord.PanelDatabaseId);
         }
     }
     if (device != null)
     {
         journalRecord.DeviceCategory = (int)device.Driver.Category;
     }
     else
     {
         journalRecord.DeviceCategory = (int)DeviceCategoryType.None;
     }
 }
Ejemplo n.º 13
0
        public void Execute(object parameter)
        {
            JournalRecord newRecord = new JournalRecord()
            {
                Date = StoredDate, Shift = StoredShift, WorkArea = StoredWorkArea
            };

            _uncheckedRecord.Model       = newRecord;
            _uncheckedRecord.IsNewRecord = true;
        }
Ejemplo n.º 14
0
 void OnNewJournalItemEvent(JournalRecord journalRecord)
 {
     if (journalRecord.DeviceDatabaseId != null)
     {
         SendEvent(journalRecord, journalRecord.DeviceDatabaseId);
     }
     if (journalRecord.PanelDatabaseId != null)
     {
         SendEvent(journalRecord, journalRecord.PanelDatabaseId);
     }
 }
Ejemplo n.º 15
0
        private void SendMatchingEvents(JournalRecord journalRecord, bool isLocal, IEnumerable <Event> events)
        {
            var matchingEvents = events
                                 .Where(e => _subscriptions.Values.Any(matcher => matcher.IsMatch(e)))
                                 .ToArray();

            if (matchingEvents.Length > 0)
            {
                _logger.LogTrace("Sending {0} events", matchingEvents.Length);
                OnMessage.Invoke(new EventsRaised(matchingEvents));
            }
        }
Ejemplo n.º 16
0
		void SendEvent(JournalRecord journalRecord, string dataBaseId)
		{
			var device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == dataBaseId);
			if (device != null)
			{
				var assadDevice = Configuration.Devices.FirstOrDefault(x => x.Id == device.PathId);
				if (assadDevice != null)
				{
                    string eventName = journalRecord.StateType.ToDescription();
					assadDevice.FireEvent(eventName);
				}
			}
		}
Ejemplo n.º 17
0
        public void UpdateRecord(JournalRecord record)
        {
            var journalRecordRepository = RepositoryFactory.GetJournalRecordRepository();

            try
            {
                journalRecordRepository.Update(record);
            }
            catch (RepositoryException ex)
            {
                throw new JournalServiceException(ex);
            }
        }
Ejemplo n.º 18
0
        public JournalRecordViewModel(JournalRecord journalRecord)
        {
            ShowPlanCommand = new RelayCommand(OnShowPlan, CanShowPlan);
            ShowTreeCommand = new RelayCommand(OnShowTree, CanShowTree);
            ShowZoneCommand = new RelayCommand(OnShowZone, CanShowZone);

            JournalRecord = journalRecord;

            if (string.IsNullOrWhiteSpace(journalRecord.DeviceDatabaseId) == false)
                _device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == journalRecord.DeviceDatabaseId);
            else
                _device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == journalRecord.PanelDatabaseId);
        }
Ejemplo n.º 19
0
        private async Task Run()
        {
            var recordNumber = 0;

            while (await _reader.MoveNext(_cts.Token))
            {
                var eventsResponse = _reader.Current;
                var bytes          = eventsResponse.Event.ToByteArray();
                var savedRecord    = (JournalRecord)_serializer.Deserialize(bytes);
                var record         = new JournalRecord(recordNumber++, savedRecord.Written, savedRecord.Command);
                _handler.Invoke(record);
            }
        }
Ejemplo n.º 20
0
        public async Task AddAsync_Success()
        {
            var journalRecord = new JournalRecord
            {
                AppliedAt  = DateTime.Now,
                ScriptName = "Test",
                Version    = 3
            };
            await _journalRepository.AddAsync(journalRecord);

            var lastVersion = await _journalRepository.GetLastScriptAsync();

            Assert.Equal(journalRecord.Version, lastVersion.Version);
        }
Ejemplo n.º 21
0
        public IEnumerable <JournalRecord> GetRecords(long fromRecord = 0)
        {
            using (var queue = new BlockingCollection <JournalRecord>())
            {
                async Task MessageReceived(IStreamSubscription subscription, StreamMessage message,
                                           CancellationToken cancellationToken)
                {
                    var json = await message.GetJsonData(cancellationToken);

                    var command       = (Command)_serializer.FromString(json);
                    var journalRecord = new JournalRecord(message.StreamVersion, message.CreatedUtc, command);

                    queue.Add(journalRecord);
                }

                // pass null to subscribe from the beginning
                //or the version of the previous record
                int?version = null;
                if (fromRecord > 0)
                {
                    version = (int)fromRecord - 1;
                }

                var caughtUp = false;

                using (
                    var sub = _streamStore.SubscribeToStream(
                        _streamId,
                        version,
                        MessageReceived,
                        SubscriptionDropped,
                        hasCaughtUp => caughtUp = hasCaughtUp))
                {
                    sub.MaxCountPerRead = 100;

                    while (!caughtUp || queue.Any())
                    {
                        if (queue.TryTake(out var journalRecord))
                        {
                            yield return(journalRecord);
                        }
                        else if (!caughtUp)
                        {
                            Thread.Sleep(100);
                        }
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public void Save(JournalRecord oldRecord, JournalRecord newRecord)
        {
            var entity = _ctx.JournalRecords.Single(jr => jr.Id == oldRecord.Id);

            entity.Date             = newRecord.Date;
            entity.DefectoscopeName = newRecord.DefectoscopeName;
            entity.Description      = newRecord.Description;
            entity.Employee         = newRecord.Employee;
            entity.End           = newRecord.End;
            entity.OperationName = newRecord.OperationName;
            entity.ShiftValue    = newRecord.ShiftValue;
            entity.Start         = newRecord.Start;
            entity.WorkArea      = newRecord.WorkArea;
            _ctx.SaveChanges();
        }
        public void CompareTest3()
        {
            var comparer = new JournalRecordsBeginTimeComparer();
            var today    = new DateTime().AddDays(1);
            var journalRecordForTodayStartedShift = new JournalRecord {
                Date = today, Start = TimeSpan.FromHours(9)
            };
            var journalRecordForTodayStartedShiftToo = new JournalRecord {
                Date = today, Start = TimeSpan.FromHours(7)
            };
            var actual = comparer.Compare(journalRecordForTodayStartedShift, journalRecordForTodayStartedShiftToo);

            Assert.IsTrue(actual < 0);
            actual = comparer.Compare(journalRecordForTodayStartedShiftToo, journalRecordForTodayStartedShift);
            Assert.IsTrue(actual > 0);
        }
Ejemplo n.º 24
0
        public async Task PostTest()
        {
            // Arrange
            await using (ApplicationContext context = _contextFactory.CreateDbContext())
            {
                await context.Lecturers.AddAsync(new Lecturer { FullName = "Test Lecturer" });

                await context.SaveChangesAsync();

                await context.Courses.AddRangeAsync(
                    new Course { Name = "Test Course 1", LecturerId = 1 },
                    new Course { Name = "Test Course 2", LecturerId = 1 });

                await context.SaveChangesAsync();

                await context.Lectures.AddRangeAsync(
                    new Lecture { Name = "Test Lecture 1 1", CourseId = 1 },
                    new Lecture { Name = "Test Lecture 2 1", CourseId = 1 },
                    new Lecture { Name = "Test Lecture 3 1", CourseId = 1 },
                    new Lecture { Name = "Test Lecture 1 2", CourseId = 2 },
                    new Lecture { Name = "Test Lecture 2 2", CourseId = 2 },
                    new Lecture { Name = "Test Lecture 3 2", CourseId = 2 });

                await context.SaveChangesAsync();

                await context.Students.AddRangeAsync(
                    new Student { FullName = "Test Student 1" },
                    new Student { FullName = "Test Student 2" });

                await context.SaveChangesAsync();
            }

            // Act
            var model    = new JournalRecordModel(true, 5, 1, 1);
            var response = await _client.PostAsJsonAsync("/Journal", model);

            // Assert
            response.EnsureSuccessStatusCode();
            await using (ApplicationContext context = _contextFactory.CreateDbContext())
            {
                JournalRecord record = await context.JournalRecords.FirstAsync();

                Assert.That(record, Is.EqualTo(new JournalRecord {
                    Id = 1, Attendance = true, Score = 5, StudentId = 1, LectureId = 1
                }));
            }
        }
Ejemplo n.º 25
0
        private async Task <IncomingRequests> PrepareIncoming()
        {
            bool isManager = await _userManager.IsInRoleAsync(User, "manager");

            bool isDirector = await _userManager.IsInRoleAsync(User, "director");

            IncomingRequests model    = new IncomingRequests();
            List <Request>   Requests = null;

            using (RequestManager rm = new RequestManager())
            {
                model.IncomingCount = rm.GetIncomingRequestsCount();
                if (isDirector || isManager)
                {
                    Requests = rm.GetRequests();
                }
                else
                {
                    var user = await _userManager.GetUserAsync(User);

                    Requests = rm.GetUserRequests(user.Id);
                }
            }
            //
            foreach (var request in Requests)
            {
                var record = new JournalRecord();
                if (!string.IsNullOrEmpty(request.UserId))
                {
                    record.UserName = _userManager.FindById(request.UserId).UserName;
                }
                record.Id = request.Id;
                record.IncomingIdentifier = request.IncomingIdentifier;
                record.LastState          = request.State;
                record.RegisterTime       = request.JournalRecords.First(jr => jr.State == RequestState.Registered).StateChanged;
                record.StartTime          = request.JournalRecords.FirstOrDefault(jr => jr.State == RequestState.Assigned)?.StateChanged;
                record.EndTime            = request.JournalRecords.OrderBy(jr => jr.Id).FirstOrDefault(jr => jr.State == RequestState.Aborted ||
                                                                                                       jr.State == RequestState.Error || jr.State == RequestState.Finalized)?.StateChanged;
                //
                model.Records.Add(record);
            }

            return(model);
        }
        public void Seed(DumaContext context)
        {
            //TODO: First variables.

            var member = new Member
            {
                Name         = "Lesha",
                Surname      = "Yurchak",
                Patronymic   = "Vladimirovich",
                PassportData = "MP"
            };

            context.Members.Add(member);
            context.SaveChanges();

            var commission = new Commission {
                Name = "Hello", President = member
            };

            context.Commissions.Add(commission);

            var roleCom = new RoleCommission {
                Value = "Commandor"
            };

            context.RoleCommissions.Add(roleCom);

            context.SaveChanges();
            commission.Consist.Add(member);

            var record = new JournalRecord
            {
                EntryDate  = DateTime.Now,
                ExitDate   = DateTime.Now.AddDays(3),
                Member     = member,
                Commission = commission,
                Role       = roleCom
            };

            commission.JournalRecords.Add(record);

            context.SaveChanges();
        }
Ejemplo n.º 27
0
        public static void AddInfoMessage(string userName, string mesage)
        {
            var journalRecord = new JournalRecord()
            {
                DeviceTime = DateTime.Now,
                SystemTime = DateTime.Now,
                StateType = StateType.Info,
                Description = mesage,
                User = userName,
                DeviceDatabaseId = "",
                DeviceName = "",
                PanelDatabaseId = "",
                PanelName = "",
                ZoneName = ""
            };

            AddJournalRecord(journalRecord);
            ClientsCash.OnNewJournalRecord(journalRecord);
        }
Ejemplo n.º 28
0
        public async Task <JournalRecord> StoreAsync(OperationDescription op, AccountWithAmount rec)
        {
            var jr = new JournalRecord
            {
                Amount      = rec.Amount,
                Currency    = rec.Account.Currency,
                Id          = ObjectId.GenerateNewId().ToString(),
                Period      = op.Period,
                UserId      = rec.Account.UserId,
                OperationId = op.Id,
                CreatedOn   = DateTime.Now
            };
            await _ms.Journal.InsertOneAsync(jr);

            _logger.LogInformation(
                "New Journal Record for {Operation} on {Period} for {Account} with {Amount} of {Currency}", op.Id,
                op.Period, rec.Account.UserId, rec.Amount, rec.Account.Currency);
            return(jr);
        }
Ejemplo n.º 29
0
        protected override void OnCommandBatch(IEnumerable <Command> commands)
        {
            foreach (var command in commands)
            {
                var record = new JournalRecord(0, DateTimeOffset.Now, command);
                var bytes  = _serializer.Serialize(record);

                var request = new WriteEventsRequest
                {
                    Event  = ByteString.CopyFrom(bytes),
                    Stream = _stream,
                    Scope  = _scope
                };

                _writer.RequestStream.WriteAsync(request).GetAwaiter().GetResult();
            }

            _writer.RequestStream.CompleteAsync().GetAwaiter().GetResult();
        }
        protected override OpResult _Store(JournalRecord _obj)
        {
            if (_obj == null)
            {
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.ObjectIsNull, _obj, "JournalRecord object cannot be created as it is null"));
            }

            if (Exists(_obj))
            {
                ExecuteNonQuery(GetQuery_UpdateQuery(_obj));
                return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Updated, _obj));
            }

            ExecuteNonQuery(GetQuery_InsertQuery(_obj));
            if (_obj.JournalRecordID == null)
            {
                _obj.JournalRecordID = DbMgr.GetLastInsertID();
            }
            _obj.FromDb = true;
            return(OpResult.NotifyStoreAction(OpResult.ResultStatus.Created, _obj));
        }
Ejemplo n.º 31
0
        public static JournalRecord Convert(journalType innerJournalRecord)
        {
            var journalRecord = new JournalRecord()
            {
                OldId = int.Parse(innerJournalRecord.IDEvents),
                DeviceTime = ConvertTime(innerJournalRecord.Dt),
                SystemTime = ConvertTime(innerJournalRecord.SysDt),
                ZoneName = innerJournalRecord.ZoneName,
                Description = innerJournalRecord.EventDesc,
                DeviceName = innerJournalRecord.CLC_Device,
                PanelName = innerJournalRecord.CLC_DeviceSource,
                DeviceDatabaseId = innerJournalRecord.IDDevices,
                PanelDatabaseId = innerJournalRecord.IDDevicesSource,
                User = innerJournalRecord.UserInfo,
                Detalization = innerJournalRecord.CLC_Detalization,
                SubsystemType = EnumsConverter.StringToSubsystemType(innerJournalRecord.IDSubSystem),
                StateType = (StateType)int.Parse(innerJournalRecord.IDTypeEvents),
            };
            SetDeviceCatogory(journalRecord);

            return journalRecord;
        }
Ejemplo n.º 32
0
        void OnNewJournalRecord(JournalRecord journalRecord)
        {
            if (IsAutoActivation)
            {
                if ((App.Current.MainWindow != null) && (App.Current.MainWindow.IsActive == false))
                {
                    App.Current.MainWindow.WindowState = System.Windows.WindowState.Maximized;
                    App.Current.MainWindow.Activate();
                }
            }
            if (IsPlansAutoActivation)
            {
                if (string.IsNullOrWhiteSpace(journalRecord.DeviceDatabaseId) == false)
                {
                    var globalStateType = StateType.No;
                    foreach (var deviceState in FiresecManager.DeviceStates.DeviceStates)
                    {
                        if (deviceState.StateType < globalStateType)
                            globalStateType = deviceState.StateType;
                    }

                    var device = FiresecManager.Devices.FirstOrDefault(x => x.DatabaseId == journalRecord.DeviceDatabaseId);
                    if (device != null)
                    {
                        var deviceState = FiresecManager.DeviceStates.DeviceStates.FirstOrDefault(x => x.UID == device.UID);
                        //if (deviceState.StateType <= globalStateType)
                        {
                            var existsOnPlan = FiresecManager.PlansConfiguration.AllPlans.Any(x => { return x.ElementDevices.Any(y => y.DeviceUID == device.UID); });
                            if (existsOnPlan)
                            {
                                ServiceFactory.Events.GetEvent<ShowDeviceOnPlanEvent>().Publish(device.UID);
                            }
                        }
                    }
                }
            }
        }
        private void HandleNotification(object sender, NpgsqlNotificationEventArgs arguments)
        {
            var serializer = _memstateSettings.CreateSerializer();

            try
            {
                var row = JsonConvert.DeserializeObject <Row>(arguments.AdditionalInformation);

                var command = (Command)serializer.Deserialize(row.Command);

                var record = new JournalRecord(row.Id, row.Written, command);

                if (_ready)
                {
                    _handler(record);
                }
                else
                {
                    lock (Lock)
                    {
                        if (_ready)
                        {
                            _handler(record);
                        }
                        else
                        {
                            _buffer.Enqueue(record);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                _log.LogError(exception, $"Exception occured in {GetType().Name}.HandleNotification");
            }
        }
Ejemplo n.º 34
0
		public JournalRecordViewModel(JournalRecord journalRecord)
		{
			ShowOnPlanCommand = new RelayCommand(OnShowOnPlan, CanShowOnPlan);
			ShowTreeCommand = new RelayCommand(OnShowTree, CanShowTree);
			ShowZoneCommand = new RelayCommand(OnShowZone, CanShowZone);

			DeviceTime = journalRecord.DeviceTime;
			SystemTime = journalRecord.SystemTime;
			ZoneName = journalRecord.ZoneName;
			Description = journalRecord.Description;
			DeviceName = journalRecord.DeviceName;
			PanelName = journalRecord.PanelName;
			User = journalRecord.User;
			SubsystemType = journalRecord.SubsystemType;
			StateType = journalRecord.StateType;
			Detalization = GetDetalization(journalRecord.Detalization);

			if (journalRecord.DeviceDatabaseUID != Guid.Empty)
				Device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(x => x.UID == journalRecord.DeviceDatabaseUID);
			else
				Device = ConfigurationCash.DeviceConfiguration.Devices.FirstOrDefault(x => x.UID == journalRecord.PanelDatabaseUID);

			Zone = FiresecManager.Zones.FirstOrDefault(x => x.FullPresentationName == journalRecord.ZoneName);
		}
Ejemplo n.º 35
0
 void AddJournalItem(JournalRecord journalRecord)
 {
     var value = count.ToString() + "\t" + DateTime.Now.TimeOfDay.ToString() + "\t" + journalRecord.SystemTime.ToString() + "\t" + journalRecord.Description;
     JournalItems.Insert(0, value);
     count++;
 }
Ejemplo n.º 36
0
 public IResult Show(JournalRecord record)
 {
     return(new SelectResult(record.Filename));
 }
Ejemplo n.º 37
0
 public IResult Open(JournalRecord record)
 {
     return(new OpenResult(record.Filename));
 }
Ejemplo n.º 38
0
		//void OnNewFS2JournalItemsEvent(List<FS2JournalItem> journalItems)
		//{
		//    Dispatcher.BeginInvoke(new Action(() =>
		//        {
		//            foreach (var journalItem in journalItems)
		//            {
		//                if (FilterFS2JournalItem(journalItem) == false)
		//                    return;

		//                if (JournalRecords.Count > 0)
		//                    JournalRecords.Insert(0, new JournalRecordViewModel(journalItem));
		//                else
		//                    JournalRecords.Add(new JournalRecordViewModel(journalItem));

		//                if (JournalRecords.Count > JournalFilter.LastRecordsCount)
		//                    JournalRecords.RemoveAt(JournalFilter.LastRecordsCount);
		//            }
		//        }));
		//}

		bool FilterJournalRecord(JournalRecord journalRecord)
		{
			if (JournalFilter.Categories.IsNotNullOrEmpty())
			{
				Device device = null;
				if (journalRecord.DeviceDatabaseUID != Guid.Empty)
				{
					device = FiresecManager.Devices.FirstOrDefault(x => x.UID == journalRecord.DeviceDatabaseUID);
				}
				else
				{
					device = FiresecManager.Devices.FirstOrDefault(x => x.UID == journalRecord.PanelDatabaseUID);
				}

				if (device != null)
				{
					if (JournalFilter.Categories.Any(daviceCategory => daviceCategory == device.Driver.Category) == false)
						return false;
				}
			}

			if (JournalFilter.StateTypes.IsNotNullOrEmpty())
			{
				if (JournalFilter.StateTypes.Any(x => x == journalRecord.StateType) == false)
					return false;
			}

			return true;
		}
Ejemplo n.º 39
0
        public ConfirmationViewModel(JournalRecord journalRecord)
		{
			Title = "Подтверждение критических событий";
            ConfirmCommand = new RelayCommand(OnConfirm);
			JournalRecord = new JournalRecordViewModel(journalRecord);
		}
Ejemplo n.º 40
0
 void OnNewJournalRecord(JournalRecord journalItem)
 {
     if (_journalItem == null || !_journalItem.IsSelected)
         ++UnreadJournalCount;
 }
Ejemplo n.º 41
0
 void OnNewJournalRecord(JournalRecord journalRecord)
 {
     Dispatcher.CurrentDispatcher.Invoke(new Action(() => { JournalRecords.Add(journalRecord); }));
     OnPropertyChanged("JournalRecords");
 }
Ejemplo n.º 42
0
 public void Remove(JournalRecord model)
 {
     _ctx.JournalRecords.Remove(model);
     _ctx.SaveChanges();
 }
Ejemplo n.º 43
0
 public JournalRecordViewModel(JournalRecord jr)
 {
     this._jr = jr;
 }
Ejemplo n.º 44
0
        void OnNewJournalRecord(JournalRecord journalRecord)
        {
            journalRecord.Time3 = DateTime.Now.TimeOfDay;

            if (FilterRecord(journalRecord) == false)
                return;

            if (JournalRecords.Count > 0)
                JournalRecords.Insert(0, new JournalRecordViewModel(journalRecord));
            else
                JournalRecords.Add(new JournalRecordViewModel(journalRecord));

            if (JournalRecords.Count > JournalFilter.LastRecordsCount)
                JournalRecords.RemoveAt(JournalFilter.LastRecordsCount);
        }
Ejemplo n.º 45
0
 partial void DeleteJournal(JournalRecord instance);
Ejemplo n.º 46
0
 partial void UpdateJournal(JournalRecord instance);
Ejemplo n.º 47
0
 partial void InsertJournal(JournalRecord instance);
Ejemplo n.º 48
0
 static void OnNewJournalRecordEvent(JournalRecord journalRecord)
 {
     ServiceFactory.Events.GetEvent<NewJournalRecordEvent>().Publish(journalRecord);
 }
Ejemplo n.º 49
0
 public void AddJournalRecord(JournalRecord journalRecord)
 {
     SafeOperationCall(() => { FiresecService.AddJournalRecord(journalRecord); });
 }
Ejemplo n.º 50
0
		static JournalRecord ReadOneJournalRecord(SqlCeDataReader reader)
		{
			var journalRecord = new JournalRecord();
			if (!reader.IsDBNull(reader.GetOrdinal("Description")))
				journalRecord.Description = reader.GetString(reader.GetOrdinal("Description"));
			if (!reader.IsDBNull(reader.GetOrdinal("Detalization")))
				journalRecord.Detalization = reader.GetString(reader.GetOrdinal("Detalization"));
			if (!reader.IsDBNull(reader.GetOrdinal("DeviceCategory")))
				journalRecord.DeviceCategory = reader.GetInt32(reader.GetOrdinal("DeviceCategory"));
			if (!reader.IsDBNull(reader.GetOrdinal("DeviceDatabaseId")))
				journalRecord.DeviceDatabaseId = reader.GetString(reader.GetOrdinal("DeviceDatabaseId"));
			if (!reader.IsDBNull(reader.GetOrdinal("DeviceName")))
				journalRecord.DeviceName = reader.GetString(reader.GetOrdinal("DeviceName"));
			if (!reader.IsDBNull(reader.GetOrdinal("DeviceTime")))
				journalRecord.DeviceTime = reader.GetDateTime(reader.GetOrdinal("DeviceTime"));
			if (!reader.IsDBNull(reader.GetOrdinal("OldId")))
				journalRecord.OldId = reader.GetInt32(reader.GetOrdinal("OldId"));
			if (!reader.IsDBNull(reader.GetOrdinal("PanelDatabaseId")))
				journalRecord.PanelDatabaseId = reader.GetString(reader.GetOrdinal("PanelDatabaseId"));
			if (!reader.IsDBNull(reader.GetOrdinal("PanelName")))
				journalRecord.PanelName = reader.GetString(reader.GetOrdinal("PanelName"));
			if (!reader.IsDBNull(reader.GetOrdinal("StateType")))
				journalRecord.StateType = (StateType)reader.GetInt32(reader.GetOrdinal("StateType"));
			if (!reader.IsDBNull(reader.GetOrdinal("SubsystemType")))
				journalRecord.SubsystemType = (SubsystemType)reader.GetInt32(reader.GetOrdinal("SubsystemType"));
			if (!reader.IsDBNull(reader.GetOrdinal("SystemTime")))
				journalRecord.SystemTime = reader.GetDateTime(reader.GetOrdinal("SystemTime"));
			if (!reader.IsDBNull(reader.GetOrdinal("UserName")))
				journalRecord.User = reader.GetString(reader.GetOrdinal("UserName"));
			if (!reader.IsDBNull(reader.GetOrdinal("ZoneName")))
				journalRecord.ZoneName = reader.GetString(reader.GetOrdinal("ZoneName"));
			if (!reader.IsDBNull(reader.GetOrdinal("Id")))
				journalRecord.No = reader.GetInt32(reader.GetOrdinal("Id"));
			return journalRecord;
		}
Ejemplo n.º 51
0
		void OnNewJournalRecord(JournalRecord journalRecord)
		{
			JournalRecords.Add(journalRecord);
		}
Ejemplo n.º 52
0
 public void Add(JournalRecord newRecord)
 {
     _ctx.JournalRecords.Add(newRecord);
     _ctx.SaveChanges();
 }
        private DbInsertStatement GetQuery_InsertQuery(JournalRecord _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("JournalRecords", fields));
        }
Ejemplo n.º 54
0
		void AddInfoMessage(string userName, string mesage)
		{
			var journalRecord = new JournalRecord()
			{
				DeviceTime = DateTime.Now,
				SystemTime = DateTime.Now,
				StateType = StateType.Info,
				Description = mesage,
				User = userName,
				DeviceDatabaseId = "",
				DeviceName = "",
				PanelDatabaseId = "",
				PanelName = "",
				ZoneName = ""
			};

			FiresecDB.DatabaseHelper.AddJournalRecords(new List<JournalRecord>() { journalRecord });
			NotifyNewJournal(new List<JournalRecord>() { journalRecord });

			//try
			//{
			//    var journalItem = new FS2JournalItem()
			//    {
			//        DeviceTime = DateTime.Now,
			//        SystemTime = DateTime.Now,
			//        StateType = StateType.Info,
			//        Description = mesage,
			//        UserName = userName,
			//        DeviceName = "",
			//        PanelName = "",
			//        ZoneName = ""
			//    };
			//    ServerFS2Database.AddJournalItems(new List<FS2JournalItem>() { journalItem });
			//}
			//catch
			//{
			//    Logger.Error("FiresecService.AddInfoMessage.FS2JournalItem");
			//}
		}
 private DbUpdateStatement GetQuery_UpdateQuery(JournalRecord _obj)
 {
     return(DbMgr.CreateUpdateClause("JournalRecords", GetFields(_obj), "JournalRecordID", _obj.JournalRecordID));
 }