Ejemplo n.º 1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            ///The following code is only used for submitting samples to the server so that there is work
            ///to process and experiment with.  THe code is not pretty.
            if (lstSubmit.SelectedItems.Count == 0)
            {
                MessageBox.Show("Please select a filing to submit", "Submit Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (this.txtFIPS.Text.Trim() == "")
            {
                MessageBox.Show("Please enter the FIPS code for the county in which you want to file", "Submit Filing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            string        theFiling     = File.ReadAllText(lstSubmit.SelectedItems[0].SubItems[0].Text).Replace("FIPS_CODE", this.txtFIPS.Text);
            FilingHandler filingManager = getConfiguedFilingHandler();

            int numPackages = 1;

            int.TryParse(txtTotalPackages.Text, out numPackages);
            string warningtext = string.Format("About to process {0} packages. Proceed?", numPackages);
            string warningcap  = "Continue?";

            var result = MessageBox.Show(warningtext, warningcap, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (result == DialogResult.No)
            {
                MessageBox.Show("Process halted.");
                return;
            }

            bool success = true;

            for (int i = 0; i < numPackages; i++)
            {
                string returnXML = filingManager.PRIATestSubmit(theFiling);
                if (returnXML.ToUpper().Contains("ERROR"))
                {
                    MessageBox.Show("An Error occurred: \r\n\r\n:" + returnXML);
                    success = false;
                    break;
                }
            }

            if (success)
            {
                showSuccess();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convenience method for creating a FilingHandler object using the account values on the form
        /// </summary>
        /// <returns> A configured FilingHandler</returns>
        private FilingHandler getConfiguedFilingHandler()
        {
            // Create the filingHandler using a convenience constructor.
            // USERNAME, PASSWORD, and URL **MUST** be set
            FilingHandler fileManager = new FilingHandler(this.txtUser.Text, this.txtPassword.Text, this.txtURL.Text);

            // On slow networks, it may be a good idea to increase the service request timeout.  Packages
            // have at least 1 image but could have several.
            if (!string.IsNullOrEmpty(this.txtTimeout.Text))
            {
                int timeout = 30;
                Int32.TryParse(this.txtTimeout.Text, out timeout);
                fileManager.TimeoutInSeconds = timeout;
            }

            return(fileManager);
        }
Ejemplo n.º 3
0
        private void RejectPackage(Package package, string reason)
        {
            // Get a Configured filinghandler using the form values
            FilingHandler filingManager = this.getConfiguedFilingHandler();


            try
            {
                // Rejected packages must provide reasons.  Insert the reasons into the pacakge
                if (!string.IsNullOrEmpty(reason.Trim()))
                {
                    package.ReasonsForRejection.Add(new RejectionReason(reason));

                    //NOTE - you can add any number of reasons.......
                }



                //Reject the package
                bool success = filingManager.RejectPackage(package);

                //if RejectPacakge returns true, then the package was successfully rejected.  If not, you might want
                // to check the raw response or status returned.

                if (!success)
                {
                    string err = filingManager.Status;
                    MessageBox.Show(err);

                    //or check the raw response.
                    string response = filingManager.RawXMLResponse;
                    Console.WriteLine(response);
                }
                else
                {
                    showSuccess();
                }
            }
            catch (Exception ex)
            {
                showError(ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Uses the API to retrieve a list of pending packages from the server and loads the list
        /// into the ListBox specified
        /// </summary>
        /// <param name="l">A listBox that will contain the list of pending packages</param>
        private void LoadPendingPackages(ListBox l)
        {
            // Get a Configured filinghandler using the form values
            FilingHandler filingManager = this.getConfiguedFilingHandler();


            try
            {
                //Request a list of pending packages.  This can return null if there was an issue.
                List <string> packageGUIDS = filingManager.GetPendingPackages();

                //the list returned is a list of the ids of all the pending packages.  The ids are just guids,
                //and will be used for all subsequent actions on a filing.

                //check to see if any guids were returned.  If the object is null, there was a business rule
                //error.  A non-null object with a count of zero in its collection simply means there are no
                //pending filings.
                if (packageGUIDS != null)
                {
                    //Lets load the listbox with the filing guids.
                    l.Items.Clear();
                    foreach (string guid in packageGUIDS)
                    {
                        l.Items.Add(guid);
                    }
                    showSuccess();
                }

                else
                {
                    // Part of the response is a status
                    // element, which can contain additional information if there were errors.  We don't anticipate errors here,
                    // but if one occurred (or the list returned null and we KNOW there are pending packages) it might be meaningful
                    // to check the status.  Try not setting the username for an example.
                    string status = filingManager.Status;
                    MessageBox.Show(status);
                    Console.WriteLine(status);

                    // ADDITIONAL INFO----
                    // If you can manipulate pria responses directly, you can simply invoke the raw webservice using the API
                    // as a proxy.  This gives you the response as a well formed pria response xml document.
                    string priaResponse = filingManager.PRIAGetPendingPackages();
                    Console.WriteLine(priaResponse);
                }

                // ADDITIONAL INFO----
                // The request to the server did not require actual pria xml but if it did and we wanted to get at the
                // raw XML we would do something like:
                string theRawRequest = filingManager.RawXMLReqest;
                Console.WriteLine(theRawRequest);

                // ADDITIONAL INFO----
                //The response from the server was a well formed pria respone.  To see it:
                string theRawResponse = filingManager.RawXMLResponse;
                Console.WriteLine(theRawResponse);
            }
            catch (Exception ex)
            {
                showError(ex);
            }
        }
Ejemplo n.º 5
0
        private void btnAccept_Click(object sender, EventArgs e)
        {
            try
            {
                if (!validateAcceptForm())
                {
                    return;
                }

                // All calls to AcceptPackage require a full document package to be sent in xml format.
                // The API handles this for you, but it is important to note a few things.
                // 1) Each document delivered in the original filing package MUST be represented in the accept package.
                // 2) It is important to look at the "recordable" property of each filing.  Some documents may not be submitted
                //    for recording.
                // 3) Entire packages are accepted or rejected, not individual filings.


                // for simplicity, we are going to accept the retrieved pending package "as is", but this is NOT
                // a reasonable way to accept the documents.  In the real world, the document images within the pacakge
                // would be updated to contain the stamped and final versions.

                Package p = this.mainPackage;

                //psuedo code to mock update and process the filings with actual images.
                foreach (Filing f in p.Filings)
                {
                    foreach (DocumentImage di in f.Images)
                    {
                        // blah blah ..
                    }
                }

                //The previous lines of code did absolutely nothing but the point was to illustrate that some
                // manipulation could be done to the received pending filing. You could have started from scratch
                // and built the objects yourself.

                //we are going to step through the filing collection again and apply the endorsement to each
                //recordable document.  Again, this is not suitable for the real world because each document will have its
                //own endorsement and fee, but it serves the purposed for this very simple demo.

                foreach (Filing f in p.Filings)
                {
                    if (f.Recordable)
                    {
                        //Assign the endorsement info
                        f.Endorsement.Book = this.txtBook.Text;
                        f.Endorsement.Page = this.txtPage.Text;

                        //This representes the ACTUAL  (stamped) filing date
                        f.Endorsement.FileDate = DateTime.Now;

                        //Docket type
                        f.Endorsement.DocketType = (DOCKET_TYPES)Enum.Parse(typeof(DOCKET_TYPES), this.txtDocket.Text, true);

                        //If this was something other than a book/page filing, the instrument number
                        // would have to be set:
                        //f.Endorsement.InstrumentNumber = "000000232";

                        //set the fees.
                        foreach (ListViewItem l in this.lstFees.Items)
                        {
                            //no error checking here, but there should be.
                            FilingFee newFee = new FilingFee(Convert.ToDouble(l.SubItems[0].Text), l.SubItems[1].Text);
                            f.Fees.Add(newFee);
                        }
                    }
                }

                //So we have endorsed all of our documents, time to submit the package.
                // Get a Configured filinghandler using the form values
                FilingHandler filingManager = this.getConfiguedFilingHandler();

                filingManager.TimeoutInSeconds = Int32.MaxValue;
                bool acceptedOnServer = filingManager.AcceptPackage(p);
                if (!acceptedOnServer)
                {
                    //something happened such as a business rule violation.
                    string err = filingManager.Status;
                    MessageBox.Show(err);

                    //or check the raw response.
                    string response = filingManager.RawXMLResponse;
                    Console.WriteLine(response);
                }
                else
                {
                    showSuccess();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
        private void GetPendingPackage(string guid)
        {
            // Get a Configured filinghandler using the form values
            FilingHandler filingManager = this.getConfiguedFilingHandler();


            try
            {
                filingManager.TimeoutInSeconds = Int32.MaxValue;
                //Retrieve the package from the GSCCCA server.
                Package package = filingManager.GetPendingPackage(guid);

                //package may be null if there was an issue, so be sure to check
                if (package != null)
                {
                    // the package object contains information about the filing package including the filer,
                    // filings, etc...  Explore the API documentation to get a full list of data that is contained in a package

                    //Lets save the package on the form so it can be generally used by other demos.
                    this.mainPackage = package;

                    // ADDITIONAL INFO----
                    // To get the filer...
                    FilingParty filer = package.OriginalFiler;
                    Console.WriteLine(filer.Name);

                    // ADDITIONAL INFO----
                    // Every pending package is guaranteed to have at least one filing, but may have more.
                    foreach (Filing f in package.Filings)
                    {
                        foreach (var doc in f.Images)
                        {
                            // ADDITIONAL INFO----
                            // EACH filing has a unique ID associated with it.  THIS IS IMPORTANT.
                            // ACCEPTING / REJECTING is performed on the entire package.  HOWEVER, when accepting a package,
                            // each filing in the package must be accounted for and this is tracked by the Filing.GSCCCAID
                            // property.  Do keep up with the GSCCCAID of the filing.
                            Guid thisFilingID = f.GSCCCAID;


                            // ADDITIONAL INFO----
                            // Packages may include documents that do not need to be recorded.  It is important to pay attention
                            // to such flags.
                            bool recordDocument = f.Recordable;

                            // ADDITIONAL INFO----
                            // When accepting a package, each filing in the pacakge THAT IS RECORDABLE must contain an endoresement and fee
                            // information.  More on this in the ACCEPTPACAKGE demo...


                            // ADDITIONAL INFO----
                            // Each filing contains at least one, but potentially more document images
                            // The byte data of the image can be found in the Data property.
                            // FOR THE DEMO, lets load the first image into the picture box on the page.
                            try
                            {
                                MemoryStream ms = new MemoryStream(doc.Data);
                                this.picImageDemo.Image = Image.FromStream(ms);
                            }
                            catch (Exception)
                            {
                            }
                        }

                        //NOTE: you can also iterate through the images
                        //foreach (DocumentImage di in f.Images)
                        //{
                        //    //do something....
                        //}

                        //break out of the foreach which was just showing that the filings can be iterated over.
                        //break;
                    }
                }
                else
                {
                    //If we branch here, the returned package was null.  This is an unexpected case.  Always check the status
                    //property of the FilingHandler when this occurs.
                    string whatWentWrong = filingManager.Status;
                    MessageBox.Show(whatWentWrong);
                }


                //// ADDITIONAL INFO----
                //// The request to the server did not require actual pria xml but if it did and we wanted to get at the
                //// raw XML we would do something like:
                //string theRawRequest = filingManager.RawXMLReqest;
                //Console.WriteLine(theRawRequest);

                //// ADDITIONAL INFO----
                ////The response from the server was a well formed pria respone.  To see it:
                //string theRawResponse = filingManager.RawXMLResponse;
                //Console.WriteLine(theRawResponse);


                //// ADDITIONAL INFO----
                //// If you can manipulate pria responses directly, you can simply invoke the raw webservice using the API
                //// as a proxy.  This gives you the response as a well formed pria response xml document.
                //string priaResponse = filingManager.PRIAGetPendingPackage(guid);
                //Console.WriteLine(priaResponse);



                //Tell the user the operation completed.
                showSuccess();
            }
            catch (Exception ex)
            {
                showError(ex);
            }
        }