Пример #1
0
        protected void SetupFileManager(int auditId, int auditDetailId)
        {
            string questionFolder = Audit.GetAuditDetailFolder(auditDetailId);
            string rootFolder     = $"{PhotoFiles.PhotosAppPath}{auditId}/{questionFolder}/";
            string serverPath     = HttpContext.Current.Server.MapPath(rootFolder);

            if (!Directory.Exists(serverPath))
            {
                Directory.CreateDirectory(serverPath);
            }
            dxFileManager.Settings.RootFolder           = rootFolder;
            dxFileManager.JSProperties["cp_root"]       = rootFolder;
            dxFileManager.Settings.ThumbnailFolder      = PhotoFiles.ThumbnailsAppPath;
            dxFileManager.SettingsEditing.AllowCopy     = false;
            dxFileManager.SettingsEditing.AllowCreate   = false;
            dxFileManager.SettingsEditing.AllowDelete   = true;
            dxFileManager.SettingsEditing.AllowDownload = false;
            dxFileManager.SettingsEditing.AllowMove     = false;
            dxFileManager.SettingsEditing.AllowRename   = false;
            dxFileManager.SettingsFolders.Visible       = false;
            dxFileManager.SettingsToolbar.ShowFilterBox = false;
            dxFileManager.SettingsToolbar.ShowPath      = false;
            dxFileManager.SettingsUpload.Enabled        = true;
            dxFileManager.SettingsUpload.ValidationSettings.MaxFileCount        = 5;
            dxFileManager.SettingsUpload.ValidationSettings.MaxFileSize         = 26214400;
            dxFileManager.SettingsUpload.AdvancedModeSettings.EnableMultiSelect = true;
            dxFileManager.Settings.AllowedFileExtensions = new String[] { ".jpg", ".jpeg", ".bmp", ".gif", ".png" };
            dxFileManager.SettingsUpload.ValidationSettings.MaxFileCountErrorText            = "You can only upload 5 files at a time!";
            dxFileManager.SettingsUpload.ValidationSettings.MaxFileSizeErrorText             = "File too big! The maximum size is 25 Mb!";
            dxFileManager.SettingsUpload.ValidationSettings.NotAllowedFileExtensionErrorText = "Illegal extension! You can upload [.jpg, .jpeg, .bmp, .gif, .png]!";
            dxFileManager.SettingsUpload.AutoStartUpload = true;
            dxFileManager.SettingsContextMenu.Enabled    = false;
        }
Пример #2
0
 public static void SavePhoto(int auditId, int auditDetailId)
 {
     if (HttpContext.Current.Request.Files.Count > 0)
     {
         HttpPostedFile postedFile = HttpContext.Current.Request.Files[0];
         if (postedFile.FileName.ToLower().EndsWith(".png"))
         {
             try
             {
                 string imageName      = DateTime.Now.ToString("yyyyMMddhhmmss");
                 string questionFolder = Audit.GetAuditDetailFolder(auditDetailId);
                 string imagePath      = $"{PhotoFiles.PhotosAppPath}{auditId}/{questionFolder}/{imageName}.png";
                 using (Stream inStream = postedFile.InputStream)
                 {
                     byte[] fileData = new byte[postedFile.ContentLength];
                     inStream.Read(fileData, 0, postedFile.ContentLength);
                     postedFile.SaveAs(HttpContext.Current.Server.MapPath(imagePath));
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
     }
 }