Example #1
0
 public Repository(
     string instance,
     string user,
     string password,
     type_of_authentication authenticationMode//SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
     )
 {
     Connect(instance, user, password, authenticationMode);//SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
 }
Example #2
0
        //SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
        public bool Connect(string instance, string user, string password, type_of_authentication authenticationMode)
        {
            try
            {
                if ((instance.ToUpper() + "\\").StartsWith("(LOCAL)\\"))
                {
                    m_ServerName = instance.ToUpper().Replace("(LOCAL)", Environment.MachineName).ToUpper();
                }
                else if ((instance + "\\").StartsWith(".\\"))
                {
                    m_ServerName = instance.Replace(".", Environment.MachineName).ToUpper();
                }
                else if ((instance + "\\").StartsWith("localhost\\"))
                {
                    m_ServerName = instance.Replace("localhost", Environment.MachineName).ToUpper();
                }
                else
                {
                    m_ServerName = instance.ToUpper();
                }
                //Start-SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
                if (authenticationMode == type_of_authentication.windows)
                {
                    m_ConnectionStringBuilder = Sql.SqlHelper.ConstructConnectionString(m_ServerName, string.Empty, string.Empty, Utility.Activity.TypeServerOnPremise);
                }
                else
                {
                    m_ConnectionStringBuilder = Sql.SqlHelper.ConstructConnectionString(m_ServerName, user, password, Utility.Activity.TypeServerOnPremise);
                }
                //End-SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
                if (Connect())
                {
                    //SQLsecure 3.1 (Tushar)--Saving UserName and Password in UserData object which will be saved in config file on closure of UI.
                    //m_User = user;
                    //m_Password = password;
                    UserData.Current.RepositoryInfo.UserName           = m_User = user;
                    UserData.Current.RepositoryInfo.Password           = m_Password = password;
                    UserData.Current.RepositoryInfo.AuthenticationMode = Convert.ToString(authenticationMode);//SQLsecure 3.1 (Tushar)--Supporting windows auth for repository connection
                }
            }
            catch (SqlException ex)
            {
                logX.loggerX.Error(string.Format(Utility.ErrorMsgs.ErrorStub, Utility.ErrorMsgs.CantConnectRepository), ex);
                MsgBox.ShowError(Utility.ErrorMsgs.CantConnectRepository, ex);
            }

            return(m_IsValid);
        }