Пример #1
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";
     }
 }
Пример #2
0
 public FaceReportPrivate(FactReport report)
 {
     ReportID = report.ReportID;
     TimeStamp = report.TimeStamp;
     URL = report.URL;
     CategoryID = report.CategoryID;
     Location = report.Location;
     Name = report.Name;
     LastName = report.LastName;
     Phone = report.Phone;
     Description = report.Description;
     Email = report.Description;
     StatusID = report.StatusID;
     ScreenShot = report.ScreenShot;
 }