Ejemplo n.º 1
0
        /// <summary>
        /// Uploads the file.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="fileData">The file data.</param>
        /// <param name="recipientAddress">The recipient address.</param>
        /// <param name="worker">The worker.</param>
        /// <returns></returns>
        public bool UploadFile(string fileName, byte[] fileData, string recipientAddress, ActionWorker worker)
        {
            var result = false;

            if (client != null)
            {
                try
                {
                    OnBeforeUpload(new WcfClientArgs(client, fileName));
                    client.UploadFile(fileName, fileData);
                    OnAfterUpload(new WcfClientArgs(client, fileName));
                    worker.ReportProgress(Localizer.UploadOk);
                    result = true;
                }
                catch (Exception exception)
                {
                    worker.ReportError(Localizer.UploadError, fileName, exception.Message);
                }
            }
            else
            {
                worker.ReportError(Localizer.ClientIsNotOpened);
            }
            return(result);
        }