Ejemplo n.º 1
0
        public static string PostRequestUrl(string companyId, string userId, string encryptedUserkey)
        {
            string str  = CRMCrypto.Encrypt(CRMCheckFormat.CheckFormat(encryptedUserkey), companyId, userId);
            string str1 = string.Concat(CommonPage.GetConfigField("AccP_ServerName", companyId), "/WebScreenProxy/Home/ProxyRequest/?appUrl=");
            string str2 = CommonPage.Base64Encode(str);
            string str3 = string.Format("&companyId={0}&userId={1}&userKey={2}&timeout=120", companyId, userId, str2);

            return(string.Concat(str1, str3));
        }
Ejemplo n.º 2
0
        public override void BuildContents()
        {
            LogMessage("ConradDebug", "In Build", 1);

            string upper = (base.Dispatch.EitherField("Option") ?? "Customer").ToUpper();
            string str   = base.Dispatch.EitherField("HiddenMode");

            this._comp_companyid  = base.GetContextInfo("Company", "comp_companyid");
            this._comp_name       = base.GetContextInfo("Company", "Comp_Name");
            this.userId           = base.GetContextInfo("User", "User_AccpacID");
            this.encryptedUserkey = base.GetContextInfo("User", "User_AccpacPSWD");
            this.userKey          = CRMCheckFormat.CheckFormat(this.encryptedUserkey);
            base.AddContent("<div id='sage300Loading' style='width:100%; text-align:center'><img src='../Themes/img/ergonomic/sage300loading.gif'></div>");
            if (upper == "FINALIZELINK")
            {
                Record record         = base.FindRecord("Company", string.Format("Comp_CompanyId = {0}", this._comp_companyid));
                bool   flag           = false;
                string fieldAsString  = record.GetFieldAsString("comp_idcust");
                string fieldAsString1 = record.GetFieldAsString("comp_idvend");
                string str1           = "";
                if (string.IsNullOrEmpty(fieldAsString) || !string.IsNullOrEmpty(fieldAsString1))
                {
                    str1 = fieldAsString1;
                }
                else
                {
                    flag = true;
                    str1 = fieldAsString;
                }
                record.GetFieldAsString("Comp_Name");
                this._database       = record.GetFieldAsString("comp_database");
                this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database);
                PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler()
                {
                    Credentials = new NetworkCredential(this.userId, this.userKey)
                };
                if (this.CheckExist(str1, (flag ? "ARCustomers" : "APVendors")))
                {
                    record.SetField("Comp_Database", "");
                    record.SetField("Comp_IdCust", "");
                    record.SetField("Comp_IdVend", "");
                    record.SaveChanges();
                    string str2 = this.Url("200");
                    base.Dispatch.Redirect(str2);
                    return;
                }
                record.SetField("Comp_IdGrp", base.Dispatch.ContentField("GroupCode"));
                record.SetField("Comp_CodeTaxGrp", base.Dispatch.ContentField("TaxGroup"));
                record.SetField("Comp_CodeTerm", base.Dispatch.ContentField("TermsCode"));
                record.SetField("Comp_Status", base.Dispatch.ContentField("Status"));
                record.SetField("Comp_AmtCrLimt", base.Dispatch.ContentField("CreditLimit"));
                record.SaveChanges();
                string str3 = this.Url("200");
                base.Dispatch.Redirect(str3);
                return;
            }
            if (upper.ToUpper() == "PROMOTE" && string.IsNullOrEmpty(str))
            {
                this.DisplayPromoteForm(upper);
            }
            this.GetTabs();
            if (str == "PromoteCustomer" || str == "PromoteVendor")
            {
                this._database = base.Dispatch.ContentField("database");
                bool   flag1 = str == "PromoteCustomer";
                string str4  = base.Dispatch.ContentField("txtId");
                this._comp_type    = (flag1 ? "Customer" : "Vendor");
                this._Sage300Field = (flag1 ? "comp_idcust" : "comp_idvend");
                string contextInfo = base.GetContextInfo("Company", "Comp_CompanyId");
                Record record1     = base.FindRecord("Company", string.Concat("Comp_CompanyId=", contextInfo));
                if (string.IsNullOrEmpty(record1.GetFieldAsString("Comp_database")))
                {
                    record1.SetField("Comp_database", this._database);
                    record1.SaveChanges();
                }
                string str5 = CommonPage.PostRequestUrl(this._database, this.userId, this.encryptedUserkey);
                base.AddContent(base.HTML.InputHidden("postRequestUrl", str5));
                this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database);
                PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler()
                {
                    Credentials = new NetworkCredential(this.userId, this.userKey)
                };
                if (string.IsNullOrEmpty(str4))
                {
                    base.Dispatch.Redirect(base.UrlDotNet("PromoteCompany", "GetPromotePage&Option=PROMOTE&T=Company&ErrCode=1"));
                    return;
                }
                if (!this.CheckExist(str4, (flag1 ? "ARCustomers" : "APVendors")))
                {
                    base.Dispatch.Redirect(base.UrlDotNet("PromoteCompany", string.Format("GetPromotePage&Option=PROMOTE&T=Company&ErrCode=2&id={0}", str4)));
                    return;
                }
                string      str6        = string.Concat("Select ainq_url From AccpacInquiry where ainq_module = '", (flag1 ? "AR1399" : "AP1299"), "'");
                QuerySelect querySelect = new QuerySelect();
                querySelect.SQLCommand = str6;
                QuerySelect querySelect1 = querySelect;
                querySelect1.ExecuteReader();
                string str7 = "";
                if (!querySelect1.Eof())
                {
                    str7 = querySelect1.FieldValue("ainq_url");
                }
                base.AddContent("<iframe id='Sage300PageFrame' sandbox='allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation' width='100%' height='700' frameBorder='0'></iframe>");
                string str8       = string.Concat(str7, str4);
                string requestUrl = CommonPage.GetRequestUrl(this._database, this.userId, str8);
                base.AddContent(string.Format("<a id='Sage300PageLinkId' href={0}></a>", requestUrl));
                string str9 = base.UrlDotNet("PromoteCompany", "GetPromotePage&Option=FinalizeLink");
                base.AddContent(string.Concat("<a href=", str9, " target='_blank' id='linkFinalizeLink' style='display: none;'><a>"));
                string str10 = string.Format("<input id='txtHostNameID' name='txtHostNameID' type='hidden' value='{0}'>", string.Concat("http://", base.Dispatch.Host, "|", this.sage300HostName));
                base.AddContent(str10);
                string customerOrVendor = this.GetCustomerOrVendor(this._comp_companyid, flag1, this._database, str4);
                base.AddContent(customerOrVendor);
                string str11 = this.Url("200");
                base.AddContent(base.HTML.InputHidden("SummaryPageUrl", str11));
            }
            else if (str == "UnlinkCustomer" || str == "UnlinkVendor")
            {
                this._database = base.GetContextInfo("Company", "comp_database");
                bool flag2 = str == "UnlinkCustomer";
                this._comp_type    = base.GetContextInfo("Company", "comp_type");
                this._Sage300Field = (flag2 ? "comp_idcust" : "comp_idvend");
                if (!flag2)
                {
                    base.Metadata.GetTranslation("ainq_selection", "apVendor");
                }
                else
                {
                    base.Metadata.GetTranslation("ainq_selection", "arCustomer");
                }
                this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database);
                PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler()
                {
                    Credentials = new NetworkCredential(this.userId, this.userKey)
                };
                if (this.CheckExist(this._comp_companyid, "OEOrders"))
                {
                    this.UnlinkCompany(Convert.ToInt32(this._comp_companyid));
                    string str12 = string.Format(base.Metadata.GetTranslation("Company_Promote", "ConfirmMessage"), this._comp_companyid);
                    base.AddContent(string.Format("<h3>{0}</h3>", str12));
                    string str13 = this.Url("200");
                    base.Dispatch.Redirect(str13);
                }
                else
                {
                    this.DisplayCustomerOrVendorExist();
                }
            }
            string str14 = string.Format("{0}/WebScreenProxy/Home/CreateSage300Cookies?userId={1}&companyId={2}", this.sage300HostName, this.userId, this._database);

            base.AddContent(string.Format("<iframe id='Sage300ProxyCookieFrame' src='{0}' height='0' frameBorder='0'></iframe>", str14));
            base.AddContent("<script type='text/javascript' src='../CustomPages/Sage300Integration/PromoteCompany.js'></script>");
        }