Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        private void Settings_Load(object sender, EventArgs e)
        {
            tbMitelDataLogPath.Text = MiConfig.GetLogPath();

            cbShowDebug.Checked         = MiConfig.GetShowDebug();
            cbConnectOnStartup.Checked  = MiConfig.GetConnectOnStartup();
            cbShowNotifications.Checked = MiConfig.GetShowNotifications();
            cbShowSplash.Checked        = MiConfig.GetShowSplash();
            cbMinimiseToTray.Checked    = MiConfig.GetMinimiseToTray();

            //Get the registry setting
            RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

            if (rkApp.GetValue("MiSMDR") == null)
            {
                cbStartWithWindows.Checked = false;
            }
            else
            {
                cbStartWithWindows.Checked = true;
            }

            //Load the database strings
            string[] pieces = MiConfig.GetConnectionString("MiDatabaseString").Split(new string[] { ";" }, StringSplitOptions.None);
            tbCallRecordLoc.Text = pieces[0].Remove(0, 12);
            pieces                 = MiConfig.GetConnectionString("MiDemoString").Split(new string[] { ";" }, StringSplitOptions.None);
            tbDemoRecords.Text     = pieces[0].Remove(0, 12);
            tbCallRecordLimit.Text = MiConfig.GetRecordLimit().ToString();
        }
Esempio n. 3
0
        private void bnResetSettings_Click(object sender, EventArgs e)
        {
            DialogResult d = MessageBox.Show("This will reset all your settings and restart MiSMDR.\nAre you sure?", "Reset MiSMDR Settings", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (d == DialogResult.Yes)
            {
                MiConfig.buildDefaultConfigFile("");
                Application.Restart();
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public SplashScreen()
        {
            try
            {
                SingleInstanceMutex = Mutex.OpenExisting("MiSMDRMutex0");
                MessageBox.Show("There is already an instance of MiSMDR running.", "MiSMDR already running", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Process.GetCurrentProcess().Kill();
            }
            catch (Exception ex)
            {
                SingleInstanceMutex = new Mutex(false, "MiSMDRMutex0");

                _firstTime   = true; //Never change this
                _statusCount = 0;

                CheckVersion();

                _forcedDemo  = false; // TURN ON AND OFF DEMO HERE - to force into demo mode every startup
                _popup       = false;
                _trialStatus = false;

                Microsoft.Win32.RegistryKey key;
                key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\\MiSMDR");
                string existing_key = (string)key.GetValue("MiSMDRKey");
                key.Close();
                LicenseBreaker    breaker = new LicenseBreaker(existing_key);
                RegisteredDetails details = breaker.BreakKey();

                if ((details.licence_type == "expired-trial") || (details.licence_type == "unregistered") || (details.licence_type == "invalid")) //only show popup for expired trial, invalid or unregistered
                {
                    _popup = true;                                                                                                                //make the registration page popup
                }
                if ((details.licence_type == "trial") || (details.licence_type == "expired-trial"))
                {
                    _trialStatus = true; //make the trial status appear
                }

                if (_forcedDemo)
                {
                    MiConfig.SetDemoMode(_forcedDemo); //always overwrite the config file if this is forced Demo Only
                    _demo = true;
                }
                else
                {
                    _demo = MiConfig.GetDemoMode(); //get the stored demo mode if it is not forced (returns true if there is no config)
                }

                //get the location of the user settings
                Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
                _configPath = config.FilePath.Remove(config.FilePath.Length - 11); // user.config is 11 characters

                InitializeComponent();
            }
        }
Esempio n. 6
0
 private void SplashScreen_Load(object sender, EventArgs e)
 {
     linkLabel1.Links.Remove(linkLabel1.Links[0]);
     linkLabel1.Links.Add(0, linkLabel1.Text.Length, "http://www.MiSMDR.info");
     if (MiConfig.GetShowSplash())
     {
         this.WindowState = FormWindowState.Normal;
     }
     else
     {
         this.WindowState = FormWindowState.Minimized;
     }
 }
Esempio n. 7
0
 private void cbMinimiseToTray_CheckedChanged(object sender, EventArgs e)
 {
     if (cbMinimiseToTray.Checked)
     {
         cbShowNotifications.Enabled = true;
         cbShowNotifications.Checked = MiConfig.GetShowNotifications();
     }
     else
     {
         cbShowNotifications.Enabled = false;
         cbShowNotifications.Checked = false;
     }
 }
Esempio n. 8
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;
            }
        }
Esempio n. 9
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;
            }
        }
Esempio n. 10
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);
            }
        }
Esempio n. 11
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);
            }
        }
Esempio n. 12
0
 private void SetText(string text)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (MiConfig.GetShowSplash())
     {
         Thread.Sleep(20);
     }
     if (this.lbStatus.InvokeRequired)
     {
         SetTextCallback d = new SetTextCallback(SetText);
         this.Invoke(d, new object[] { text });
     }
     else
     {
         this.lbStatus.Text = text;
     }
 }
Esempio n. 13
0
        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
        }