Пример #1
0
        public string GetConnectionString()
        {
            if (System.Web.HttpContext.Current.Session["Connection_String"] == null)
            {
                string        subDomainName    = System.Web.HttpContext.Current.Request.Url.DnsSafeHost;
                DataSet       dsCredentials    = new DataSet();
                SPData        objData          = new SPData();
                StringBuilder connectionString = new StringBuilder();
                dsCredentials = objData.GetConnectionString(subDomainName);
                DataTable dtCredentials = dsCredentials.Tables[0];
                if (dtCredentials != null && dtCredentials.Rows.Count > 0)
                {
                    connectionString.Append("data source=");
                    connectionString.Append(dtCredentials.Rows[0]["SqlIPAddress"].ToString().Trim());
                    connectionString.Append(";Initial Catalog=");
                    connectionString.Append(dtCredentials.Rows[0]["DatabaseName"].ToString().Trim());
                    connectionString.Append(";User Id=");
                    connectionString.Append(dtCredentials.Rows[0]["SqlLoginId"].ToString().Trim());
                    connectionString.Append(";Password="******"SqlPassword"].ToString().Trim());

                    System.Web.HttpContext.Current.Session["Connection_String"] = connectionString.ToString();
                }
            }



            return(System.Web.HttpContext.Current.Session["Connection_String"].ToString());
        }
Пример #2
0
 public bool OpenConnectionAsync(string subDomainName)
 {
     try
     {
         _objSPData = new SPData();
         DataSet dsCredentials = _objSPData.GetConnectionString(subDomainName);
         if (dsCredentials != null && dsCredentials.Tables.Count > 0 && dsCredentials.Tables[0].Rows.Count > 0)
         {
             SqlConnectionStringBuilder sqlConnStringBuilder = new SqlConnectionStringBuilder(GetConnectionStringAsync(subDomainName).ToString());
             sqlConnStringBuilder.AsynchronousProcessing = true;
             _conn = new SqlConnection();
             _conn.ConnectionString = sqlConnStringBuilder.ConnectionString;
             _conn.Open();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         //System.Web.HttpContext.Current.Response.Write("Exception: " + ex.Message);
         _strError = "DCRMobile " + " Public_fn:OpenConnection " + " Stack Trace : " + ex.StackTrace + " Error msg " + ex.Message;
         return(false);
     }
 }
Пример #3
0
        public StringBuilder GetCompanyConnectionString(string subDomainName)
        {
            StringBuilder connectionString = new StringBuilder();

            _objSPData = new SPData();
            DataSet dsCredentials = _objSPData.GetConnectionString(subDomainName);

            if (dsCredentials != null && dsCredentials.Tables.Count > 0 && dsCredentials.Tables[0].Rows.Count > 0)
            {
                connectionString.Append("data source=" + dsCredentials.Tables[0].Rows[0]["SqlIPAddress"].ToString().Trim());
                connectionString.Append(";Initial Catalog=" + dsCredentials.Tables[0].Rows[0]["DatabaseName"].ToString().Trim());
                connectionString.Append(";User Id=" + dsCredentials.Tables[0].Rows[0]["SqlLoginId"].ToString().Trim());
                connectionString.Append(";Password="******"SqlPassword"].ToString().Trim());
            }
            return(connectionString);
        }
Пример #4
0
        public bool SetCompanyCode()
        {
            bool isTrue = false;

            if (System.Web.HttpContext.Current.Session["Comp_Code"] == null)
            {
                string  subDomainName = System.Web.HttpContext.Current.Request.Url.DnsSafeHost;
                DataSet dsCredentials = new DataSet();
                SPData  objData       = new SPData();
                try
                {
                    dsCredentials = objData.GetConnectionString(subDomainName);

                    if (dsCredentials != null && dsCredentials.Tables.Count > 0 && dsCredentials.Tables[0].Rows.Count > 0)
                    {
                        System.Web.HttpContext.Current.Session["Comp_Code"]                     = dsCredentials.Tables[0].Rows[0]["CompanyCode"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["SubDomain"]                     = dsCredentials.Tables[0].Rows[0]["SubDomain"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["SFAWAUrl"]                      = dsCredentials.Tables[0].Rows[0]["SFAWAUrl"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["SalesDriveUrl"]                 = dsCredentials.Tables[0].Rows[0]["SalesDriveUrl"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["WideAngleUrl"]                  = dsCredentials.Tables[0].Rows[0]["WideAngleUrl"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["OneLibUrl"]                     = dsCredentials.Tables[0].Rows[0]["OneLibUrl"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Is_Payroll_Integrated"]         = dsCredentials.Tables[0].Rows[0]["Is_Payroll_Integrated"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Payroll_Integrated_URL"]        = dsCredentials.Tables[0].Rows[0]["Payroll_Integrated_URL"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Payroll_Security_Token"]        = dsCredentials.Tables[0].Rows[0]["Payroll_Security_Token"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Payroll_Vendor_Security_Token"] = dsCredentials.Tables[0].Rows[0]["Payroll_Vendor_Security_Token"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Is_Kangle_Integrated"]          = dsCredentials.Tables[0].Rows[0]["Is_Kangle_Integrated"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["KangleUrl"]                     = dsCredentials.Tables[0].Rows[0]["KangleUrl"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["FormsManagement_Integrated"]    = dsCredentials.Tables[0].Rows[0]["FormsManagement_Integrated"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["FormsManagement_URL"]           = dsCredentials.Tables[0].Rows[0]["FormsManagement_URL"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["FAQ_Url"]            = dsCredentials.Tables[0].Rows[0]["FAQ_Url"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["EDetailing_URL"]     = dsCredentials.Tables[0].Rows[0]["EDetailing_URL"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["CompanyId"]          = dsCredentials.Tables[0].Rows[0]["CompanyId"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["CommonPassword"]     = dsCredentials.Tables[0].Rows[0]["CommonPassword"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["GeoLocationSupport"] = "NO";
                        if (dsCredentials.Tables[0].Rows[0]["GeoLocationSupport"].ToString().Trim().ToUpper() == "1" ||
                            dsCredentials.Tables[0].Rows[0]["GeoLocationSupport"].ToString().Trim().ToUpper() == "TRUE")
                        {
                            System.Web.HttpContext.Current.Session["GeoLocationSupport"] = "YES";
                        }
                        System.Web.HttpContext.Current.Session["HRMS_URL"]           = dsCredentials.Tables[0].Rows[0]["HRMS_URL"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Is_HRMS_Integrated"] = dsCredentials.Tables[0].Rows[0]["Is_HRMS_Integrated"].ToString().Trim();

                        // KRA Integration
                        System.Web.HttpContext.Current.Session["KRA_URL"]           = dsCredentials.Tables[0].Rows[0]["KRA_URL"].ToString().Trim();
                        System.Web.HttpContext.Current.Session["Is_KRA_Integrated"] = dsCredentials.Tables[0].Rows[0]["Is_KRA_Integrated"].ToString().Trim();


                        //SetCommonPassword(dsCredentials);
                        //SetGeoLocationSupport(dsCredentials);

                        isTrue = true;
                    }
                }
                finally
                {
                    dsCredentials.Dispose();
                }
            }

            return(isTrue);
        }