コード例 #1
0
        private void btnGetData_Click(object sender, EventArgs e)
        {
            string requestId = txtRequestId.Text;
            Stream data;
            long   filePosisiton = 0;
            long   fileSize      = 0;

            try
            {
                NncLogisticServiceClient client = new NncLogisticServiceClient();
                fileSize = client.FulFillOnDemandRequest(ref filePosisiton, ref requestId, out data);
            }

            catch (FaultException <ValidationFault> fault)
            {
                string          erroMsg         = "Validation fault caught \n";
                ValidationFault validationFault = fault.Detail;
                if (validationFault.Details.Count > 0)
                {
                    foreach (ValidationDetail detail in validationFault.Details)
                    {
                        erroMsg += detail.Message + "\n";
                    }

                    MessageBox.Show(erroMsg);
                }

                return;
            }
            catch (FaultException <RequestFault> rf)
            {
                RequestFault fault = rf.Detail;

                MessageBox.Show("Request Fault caught.\n" +
                                "Error code: " + fault.ErrorCode + "\n" +
                                "Error message: " + fault.ErrorMessage);
                return;
            }
            catch (FaultException <ExceptionFault> ef)
            {
                ExceptionFault fault = ef.Detail;

                MessageBox.Show("Exception Fault caught.\n" +
                                fault.Message + "\n" +
                                fault.OriginalStackTrace);
                return;
            }
            catch (LogisticServiceException le)
            {
                MessageBox.Show("Logistic Service Exception caught.\n" +
                                le.ToString());
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception caught \n" + ex.ToString());
                return;
            }

            DialogResult result = MessageBox.Show("Successfully retrieved data. " + "Total file size = " + fileSize + " (bytes).\n" +
                                                  "Do you want to see some data?", "Data Confirmation", MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result != DialogResult.Yes)
            {
                return;
            }
        }
コード例 #2
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            SubscriptionRequest request = GetRequest();
            string requestId            = string.Empty;

            if (request == null)
            {
                return;
            }

            request.IsForced = true;

            try
            {
                NncLogisticServiceClient client = new NncLogisticServiceClient();


                if (this.QueryType == "Ammunition")
                {
                    requestId = client.RequestAmmunitionSubscription(request);
                }
                else if (this.QueryType == "Blood Inventory")
                {
                    requestId = client.RequestBloodSubscription(request);
                }
                else if (this.QueryType == "Requisition Summary")
                {
                    requestId = client.RequestRequisitionSummarySubscription(request);
                }
                else if (this.QueryType == "Unit Equipment")
                {
                    requestId = client.RequestUnitEquipmentSubscription(request);
                }
                else if (this.QueryType == "War Reserves")
                {
                    requestId = client.RequestWarReserveSubscription(request);
                }
                else if (this.QueryType == "Wholesale Inventory")
                {
                    requestId = client.RequestWholesaleRetailSubscription(request);
                }
            }
            catch (FaultException <ValidationFault> fault)
            {
                string          erroMsg         = "Validation fault caught \n";
                ValidationFault validationFault = fault.Detail;
                if (validationFault.Details.Count > 0)
                {
                    foreach (ValidationDetail detail in validationFault.Details)
                    {
                        erroMsg += detail.Message + "\n";
                    }

                    MessageBox.Show(erroMsg);
                }

                return;
            }
            catch (FaultException <RequestFault> rf)
            {
                RequestFault fault = rf.Detail;

                MessageBox.Show("Request Fault caught.\n" +
                                "Error code: " + fault.ErrorCode + "\n" +
                                "Error message: " + fault.ErrorMessage);
                return;
            }
            catch (FaultException <ExceptionFault> ef)
            {
                ExceptionFault fault = ef.Detail;

                MessageBox.Show("Exception Fault caught.\n" +
                                fault.Message + "\n" +
                                fault.OriginalStackTrace);
                return;
            }
            catch (LogisticServiceException le)
            {
                MessageBox.Show("Logistic Service Exception caught.\n" +
                                le.ToString());
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception caught \n" + ex.ToString());
                return;
            }

            MessageBox.Show("Successful. RequestId = " + requestId);
            txtRequestId.Text = requestId;
        }
コード例 #3
0
        private void SubmitWholesaleOnDemandRequest()
        {
            string requestId = string.Empty;

            WholesaleOnDemandPrimaryClass primary = new WholesaleOnDemandPrimaryClass();

            primary.FieldName = TypeOfWholesaleOnDemandPrimaryField.MaterialAssetId;
            if (this.PrimaryValues == null)
            {
                primary.ClassValues = null;
            }
            else
            {
                primary.ClassValues.AddRange(this.PrimaryValues);
            }

            WholesaleOnDemandRequest request = new WholesaleOnDemandRequest(primary);

            if ((this.SecondaryValues != null) && (this.SecondaryValues.Length != 0))
            {
                request.SecondaryClass           = new WholesaleOnDemandSecondaryClass();
                request.SecondaryClass.FieldName = TypeOfWholesaleOnDemandSecondaryField.Node;
                request.SecondaryClass.ClassValues.AddRange(this.SecondaryValues);
            }

            try
            {
                NncLogisticServiceClient client = new NncLogisticServiceClient();
                requestId = client.RequestOnDemandWholesaleRetail(request);
            }
            catch (FaultException <ValidationFault> fault)
            {
                string          erroMsg         = "Validation fault caught \n";
                ValidationFault validationFault = fault.Detail;
                if (validationFault.Details.Count > 0)
                {
                    foreach (ValidationDetail detail in validationFault.Details)
                    {
                        erroMsg += detail.Message + "\n";
                    }

                    MessageBox.Show(erroMsg);
                }

                return;
            }
            catch (FaultException <RequestFault> rf)
            {
                RequestFault fault = rf.Detail;

                MessageBox.Show("Request Fault caught.\n" +
                                "Error code: " + fault.ErrorCode + "\n" +
                                "Error message: " + fault.ErrorMessage);
            }
            catch (FaultException <ExceptionFault> ef)
            {
                ExceptionFault fault = ef.Detail;

                MessageBox.Show("Exception Fault caught.\n" +
                                fault.Message + "\n" +
                                fault.OriginalStackTrace);
            }
            catch (LogisticServiceException le)
            {
                MessageBox.Show("Logistic Service Exception caught.\n" +
                                le.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception caught \n" + ex.ToString());

                return;
            }

            MessageBox.Show("Successful. RequestId = " + requestId);
            txtRequestId.Text = requestId;
        }
コード例 #4
0
        private void btnCheckData_Click(object sender, EventArgs e)
        {
            SubscriptionRequest request = GetRequest();
            SubscriptionInfo    info    = null;

            if (request == null)
            {
                return;
            }

            try
            {
                NncLogisticServiceClient client = new NncLogisticServiceClient();


                if (this.QueryType == "Ammunition")
                {
                    info = client.IsAmmunitionSubscriptionUpdated(request);
                }
                else if (this.QueryType == "Blood Inventory")
                {
                    info = client.IsBloodSubscriptionUpdated(request);
                }
                else if (this.QueryType == "Requisition Summary")
                {
                    info = client.IsRequisitionSummarySubscriptionUpdated(request);
                }
                else if (this.QueryType == "Unit Equipment")
                {
                    info = client.IsUnitEquipmentSubscriptionUpdated(request);
                }
                else if (this.QueryType == "War Reserves")
                {
                    info = client.IsWarReserveSubscriptionUpdated(request);
                }
                else if (this.QueryType == "Wholesale Inventory")
                {
                    info = client.IsWholesaleRetailSubscriptionUpdated(request);
                }
            }
            catch (FaultException <ValidationFault> fault)
            {
                string          erroMsg         = "Validation fault caught \n";
                ValidationFault validationFault = fault.Detail;
                if (validationFault.Details.Count > 0)
                {
                    foreach (ValidationDetail detail in validationFault.Details)
                    {
                        erroMsg += detail.Message + "\n";
                    }

                    MessageBox.Show(erroMsg);
                }

                return;
            }
            catch (FaultException <RequestFault> rf)
            {
                RequestFault fault = rf.Detail;

                MessageBox.Show("Request Fault caught.\n" +
                                "Error code: " + fault.ErrorCode + "\n" +
                                "Error message: " + fault.ErrorMessage);
                return;
            }
            catch (FaultException <ExceptionFault> ef)
            {
                ExceptionFault fault = ef.Detail;

                MessageBox.Show("Exception Fault caught.\n" +
                                fault.Message + "\n" +
                                fault.OriginalStackTrace);
                return;
            }
            catch (LogisticServiceException le)
            {
                MessageBox.Show("Logistic Service Exception caught.\n" +
                                le.ToString());
                return;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception caught \n" + ex.ToString());
                return;
            }

            string message = "Successful. New data availability = {0}. File generation = {1}. File generation time = {2}.";


            MessageBox.Show(string.Format(message, info.IsUpdateAvailable, info.IsFileGenerated, info.LastTimeUpdated.ToShortDateString()));
        }