コード例 #1
0
            override public void __Processor(BotCycle bc)
            {
                CustomSession session = (CustomSession)bc.Session;

                session.send(Data, Pdf, Addendum, Addendum1);
            }
コード例 #2
0
            override public void __Processor(BotCycle bc)
            {
                CustomSession session = (CustomSession)bc.Session;

                string address  = new System.Globalization.CultureInfo("en-US", false).TextInfo.ToTitleCase(Address.ToLower());
                string file_dir = PathRoutines.CreateDirectory(session.output_dir + "\\" + address, true);

                string output_pdf = file_dir + "\\" + Regex.Replace(address + " RPA.pdf", @"\s+", " ");
                {
                    //lock (template_pdf)
                    //{
                    //    File.Copy(template_pdf, pdf);
                    //}

                    PdfReader.unethicalreading = true;
                    PdfReader pr = new PdfReader(template_pdf);
                    //pr.RemoveUsageRights();
                    //pr.SelectPages("7,8");
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    //string fs = "";
                    //foreach (KeyValuePair<string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    //    fs += "\n{\"" + kvp.Key + "\", \"\"},";

                    set_field(ps.AcroFields, "Todays Date", DateTime.Today.ToShortDateString());
                    set_field(ps.AcroFields, "Buyer Name", Settings.Parties.BuyerProfile.Name);
                    set_field(ps.AcroFields, "Address and Unit Number", address + " " + UnitNumber);
                    set_field(ps.AcroFields, "City/Town", City);
                    //set_field(ps.AcroFields, "CLARK", );
                    set_field(ps.AcroFields, "Zip", ZipCode);
                    set_field(ps.AcroFields, "PARCEL NUMBER", ParcelNumber);
                    set_field(ps.AcroFields, "OfferAmt", OfferAmt);
                    string offer_amt_ = Regex.Replace(OfferAmt, @"[^\d]", "");
                    if (offer_amt_.Length > 0)
                    {
                        set_field(ps.AcroFields, "OfferAmt in words", ConvertionRoutines.NumberToWords(int.Parse(offer_amt_)).ToUpper());
                    }
                    set_field(ps.AcroFields, "EMD", Settings.Offer.Emd);
                    //set_field(ps.AcroFields, "Check Box1", );
                    //set_field(ps.AcroFields, "Balance", );
                    set_field(ps.AcroFields, "Co Buyer Name", Settings.Parties.BuyerProfile.CoBuyerName);
                    set_field(ps.AcroFields, "<address> <UnitNumber> <City/town> NV <ZIP Code>", address + " " + UnitNumber + ", " + City + " NV " + ZipCode);
                    set_field(ps.AcroFields, "ML#", "ALL PER ML# " + ML_Id);
                    set_field(ps.AcroFields, "Title Company", Settings.Parties.EscrowProfile.TitleCompany);
                    set_field(ps.AcroFields, "Escrow Officer", Settings.Parties.EscrowProfile.Officer);
                    set_field(ps.AcroFields, "Close of Escrow", Settings.Offer.CloseOfEscrow.ToShortDateString());

                    //String[] values = ps.AcroFields.GetAppearanceStates("Licensee Yes");
                    //String[] values2 = ps.AcroFields.GetAppearanceStates("Licensee No");
                    if (Settings.Parties.BuyerProfile.UseLicensee)
                    {
                        set_field(ps.AcroFields, "Licensee Yes", "Yes");
                        //set_field(ps.AcroFields, "Licensee No", "Off");
                        //set_field(ps.AcroFields, "Licensee relationship", DateTime.Today.ToShortDateString());
                        set_field(ps.AcroFields, "Licensee relationship", Settings.Parties.BuyerProfile.LicenseeRelationship);
                        switch (Settings.Parties.BuyerProfile.RelationshipType)
                        {
                        case "Family Firm":
                            set_field(ps.AcroFields, "Licensee Family Firm", "Yes");
                            break;

                        case "Principal":
                            set_field(ps.AcroFields, "Licensee Principal", "Yes");
                            break;
                        }
                    }
                    else
                    {
                        set_field(ps.AcroFields, "Licensee No", "Yes");
                        //set_field(ps.AcroFields, "Licensee Yes", "Off");
                    }

                    DateTime date = DateTime.Now.AddDays(7);
                    set_field(ps.AcroFields, "Response Month", date.ToString("MMMM"));
                    set_field(ps.AcroFields, "Response day", date.ToString("%d"));
                    set_field(ps.AcroFields, "year", date.ToString("yyyy"));;
                    string emd_ = Regex.Replace(Settings.Offer.Emd, @"[^\d]", "");
                    if (offer_amt_.Length > 0 && emd_.Length > 0)
                    {
                        set_field(ps.AcroFields, "Balance", (int.Parse(offer_amt_) - int.Parse(emd_)).ToString());
                    }

                    //                    string AdditionalTerms = @"This form is available for use by the real estate industry. It is not intended to identify the user as a REALTOR®.
                    //8 REALTOR® is a registered collective membership mark which may be used only by members of the NATIONAL
                    //9 ASSOCIATION OF REALTORS® who subscribe to its Code.";
                    string s = AdditionalTerms;
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms1", s);
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms2", s);
                    s = fill_field_by_words(ps.AcroFields, "AdditionalTerms3", s);
                    if (s.Length > 0)
                    {
                        s = AdditionalTerms;
                        s = fill_field_by_chars(ps.AcroFields, "AdditionalTerms1", s);
                        s = fill_field_by_chars(ps.AcroFields, "AdditionalTerms2", s);
                        set_field(ps.AcroFields, "AdditionalTerms3", s);
                    }

                    set_field(ps.AcroFields, "Buyer Broker", Settings.Parties.BrokerProfile.Name);
                    set_field(ps.AcroFields, "Agent Name", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "ListAgentFullName", ListAgentFullName);
                    set_field(ps.AcroFields, "Company Name", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "ListOfficeName", ListOfficeName);
                    set_field(ps.AcroFields, "Agents License", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Brokers License", Settings.Parties.BrokerProfile.LicenseNo);
                    set_field(ps.AcroFields, "Office Address", Settings.Parties.BrokerProfile.Address);
                    set_field(ps.AcroFields, "Office Phone", Settings.Parties.BrokerProfile.Phone);
                    set_field(ps.AcroFields, "City State Zip", Settings.Parties.BrokerProfile.City + " " + Settings.Parties.BrokerProfile.State + " " + Settings.Parties.BrokerProfile.Zip);
                    set_field(ps.AcroFields, "Agent Email", Settings.Parties.AgentProfile.Email);
                    //set_field(ps.AcroFields, "Response Month", );
                    //set_field(ps.AcroFields, "Response day", );
                    //set_field(ps.AcroFields, "year", );
                    //set_field(ps.AcroFields,  "Date_2", );
                    //set_field(ps.AcroFields, "Date_3", );
                    //set_field(ps.AcroFields, "Sellers Broker", );
                    set_field(ps.AcroFields, "Agents Name_2", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "Company Name_2", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "Agents License Number_2", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Brokers License Number_2", Settings.Parties.BrokerProfile.LicenseNo);
                    set_field(ps.AcroFields, "Office Address_2", Settings.Parties.BrokerProfile.Address);
                    set_field(ps.AcroFields, "Phone_2", Settings.Parties.BrokerProfile.Phone);
                    set_field(ps.AcroFields, "City State Zip_2", Settings.Parties.BrokerProfile.Zip);
                    set_field(ps.AcroFields, "Email_2", Settings.Parties.AgentProfile.Email);
                    set_field(ps.AcroFields, "ListAgentEmail", ListAgentEmail);

                    ps.FormFlattening = true;

                    for (int i = 1; i <= pr.NumberOfPages; i++)
                    {
                        var pcb = ps.GetOverContent(i);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(497, 67));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(536, 67));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(3);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(140, 103));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(280, 103));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(9);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(60, 190));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(60, 155));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                string output_addendum_pdf = null;

                if (Settings.Offer.ShortSaleAddendum)
                {
                    output_addendum_pdf = file_dir + "\\" + Regex.Replace(address + " SS Addendum.pdf", @"\s+", " ");

                    PdfReader.unethicalreading = true;
                    PdfReader  pr = new PdfReader(template_addendum_pdf);
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_addendum_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    string fs = "";
                    foreach (KeyValuePair <string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    {
                        fs += "\n{\"" + kvp.Key + "\", \"\"},";
                    }

                    if (Settings.Parties.BuyerProfile.UseCoBuyer)
                    {
                        set_field(ps.AcroFields, "<Buyer Name> and <Co Buyer Name>", Settings.Parties.BuyerProfile.Name + " and " + Settings.Parties.BuyerProfile.CoBuyerName);
                    }
                    else
                    {
                        set_field(ps.AcroFields, "<Buyer Name> and <Co Buyer Name>", Settings.Parties.BuyerProfile.Name);
                    }
                    set_field(ps.AcroFields, "Todays Date", DateTime.Today.ToShortDateString());
                    set_field(ps.AcroFields, "<Address> <UnitNumber> <City/Town> NV <Zip Code>", address + " " + UnitNumber + ", " + City + " NV " + ZipCode);
                    set_field(ps.AcroFields, "Agent Name", Settings.Parties.AgentProfile.Name);
                    //set_field(ps.AcroFields, "Agent Phone", );

                    ps.FormFlattening = true;

                    for (int i = 1; i <= pr.NumberOfPages; i++)
                    {
                        var pcb = ps.GetOverContent(i);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(120, 70));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(157, 70));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(140, 400));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(197, 400));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(3);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(150, 547));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(150, 504));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                string output_addendum1_pdf = null;

                if (Settings.Offer.OtherAddendum1)
                {
                    output_addendum1_pdf       = file_dir + "\\" + Regex.Replace("duites " + address + ".pdf", @"\s+", " ");
                    PdfReader.unethicalreading = true;
                    PdfReader  pr = new PdfReader(template_addendum1_pdf);
                    PdfStamper ps = new PdfStamper(pr, new FileStream(output_addendum1_pdf, FileMode.Create, FileAccess.Write, FileShare.None));

                    string fs = "";
                    foreach (KeyValuePair <string, AcroFields.Item> kvp in ps.AcroFields.Fields)
                    {
                        fs += "\n{\"" + kvp.Key + "\", \"\"},";
                    }

                    set_field(ps.AcroFields, "AgentName", Settings.Parties.AgentProfile.Name);
                    set_field(ps.AcroFields, "LicenseNumber", Settings.Parties.AgentProfile.LicenseNo);
                    set_field(ps.AcroFields, "Buyer Name", Settings.Parties.BuyerProfile.Name);
                    set_field(ps.AcroFields, "Co-Buyer Name", Settings.Parties.BuyerProfile.CoBuyerName);
                    set_field(ps.AcroFields, "BrokerName", Settings.Parties.BrokerProfile.Name);
                    set_field(ps.AcroFields, "Company", Settings.Parties.BrokerProfile.Company);
                    set_field(ps.AcroFields, "Date_3", DateTime.Now.ToShortDateString());
                    set_field(ps.AcroFields, "Time_3", DateTime.Now.ToShortTimeString());
                    set_field(ps.AcroFields, "Date_4", DateTime.Now.ToShortDateString());
                    set_field(ps.AcroFields, "Time_4", DateTime.Now.ToShortTimeString());

                    ps.FormFlattening = true;

                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.InitialFile), new System.Drawing.Point(70, 190));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerInitialFile), new System.Drawing.Point(140, 190));
                        }
                    }
                    {
                        var pcb = ps.GetOverContent(1);
                        add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.SignatureFile), new System.Drawing.Point(110, 85));
                        if (Settings.Parties.BuyerProfile.UseCoBuyer)
                        {
                            add_image(pcb, System.Drawing.Image.FromFile(Settings.Parties.BuyerProfile.CoBuyerSignatureFile), new System.Drawing.Point(110, 85));
                        }
                    }

                    ps.Close();
                    pr.Close();
                }

                bc.Add(new EmailItem(output_pdf, output_addendum_pdf, output_addendum1_pdf));
            }