public void changeStatus(Cluster sCluster, string user)
 {
     using (DGGuardEntities entities = new DGGuardEntities())
     {
         foreach (FactReport report in sCluster.Reports)
         {
             var data = entities.FactReports.FirstOrDefault(x => x.ReportID == report.ReportID);
             if (data != null)
             {
                 if (data.StatusID < entities.DimStatus.Max(x => x.StatusID))
                 {
                     string oldStat = data.DimStatu.StatusName;
                     data.StatusID++;
                     Change c = new Change()
                     {
                         ReportID = data.ReportID,
                         UserName = user,
                         Data = "Status Changed From " + oldStat + " To " + entities.DimStatus.First(x=>x.StatusID==data.StatusID+1).StatusName,
                         Time = DateTime.Now
                     };
                     entities.Changes.Add(c);
                 }
                 entities.SaveChanges();
             }
         }
     }
 }
        public string GetReports()
        {
            using (DGGuardEntities entities = new DGGuardEntities())
            {
                var data = entities.FactReports.Where(x => x.StatusID != 2).ToList();
                List<Cluster> list = new List<Cluster>();
                foreach (FactReport report in data)
                {
                    Cluster c = list.FirstOrDefault(x => String.Equals(x.URL, report.URL));
                    if (c == null)
                    {
                        c = new Cluster() { URL = report.URL, status = report.DimStatu };
                        list.Add(c);
                    }
                    c.Amount++;
                    c.Reports.Add(report);

                }
                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                };
                return JsonConvert.SerializeObject(list, settings);
            }
        }
Esempio n. 3
0
        public string GetReports()
        {
            List<Cluster> list = new List<Cluster>();
            try
            {
                using (DGGuardEntities entities = new DGGuardEntities())
                {
                    var data = entities.FactReports.Where(x => x.StatusID < 2).ToList();
                    foreach (FactReport report in data)
                    {
                        Cluster c = list.FirstOrDefault(x => String.Equals(x.URL, report.URL));
                        if (c == null)
                        {
                            c = new Cluster
                            {
                                URL = report.URL,
                                status = new DimStatuPrivate(report.DimStatu.StatusID, report.DimStatu.StatusName)
                            };
                            if (report.TimeStamp > c.Time)
                                c.Time = report.TimeStamp;
                            list.Add(c);
                        }
                        c.Amount++;
                        c.Reports.Add(new FaceReportPrivate(report));

                    }

                }
                JsonSerializerSettings settings = new JsonSerializerSettings
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                };
                return JsonConvert.SerializeObject(list, settings);

            }
            catch (Exception e)
            {
                Logger.GetInstance.Log(LogType.Error, "GetRerpots Failed: " + e.Message);
                return "";
            }
        }