Ejemplo n.º 1
0
        static bool uploadFile(HttpRequestMessageProperty httpRequest, string jobID, string fileRefID, string FileContent)
        {
            try
            {
                FileTransferServicePortClient client = new FileTransferServicePortClient(FTconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

                    UploadFileRequest uploadReq = new UploadFileRequest();

                    uploadReq.fileAttachment = getFileAttachment(FileContent);
                    uploadReq.fileReferenceId = fileRefID;
                    uploadReq.taskReferenceId = jobID;
                    uploadReq.fileFormat = "gzip";

                    UploadFileResponse uploadResponse = client.uploadFile(uploadReq);

                    if (uploadResponse.ack.ToString().Equals("Success"))
                    {
                        LMSMessage += Environment.NewLine + " request file uploaded successfully";
                        return true;
                    }
                    else
                    {
                        throw new Exception(uploadResponse.errorMessage[0].message);
                        return false;
                    }

                }
            }
            catch (Exception ex)
            {
                LMSMessage += Environment.NewLine + " uploadFile:" + ex.Message;
                return false;
            }
        }
Ejemplo n.º 2
0
        private bool uploadFile(frmLMSMain sender, HttpRequestMessageProperty httpRequest, string jobID, string fileRefID, string fileName)
        {
            sender.UploadStatus += "\n\nUploading the request file.\n";
                try
                {
                    FileTransferServicePortClient client = new FileTransferServicePortClient(FTconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

                        OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

                        UploadFileRequest uploadReq = new UploadFileRequest();

                        uploadReq.fileAttachment = getFileAttachment(fileName);
                        uploadReq.fileReferenceId = fileRefID;
                        uploadReq.taskReferenceId = jobID;
                        uploadReq.fileFormat = "gzip";

                        UploadFileResponse uploadResponse = client.uploadFile(uploadReq);

                        if (uploadResponse.ack.ToString().Equals("Success"))
                        {
                            sender.UploadStatus += uploadResponse.timestamp + " :: " + fileName + " has been successfully uploaded to the server.\n";
                            return true;
                        }
                        else
                        {
                            sender.UploadStatus += uploadResponse.timestamp + " :: " + "Could not upload file to Server\n";

                            if (uploadResponse.errorMessage != null)
                            {
                                ErrorAdmin.updateResponseStatus(uploadResponse, sender, true);
                            }
                            return false;
                        }

                    }
                }
                catch (Exception ex)
                {
                    sender.UploadStatus += ex + "\n";
                    return false;
                }
        }
Ejemplo n.º 3
0
        static void downloadFile(bool isUpload, HttpRequestMessageProperty httpRequest, string jobID, string fileRefID, string fileName)
        {
            //Downloading the response file.\n";
            try
            {
                FileTransferServicePortClient client = new FileTransferServicePortClient(FTconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

                    DownloadFileRequest downloadReq = new DownloadFileRequest();
                    downloadReq.fileReferenceId = fileRefID;
                    downloadReq.taskReferenceId = jobID;

                    DownloadFileResponse downloadResponse = client.downloadFile(downloadReq);

                    if (downloadResponse.ack.ToString().Equals("Success"))
                    {
                        //log into database
                        FileAttachment attachment = downloadResponse.fileAttachment;
                        saveFileAttachment(attachment, fileName);
                        LMSMessage += Environment.NewLine + " response file successfully downloaded:";
                    }
                    else
                    {
                        throw new Exception(downloadResponse.errorMessage[0].message);
                        // "Problem downloading the file.";
                    }

                }
            }
            catch (Exception ex)
            {
                LMSMessage += Environment.NewLine + " downloadFile:" + ex.Message;
            }
        }
Ejemplo n.º 4
0
        private void downloadFile(frmLMSMain sender, bool isUpload, HttpRequestMessageProperty httpRequest, string jobID, string fileRefID, string fileName)
        {
            string txt = "";

                if (isUpload)
                    sender.UploadStatus += "Downloading the response file.\n";
                else
                    sender.DownloadStatus += "Downloading the report file.\n";

                try
                {
                    FileTransferServicePortClient client = new FileTransferServicePortClient(FTconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

                        OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

                        DownloadFileRequest downloadReq = new DownloadFileRequest();
                        downloadReq.fileReferenceId = fileRefID;
                        downloadReq.taskReferenceId = jobID;

                        DownloadFileResponse downloadResponse = client.downloadFile(downloadReq);

                        if (downloadResponse.ack.ToString().Equals("Success"))
                        {
                            FileAttachment attachment = downloadResponse.fileAttachment;
                            saveFileAttachment(attachment, fileName);

                            txt += downloadResponse.timestamp + " :: " + "File was successfully downloaded to " + fileName;
                            Console.WriteLine(txt);
                            if (isUpload)
                                sender.UploadStatus += txt;
                            else
                                sender.DownloadStatus += txt;
                        }
                        else
                        {
                            txt = downloadResponse.timestamp + " :: " + "Problem downloading the file.";
                            Console.WriteLine(txt);
                            if (isUpload)
                                sender.UploadStatus += txt;
                            else
                                sender.DownloadStatus += txt;

                            if (downloadResponse.errorMessage != null)
                            {
                                ErrorAdmin.updateResponseStatus(downloadResponse, sender, isUpload);
                            }
                        }

                    }
                }
                catch (Exception ex)
                {

                    if (isUpload)
                        sender.UploadStatus += ex + "\n";
                    else
                        sender.DownloadStatus += ex + "\n";
                }
        }