Exemplo n.º 1
0
        public ActionResult Upload(string dir = null)
        {
            //定义允许上传的文件扩展名
            Dictionary <string, string> extTable = new Dictionary <string, string>();

            extTable.Add("image", "gif,jpg,jpeg,png,bmp");
            extTable.Add("flash", "swf,flv");
            extTable.Add("media", "swf,flv,mp3,wav,wma,wmv,mid,avi,mpg,asf,rm,rmvb");
            extTable.Add("file", "doc,docx,xls,xlsx,ppt,htm,html,txt,zip,rar,gz,bz2");
            String dirName = dir;

            if (String.IsNullOrEmpty(dirName))
            {
                dirName = "image";
            }
            if (!extTable.ContainsKey(dirName))
            {
                return(showError("目录名不正确。"));
            }

            RequestUtil req  = new RequestUtil();
            var         file = req.File("imgFile", false, "请选择文件。", extTable[dirName], "上传文件扩展名是不允许的扩展名。\n只允许" + extTable[dirName] + "格式。");

            if (req.HasError)
            {
                return(showError(req.FirstError));
            }

            String src     = file.Save();
            String fileUrl = RequestFile.FullUrl(src);

            return(Content(System.Web.Helpers.Json.Encode(new { error = 0, url = fileUrl, src = src })));
        }
Exemplo n.º 2
0
        public async Task Handle(RecipientsAddedToFolderNotification value, CancellationToken cancellationToken)
        {
            WorkerLog.Instance.Information("Handling notification that recipients are added");
            WorkerLog.Instance.Debug($"Getting files of folder '{value.FolderId}' for following recipients: '{string.Join(", ", value.Recipients)}'");
            var filesResult = await _fileRepository.GetFilesForFolder(value.FolderId);

            var folderResult = await _folderRepository.GetFolder(value.FolderId);

            if (filesResult.WasSuccessful && folderResult.WasSuccessful)
            {
                var neededRecipients = folderResult.Data.Recipients?.Where(x => value.Recipients.Any(y => y == x.Id)).ToList();
                foreach (var file in filesResult.Data)
                {
                    var requestFile = new RequestFile
                                      (
                        file.Id,
                        file.FolderId,
                        file.Name,
                        file.Path,
                        file.LastModifiedDate,
                        file.Size,
                        file.Source,
                        file.Version,
                        neededRecipients
                                      );

                    await _workerQueueContainer.ToSendFiles.Writer.WriteAsync(requestFile, cancellationToken);
                }
            }
        }
Exemplo n.º 3
0
        RequestFile SaveRequest()
        {
            TreeNode node = tvTemplates.SelectedNode;

            string initialPath = null;

            if (node != null)
            {
                RequestFolder f = node.Tag as RequestFolder;
                if (f != null)
                {
                    // folder is selected - save in this folder
                    initialPath = f.Path;
                }
                else
                {
                    // file is selected
                    TreeNode parent = node.Parent;
                    if (parent != null)
                    {
                        f = parent.Tag as RequestFolder;
                        if (f != null)
                        {
                            // folder is selected - save in this folder
                            initialPath = f.Path;
                        }
                    }
                }
            }
            if (initialPath == null)
            {
                initialPath = _controller.RequestsRootPath;
            }

            SaveFileDialog dlg = new SaveFileDialog();

            dlg.InitialDirectory = initialPath;
            dlg.AddExtension     = true;
            dlg.Filter           = "XML files | *.xml";
            dlg.DefaultExt       = "xml";
            dlg.OverwritePrompt  = true;

            RequestFile newFile = null;

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                string fileName = dlg.FileName;

                try
                {
                    newFile = _controller.SaveRequest(fileName, tbRequest.Text);
                }
                catch (Exception)
                {
                    ShowError("An error occured during saving the request. File was not saved.");
                }
            }

            return(newFile);
        }
Exemplo n.º 4
0
        private void tvTemplates_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = tvTemplates.SelectedNode;

            if (node != null)
            {
                RequestFile file = node.Tag as RequestFile;
                btnDelete.Enabled = (file != null);
                if (file != null)
                {
                    try
                    {
                        tbRequest.Text = _controller.ApplySecurity(file.Content);
                    }
                    catch (Exception)
                    {
                        DialogResult dr =
                            MessageBox.Show(
                                "An error occurred during loading the file. Remove this request from the hierarchy?",
                                "Unable to load request", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (dr == DialogResult.Yes)
                        {
                            node.Remove();
                        }
                    }

                    return;
                }
            }

            btnDelete.Enabled = false;
            tbRequest.Text    = string.Empty;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Saves request.
        /// </summary>
        /// <param name="path">Path to desired file.</param>
        /// <param name="content">Request string.</param>
        /// <returns>Structure with request file data.</returns>
        public RequestFile SaveRequest(string path, string content)
        {
            if (File.Exists(path))
            {
                File.Delete(path);

                string dir = Path.GetDirectoryName(path);
                if (_foldersList.ContainsKey(dir))
                {
                    RequestFolder rf   = _foldersList[dir];
                    RequestFile   file = rf.Requests.Where(r => r.FileName == Path.GetFileName(path)).FirstOrDefault();
                    if (file != null)
                    {
                        rf.Requests.Remove(file);
                        View.DeleteFile(file, rf);
                    }
                }
                else
                {
                    RequestFile file = _rootFiles.Where(r => r.FileName == Path.GetFileName(path)).FirstOrDefault();
                    View.DeleteFile(file, null);
                }
            }
            FileStream fs = File.Create(path);
            TextWriter tw = new StreamWriter(fs);

            tw.Write(content);
            tw.Close();

            return(AddFileToHierarchy(path));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 封裝檔案
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static async Task <List <RequestFile> > GetRequestFilesAsync(HttpRequestMessage request)
        {
            List <RequestFile> requestFiles = new List <RequestFile>();

            if (request.Content.IsMimeMultipartContent())
            {
                var files = await request.Content.ReadAsMultipartAsync();

                // 取得實際檔案內容
                foreach (var httpContent in files.Contents)
                {
                    if (httpContent.Headers.ContentDisposition.FileName != null)
                    {
                        RequestFile requestFile   = new RequestFile();
                        var         fileName      = httpContent.Headers.ContentDisposition.FileName.ToString().Replace("\"", "");
                        var         contentType   = httpContent.Headers.ContentType.MediaType;
                        var         size          = httpContent.Headers.ContentLength;
                        var         stream        = httpContent.ReadAsStreamAsync().Result;
                        var         bytesInStream = httpContent.ReadAsByteArrayAsync().Result;
                        requestFiles.Add(requestFile);
                    }
                }
            }

            return(requestFiles);
        }
Exemplo n.º 7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            TreeNode node = tvTemplates.SelectedNode;

            if (node != null)
            {
                RequestFile file = node.Tag as RequestFile;
                if (file != null)
                {
                    DialogResult dr = MessageBox.Show("Request will be deleted. Continue?", "Question",
                                                      MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (dr == DialogResult.Yes)
                    {
                        try
                        {
                            _controller.DeleteRequest(file);
                            tvTemplates.Nodes.Remove(node);
                        }
                        catch (Exception exc)
                        {
                            MessageBox.Show(string.Format("Request could not be deleted: {0}", exc.Message), "Error");
                        }
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        ///     Return the location for a Request
        /// </summary>
        /// <param name="file">the file type you want the parent directory for</param>
        /// <returns></returns>
        public static string Location(RequestFile file)
        {
            switch (file)
            {
            case RequestFile.Appdata:
                return(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + AppdataSubfolder);

            case RequestFile.Local:
                return(AppDomain.CurrentDomain.BaseDirectory + LocalSubfolder);

            case RequestFile.StorageRoot:
                return(Location(RequestFile.Appdata));                        //Should return appdata or local, right now always appdata

            case RequestFile.Log:
                return(Location(RequestFile.StorageRoot) + LogFolder);

            case RequestFile.Config:
                return(Location(RequestFile.StorageRoot) + ConfFolder);

            case RequestFile.Temp:
                return(Location(RequestFile.StorageRoot) + TmpFolder);

            default:
                return(Location(RequestFile.StorageRoot));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the full path to the file corresponding to the path parts and filename passed across.
        /// </summary>
        /// <param name="pathParts"></param>
        /// <param name="fileName"></param>
        /// <returns></returns>
        private RequestFile GetRequestFile(List<string> pathParts, string fileName)
        {
            RequestFile result = null;

            var fileNameHasInvalidCharacters = fileName.Intersect(Path.GetInvalidFileNameChars()).Any();
            var pathHasInvalidCharacters = false;
            foreach(var pathPart in pathParts) {
                pathHasInvalidCharacters = pathPart.Intersect(Path.GetInvalidPathChars()).Any();
                if(pathHasInvalidCharacters) break;
            }

            if(!fileNameHasInvalidCharacters && !pathHasInvalidCharacters) {
                foreach(var root in _Roots) {
                    var folder = root.Folder;
                    foreach(var pathPart in pathParts) {
                        folder = Path.Combine(folder, pathPart);
                    }
                    if(Directory.Exists(folder)) {
                        folder = Path.GetFullPath(folder);
                        var isSiteFolder = folder.ToUpper().StartsWith(root.Folder.ToUpper());
                        if(isSiteFolder) {
                            var fullPath = Path.Combine(folder, fileName);
                            if(File.Exists(fullPath)) {
                                result = new RequestFile(root, fullPath);
                                break;
                            }
                        }
                    }
                }
            }

            return result;
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Return the location for a certain file type. Create the folder if it doesn't exist.
        /// </summary>
        /// <param name="file">the file type you want the parent directory for</param>
        /// <returns></returns>
        public static string SafeLocation(RequestFile file)
        {
            string location = Location(file);

            if (!Directory.Exists(location))
            {
                Directory.CreateDirectory(location);
            }
            return(location);
        }
Exemplo n.º 11
0
 public static RegisteredRequestFile ToDTO(this RequestFile requestFileOnDb)
 {
     return(new RegisteredRequestFile()
     {
         Source = requestFileOnDb.Source
         ,
         RequestId = requestFileOnDb.RequestId
         ,
     });
 }
Exemplo n.º 12
0
 /// <summary>
 /// Deletes request file.
 /// </summary>
 /// <param name="file">Request file information.</param>
 public void DeleteRequest(RequestFile file)
 {
     if (File.Exists(file.Path))
     {
         File.Delete(file.Path);
     }
     else
     {
         throw new FileNotFoundException("File not found", file.Path);
     }
 }
        private ResponseFile DownloadFile(RequestFile request)
        {
            ResponseFile result = new ResponseFile();

            FileStream stream = this.GetFileStream(Path.GetFullPath(request.FileName));

            stream.Seek(request.byteStart, SeekOrigin.Begin);
            result.FileName       = request.FileName;
            result.Length         = stream.Length;
            result.FileByteStream = stream;
            return(result);
        }
Exemplo n.º 14
0
 public void AddFile(RequestFile file,
                     RequestFolder parentFolder)
 {
     if (parentFolder == null)
     {
         AddRequestNode(null, file);
     }
     else
     {
         TreeNode parent = _folderNodes[parentFolder];
         AddRequestNode(parent, file);
     }
 }
Exemplo n.º 15
0
        public void DeleteFile(RequestFile file, RequestFolder parentFolder)
        {
            TreeNode node = _requestNodes[file];

            if (parentFolder == null)
            {
                tvTemplates.Nodes.Remove(node);
            }
            else
            {
                TreeNode parent = _folderNodes[parentFolder];
                parent.Nodes.Remove(node);
            }
        }
Exemplo n.º 16
0
        void AddRequestNode(TreeNode parent, RequestFile file)
        {
            TreeNode requestNode = new TreeNode(file.FileName);

            requestNode.Tag = file;
            if (parent != null)
            {
                parent.Nodes.Add(requestNode);
            }
            else
            {
                tvTemplates.Nodes.Add(requestNode);
            }
            _requestNodes.Add(file, requestNode);
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Return the location for a Request
        /// </summary>
        /// <param name="file">the file type you want the parent directory for</param>
        /// <returns></returns>
        public static string Location(RequestFile file)
        {
            switch (file)
            {
            case RequestFile.Appdata:
                return(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + AppdataSubfolder);

            case RequestFile.GuiDir:
                return(Share.AssemblyLocation);

            case RequestFile.Local:
                return(Location(RequestFile.GuiDir) + LocalSubfolder);

            case RequestFile.StorageRoot:
                return(_workingdirectory);

            case RequestFile.Log:
                return(Location(RequestFile.StorageRoot) + LogFolder);

            case RequestFile.Config:
                return(Location(RequestFile.StorageRoot) + ConfFolder);

            case RequestFile.Language:
                return(Location(RequestFile.StorageRoot) + LangFolder);

            case RequestFile.Temp:
                return(Location(RequestFile.StorageRoot) + TmpFolder);

            case RequestFile.Cache:
                return(Location(RequestFile.StorageRoot) + CacheFolder);

            case RequestFile.Serverdir:
                if (!_customWorkingDirectory)
                {
                    return(Location(RequestFile.GuiDir));
                }
                return(_workingdirectory);

            case RequestFile.Plugindir:
                return(Location(RequestFile.Serverdir) + "\\plugins");

            default:
                return(Location(RequestFile.StorageRoot));
            }
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            var port = 8081;
            var ip   = "127.0.0.1";

            listener = new TcpListener(IPAddress.Parse(ip), 8081);
            listener.Start();
            Console.WriteLine($"Listening in {ip}:{port}");

            while (true)
            {
                Socket s  = listener.AcceptSocket();
                var    rf = new RequestFile(s);
                Console.WriteLine($"\n\nRequest filename: {rf.FileName}");
                var r = new Response(rf);
                s.Send(r.getBytes());
                s.Close();
            }
        }
Exemplo n.º 19
0
 public ActionResult <RequestFile> PostRequestFile(RequestFileCM model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         RequestFile requestFile = new RequestFile();
         requestFile = _mapper.Map <RequestFile>(model);
         _requestFileService.Create(requestFile);
         _requestFileService.Save();
         return(StatusCode(201, "RequestFile Type Created!"));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 20
0
        public void SwitchToState(Enums.ApplicationState state)
        {
            Control[] controls = new Control[]
            {
                cmbService,
                tbServiceAddress,
                tvTemplates,
                btnAddRequestToTemplates,
                btnSendRequest,
                btnRequestFile,
                tbRequestFile,
                tbRequest,
                tbResponse
            };

            if (state.IsActive())
            {
                BeginInvoke(new Action(() =>
                {
                    DisableControls(controls);
                    btnDelete.Enabled = false;
                }));
            }
            else
            {
                BeginInvoke(new Action(() =>
                {
                    EnableControls(controls);
                    TreeNode node = tvTemplates.SelectedNode;
                    if (node != null)
                    {
                        RequestFile file  = node.Tag as RequestFile;
                        btnDelete.Enabled = (file != null);
                    }
                    else
                    {
                        btnDelete.Enabled = false;
                    }
                }));
            }
        }
Exemplo n.º 21
0
        //@Headers({ "Content-Type: application/json"})
        //@POST("api/v1/deletefile")
        //Call<ResponseCodes> deleteFile(@Body RequestFile requestDeleteFile);
        public async Task <ResponseCodes> DeleteFileAsync(RequestFile requestDeleteFile)
        {
            var uri = new Uri(baseUri + @"api/v1/deletefile");
            // Сформировать JSON данные
            string jsonContent = JsonConvert.SerializeObject(requestDeleteFile);
            HttpResponseMessage httpResponse = await cmd.PostAsync(uri, jsonContent);

            ResponseCodes responseCodes = new ResponseCodes();

            if (httpResponse.IsSuccessStatusCode)
            {
                responseCodes = JsonConvert.DeserializeObject <ResponseCount>(httpResponse.Content.ToString());
            }
            else
            {
                responseCodes.Error   = true;
                responseCodes.ErrCode = "";
                responseCodes.ErrMsg  = "Ошибка HttpClient.";
            }
            return(responseCodes);
        }
Exemplo n.º 22
0
        public async Task <IActionResult> UploadFile(RequestFile upload)
        {
            var uploaded = new FilesViewModel();

            try
            {
                if (upload == null || upload.Files.Count == 0)
                {
                    return(StatusCode((int)HttpStatusCode.BadRequest, "files not selected"));
                }

                foreach (var file in upload.Files)
                {
                    Guid g = Guid.NewGuid();

                    var path = Path.Combine(
                        Directory.GetCurrentDirectory(), "wwwroot\\Files",
                        g + Path.GetExtension(file.FileName));

                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }

                    uploaded.Files.Add(
                        new FileDetails {
                        Name = file.FileName, Path = Request.Host.ToString() + "/Files/" + g + Path.GetExtension(file.FileName)
                    });
                }

                return(Ok(uploaded));
            }
            catch (Exception exception)
            {
                return(StatusCode(StatusCodes.Status400BadRequest, exception.ToString()));
            }
        }
Exemplo n.º 23
0
		/// <summary>
		///     Return the location for a certain file type. Create the folder if it doesn't exist.
		/// </summary>
		/// <param name="file">the file type you want the parent directory for</param>
		/// <returns></returns>
		public static string SafeLocation(RequestFile file)
		{
			string location = Location(file);
			if (!Directory.Exists(location)) Directory.CreateDirectory(location);
			return location;
		}
Exemplo n.º 24
0
		/// <summary>
		///     Return the location for a Request
		/// </summary>
		/// <param name="file">the file type you want the parent directory for</param>
		/// <returns></returns>
		public static string Location(RequestFile file)
		{
			switch (file)
			{
				case RequestFile.Appdata:
					return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + AppdataSubfolder;
				case RequestFile.GuiDir:
					return Share.AssemblyLocation;
				case RequestFile.Local:
					return Location(RequestFile.GuiDir) + LocalSubfolder;
				case RequestFile.StorageRoot:
					return _workingdirectory;
				case RequestFile.Log:
					return Location(RequestFile.StorageRoot) + LogFolder;
				case RequestFile.Config:
					return Location(RequestFile.StorageRoot) + ConfFolder;
				case RequestFile.Language:
					return Location(RequestFile.StorageRoot) + LangFolder;
				case RequestFile.Temp:
					return Location(RequestFile.StorageRoot) + TmpFolder;
				case RequestFile.Cache:
					return Location(RequestFile.StorageRoot) + CacheFolder;
				case RequestFile.Serverdir:
					if (!_customWorkingDirectory)
						return Location(RequestFile.GuiDir);
					return _workingdirectory;
				case RequestFile.Plugindir:
					return Location(RequestFile.Serverdir) + "\\plugins";
				default:
					return Location(RequestFile.StorageRoot);
			}
		}
Exemplo n.º 25
0
        /// <summary>
        /// Adds new request to hierarchy.
        /// </summary>
        /// <param name="path">Request path.</param>
        /// <returns>Structure with request data.</returns>
        RequestFile AddFileToHierarchy(string path)
        {
            if (!path.StartsWith(RequestsRootPath))
            {
                RequestFile requestFile = new RequestFile(new FileInfo(path));
                View.AddFile(requestFile, null);
                return(requestFile);
            }

            // if no directory to add file exists in the hierarchy - go upstream until
            // parent folder is found.

            // folders to create
            List <string> newFolders = new List <string>();
            // current folder
            string folderPath = Path.GetDirectoryName(path);
            // existing folder
            RequestFolder existing = null;

            // Go to the parent folder. Stop at the root or at some existing folder.
            while (!_foldersList.ContainsKey(folderPath) && (folderPath != _requestsRootPath))
            {
                int idx = folderPath.LastIndexOf(Path.DirectorySeparatorChar);

                System.Diagnostics.Debug.WriteLine(string.Format("Create directory: {0}", folderPath.Substring(idx + 1)));
                newFolders.Insert(0, folderPath.Substring(idx + 1));
                folderPath = folderPath.Substring(0, idx);

                System.Diagnostics.Debug.WriteLine(string.Format("Check if exists: {0}", folderPath));

                if (!folderPath.Contains(Path.DirectorySeparatorChar))
                {
                    // user wants to create file out of hierarchy - create in root folder!
                    folderPath = RequestsRootPath;
                    newFolders.Clear();
                    break;
                }
            }

            if (_foldersList.ContainsKey(folderPath))
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Existing: {0}", folderPath));
                existing = _foldersList[folderPath];
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Add as root folder/file");
            }

            // create new folders

            // top new folder
            RequestFolder topFolder = null;

            // folder to add file in
            RequestFolder parentFolder = existing;

            // enumerate new folders.
            foreach (string folder in newFolders)
            {
                // next name
                string newDirectory = Path.Combine(folderPath, folder);

                System.Diagnostics.Debug.WriteLine(string.Format("Create {0} in {1}", folder, folderPath));

                // create directory
                DirectoryInfo directory = Directory.CreateDirectory(newDirectory);
                // add to the hierarchy
                RequestFolder requestFolder = new RequestFolder(directory);
                // save top folder
                if (topFolder == null)
                {
                    topFolder = requestFolder;
                }
                // add to parent folder or directly to the list
                if (_foldersList.ContainsKey(folderPath))
                {
                    _foldersList[folderPath].Folders.Add(requestFolder);
                }
                else
                {
                    _folders.Add(requestFolder);
                }
                // add to the dictionary
                _foldersList.Add(requestFolder.Path, requestFolder);

                // change current path
                folderPath = newDirectory;
                // folder where file should be added
                parentFolder = requestFolder;
            }

            // create file structure
            RequestFile newFile = new RequestFile(new FileInfo(path));

            // add to parent folder
            if (parentFolder != null)
            {
                System.Diagnostics.Debug.WriteLine(string.Format("Add file to: {0}", parentFolder.Path));
                parentFolder.Requests.Add(newFile);
            }
            else
            {
                _rootFiles.Add(newFile);
            }
            // add file in the view
            if (topFolder == null)
            {
                // add file only
                View.AddFile(newFile, existing);
            }
            else
            {
                // add top folder. Other will be added automatically.
                System.Diagnostics.Debug.WriteLine(string.Format("Add folder {0} to {1}", topFolder.Name, existing == null ? "TOP" : existing.Path));

                View.AddFolder(topFolder, existing);
            }

            return(newFile);
        }
Exemplo n.º 26
0
        public long SaveFile(IFileUploadDTO dto)
        {
            lock (lockObj)
            {
                Settings settings = settingsService.Get();

                int c = requestFileRepository.GetList(
                    new RequestFileByNameAndForignKeyOrTempKeySpecification(dto.Name, dto.ForignKeyId, dto.TempRequestKey))
                        .Count();

                if (c > 0)
                {
                    return(0);
                }


                c = requestFileRepository.Count(t => t.RequestId != null && t.RequestId == dto.ForignKeyId ||
                                                t.TempRequestKey != null && t.TempRequestKey == dto.TempRequestKey);

                if (c >= settings.MaxRequestFileCount)
                {
                    throw new DataServiceException(String.Format(Resource.MaxRequestFileCountConstraintMsg, settings.MaxRequestFileCount));
                }

                if (dto.Size / 1024 >= settings.MaxRequestFileSize)
                {
                    throw new DataServiceException(String.Format(Resource.MaxRequestFileSizeConstraintMsg, settings.MaxRequestFileSize, dto.Name));
                }

                if (String.IsNullOrWhiteSpace(dto.Name))
                {
                    throw new DataServiceException(Resource.EmptyFileNameConstraintMsg);
                }

                if (dto.Name.Length > settings.MaxFileNameLength)
                {
                    throw new DataServiceException(String.Format(Resource.MaxFileNameConstraintMsg, settings.MaxFileNameLength, dto.Name));
                }

                if (dto.Body == null || dto.Body.Length == 0)
                {
                    throw new DataServiceException(Resource.EmptyFileBodyConstraintMsg);
                }

                RequestFile file = new RequestFile()
                {
                    Body           = dto.Body,
                    Name           = dto.Name,
                    RequestId      = dto.ForignKeyId,
                    Size           = dto.Size,
                    TempRequestKey = dto.TempRequestKey,
                    Thumbnail      = dto.Thumbnail,
                    Type           = dto.Type
                };

                requestFileRepository.Save(file);
                repository.SaveChanges();

                return(file.Id);
            }
        }
Exemplo n.º 27
0
 public async Task <ResponseFile> WcfDownloadFile(RequestFile request)
 {
     return(await _transferService.StartDownloadFile(request));
 }
Exemplo n.º 28
0
 public TypedForm <T> AddFormFile(RequestFile formFile)
 {
     _formFiles.Add(formFile);
     return(this);
 }
Exemplo n.º 29
0
        public void AddFormFile(RequestFile file)
        {
            file.AssertNotNull(nameof(file));

            _formFiles.Add(file);
        }
 public async Task <ResponseFile> StartDownloadFile(RequestFile request)
 {
     return(await Task.Run(() => DownloadFile(request)));
 }
Exemplo n.º 31
0
 public void Create(RequestFile requestFile)
 {
     _requestFileRepository.Add(requestFile);
 }
Exemplo n.º 32
0
 public void Delete(RequestFile requestFile)
 {
     _requestFileRepository.Delete(requestFile);
 }