Example #1
0
        protected void findInDatabase()
        {
            try
            {
                if (consentNumber != null)
                {
                    bcResults.Style.Add("display", "block");
                    string     uri        = "http://api.waitaki.govt.nz/BuildingConsents/GetConsent?ConsentNumber=" + consentNumber;
                    WebRequest webRequest = WebRequest.Create(uri);
                    webRequest.Method      = "GET";
                    webRequest.ContentType = "application/json; charset=utf-8";

                    HttpWebResponse webResponce = (HttpWebResponse)webRequest.GetResponse();
                    string          responceResult;
                    using (var sr = new StreamReader(webResponce.GetResponseStream()))
                    {
                        responceResult = sr.ReadToEnd();
                    }

                    BuildingConsent results = TransformConsentInfoIntoObject(responceResult);
                    if (results.consentNumber != null)
                    {
                        writeToHTML(results);
                    }
                    else
                    {
                        bcResults.Style.Add("display", "none");
                        bcError.Style.Add("display", "block");
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Example #2
0
        protected BuildingConsent TransformConsentInfoIntoObject(string json)
        {
            try
            {
                JavaScriptSerializer jss     = new JavaScriptSerializer();
                BuildingConsent      consent = jss.Deserialize <BuildingConsent>(json);

                return(consent);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
        protected void writeToHTML(BuildingConsent consent)
        {
            HtmlTableRow bcsum = new HtmlTableRow();

            HtmlTableCell conNum = new HtmlTableCell();
            HtmlTableCell desc = new HtmlTableCell();
            HtmlTableCell status = new HtmlTableCell();
            HtmlTableCell estdurdate = new HtmlTableCell();

            conNum.InnerHtml = consent.consentNumber;
            desc.InnerHtml = consent.description;
            status.InnerHtml = consent.status;
            estdurdate.InnerHtml = consent.estimatedDueDate.Split(' ')[0];

            bcsum.Controls.Add(conNum);
            bcsum.Controls.Add(desc);
            bcsum.Controls.Add(status);
            bcsum.Controls.Add(estdurdate);

            bcTableBCSum.Controls.Add(bcsum);

            foreach (BuildingConsentTask task in consent.tasks)
            {
                HtmlTableRow bctask = new HtmlTableRow();

                HtmlTableCell tasktask = new HtmlTableCell();
                HtmlTableCell taskstatus = new HtmlTableCell();
                HtmlTableCell taskdate = new HtmlTableCell();

                tasktask.InnerHtml = task.task;
                taskstatus.InnerHtml = task.Status;
                taskdate.InnerHtml = task.dateStarted.Split(' ')[0];

                if (taskstatus.InnerHtml == "Completed")
                {
                    taskstatus.InnerHtml =  "<div class=\"bcGreen\"></div>" + taskstatus.InnerHtml;
                }
                else if (taskstatus.InnerHtml == "In Process")
                {
                    taskstatus.InnerHtml = "<div class=\"bcYellow\"></div>" + taskstatus.InnerHtml;
                }

                if (tasktask.InnerHtml == "Request Info   " && task.Status == "In Process")
                {
                    taskstatus.InnerHtml = "<div class=\"bcRed\"></div>" + task.Status;
                }

                bctask.Controls.Add(tasktask);
                bctask.Controls.Add(taskstatus);
                bctask.Controls.Add(taskdate);

                bcTableBCStat.Controls.Add(bctask);
            }

            HtmlTableRow bcRequiredInfo = new HtmlTableRow();
            HtmlTableCell bcReqInfo = new HtmlTableCell();
            bcReqInfo.InnerHtml = consent.currentRequiredInfo;

            bcRequiredInfo.Controls.Add(bcReqInfo);
            bcTableCRInfo.Controls.Add(bcRequiredInfo);
        }
Example #4
0
        protected void writeToHTML(BuildingConsent consent)
        {
            HtmlTableRow bcsum = new HtmlTableRow();

            HtmlTableCell conNum     = new HtmlTableCell();
            HtmlTableCell desc       = new HtmlTableCell();
            HtmlTableCell status     = new HtmlTableCell();
            HtmlTableCell estdurdate = new HtmlTableCell();

            conNum.InnerHtml     = consent.consentNumber;
            desc.InnerHtml       = consent.description;
            status.InnerHtml     = consent.status;
            estdurdate.InnerHtml = consent.estimatedDueDate.Split(' ')[0];

            bcsum.Controls.Add(conNum);
            bcsum.Controls.Add(desc);
            bcsum.Controls.Add(status);
            bcsum.Controls.Add(estdurdate);

            bcTableBCSum.Controls.Add(bcsum);

            foreach (BuildingConsentTask task in consent.tasks)
            {
                HtmlTableRow bctask = new HtmlTableRow();

                HtmlTableCell tasktask   = new HtmlTableCell();
                HtmlTableCell taskstatus = new HtmlTableCell();
                HtmlTableCell taskdate   = new HtmlTableCell();

                tasktask.InnerHtml   = task.task;
                taskstatus.InnerHtml = task.Status;
                taskdate.InnerHtml   = task.dateStarted.Split(' ')[0];

                if (taskstatus.InnerHtml == "Completed")
                {
                    taskstatus.InnerHtml = "<div class=\"bcGreen\"></div>" + taskstatus.InnerHtml;
                }
                else if (taskstatus.InnerHtml == "In Process")
                {
                    taskstatus.InnerHtml = "<div class=\"bcYellow\"></div>" + taskstatus.InnerHtml;
                }

                if (tasktask.InnerHtml == "Request Info   " && task.Status == "In Process")
                {
                    taskstatus.InnerHtml = "<div class=\"bcRed\"></div>" + task.Status;
                }

                bctask.Controls.Add(tasktask);
                bctask.Controls.Add(taskstatus);
                bctask.Controls.Add(taskdate);

                bcTableBCStat.Controls.Add(bctask);
            }

            HtmlTableRow  bcRequiredInfo = new HtmlTableRow();
            HtmlTableCell bcReqInfo      = new HtmlTableCell();

            bcReqInfo.InnerHtml = consent.currentRequiredInfo;

            bcRequiredInfo.Controls.Add(bcReqInfo);
            bcTableCRInfo.Controls.Add(bcRequiredInfo);
        }