Ejemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ID,Username,FirstName,LastName,Address,City,State,Zip,email")] Homeowner homeowner)
        {
            string identity = System.Web.HttpContext.Current.User.Identity.GetUserId();

            if (identity == null)
            {
                return(RedirectToAction("Must_be_logged_in", "Homeowners"));
            }

            if (!this.User.IsInRole("Admin") && (!this.User.IsInRole("Homeowner")))
            {
                return(RedirectToAction("Must_be_logged_in", "Homeowners"));
            }

            foreach (var user in db.Users)
            {
                if (user.Id == identity)
                {
                    homeowner.email     = user.Email;
                    homeowner.Username  = user.Screen_Name;
                    homeowner.FirstName = user.First_Name;
                    homeowner.LastName  = user.Last_Name;
                }
            }
            if (ModelState.IsValid)
            {
                db.Homeowners.Add(homeowner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(homeowner));
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Homeowner homeowner = db.Homeowners.Find(id);

            db.Homeowners.Remove(homeowner);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
 public void Create(Homeowner homeowner)
 {
     using (var context = new ApartmentContext())
     {
         context.Homeowners.Add(homeowner);
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "ID,Username,FirstName,LastName,Address,City,State,Zip,email")] Homeowner homeowner)
 {
     if (ModelState.IsValid)
     {
         db.Entry(homeowner).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(homeowner));
 }
Ejemplo n.º 5
0
        public ActionResult HomeownerForm(Homeowner homeOwner)
        {
            if (!ModelState.IsValid)
            {
                return(View(homeOwner));
            }

            Session["Homeowner"] = homeOwner;
            return(RedirectToAction("LocationForm", "Location"));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "ID,Username,FirstName,LastName,Address,City,State,Zip,email")] Homeowner homeowner)
        {
            if (ModelState.IsValid)
            {
                db.Homeowners.Add(homeowner);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(homeowner));
        }
        public ActionResult Index(string phoneNumber)
        {
            var homeowner = homeownerRepository.GetHomeowners().FirstOrDefault(h => h.PhoneNumber == phoneNumber);

            if (homeowner != null)
            {
                _homeowner = homeowner;
                return(RedirectToAction("Apartments"));
            }
            _homeowner = new Homeowner {
                PhoneNumber = phoneNumber
            };
            return(RedirectToAction("RegisterHomeowner"));
        }
Ejemplo n.º 8
0
        // GET: Email/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Homeowner homeowner = db.Homeowners.Find(id);

            if (homeowner == null)
            {
                return(HttpNotFound());
            }
            return(View(homeowner));
        }
Ejemplo n.º 9
0
        public ActionResult MyPolicies()
        {
            User          user     = Session["User"] as User;
            List <Policy> policies = new List <Policy>();

            using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity())
            {
                Homeowner ho = qe.Homeowners.FirstOrDefault(h => h.UserId == user.Id);
                if (ho == null)
                {
                    return(View(policies));
                }
                policies.AddRange(qe.IncludeInPolicies("Quote.Property.Location.Homeowner.User")
                                  .Where(p => p.Quote.Property.Location.Homeowner.UserId == ho.UserId));
                return(View(policies));
            }
        }
Ejemplo n.º 10
0
        public ActionResult UserPolicies()
        {
            User          user       = Session["User"] as User;
            List <Policy> policyList = new List <Policy>();

            using (QuotesEntity qe = new QuotesEntity()) {
                List <Policy> allPolicy = qe.Policies.Include("Quote.Property.Location.Homeowner.User").ToList();

                Homeowner ho = qe.HomeOwners.FirstOrDefault(h => h.UserId == user.Id);
                if (ho == null)
                {
                    return(View(policyList));
                }

                policyList.AddRange(qe.Policies.Where(p => p.Quote.Property.Location.HomeownerId == ho.Id));
                return(View(policyList));
            }
        }
Ejemplo n.º 11
0
        public ActionResult QuoteDetails()
        {
            User         user      = Session["User"] as User;
            List <Quote> quoteList = new List <Quote>();

            //List<Policy> policyList = new List<Policy>();
            using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity())
            {
                Homeowner ho = qe.Homeowners.FirstOrDefault(h => h.UserId == user.Id);
                quoteList.AddRange(qe.IncludeInQuotes("Property.Location.Homeowner.User")
                                   .Where(q => q.Property.Location.Homeowner.UserId == user.Id));
                //policyList.AddRange(qe.IncludeInPolicies("Quote.Property.Location.Homeowner.User")
                //    .Where(p => p.Quote.Property.Location.Homeowner.UserId == ho.UserId));
                //var quotesWithPolicy = quoteList.Where(q => policyList.Any(p => p.QuoteId == q.Id));
                //var quotesWithoutPolicy = quoteList.Except(quotesWithPolicy);
                return(View(quoteList));
                //return View(quotesWithoutPolicy);
            }
        }
Ejemplo n.º 12
0
        public ProfileViewModel(User user) : this()
        {
            if (user == null)
            {
                return;
            }

            Firstname   = user.Firstname;
            Lastname    = user.Lastname;
            Email       = user.Email;
            Role        = user.Role;
            PhoneNumber = user.PhoneNumber;
            Description = user.Description;
            Photo       = user.Photo;

            Contractor   = user.ContractorRef;
            InternalUser = user.InternalUserRef;
            Homeowner    = user.HomeownerRef;
        }
        // Full summary of Quote/Property/Location
        public ActionResult QuoteSummary(int?quoteId)
        {
            if (!quoteId.HasValue)
            {
                try
                {
                    quoteId = (int)Session["quoteId"];
                }

                catch
                {
                    // TODO: redirect
                    return(RedirectToAction("GetStarted", "Quotes"));
                }
            }

            else
            {
                Session["quoteId"] = quoteId;
            }

            // TODO: do we have a User?
            using (IQuotesEntity qe = QuoteSource.CreateQuotesEntity())
            {
                Quote q = qe.IncludeInQuotes("Property.Location.Homeowner.User").Where(qq => qq.Id == quoteId).FirstOrDefault();
                // TODO: is q null?

                //Added this section in order to stop the user from being able to buy same quote multiple times
                List <Policy> policies = new List <Policy>();
                User          user     = Session["User"] as User;
                Homeowner     ho       = qe.Homeowners.FirstOrDefault(h => h.UserId == user.Id);
                policies.AddRange(qe.IncludeInPolicies("Quote.Property.Location.Homeowner.User")
                                  .Where(p => p.Quote.Property.Location.Homeowner.UserId == ho.UserId && p.QuoteId == q.Id));
                bool isPolicyExist = policies.Count > 0;
                Tuple <Quote, bool> returningParameters = new Tuple <Quote, bool>(q, isPolicyExist);              //Tuple used for multiple returns
                return(View(returningParameters));

                //return View(q); This not needed anymore, q returned in line 55 via Tuple
            }
        }
Ejemplo n.º 14
0
        public ActionResult SaveQuote()
        {
            Quote     quote     = Session["Quote"] as Quote;
            Property  property  = Session["Property"] as Property;
            Location  location  = Session["Location"] as Location;
            Homeowner homeowner = Session["Homeowner"] as Homeowner;
            User      user      = Session["User"] as User;

            quote.Property     = property;
            property.Location  = location;
            location.Homeowner = homeowner;
            homeowner.UserId   = user.Id;

            using (QuotesEntity qe = new QuotesEntity()) {
                qe.Quotes.Add(quote);
                qe.SaveChanges();
            }

            Session.Clear();
            Session["User"] = user;
            return(RedirectToAction("QuoteDetails"));
        }
Ejemplo n.º 15
0
        public string FTP_CASantaClara(string address, string assessment_id, string parcelNumber, string searchType, string orderNumber, string directParcel, string ownername)
        {
            GlobalClass.global_orderNo             = orderNumber;
            HttpContext.Current.Session["orderNo"] = orderNumber;
            GlobalClass.global_parcelNo            = parcelNumber;

            string StartTime = "", AssessmentTime = "", TaxTime = "", CitytaxTime = "", LastEndTime = "";

            //var driverService = PhantomJSDriverService.CreateDefaultService();
            //driverService.HideCommandPromptWindow = true;
            // driver = new PhantomJSDriver();
            //driver = new ChromeDriver();

            var option = new ChromeOptions();

            option.AddArgument("No-Sandbox");
            using (driver = new ChromeDriver(option))
            {
                try
                {
                    StartTime = DateTime.Now.ToString("HH:mm:ss");

                    if (searchType == "titleflex")
                    {
                        gc.TitleFlexSearch(orderNumber, parcelNumber, ownername, "", "CA", "Santa Clara");
                        if ((HttpContext.Current.Session["TitleFlex_Search"] != null && HttpContext.Current.Session["TitleFlex_Search"].ToString() == "Yes"))
                        {
                            driver.Quit();
                            return("MultiParcel");
                        }
                        else if (HttpContext.Current.Session["titleparcel"].ToString() == "")
                        {
                            HttpContext.Current.Session["Nodata_CASantaClara"] = "Zero";
                            driver.Quit();
                            return("No Data Found");
                        }
                        parcelNumber = HttpContext.Current.Session["titleparcel"].ToString();
                        searchType   = "parcel";
                    }

                    if (searchType == "address")
                    {
                        try
                        {
                            driver.Navigate().GoToUrl("https://www.sccassessor.org/index.php/online-services/property-search/real-property");
                            Thread.Sleep(2000);

                            IWebElement iframeElementAdd = driver.FindElement(By.XPath("//*[@id='blockrandom']"));
                            driver.SwitchTo().Frame(iframeElementAdd);
                            Thread.Sleep(2000);

                            driver.FindElement(By.XPath("//*[@id='searchinput']")).SendKeys(address);
                            gc.CreatePdf_WOP(orderNumber, "Address search", driver, "CA", "Santa Clara");
                            driver.FindElement(By.Id("btnAddress")).SendKeys(Keys.Enter);
                            Thread.Sleep(4000);

                            //MultiParcel
                            try
                            {
                                IWebElement         MultiTable = driver.FindElement(By.XPath("//*[@id='asrGrid']/div[2]/table/tbody"));
                                IList <IWebElement> MultiTR    = MultiTable.FindElements(By.TagName("tr"));
                                IList <IWebElement> MultiTD;
                                gc.CreatePdf_WOP(orderNumber, "Multi Address search", driver, "CA", "Santa Clara");
                                int maxCheck = 0;

                                foreach (IWebElement multi in MultiTR)
                                {
                                    if (maxCheck <= 25)
                                    {
                                        MultiTD = multi.FindElements(By.TagName("td"));
                                        if (MultiTD.Count != 0)
                                        {
                                            parcelNumber     = MultiTD[0].Text;
                                            property_Address = MultiTD[1].Text;
                                            MultiParcelData  = property_Address;
                                            gc.insert_date(orderNumber, parcelNumber, 547, MultiParcelData, 1, DateTime.Now);
                                        }
                                        maxCheck++;
                                    }
                                }

                                if (MultiTR.Count > 25)
                                {
                                    HttpContext.Current.Session["multiParcel_SantaClara_Multicount"] = "Maximum";
                                }
                                else
                                {
                                    HttpContext.Current.Session["multiparcel_SantaClara"] = "Yes";
                                }
                                driver.Quit();

                                return("MultiParcel");
                            }
                            catch
                            { }
                        }
                        catch
                        { }
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.XPath("//*[@id='ContentMasterPage_lblError']/div")).Text;
                            if (nodata.Contains("No records meet your search criteria:"))
                            {
                                HttpContext.Current.Session["Nodata_CASantaClara"] = "Zero";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                        try
                        {
                            //No Data Found
                            string nodata = driver.FindElement(By.XPath("//*[@id='ui-id-1']")).Text;
                            if (nodata.Contains("No Such Address"))
                            {
                                HttpContext.Current.Session["Nodata_CASantaClara"] = "Zero";
                                driver.Quit();
                                return("No Data Found");
                            }
                        }
                        catch { }
                    }

                    if (searchType == "parcel")
                    {
                        try
                        {
                            driver.Navigate().GoToUrl("https://www.sccassessor.org/index.php/online-services/property-search/real-property");
                            Thread.Sleep(2000);

                            IWebElement iframeElement1 = driver.FindElement(By.XPath("//*[@id='blockrandom']"));
                            driver.SwitchTo().Frame(iframeElement1);
                            Thread.Sleep(2000);

                            driver.FindElement(By.XPath("//*[@id='myTab-accordion']/div[3]/div[1]/h4/a")).Click();
                            Thread.Sleep(2000);

                            driver.FindElement(By.Id("apninput")).SendKeys(parcelNumber);
                            gc.CreatePdf_WOP(parcelNumber, "Parcel search", driver, "CA", "Santa Clara");
                            driver.FindElement(By.Id("btnAPN")).SendKeys(Keys.Enter);
                            Thread.Sleep(4000);
                            try
                            {
                                //No Data Found
                                string nodata = driver.FindElement(By.XPath("//*[@id='ContentMasterPage_lblError']/div")).Text;
                                if (nodata.Contains("No records meet your search criteria:"))
                                {
                                    HttpContext.Current.Session["Nodata_CASantaClara"] = "Zero";
                                    driver.Quit();
                                    return("No Data Found");
                                }
                            }
                            catch { }
                        }
                        catch
                        { }
                    }

                    //Property Details
                    parcelno         = driver.FindElement(By.XPath("//*[@id='divFrame']/div[1]/div/div[1]")).Text;
                    parcelno         = WebDriverTest.After(parcelno, ":").Replace("\r\n", " ").Trim();
                    Property_Address = driver.FindElement(By.XPath("//*[@id='oneAddress']/div/div[1]/div")).Text;


                    //Assessment Deatils
                    Tax_Default_Date = driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[1]/div/div/div/table/tbody/tr[2]/td[2]")).Text;
                    Tax_Default_Date = WebDriverTest.After(Tax_Default_Date, ": ");

                    IWebElement         AssementTB = driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[2]/div/div[2]/div/table/tbody"));
                    IList <IWebElement> AssementTR = AssementTB.FindElements(By.TagName("tr"));
                    IList <IWebElement> AssementTD;
                    foreach (IWebElement Assement in AssementTR)
                    {
                        AssementTD = Assement.FindElements(By.TagName("td"));
                        if (AssementTD.Count != 0 || !Assement.Text.Contains(" "))
                        {
                            lan = AssementTD[0].Text;
                            if (lan.Contains("Land:"))
                            {
                                Land_Value = AssementTD[1].Text;
                            }
                            Imp = AssementTD[0].Text;
                            if (Imp.Contains("Improvements:"))
                            {
                                Impovement = AssementTD[1].Text;
                            }
                            TAss = AssementTD[0].Text;
                            if (TAss.Contains("Total:"))
                            {
                                Total_Assessed = AssementTD[1].Text;
                            }
                        }
                    }

                    IWebElement         AssementTB1 = driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[2]/div/div[4]/div/table/tbody"));
                    IList <IWebElement> AssementTR1 = AssementTB1.FindElements(By.TagName("tr"));
                    IList <IWebElement> AssementTD1;
                    foreach (IWebElement Assement1 in AssementTR1)
                    {
                        AssementTD1 = Assement1.FindElements(By.TagName("td"));
                        if (AssementTD1.Count != 0 || !Assement1.Text.Contains(" "))
                        {
                            Homeowner = AssementTD1[0].Text;
                            if (Homeowner.Contains("Homeowner:"))
                            {
                                Home_Owner = AssementTD1[1].Text;
                            }
                            other = AssementTD1[0].Text;
                            if (other.Contains("Other:"))
                            {
                                Other = AssementTD1[1].Text;
                            }
                            TExe = AssementTD1[0].Text;
                            if (TExe.Contains("Total:"))
                            {
                                Total_Expections = AssementTD1[1].Text;
                            }
                        }
                    }

                    IWebElement         AssementTB2 = driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[2]/div/div[5]/div/table/tbody"));
                    IList <IWebElement> AssementTR2 = AssementTB2.FindElements(By.TagName("tr"));
                    IList <IWebElement> AssementTD2;
                    foreach (IWebElement Assement2 in AssementTR2)
                    {
                        AssementTD2 = Assement2.FindElements(By.TagName("td"));
                        if (AssementTD2.Count != 0 || !Assement2.Text.Contains(" "))
                        {
                            Net_Total = AssementTD2[0].Text;
                            if (Net_Total.Contains("Total:"))
                            {
                                Net_Assed_Value = AssementTD2[1].Text;
                            }
                        }
                    }

                    Assesssment_Details = Land_Value + "~" + Impovement + "~" + Total_Assessed + "~" + Home_Owner + "~" + Other + "~" + Total_Expections + "~" + Net_Assed_Value + "~" + Tax_Default_Date;
                    gc.CreatePdf(orderNumber, parcelno, "Assessment Details", driver, "CA", "Santa Clara");
                    ByVisibleElement(driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[2]/div/div[2]/div/table/tbody/tr[4]/td[1]")));
                    gc.CreatePdf(orderNumber, parcelno, "Assessment Details1", driver, "CA", "Santa Clara");
                    ByVisibleElement(driver.FindElement(By.XPath("//*[@id='tab-1-collapse']/div/div/div[2]/div/div[4]/div/table/thead/tr/td")));
                    gc.CreatePdf(orderNumber, parcelno, "Assessment Details2", driver, "CA", "Santa Clara");
                    gc.insert_date(orderNumber, parcelno, 542, Assesssment_Details, 1, DateTime.Now);

                    driver.FindElement(By.XPath("//*[@id='myTab-accordion']/div[5]/div[1]/h4/a")).Click();
                    Thread.Sleep(2000);

                    TRA = driver.FindElement(By.XPath("//*[@id='tab-5-collapse']/div/div/div/div/div[1]/div[1]/div/div/div[1]")).Text;
                    TRA = gc.Between(TRA, "TAX RATE AREA INFORMATION  ", "(Tax Rate Information as").Trim();

                    Property_Details = Property_Address + "~" + TRA;
                    gc.insert_date(orderNumber, parcelno, 541, Property_Details, 1, DateTime.Now);

                    AssessmentTime = DateTime.Now.ToString("HH:mm:ss");

                    //Tax Information
                    driver.Navigate().GoToUrl("https://payments.sccgov.org/propertytax/Secured");
                    Thread.Sleep(2000);

                    //Address Search
                    //driver.FindElement(By.XPath("//*[@id='tab2_link']/a")).SendKeys(Keys.Enter);
                    //Thread.Sleep(2000);

                    //driver.FindElement(By.Id("FullAddress")).SendKeys(address);
                    //driver.FindElement(By.XPath("//*[@id='FullAddress']")).SendKeys(Keys.Enter);
                    //Thread.Sleep(2000);

                    //parcelno = driver.FindElement(By.XPath("/html/body/div[2]/div/div[2]/div/form/div[1]/div/dl/dd[1]")).Text;
                    //parcelno = WebDriverTest.Before(parcelno, " View Payment History");

                    driver.FindElement(By.Id("ParcelNumber")).SendKeys(parcelno);
                    try
                    {
                        gc.CreatePdf(orderNumber, parcelno, "Tax Details 1", driver, "CA", "Santa Clara");
                        driver.FindElement(By.Id("ParcelSubmit")).SendKeys(Keys.Enter);
                        Thread.Sleep(2000);
                    }
                    catch
                    { }


                    try
                    {
                        ByVisibleElement(driver.FindElement(By.XPath("//*[@id='index_avoidconv_link']/span")));
                        gc.CreatePdf(orderNumber, parcelno, "Tax Details 2", driver, "CA", "Santa Clara");
                    }
                    catch
                    {
                    }
                    //Tax Payment History Details
                    try
                    {
                        driver.FindElement(By.XPath("//*[@id='tabs']/a/span")).Click();
                        Thread.Sleep(5000);
                    }
                    catch
                    { }

                    try
                    {
                        driver.FindElement(By.XPath("/html/body/div[2]/div/div[2]/div/form/div[1]/div/dl/dd[1]/a")).Click();
                        Thread.Sleep(5000);
                    }
                    catch
                    { }
                    IWebElement         TaxHistoryTB = driver.FindElement(By.XPath("//*[@id='historybody']"));
                    IList <IWebElement> TaxHistoryTR = TaxHistoryTB.FindElements(By.TagName("tr"));
                    IList <IWebElement> TaxHistoryTD;

                    foreach (IWebElement TaxHistory in TaxHistoryTR)
                    {
                        TaxHistoryTD = TaxHistory.FindElements(By.TagName("td"));
                        if (TaxHistoryTD.Count != 0)
                        {
                            Tax_Year_Payment           = TaxHistoryTD[0].Text;
                            APN_Suffix_Payment         = TaxHistoryTD[1].Text;
                            Installment_Payment        = TaxHistoryTD[2].Text;
                            Tax_Amount_Payment         = TaxHistoryTD[3].Text;
                            Additional_Charges_Payment = TaxHistoryTD[4].Text;
                            Paid_Amount_Payment        = TaxHistoryTD[5].Text;
                            Paid_Date_Payment          = TaxHistoryTD[6].Text;


                            Taxpayment_Details = Tax_Year_Payment + "~" + APN_Suffix_Payment + "~" + Installment_Payment + "~" + Tax_Amount_Payment + "~" + Additional_Charges_Payment + "~" + Paid_Amount_Payment + "~" + Paid_Date_Payment;
                            gc.CreatePdf(orderNumber, parcelno, "Tax Payment History Details", driver, "CA", "Santa Clara");
                            gc.insert_date(orderNumber, parcelno, 544, Taxpayment_Details, 1, DateTime.Now);
                        }
                    }
                    try
                    {
                        ByVisibleElement(driver.FindElement(By.XPath("//*[@id='historybody']/tr[11]/td[1]")));
                        gc.CreatePdf(orderNumber, parcelno, "Tax Payment History Details1", driver, "CA", "Santa Clara");
                    }
                    catch { }

                    try
                    {
                        driver.FindElement(By.XPath("//*[@id='closebutton']")).Click();
                        Thread.Sleep(2000);
                    }
                    catch { }



                    //Current Tax Details
                    try
                    {
                        tax_type = driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[1]/div[1]/span")).Text;

                        try
                        {
                            IWebElement CurrentBill    = driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div/div[1]/div/a"));
                            string      CurrentTaxBill = CurrentBill.GetAttribute("href");
                            gc.downloadfile(CurrentTaxBill, orderNumber, parcelno, "Current Tax Bill", "CA", "Santa Clara");
                        }
                        catch
                        { }

                        if (tax_type == "Annual Tax Bill" || tax_type == "Supplemental Tax Bill")
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                for (int j = 2; j < 11; j++)
                                {
                                    Installment += driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div/div[3]/div[" + (i + 2) + "]/div[ " + j + " ]")).Text + "~";
                                }
                                Installment = tax_type + "~" + Installment.Remove(Installment.Length - 1, 1);
                                i++;
                                gc.CreatePdf(orderNumber, parcelno, "Current Tax Details", driver, "CA", "Santa Clara");
                                gc.insert_date(orderNumber, parcelno, 540, Installment, 1, DateTime.Now);
                                Installment = "";
                            }
                        }
                    }
                    catch
                    { }


                    try
                    {
                        tax_type_Supp = driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[2]/div[1]/span")).Text;

                        try
                        {
                            IWebElement SupplementalBill    = driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[2]/div[1]/div/a"));
                            string      SupplementalTaxBill = SupplementalBill.GetAttribute("href");
                            gc.downloadfile(SupplementalTaxBill, orderNumber, parcelno, "Supplemental Tax Bill", "CA", "Santa Clara");
                        }
                        catch
                        { }

                        if (tax_type_Supp == "Supplemental Tax Bill")
                        {
                            InstallmentSupplemnt = "";
                            for (int k = 0; k < 3; k++)
                            {
                                for (int l = 2; l < 11; l++)
                                {
                                    InstallmentSupplemnt += driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[2]/div[3]/div[" + (k + 2) + "]/div[" + l + "]")).Text + "~";
                                }
                                InstallmentSupplemnt = tax_type_Supp + "~" + InstallmentSupplemnt.Remove(InstallmentSupplemnt.Length - 1, 1);
                                k++;
                                gc.CreatePdf(orderNumber, parcelno, "Supplemental Tax Details", driver, "CA", "Santa Clara");
                                gc.insert_date(orderNumber, parcelno, 545, InstallmentSupplemnt, 1, DateTime.Now);
                                InstallmentSupplemnt = "";
                            }
                        }


                        if (tax_type_Supp == "Supplemental Tax Bill")
                        {
                            InstallmentSupplemnt1 = "";
                            for (int m = 0; m < 3; m++)
                            {
                                for (int n = 2; n < 11; n++)
                                {
                                    try
                                    {
                                        InstallmentSupplemnt1 += driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[3]/div[3]/div[" + (m + 2) + "]/div[" + n + "]")).Text + "~";
                                    }
                                    catch
                                    { }
                                }
                                InstallmentSupplemnt1 = tax_type_Supp + "~" + InstallmentSupplemnt1.Remove(InstallmentSupplemnt1.Length - 1, 1);
                                m++;
                                try
                                {
                                    ByVisibleElement(driver.FindElement(By.XPath("//*[@id='select_invoiceslist']/div[3]/div[3]/div[1]/div[2]")));
                                    gc.CreatePdf(orderNumber, parcelno, "Supplemental Tax Details1", driver, "CA", "Santa Clara");
                                    Thread.Sleep(2000);
                                }
                                catch { }
                                gc.insert_date(orderNumber, parcelno, 546, InstallmentSupplemnt1, 1, DateTime.Now);
                                InstallmentSupplemnt1 = "";
                            }
                        }
                    }
                    catch
                    { }


                    TaxTime = DateTime.Now.ToString("HH:mm:ss");

                    LastEndTime = DateTime.Now.ToString("HH:mm:ss");
                    gc.insert_TakenTime(orderNumber, "CA", "Santa Clara", StartTime, AssessmentTime, TaxTime, CitytaxTime, LastEndTime);

                    driver.Quit();
                    gc.mergpdf(orderNumber, "CA", "Santa Clara");
                    return("Data Inserted Successfully");
                }
                catch (Exception ex)
                {
                    driver.Quit();
                    GlobalClass.LogError(ex, orderNumber);
                    throw;
                }
            }
        }
    protected void submitLogin_Click(object sender, EventArgs e)
    {
        //makes sure username does not already exist in the database
        String userNew = userNameTextbox.Text;

        Session["username"] = userNew;
        sc.Open();
        SqlCommand userCheck = new SqlCommand("SELECT Count(*) FROM [dbo].[Login] WHERE lower(Username) = @Username", sc);

        userCheck.Parameters.AddWithValue("@Username", userNew);
        userCheck.Connection = sc;
        int count = Convert.ToInt32(userCheck.ExecuteScalar());

        userCheck.ExecuteNonQuery();
        sc.Close();


        System.Data.SqlClient.SqlCommand insertHost = new System.Data.SqlClient.SqlCommand();
        insertHost.Connection = sc;
        System.Data.SqlClient.SqlCommand insertLogin = new System.Data.SqlClient.SqlCommand();
        insertLogin.Connection = sc;

        firstName   = Session["firstName"].ToString();
        lastName    = Session["lastName"].ToString();
        gender      = Session["gender"].ToString();
        dateOfBirth = Session["dateOfBirth"].ToString();
        email       = Session["email"].ToString();
        phoneNumber = Session["phoneNumberTextbox"].ToString();

        //confirms that the passwords match and meet requirements
        String password  = passwordTextbox.Text;
        String cpassword = confirmPasswordTextbox.Text;

        Session["password"] = password;

        if (count == 0)
        {
            bool isValid;
            if (password.Length > 8 && (isValid = ValidatePassword(password)))
            {
                if (password == cpassword)
                {
                    Homeowner newHost = new Homeowner(firstName, lastName, gender, dateOfBirth, email, phoneNumber, userNameTextbox.Text, passwordTextbox.Text, confirmPasswordTextbox.Text);
                    resultmessage.Text     = "";
                    insertHost.CommandText = "INSERT INTO [dbo].[Host] (Email, PhoneNumber, Firstname, MiddleName, LastName, BirthDate," +
                                             "Gender, BackgroundCheckDate, BackgroundCheckResult, LastUpdatedBy, LastUpdated, HostBio, ShowHost) VALUES (@Email, @PhoneNumber, @FirstName, @MiddleName," +
                                             "@LastName, @BirthDate, @Gender, @BackgroundCheckDate, @BackgroundCheckResult, @LastUpdatedBy, @LastUpdated, @HostBio, @ShowHost); ";

                    insertHost.Parameters.AddWithValue("@Email", email);
                    insertHost.Parameters.AddWithValue("@PhoneNumber", phoneNumber);
                    insertHost.Parameters.AddWithValue("@FirstName", firstName);
                    insertHost.Parameters.AddWithValue("@MiddleName", " ");
                    insertHost.Parameters.AddWithValue("@LastName", lastName);
                    insertHost.Parameters.AddWithValue("@BirthDate", dateOfBirth);
                    insertHost.Parameters.AddWithValue("@Gender", gender);
                    insertHost.Parameters.AddWithValue("@BackgroundCheckDate", DateTime.Now);
                    insertHost.Parameters.AddWithValue("@BackgroundCheckResult", "n");
                    insertHost.Parameters.AddWithValue("@LastUpdatedBy", lastName);
                    insertHost.Parameters.AddWithValue("@LastUpdated", DateTime.Now);
                    insertHost.Parameters.AddWithValue("@HostBio", Session["hostBio"].ToString());
                    insertHost.Parameters.AddWithValue("@ShowHost", "y");


                    sc.Open();
                    insertHost.ExecuteNonQuery();

                    SqlCommand insert = new SqlCommand("SELECT HostID FROM [dbo].[Host] WHERE lower(Email) = @Email", sc);
                    insert.Parameters.AddWithValue("@Email", email.ToLower());
                    insert.Connection = sc;
                    int hostID = Convert.ToInt32(insert.ExecuteScalar());
                    insert.ExecuteNonQuery();
                    Session["hostID"] = hostID;

                    //uploads the image to the database
                    if (FileUploadControlHost.HasFile)
                    {
                        HttpPostedFile postedFile    = FileUploadControlHost.PostedFile;
                        string         fileName      = Path.GetFileName(postedFile.FileName);
                        string         fileExtension = Path.GetExtension(fileName);
                        int            fileSize      = postedFile.ContentLength;

                        if (fileExtension.ToLower() == ".jpg" || fileExtension.ToLower() == ".bmp" ||
                            fileExtension.ToLower() == ".gif" || fileExtension.ToLower() == ".png")
                        {
                            Stream       stream = postedFile.InputStream;
                            BinaryReader br     = new BinaryReader(stream);
                            byte[]       bytes  = br.ReadBytes((int)stream.Length);

                            SqlCommand cmd = new SqlCommand("UPDATE [dbo].[Host] SET imageV2 = @imgdata WHERE HostID = @HostID", sc);
                            cmd.Parameters.AddWithValue("@HostID", hostID);
                            cmd.Parameters.AddWithValue("@imgdata", bytes);
                            cmd.ExecuteNonQuery();

                            StatusLabel.Text = "Image Uploaded successfully";
                        }
                        else
                        {
                            StatusLabel.Text = "Only Images (.jpg, .png, .gif and .bmp) can be uploaded!";
                        }
                    }
                    else
                    {
                        StatusLabel.Text = "Please select an image to upload";
                    }

                    //inserts login info to the database
                    Login tempLogin = new Login(userNameTextbox.Text, passwordTextbox.Text);
                    insertLogin.CommandText = "INSERT INTO [dbo].[Login] (Username, Password, hostID) VALUES (@userName, @Password, @hostID)";
                    insertLogin.Parameters.AddWithValue("@userName", newHost.userName);
                    insertLogin.Parameters.AddWithValue("@Password", PasswordHash.HashPassword(newHost.password));
                    insertLogin.Parameters.AddWithValue("@hostID", hostID);

                    SqlCommand getAccountID = new SqlCommand("SELECT AccountID FROM [dbo].[Login] WHERE HostID = @HostID", sc);
                    getAccountID.Parameters.AddWithValue("@HostID", hostID);
                    getAccountID.Connection = sc;
                    int accountID = Convert.ToInt32(getAccountID.ExecuteScalar());
                    getAccountID.ExecuteNonQuery();
                    Session["accountID"] = accountID;
                    Session["username"]  = newHost.userName;

                    insertLogin.ExecuteNonQuery();
                    sc.Close();
                    Response.Redirect("PropertyInfoHomeowner.aspx");
                }
                else
                {
                    resultmessage.Text = "Passwords does not match.";
                }
            }
            else
            {
                resultmessage.Text = "Password does not meet minimum password requirements.";
            }
        }
        else
        {
            resultmessage.Text = "Username already exists.";
        }
    }
    protected void submitLogin_Click(object sender, EventArgs e)
    {
        //Username


        //ValidatePassword(username);
        String userNew = userNameTextbox.Text;

        Session["username"] = userNew;


        sc.Open();
        SqlCommand userCheck = new SqlCommand("SELECT Count(*) FROM [Capstone].[dbo].[Login] WHERE lower(Username) = @Username", sc);

        userCheck.Parameters.AddWithValue("@Username", userNew);
        userCheck.Connection = sc;
        int count = Convert.ToInt32(userCheck.ExecuteScalar());

        userCheck.ExecuteNonQuery();
        sc.Close();



        //Password
        System.Data.SqlClient.SqlCommand insertHost = new System.Data.SqlClient.SqlCommand();
        insertHost.Connection = sc;
        System.Data.SqlClient.SqlCommand insertLogin = new System.Data.SqlClient.SqlCommand();
        insertLogin.Connection = sc;

        firstName   = Session["firstName"].ToString();
        lastName    = Session["lastName"].ToString();
        gender      = Session["gender"].ToString();
        dateOfBirth = Session["dateOfBirth"].ToString();
        email       = Session["email"].ToString();
        phoneNumber = Session["phoneNumberTextbox"].ToString();

        String password  = passwordTextbox.Text;
        String cpassword = confirmPasswordTextbox.Text;

        Session["password"] = password;

        if (count == 0)
        {
            bool isValid;
            if (password.Length > 8 && (isValid = ValidatePassword(password)))
            {
                if (password == cpassword)
                {
                    Homeowner newHost = new Homeowner(firstName, lastName, gender, dateOfBirth, email, phoneNumber, userNameTextbox.Text, passwordTextbox.Text, confirmPasswordTextbox.Text);
                    resultmessage.Text     = "";
                    insertHost.CommandText = "INSERT INTO [Capstone].[dbo].[Host] (Email, PhoneNumber, Firstname, MiddleName, LastName, BirthDate," +
                                             "Gender, BackgroundCheckDate, BackgroundCheckResult, LastUpdatedBy, LastUpdated) VALUES (@Email, @PhoneNumber, @FirstName, @MiddleName," +
                                             "@LastName, @BirthDate, @Gender, @BackgroundCheckDate, @BackgroundCheckResult, @LastUpdatedBy, @LastUpdated); ";

                    insertHost.Parameters.AddWithValue("@Email", email);
                    insertHost.Parameters.AddWithValue("@PhoneNumber", phoneNumber);
                    insertHost.Parameters.AddWithValue("@FirstName", firstName);
                    insertHost.Parameters.AddWithValue("@MiddleName", " ");
                    insertHost.Parameters.AddWithValue("@LastName", lastName);
                    insertHost.Parameters.AddWithValue("@BirthDate", dateOfBirth);
                    insertHost.Parameters.AddWithValue("@Gender", gender);
                    insertHost.Parameters.AddWithValue("@BackgroundCheckDate", DateTime.Now);
                    insertHost.Parameters.AddWithValue("@BackgroundCheckResult", "Y");
                    //ADD USERNAME and CONFIRM PASSOWRD IN DATABASE
                    insertHost.Parameters.AddWithValue("@LastUpdatedBy", lastName);
                    insertHost.Parameters.AddWithValue("@LastUpdated", DateTime.Now);

                    sc.Open();
                    insertHost.ExecuteNonQuery();

                    SqlCommand insert = new SqlCommand("SELECT HostID FROM [Capstone].[dbo].[Host] WHERE lower(Email) = @Email", sc);
                    insert.Parameters.AddWithValue("@Email", email.ToLower());
                    insert.Connection = sc;
                    int hostID = Convert.ToInt32(insert.ExecuteScalar());
                    insert.ExecuteNonQuery();
                    Session["hostID"] = hostID;


                    Login tempLogin = new Login(userNameTextbox.Text, passwordTextbox.Text);
                    insertLogin.CommandText = "INSERT INTO [Capstone].[dbo].[Login] (Username, Password, hostID) VALUES (@userName, @Password, @hostID)";
                    insertLogin.Parameters.AddWithValue("@userName", newHost.userName);
                    insertLogin.Parameters.AddWithValue("@Password", PasswordHash.HashPassword(newHost.password));
                    insertLogin.Parameters.AddWithValue("@hostID", hostID);

                    SqlCommand getAccountID = new SqlCommand("SELECT AccountID FROM [Capstone].[dbo].[Login] WHERE HostID = @HostID", sc);
                    getAccountID.Parameters.AddWithValue("@HostID", hostID);
                    getAccountID.Connection = sc;
                    int accountID = Convert.ToInt32(getAccountID.ExecuteScalar());
                    getAccountID.ExecuteNonQuery();
                    Session["accountID"] = accountID;
                    Session["username"]  = newHost.userName;

                    insertLogin.ExecuteNonQuery();
                    sc.Close();
                    Response.Redirect("PropertyInfoHomeowner.aspx");
                }
                else
                {
                    resultmessage.Text = "Passwords does not match.";
                }
            }
            else
            {
                resultmessage.Text = "Password does not meet minimum password requirements.";
            }
        }
        else
        {
            resultmessage.Text = "Username already exists.";
        }
    }
Ejemplo n.º 18
0
    //Use method in order to validate user information.
    protected void btnSignUpHomeOwner_Click(object sender, EventArgs e)
    {
        int  age = getAge(birthDate.Value);
        bool validate;

        //check if the Host is already existing
        sc.Open();

        System.Data.SqlClient.SqlCommand readHost = new System.Data.SqlClient.SqlCommand();
        readHost.Connection = sc;

        readHost.CommandText = "SELECT HostEmail FROM Homeowner WHERE HostEmail = upper(@HostEmail);";
        readHost.Parameters.Add(new SqlParameter("@HostEmail", txtEmail.Value));

        System.Data.SqlClient.SqlDataReader reader = readHost.ExecuteReader();

        if (reader.HasRows)
        {
            lblHomeEmailNo.ForeColor = Color.Red;
            lblHomeEmailNo.Text      = "*A Host account already exists for this email.";
            lblHomeEmailNo.Visible   = true;
            validate = false;
        }
        else
        {
            validate = true;
        }
        sc.Close();

        //---------------------------
        if (validate == true)
        {
            //cheak if tenant age greater than 18
            if (age >= 18)
            {
                validate = true;

                sc.Open();
                String   email       = HttpUtility.HtmlEncode(txtEmail.Value);
                String   phone       = HttpUtility.HtmlEncode(txtHomePhone.Value);
                String   firstName   = HttpUtility.HtmlEncode(txtFName.Value);
                String   lastName    = HttpUtility.HtmlEncode(txtLName.Value);
                DateTime dob         = Convert.ToDateTime(HttpUtility.HtmlEncode(birthDate.Value));
                String   password    = HttpUtility.HtmlEncode(txtPassword.Value);
                DateTime lastUpdated = DateTime.Today;
                String   zip         = HttpUtility.HtmlEncode(txtZip.Value);
                String   state       = inputState.Value;
                String   address     = HttpUtility.HtmlEncode(inputAddress.Value);
                String   cityCo      = HttpUtility.HtmlEncode(inputCity.Value);

                Homeowner  newHomeowner = new Homeowner(firstName, lastName, email, phone, address, cityCo, state, password, dob, zip, lastUpdated);
                FileUpload img          = (FileUpload)imgUpload;
                Byte[]     imgByte      = null;
                if (img.HasFile && img.PostedFile != null)
                {
                    //To create a PostedFile
                    HttpPostedFile File = imgUpload.PostedFile;
                    //Create byte Array with file len
                    imgByte = new Byte[File.ContentLength];
                    //force the control to load data in array
                    File.InputStream.Read(imgByte, 0, File.ContentLength);


                    // Create new Insert Command
                    System.Data.SqlClient.SqlCommand insertHomeOwner = new System.Data.SqlClient.SqlCommand();
                    insertHomeOwner.Connection = sc;

                    insertHomeOwner.CommandText = "INSERT INTO HOMEOWNER VALUES(@First, @Last, @Email, @Phone, @Pass, @Street, @CityCo,@State, @Zip, @Dob, @LU, @hImage, null, 'Y')";
                    insertHomeOwner.Parameters.Add(new SqlParameter("@First", newHomeowner.getHostFirstName()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Last", newHomeowner.getHostLastName()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Email", newHomeowner.getHostEmail()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Phone", newHomeowner.getHostphoneNum()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Pass", PasswordHash.HashPassword(password))); // Password hash
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Street", newHomeowner.getAddress()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@CityCo", newHomeowner.getHostcityCo()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@State", newHomeowner.getHoststate()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Zip", newHomeowner.getZip()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@Dob", newHomeowner.getHomeDOB()));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@LU", lastUpdated));
                    insertHomeOwner.Parameters.Add(new SqlParameter("@hImage", imgByte));
                    insertHomeOwner.ExecuteNonQuery();

                    sc.Close();
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
                    txtEmail.Value             = "";
                    txtPassword.Value          = "";
                    txtFName.Value             = "";
                    txtLName.Value             = "";
                    inputAddress.Value         = "";
                    inputCity.Value            = "";
                    txtZip.Value               = "";
                    txtHomePhone.Value         = "";
                    birthDate.Value            = "";
                    inputState.SelectedIndex   = -1;
                    lblHomeBDNo.Text           = "";
                    lblHomeEmailFormat.Text    = "";
                    lblHomeEmailNo.Text        = "";
                    lblHomeBDNo.Visible        = false;
                    lblHomeEmailFormat.Visible = false;
                    lblHomeEmailNo.Visible     = false;
                    lblUpPic.Visible           = false;
                }
                else
                {
                    lblUpPic.ForeColor = Color.Red;
                    lblUpPic.Text      = "*Homeowner must upload a profile photo";
                    lblUpPic.Visible   = true;
                    validate           = false;
                }
            }
            else
            {
                lblHomeBDNo.ForeColor = Color.Red;
                lblHomeBDNo.Text      = "*Homeowner must be 18 years old or above";
                lblHomeBDNo.Visible   = true;
                validate = false;
            }
        }
    }
Ejemplo n.º 19
0
        /// <summary>
        /// Executes the workflow activity.
        /// </summary>
        /// <param name="executionContext">The execution context.</param>
        protected override void Execute(CodeActivityContext executionContext)
        {
            // Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            if (tracingService == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
            }

            tracingService.Trace("Entered " + _activityName + ".Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
                                 executionContext.ActivityInstanceId,
                                 executionContext.WorkflowInstanceId);

            // Create the context
            IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>();

            if (context == null)
            {
                throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
            }

            tracingService.Trace(_activityName + ".Execute(), Correlation Id: {0}, Initiating User: {1}",
                                 context.CorrelationId,
                                 context.InitiatingUserId);

            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                //create a new myjsonrequest object from which data will be serialized
                JsonRequest myRequest = new JsonRequest();
                myRequest.InputObj = new CrmAzureMlDemo.Input1();
                Input input = new Input();

                string[] columns = { "address1_stateorprovince", "annualincome",            "lpa_age",
                                     "numberofchildren",         "educationcodename",       "familystatuscodename",
                                     "gendercodename",           "lpa_commutedistancename", "lpa_homeownername",
                                     "lpa_occupationname",       "lpa_numberofcarsowned",   "lpa_numberofchildrenathome" };

                object[] values = { StateOrProvince.Get(executionContext), AnnualIncome.Get(executionContext),    Age.Get(executionContext),
                                    NumChildren.Get(executionContext),     Education.Get(executionContext),       MaritalStatus.Get(executionContext),
                                    Gender.Get(executionContext),          CommuteDistance.Get(executionContext), Homeowner.Get(executionContext),
                                    Occupation.Get(executionContext),      NumCars.Get(executionContext),         NumChildrenAtHome.Get(executionContext) };

                input.Columns = columns;
                input.Values  = new object[][] { values };

                myRequest.InputObj.Inputs = new Input();
                myRequest.InputObj.Inputs = input;

                //serialize the myjsonrequest to json
                System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(myRequest.GetType());
                MemoryStream ms = new MemoryStream();
                serializer.WriteObject(ms, myRequest);
                string jsonMsg = Encoding.Default.GetString(ms.ToArray());

                //create the webrequest object and execute it (and post jsonmsg to it)
                System.Net.WebRequest req = System.Net.WebRequest.Create(Endpoint.Get(executionContext));

                //must set the content type for json
                req.ContentType = "application/json";

                //must set method to post
                req.Method = "POST";

                //add authorization header
                req.Headers.Add(string.Format("Authorization:Bearer {0}", ApiKey.Get(executionContext)));

                tracingService.Trace("json request: {0}", jsonMsg);

                //create a stream
                byte[] bytes = System.Text.Encoding.ASCII.GetBytes(jsonMsg.ToString());
                req.ContentLength = bytes.Length;
                System.IO.Stream os = req.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                os.Close();

                //get the response
                System.Net.WebResponse resp = req.GetResponse();

                Stream responseStream = CopyAndClose(resp.GetResponseStream());
                // Do something with the stream
                StreamReader reader         = new StreamReader(responseStream, Encoding.UTF8);
                String       responseString = reader.ReadToEnd();
                tracingService.Trace("json response: {0}", responseString);

                responseStream.Position = 0;
                //deserialize the response to a myjsonresponse object
                JsonResponse myResponse = new JsonResponse();
                System.Runtime.Serialization.Json.DataContractJsonSerializer deserializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(myResponse.GetType());
                myResponse = deserializer.ReadObject(responseStream) as JsonResponse;

                //set output values from the fields of the deserialzed myjsonresponse object
                BikeBuyer.Set(executionContext, myResponse.Results.Output1.Value.Values[0][0]);
            }

            catch (WebException exception)
            {
                string str = string.Empty;
                if (exception.Response != null)
                {
                    using (StreamReader reader =
                               new StreamReader(exception.Response.GetResponseStream()))
                    {
                        str = reader.ReadToEnd();
                    }
                    exception.Response.Close();
                }
                if (exception.Status == WebExceptionStatus.Timeout)
                {
                    throw new InvalidPluginExecutionException(
                              "The timeout elapsed while attempting to issue the request.", exception);
                }
                throw new InvalidPluginExecutionException(String.Format(CultureInfo.InvariantCulture,
                                                                        "A Web exception ocurred while attempting to issue the request. {0}: {1}",
                                                                        exception.Message, str), exception);
            }
            catch (FaultException <OrganizationServiceFault> e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());

                // Handle the exception.
                throw;
            }
            catch (Exception e)
            {
                tracingService.Trace("Exception: {0}", e.ToString());
                throw;
            }

            tracingService.Trace("Exiting " + _activityName + ".Execute(), Correlation Id: {0}", context.CorrelationId);
        }