Beispiel #1
0
        /// <summary>
        /// In the app.config file :
        ///		for the connect string - UserID comes before dlr_debug and
        ///								 if you have dlr_debug, you need to include app_path
        ///		ie: <add key="connect" value="item1=...;item2=...; User ID=apps;dlr_debug;"/>
        ///			<add key="app_path" value="C:\...\...\MyApp"/>
        /// </summary>
        private Connection()
        {
            ConfigData.CreateInstance();
            dBConnectStringBase = ConfigData.GetValue("connect"); //nwlrl_connect  **!** also uncomment the password & User lines below
            if (dBConnectStringBase.IndexOf("dlr_debug") > 0)
            {                                                     //if 'debug' then provide the user name and pw
                string[] cnctStr      = dBConnectStringBase.Split(';');
                string   userName     = "";
                string   connectItems = "";
                string   app_path     = "";
                string   pWord        = "";
                app_path            = app_path.Length > 0 ? app_path : ConfigData.GetValue("app_path").ToString();
                dBConnectStringBase = "";
                needLogIn           = false;
                for (int x = 0; x < cnctStr.Length; x++)
                {
                    if (cnctStr[x].Length > 0)
                    {
                        connectItems = cnctStr[x].ToString().Trim().Substring(0, 6);
                        if (connectItems.Equals("UserID") || connectItems.Equals("User I"))
                        {
                            string[] uid = cnctStr[x].ToString().Split('=');
                            userName = uid[1];
                        }
                        if (cnctStr[x].ToString().Trim().Equals("dlr_debug"))
                        {
                            if (userName.Length > 0)
                            {
                                Crypto cryptLogIn = new Crypto(app_path);
                                cryptLogIn.Dbug = true;

                                pWord = cryptLogIn.Decrypt(cryptLogIn.ReadFromFile(), userName).ToString();
                                if (pWord.Length > 0)
                                {
                                    dBConnectStringBase += "User ID=" + userName + ";password="******";";
                        }
                    }
                }
                dBConnectString = dBConnectStringBase;
                debug           = true;
            }
        }