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();
             }
         }
     }
 }
Ejemplo n.º 2
0
 public void changeStatus(List<int> sCluster, string user)
 {
     using (DGGuardEntities entities = new DGGuardEntities())
     {
         foreach (int reportID in sCluster)
         {
             var data = entities.FactReports.FirstOrDefault(x => x.ReportID == 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).StatusName,
                         Time = DateTime.Now
                     };
                     entities.Changes.Add(c);
                 }
                 try
                 {
                     entities.SaveChanges();
                 }
                 catch (Exception ex)
                 {
                     Console.Write(ex.Message);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
 public string RegisterUser(string username, string password, string permissions)
 {
     try
     {
         using (DGGuardEntities entities = new DGGuardEntities())
         {
             var data = entities.DimUsers.FirstOrDefault(x => x.UserName == username);
             //check for exisiting username
             if (data != null)
                 return JsonConvert.SerializeObject(false);
             string s = StringCipher.CreateHash(password);
             DimUser u = new DimUser
             {
                 UserName = username,
                 Password = s.Split(':')[1],
                 Salt = s.Split(':')[0],
                 Permisssions = permissions
             };
             entities.DimUsers.Add(u);
             entities.SaveChanges();
             Logger.GetInstance.Log(LogType.Info, "New User Registerd");
             return JsonConvert.SerializeObject(true);
         }
     }
     catch (Exception ex)
     {
         Logger.GetInstance.Log(LogType.Error, "Registration Failed: " + ex.Message);
         return JsonConvert.SerializeObject(false);
     }
 }
Ejemplo n.º 4
0
 public void Log(LogType type, string message)
 {
     using (DGGuardEntities entities = new DGGuardEntities())
     {
         Log l = new Log { TimeStamp = DateTime.Now, Data = message, Type = type };
         entities.Logs.Add(l);
         entities.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 public string PostReport(string url, string img, string dom = "", int category = -1,
     string name = "", string lName = "", string phone = "", string email = "",
     string description = "", string location = "")
 {
     try
     {
         using (DGGuardEntities entities = new DGGuardEntities())
         {
             genPath = Server.MapPath("/UploadImage/");
             ;
             string fileName = (DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".png").Replace(" ", "");
             try
             {
                 byte[] data = Convert.FromBase64String(img);
                 var fs =
                     new BinaryWriter(new FileStream(Path.Combine(genPath, fileName), FileMode.Append,
                         FileAccess.Write));
                 fs.Write(data);
                 fs.Close();
             }
             catch (Exception ex)
             {
                 Logger.GetInstance.Log(LogType.Error, "Unable to save Image: " + ex.Message);
             }
             FactReport f = new FactReport
             {
                 URL = url,
                 TimeStamp = DateTime.Now,
                 Location = location,
                 Description = description,
                 Name = name,
                 LastName = lName,
                 Email = email,
                 Phone = phone,
                 ScreenShot = genPath + fileName,
                 DimCategory = entities.DimCategories.FirstOrDefault(x => x.CategoryId == category),
                 DimStatu = entities.DimStatus.FirstOrDefault(x => x.StatusID == 0)
             };
             entities.FactReports.Add(f);
             entities.SaveChanges();
         }
         return "Success";
     }
     catch (Exception ex)
     {
         Logger.GetInstance.Log(LogType.Error, "PostReport Failed: "+ ex.Message);
         return "fail";
     }
 }