public void DeleteUploadedFile(long id)
 {
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(WebSpecificInstances.DbFactory.CreateConnection()))
     {
         var row = db.SYS_FileUploads.FirstOrDefault(r => r.id == id && r.PersonSID == Tools.Security.User.GetSID());
         if (row != null)
         {
             db.SYS_FileUploads.DeleteOnSubmit(row);
             db.SubmitChanges();
         }
     }
 }
 private string UploadFile(byte[] buffer, string fileName, string subsystem, string tableId)
 {
     WebInitializer.Initialize();
     using (var db = new DBUploadFilesDataContext(WebSpecificInstances.DbFactory.CreateConnection()))
     {
         var sfu = new SYS_FileUpload
         {
             data          = buffer,
             UploadDate    = DateTime.Now,
             PersonSID     = Tools.Security.User.GetSID(),
             SubSystemName = subsystem,
             dataFileName  = fileName,
         };
         db.SYS_FileUploads.InsertOnSubmit(sfu);
         db.SubmitChanges();
         var result = GetResult(fileName, tableId, sfu);
         return(new JavaScriptSerializer().Serialize(result));
     }
 }