private void initDatabase(string connString, bool demo)
        {
            string prefix = String.Empty;

            if (demo)
            {
                prefix = "Demo Call Records - ";
            }
            else
            {
                prefix = "Mitel Call Records - ";
            }

            DBInstaller myInstaller = new DBInstaller(connString, MiConfig.GetProvider());

            this.SetText(prefix + "Creating Database");
            myInstaller.CreateDatabase();
            this.SetText(prefix + "Adding Tables");
            myInstaller.CreateTables();
            this.SetText(prefix + "Adding default hardware formats");
            myInstaller.InsertInputFormats();
            if (demo)
            {
                this.SetText(prefix + "Adding Demo Data");
                myInstaller.InsertDefaultData();
            }
        }
Exemple #2
0
        private void bnDataClear_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("Are you sure you want to clear the Mitel Call Records file?\nWarning: you cannot undo this operation. You may want to back up your call record file before proceeding", "Clear Mitel Call Records File", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)
            {
                String       connectionString = MiConfig.GetConnectionString("MiDatabaseString");
                DataProvider provider         = MiConfig.GetProvider();
                DBInstaller  installer        = new DBInstaller(connectionString, provider);
                this.Cursor = Cursors.WaitCursor;
                installer.EmptyCallData();
                this.Cursor = Cursors.Default;
            }
        }
Exemple #3
0
        private void bnDemoData_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("Are you sure you want to clear the call records file and insert demo call records?", "Demo Call Records", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)
            {
                String       connectionString = MiConfig.GetConnectionString("MiDemoString");
                DataProvider provider         = MiConfig.GetProvider();
                DBInstaller  installer        = new DBInstaller(connectionString, provider);
                this.Cursor = Cursors.WaitCursor;
                installer.InsertDefaultData();
                installer.InsertInputFormats();
                this.Cursor = Cursors.Default;
            }
        }
        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);
            }
        }
        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);
            }
        }
        private void afterLoad()
        {
            string myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

            //first thing is to see if the config is new
            if (MiConfig.GetProvider() != DataProvider.Sqlite)
            {
                this.SetText("Updating configuration file");
                MiConfig.buildDefaultConfigFile(_configPath); //rebuild it just in case
                MiConfig.SetProvider(DataProvider.Sqlite);
            }

            if (MiConfig.GetProvider() != DataProvider.Sqlite)
            {
                //CHECK AGAIN - this is to make sure the config file is in a writable location
                this.SetText("Unable to create a config file. Please contact the MiSMDR support team at [email protected]");
            }

            if ((MiConfig.GetConnectionString("MiDatabaseString") == "notinstalled") || (MiConfig.GetConnectionString("MiDemoString") == "notinstalled"))
            {
                CheckMiSMDRFolder();

                //now we need to check the demo file location
                if (MiConfig.GetConnectionString("MiDemoString") == "notinstalled")
                {
                    BuildDemoFile();
                }

                if (MiConfig.GetConnectionString("MiDatabaseString") == "notinstalled")
                {
                    BuildMitelFile();
                }
            }

            if (MiConfig.GetLogPath() == "notinstalled")
            {
                this.SetText("Checking Mitel Data log file");
                string dataLogPath = myDocs + "\\MiSMDR\\MitelData_Log.txt";
                MiConfig.SetLogPath(dataLogPath);
            }

            DBControl demoChecker = new DBControl(MiConfig.GetConnectionString("MiDemoString"), MiConfig.GetProvider());
            DBControl liveChecker = new DBControl(MiConfig.GetConnectionString("MiDatabaseString"), MiConfig.GetProvider());

            this.SetText("Configuration looks ok");
            this.SetText("Checking Database access");
            if (!demoChecker.CheckDataAccess())
            {
                this.SetText("Demo Database looks ok");
                CheckMiSMDRFolder(); //check the folder exists
                BuildDemoFile();
            }
            if (!liveChecker.CheckDataAccess())
            {
                this.SetText("Mitel Database looks ok");
                CheckMiSMDRFolder();
                BuildMitelFile();
            }

            //Load MiSMDR main
            CheckProgressBar();
            HideSplash();
            MiSMDR.MiForm.customStart(_popup, _trialStatus);
            CloseSplash(); //after the MiForm is closed then kill the App
        }