/// <summary>
    /// Gets the init data.
    /// </summary>
    private void GetInitData()
    {
        try
        {
            modCompanyGeneral = bllCompanyGeneral.GetModel();
        }
        catch (Exception exception)
        {
            LPLog.LogMessage(exception.Message);
        }

    }
    /// <summary>
    /// 同步按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSync_Click(object sender, EventArgs e)
    {
        try
        {
            // 请大家不要使用 System.Transactions.TransactionScope, 它导致Service崩溃.
            //using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
            //{
            LPWeb.BLL.Company_General   bllCG      = new LPWeb.BLL.Company_General();
            LPWeb.Model.Company_General modGeneral = new LPWeb.Model.Company_General();

            modGeneral = bllCG.GetModel();

            modGeneral.StartMarketingSync = true;

            bllCG.Update(modGeneral);

            ServiceManager sm = new ServiceManager();

            using (LP2ServiceClient client = sm.StartServiceClient())
            {
                string err = "";
                if (!client.SyncMarketingData(ref err))
                {
                    PageCommon.AlertMsg(this, err);
                    return;
                }

                //ts.Complete();
            }
            //}

            PageCommon.WriteJsEnd(this, "Sync Marketing Info successfully.", PageCommon.Js_RefreshSelf);
        }
        catch (Exception ex)
        {
            PageCommon.AlertMsg(this, ex.Message);
            return;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            //权限验证
            var loginUser = new LoginUser();
            if (!loginUser.userRole.CompanySetup)
            {
                Response.Redirect("../Unauthorize.aspx");
                return;
            }
        }
        catch (Exception exception)
        {
            LPLog.LogMessage(exception.Message);
        }

        if (!IsPostBack)
        {
            var compMode = bllCompanyGeneral.GetModel();

            if (compMode != null && !string.IsNullOrEmpty(compMode.GlobalId))
            {
                txtSecurityToken.Text = compMode.GlobalId.ToString();
            }


            var compapp = bllCompanyEasyMortgage.GetModel();

            if (compapp != null)
            {
                ckEnable.Checked          = compapp.Enabled;
                txbSyncIntervalHours.Text = compapp.SyncIntervalHours == null ? "24" : compapp.SyncIntervalHours.ToString();
                txtURL.Text      = compapp.URL.ToString();
                txtClientID.Text = compapp.ClientID.ToString();
            }
        }
    }