コード例 #1
0
ファイル: LMSHelper.cs プロジェクト: msaleh/HRM
        static string getJobStatus(bool isUpload, HttpRequestMessageProperty httpRequest, string jobID)
        {
            string fileRefID = "";
            //nCalling getJobStatus every minute to see if the job has completed.\n";
            try
            {
                BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

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

                    while (fileRefID == "")
                    {
                        //Sleep between successive requests
                        Thread.Sleep(WaitngJobCompletedinSeconds * 1000);

                        GetJobStatusRequest req = new GetJobStatusRequest();
                        req.jobId = jobID.Trim();

                        GetJobStatusResponse resp = client.getJobStatus(req);

                        if (resp.ack == BDX.AckValue.Success)
                        {
                            if (resp.jobProfile != null)
                            {
                                foreach (JobProfile jobProfile in resp.jobProfile)
                                {
                                    if (jobProfile.fileReferenceId != null)
                                    {
                                        // log into data base
                                        LMSMessage += Environment.NewLine + " job has completed " + jobProfile.jobId;
                                        //resp.timestamp + " :: " + "Job Type: " + jobProfile.jobType + "::Job ID: " + jobProfile.jobId + "::" + "FileRefID: " + jobProfile.fileReferenceId + "::" + "Job Status: " + jobProfile.jobStatus + "\n\n";
                                        fileRefID = jobProfile.fileReferenceId;
                                        LMSJobStatus = jobProfile.jobStatus.ToString(); // "Job Completed";
                                    }
                                    else
                                    {
                                        //txt = resp.timestamp + " :: " + "Job Type: " + jobProfile.jobType + "::Job ID: " + jobProfile.jobId + "::" + "Job Status: " + jobProfile.jobStatus + "\n"; ;
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new Exception(resp.errorMessage[0].message);
                        }

                    }
                    return fileRefID;

                }
            }
            catch (Exception ex)
            {
                LMSMessage += Environment.NewLine + " getJobStatus:" + ex.Message;
                return "";
            }
        }
コード例 #2
0
ファイル: LMSHelper.cs プロジェクト: msaleh/HRM
        static bool startUploadJob(HttpRequestMessageProperty httpRequest, string jobID)
        {
            try
            {
                BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

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

                    StartUploadJobRequest req = new StartUploadJobRequest();
                    req.jobId = jobID.Trim();

                    StartUploadJobResponse resp = client.startUploadJob(req);

                    // update the status of the request (success / fail) and any messages returned
                    if (resp.ack == BDX.AckValue.Success)
                    {
                        LMSMessage += Environment.NewLine + " job has been successfully scheduled";
                        //log into database
                        //" has been successfully scheduled. \n";
                        return true;
                    }
                    else
                    {
                        throw new Exception(resp.errorMessage[0].message);
                        //"This job might have already been scheduled.\n";
                        return false;
                    }

                }
            }
            catch (Exception ex)
            {
                LMSMessage += Environment.NewLine + " startUploadJob:" + ex.Message;
                return false;
            }
        }
コード例 #3
0
ファイル: LMSHelper.cs プロジェクト: msaleh/HRM
        static CreateUploadJobResponse createUploadJob(HttpRequestMessageProperty httpRequest, string JobType)
        {
            string txt = "";
            try
            {

                BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

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

                    //Create the request
                    CreateUploadJobRequest req = new CreateUploadJobRequest();

                    //Supply additional parameters
                    // The UUID must be unique.  Once used, you can't use it again
                    req.UUID = System.Guid.NewGuid().ToString();
                    req.uploadJobType = JobType;
                    req.fileType = FileType.XML;

                    //Get the response
                    CreateUploadJobResponse resp = client.createUploadJob(req);

                    if (resp.ack == BDX.AckValue.Success)
                    {
                        LMSMessage += Environment.NewLine + resp.timestamp + " :: " + JobType + " has been created with Job ID:" + resp.jobId + " and FileRefID: " + resp.fileReferenceId;
                        // log this to database
                    }
                    else
                    {
                        throw new Exception(resp.errorMessage[0].message);
                    }

                    return resp;

                }
            }
            catch (Exception ex)
            {
                LMSMessage += Environment.NewLine + " createUploadJob:" + ex.Message;
                CreateUploadJobResponse errResp = null;
                return errResp;
            }
        }
コード例 #4
0
ファイル: LMSHelper.cs プロジェクト: msaleh/HRM
        static GetJobsResponse GetJob(HttpRequestMessageProperty httpRequest)
        {
            try
            {

                BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

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

                    //Create the request
                    GetJobsRequest req = new GetJobsRequest();

                    //Supply additional parameters
                    //The UUID must be unique.  Once used, you can't use it again
                    req.jobType = new string[] { "ReviseInventoryStatus" };

                    //Get the response
                    GetJobsResponse resp = client.getJobs(req);

                    if (resp.ack == BDX.AckValue.Success)
                    {

                    }
                    else
                    {
                        throw new Exception(resp.errorMessage[0].message);
                    }

                    return resp;

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                GetJobsResponse errResp = null;
                return errResp;
            }
        }
コード例 #5
0
ファイル: LMSHelper.cs プロジェクト: msaleh/HRM
        static AbortJobResponse AbortJob(HttpRequestMessageProperty httpRequest, string jobId)
        {
            try
            {

                BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {

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

                    //Create the request
                    AbortJobRequest req = new AbortJobRequest();

                    req.jobId = jobId;

                    //Get the response
                    AbortJobResponse resp = client.abortJob(req);

                    if (resp.ack == BDX.AckValue.Success)
                    {

                    }
                    else
                    {
                        throw new Exception(resp.errorMessage[0].message);
                    }
                    return resp;

                }
            }
            catch (Exception ex)
            {
                AbortJobResponse errResp = null;
                return errResp;
            }
        }
コード例 #6
0
ファイル: frmLMSMain.cs プロジェクト: msaleh/HRM
        private bool startUploadJob(frmLMSMain sender, HttpRequestMessageProperty httpRequest, string jobID)
        {
            string txt = "";

                sender.UploadStatus += "\nCalling startUploadJob.\n";
                try
                {
                    BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

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

                        StartUploadJobRequest req = new StartUploadJobRequest();
                        req.jobId = jobID.Trim();

                        StartUploadJobResponse resp = client.startUploadJob(req);

                        // update the status of the request (success / fail) and any messages returned
                        if (resp.ack == BDX.AckValue.Success)
                        {
                            txt += "Job with JobID " + jobID + " has been successfully scheduled. \n";
                            txt += "\n" + resp.timestamp;
                            Console.WriteLine(txt);
                            sender.UploadStatus += txt;
                            return true;
                        }
                        else
                        {
                            txt = resp.timestamp + " :: " + "This job might have already been scheduled.\n";
                            Console.WriteLine(txt);
                            sender.UploadStatus += txt;

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

                    }
                }
                catch (Exception ex)
                {
                    sender.UploadStatus += ex + "\n";
                    return false;
                }
        }
コード例 #7
0
ファイル: frmLMSMain.cs プロジェクト: msaleh/HRM
        private string startDownloadJob(frmLMSMain sender, HttpRequestMessageProperty httpRequest, string ReportType)
        {
            string txt = "";

                sender.DownloadStatus = "Calling startDownloadJob\n";
                try
                {
                    BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

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

                        StartDownloadJobRequest req = new StartDownloadJobRequest();
                        req.downloadJobType = ReportType;

                        // Generate a UUID. UUID must be unique.  Once used, you can't use it again
                        req.UUID = System.Guid.NewGuid().ToString();

                        StartDownloadJobResponse resp = client.startDownloadJob(req);

                        // update the status of the request (success / fail) and any messages returned
                        // add any error messages received
                        if (resp.errorMessage != null)
                        {
                                ErrorAdmin.updateResponseStatus(resp, sender, false);
                        }

                        if (resp.jobId != null)
                        {
                            txt += resp.timestamp + " :: " + ReportType + " with jobID: " + resp.jobId + " has been created.\n";
                            Console.WriteLine(txt);
                            sender.DownloadStatus += txt;
                            return resp.jobId;

                        }
                        else
                            return "";
                    }
                }
                catch(Exception ex)
                {
                    sender.DownloadStatus += ex + "\n";
                    return "";
                }
        }
コード例 #8
0
ファイル: frmLMSMain.cs プロジェクト: msaleh/HRM
        private string getJobStatus(frmLMSMain sender, bool isUpload, HttpRequestMessageProperty httpRequest, string jobID)
        {
            string txt = "";
                string fileRefID = "";

                if (isUpload)
                    sender.UploadStatus += "\nCalling getJobStatus every minute to see if the job has completed.\n";
                else
                    sender.DownloadStatus += "\nCalling getJobStatus every minute to see if the job has completed.\n";
                try
                {
                    BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

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

                        while (fileRefID == "")
                        {
                            //Sleep between successive requests
                            Thread.Sleep(60000);

                            GetJobStatusRequest req = new GetJobStatusRequest();
                            req.jobId = jobID.Trim();

                            GetJobStatusResponse resp = client.getJobStatus(req);

                            // update the status of the request (success / fail) and any messages returned
                            if (resp.errorMessage != null)
                            {
                                ErrorAdmin.updateResponseStatus(resp, sender, isUpload);
                            }

                            if (resp.jobProfile != null)
                            {
                                foreach (JobProfile jobProfile in resp.jobProfile)
                                {
                                    if (jobProfile.fileReferenceId != null)
                                    {
                                        txt = resp.timestamp + " :: " + "Job Type: " + jobProfile.jobType + "::Job ID: " + jobProfile.jobId + "::" + "FileRefID: " + jobProfile.fileReferenceId + "::" + "Job Status: " + jobProfile.jobStatus + "\n\n";
                                        fileRefID = jobProfile.fileReferenceId;
                                        Console.WriteLine(txt);
                                        if (isUpload)
                                            sender.UploadStatus += txt;
                                        else
                                            sender.DownloadStatus += txt;
                                    }
                                    else
                                    {
                                        txt = resp.timestamp + " :: " + "Job Type: " + jobProfile.jobType + "::Job ID: " + jobProfile.jobId + "::" + "Job Status: " + jobProfile.jobStatus + "\n";;
                                        Console.WriteLine(txt);
                                        if (isUpload)
                                            sender.UploadStatus += txt;
                                        else
                                            sender.DownloadStatus += txt;
                                    }
                                }
                            }
                        }
                        return fileRefID;

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

                    return "";
                }
        }
コード例 #9
0
ファイル: frmLMSMain.cs プロジェクト: msaleh/HRM
        private CreateUploadJobResponse createUploadJob(frmLMSMain sender, HttpRequestMessageProperty httpRequest, string JobType)
        {
            string txt = "";

                try
                {
                    sender.UploadStatus += "Calling createUploadJob\n";

                    BulkDataExchangeServicePortClient client = new BulkDataExchangeServicePortClient(BDXconfigName);
                    using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                    {

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

                        //Create the request
                        CreateUploadJobRequest req = new CreateUploadJobRequest();

                        //Supply additional parameters
                        // The UUID must be unique.  Once used, you can't use it again
                        req.UUID = System.Guid.NewGuid().ToString();
                        req.uploadJobType = JobType;
                        req.fileType = FileType.XML;

                        //Get the response
                        CreateUploadJobResponse resp = client.createUploadJob(req);

                        // update the status of the request (success / fail) and any messages returned
                        if (resp.errorMessage != null)
                        {
                            ErrorAdmin.updateResponseStatus(resp, sender, true);
                        }

                        if (resp.ack == BDX.AckValue.Success)
                        {
                            txt += resp.timestamp + " :: " + JobType + " has been created with Job ID:" + resp.jobId + " and FileRefID: " + resp.fileReferenceId;
                            Console.WriteLine(txt);
                            sender.UploadStatus += txt;
                        }

                        return resp;

                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                    sender.UploadStatus += ex + "\n";
                    CreateUploadJobResponse errResp = null;
                    return errResp;
                }
        }