示例#1
0
        private void saveCallRecordFile(bool demofile)
        {
            SaveFileDialog openFileDialog = new SaveFileDialog();

            if (!demofile)
            {
                openFileDialog.FileName = "Mitel_Call_Records.db";
            }
            else
            {
                openFileDialog.FileName = "Demo_Call_Records.db";
            }
            openFileDialog.Filter           = "MiSMDR Call Records Files (*.db)|*.db|All Files (*.*)|*.*";
            openFileDialog.OverwritePrompt  = false;
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            openFileDialog.Title            = "Call Records File";
            DialogResult d = openFileDialog.ShowDialog();

            if (d == DialogResult.OK)
            {
                ConnStringer stringer = new ConnStringer();
                if (!demofile)
                {
                    tbCallRecordLoc.Text = openFileDialog.FileName;
                }
                else
                {
                    tbDemoRecords.Text = openFileDialog.FileName;
                }
            }
        }
        public void Test_GetPasswordFromUser_TestSpecialChars()
        {
            //Test passwords that have a semicolon
            bool cnWasOpened = false;

            global::SiqConfigExport.ConnStringer connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock(loginHasSemiColonPassword, passwordWithSemiColon));
            connStringer.GenerateConnectionString(false);
            using (SqlConnection sqlCn = new SqlConnection(connStringer.GeneratedConnectionString))
            {
                sqlCn.Open();
                if (sqlCn.State == ConnectionState.Open)
                {
                    cnWasOpened = true;
                }
            }
            Assert.IsTrue(cnWasOpened, "The connection should have opend successfully for this test to pass");

            //Test passwords that have a single quote
            cnWasOpened  = false;
            connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock(loginHasSingleQuotePassword, passwordWithSingleQuote));
            connStringer.GenerateConnectionString(false);
            using (SqlConnection sqlCn = new SqlConnection(connStringer.GeneratedConnectionString))
            {
                sqlCn.Open();
                if (sqlCn.State == ConnectionState.Open)
                {
                    cnWasOpened = true;
                }
            }
            Assert.IsTrue(cnWasOpened, "The connection should have opend successfully for this test to pass");
        }
示例#3
0
        private void bnSave_Click(object sender, EventArgs e)
        {
            ConnStringer  stringer = new ConnStringer();
            List <string> errors   = new List <string>();

            if (tbMitelDataLogPath.Text == String.Empty)
            {
                errors.Add("Mitel data log file field cannot be blank");
            }
            if (tbDemoRecords.Text == String.Empty)
            {
                errors.Add("Demo Call Records file location cannot be blank");
            }
            if (tbCallRecordLoc.Text == String.Empty)
            {
                errors.Add("Mitel Call Records file location cannot be blank");
            }

            if (errors.Count == 0)
            {
                //Save the file locations
                MiConfig.SetConnectionString("MiDemoString", stringer.buildLiteConnectionString(tbDemoRecords.Text, "3", "True", "False", "", "", false));
                MiConfig.SetConnectionString("MiDatabaseString", stringer.buildLiteConnectionString(tbCallRecordLoc.Text, "3", "True", "False", "", "", false));
                MiConfig.SetLogPath(tbMitelDataLogPath.Text);

                //save options
                MiConfig.SetConnectOnStartup(cbConnectOnStartup.Checked);
                MiConfig.SetShowDebug(cbShowDebug.Checked);
                RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                if (cbStartWithWindows.Checked)
                {
                    rkApp.SetValue("MiSMDR", Application.ExecutablePath.ToString());
                }
                else
                {
                    rkApp.DeleteValue("MiSMDR", false);
                }
                MiConfig.SetShowSplash(cbShowSplash.Checked);
                MiConfig.SetMinimiseToTray(cbMinimiseToTray.Checked);
                MiConfig.SetRecordLimit(Convert.ToInt32(tbCallRecordLimit.Text));
                MiConfig.SetShowNotifications(cbShowNotifications.Checked);

                //return to MiForm
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                string errorString = "Cannot save settings: " + Environment.NewLine;
                foreach (string error in errors)
                {
                    errorString += "- " + error + Environment.NewLine;
                }
                MessageBox.Show(errorString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void Test_GetUsernameFromUser()
        {
            global::SiqConfigExport.ConnStringer connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock("someuser", "somePass"));
            string username = connStringer.GetUsernameFromUser(defaultPassword);

            Assert.AreEqual(username, "someuser", true, "The resulting username should match the user-provided string");

            connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock(null, null));
            username     = connStringer.GetUsernameFromUser(defaultPassword);
            Assert.AreEqual(username, defaultPassword, true, "The user had no input, therefore we should get the default password back.");
        }
        public void Test_GetUsernameFromConnStr()
        {
            global::SiqConfigExport.ConnStringer connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock());
            string username = connStringer.GetUsernameFromConnStr(cnStr_defaultUser);

            Assert.AreEqual(username, securityiq_default_user, true, "The username should match 'default' SecurityIQ user in the cn string");

            connStringer = new ConnStringer(cnStr_customUser, new ConsoleReaderMock());
            username     = connStringer.GetUsernameFromConnStr(cnStr_customUser);
            Assert.AreEqual(username, securityiq_custom_user, true, "The username should match the custom user in the cn string");
        }
        public void Test_GenerateConnectionStringFromAllInputs()
        {
            global::SiqConfigExport.ConnStringer connStringer = new ConnStringer(cnStr_defaultUser, new ConsoleReaderMock(securityiq_custom_user, securityiq_custom_pass));
            connStringer.GenerateConnectionString(false);

            Assert.IsTrue(
                connStringer.GeneratedConnectionString.Contains(securityiq_custom_user),
                "The user supplied username should be in the connection string.");
            Assert.IsTrue(connStringer.GeneratedConnectionString.Contains(securityiq_custom_pass),
                          "The user supplied password should be in the connection string.");
        }
示例#7
0
        private void BuildDemoFile()
        {
            ConnStringer stringer = new ConnStringer();
            string       myDocs   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            this.SetText("Creating the Demo Call Records Database");
            string demoPath   = myDocs + "\\MiSMDR\\Demo_Call_Records.db";
            string connString = stringer.buildLiteConnectionString(demoPath, "3", "True", "False", "", "", false);

            MiConfig.SetConnectionString("MiDemoString", connString);
            //initialise and put demo data in the database if there is none already
            DBControl control = new DBControl(MiConfig.GetConnectionString("MiDemoString"), MiConfig.GetProvider());

            if (!control.CheckDataAccess())
            {
                initDatabase(connString, true);
            }
        }
示例#8
0
        private void BuildMitelFile()
        {
            ConnStringer stringer = new ConnStringer();
            string       myDocs   = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            this.SetText("Creating the Mitel Call Records Database");
            string dataPath   = myDocs + "\\MiSMDR\\Mitel_Call_Records.db";
            string connString = stringer.buildLiteConnectionString(dataPath, "3", "False", "False", "", "", false);

            MiConfig.SetConnectionString("MiDatabaseString", connString);
            //we only need to intialise the database if it doesnt have any content
            DBControl control = new DBControl(MiConfig.GetConnectionString("MiDatabaseString"), MiConfig.GetProvider());

            if (!control.CheckDataAccess())
            {
                initDatabase(connString, false);
            }
        }