Пример #1
0
        public Case CreateGeneralCase(string BpName = "")
        {
            //create only 1 BP
            LogDBContext logDB = new LogDBContext();
            var          s     = logDB.EventLogs.Include(s => s.Activity).Include(s => s.Resource).OrderBy(s => s.CaseId).ThenBy(s => s.TimeStamp).ToList();

            var groups = s.GroupBy(s => s.CaseId);

            List <Case> cases = new List <Case>();

            Case general = new Case(-1);

            foreach (var g in groups)
            {
                Case bP = cases.FirstOrDefault(f => f.CaseId == g.Key);

                if (bP == null)
                {
                    bP = new Case(g.Key);
                    cases.Add(bP);
                }

                foreach (var e in g)
                {
                    bP.Add(new Event(e.Activity.ActivityText2)
                    {
                        TimeStamp = e.TimeStamp
                    });
                    general.UpdateHierarchy(bP.Events.Last());
                }
            }
            return(general);
        }
Пример #2
0
        public override void SendData()
        {
            LoadFromLocalQueue();

            LogDBContext context = new LogDBContext();

            while (Queue.Count != 0)
            {
                EventLog eventLog = JsonSerializer.Deserialize <EventLog>(Queue.Dequeue());

                if (context.Users.FirstOrDefault(s => s.Id == eventLog.ResourceId) == null)
                {
                    context.Users.Add(eventLog.Resource);
                }
                if (context.Activities.FirstOrDefault(s => s.Id == eventLog.ActivityId) == null)
                {
                    context.Activities.Add(eventLog.Activity);
                }

                eventLog.Activity = null;
                eventLog.Resource = null;
                if (context.EventLogs.FirstOrDefault(s => s.CaseId == eventLog.CaseId && s.TimeStamp == eventLog.TimeStamp) == null)
                {
                    context.EventLogs.Add(eventLog);
                }
                try
                {
                    context.SaveChanges();
                }
                catch
                {
                    SaveInLocalQueue();
                }
            }
        }
Пример #3
0
        private void UpdateCases()
        {
            LogDBContext logDB = new LogDBContext();
            var          s     = logDB.EventLogs.Include(s => s.Activity).Include(s => s.Resource).OrderBy(s => s.CaseId).ThenBy(s => s.TimeStamp).ToList();

            var groups = s.GroupBy(s => s.CaseId);

            MainDBContext mainDBContext = new MainDBContext();

            mainDBContext.BPCases.Load();

            foreach (var g in groups)
            {
                if (mainDBContext.BPCases.FirstOrDefault(s => s.CaseId == g.Key) == null)
                {
                    //пока только для 1 BP
                    mainDBContext.BPCases.Local.Add(new BPCase {
                        BPId = 1, CaseId = g.Key
                    });
                }
            }
            mainDBContext.SaveChanges();
        }
Пример #4
0
        public Case CreateCase(long CaseId)
        {
            LogDBContext  logDB  = new LogDBContext();
            MainDBContext mainDB = new MainDBContext();
            var           Events = logDB.EventLogs.Include(s => s.Resource).Include(s => s.Activity).Where(b => b.CaseId == CaseId).OrderBy(b => b.TimeStamp).ToList();

            Case newCase = new Case(CaseId);

            newCase.BPId = mainDB.BPCases.FirstOrDefault(s => s.CaseId == CaseId).BPId;
            foreach (var e in Events)
            {
                Event @event = new Event(e.Activity.ActivityText2)
                {
                    TimeStamp = e.TimeStamp
                };
                if (e.Resource.Department != null)
                {
                    @event.ResourceId = e.ResourceId;
                }
                newCase.Add(@event);
            }

            return(newCase);
        }
Пример #5
0
 public LogRepo()
 {
     _db = new LogDBContext(); _db.Database.EnsureCreated();
 }