Exemple #1
0
        private void DuplicateButton_Next_Click(object sender, EventArgs e)
        {
            dialog_duplicate.DuplicateButton_Next.Enabled = false;
            string FULL_NAME = dialog_duplicate.listBox_Duplicate.SelectedItem.ToString();

            File.Copy(DATABASE_EXTERNAL = dialog_database.openFileDialog_Welcome.FileName, AppDomain.CurrentDomain.BaseDirectory + "database_internal.db", true);
            FileInfo            fi          = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "database_internal.db");
            DATABASE_OPERATIONS database_op = new DATABASE_OPERATIONS();

            while (database_op.IsFileLocked(fi, AppDomain.CurrentDomain.BaseDirectory + "database_internal.db") == true)
            {
                Console.WriteLine("Wainting for database to unlock: Duplicate NEXT Button");
            }

            if (database_op.IsFileLocked(fi, AppDomain.CurrentDomain.BaseDirectory + "database_internal.db") == false)
            {
                DATABASE_OPERATIONS dbo = new DATABASE_OPERATIONS();
                MonolithConsole("File is unlocked in Duplicate NExt Button " + dbo.IsFileLocked(fi, AppDomain.CurrentDomain.BaseDirectory + "database_internal.db"));
                dbo.RETRIEVE_IMAGE_FILE(FULL_NAME);
                dbo.RETRIEVE_CONFIG_FILE(FULL_NAME);
                dialog_duplicate.DuplicateButton_Next.Enabled = true;
                config_load.MainLoad();
                dialog_duplicate.Hide();
                FormMaximize();
            }
            else
            {
                MonolithConsole("File is locked...");
            }
        }
        protected Image LoadImageRemote(string FileDirectory)
        {
            FileInfo filelocked = new FileInfo(FileDirectory);

            while (data_op.IsFileLocked(filelocked, FileDirectory) == true)
            {
                Console.WriteLine("Wainting for database to unlock: Duplicate NEXT Button");
            }

            //if (data_op.IsFileLocked(filelocked, FileDirectory) == false)
            //{
            MonolithConsole("File is unlocked in Set Strip Function " + data_op.IsFileLocked(filelocked, FileDirectory));

            string[] lines = File.ReadAllLines(FileDirectory);

            if (lines[11] != null)
            {
                DATABASE_OPERATIONS dbo  = new DATABASE_OPERATIONS();
                string LAST_RETRIEVE     = lines[9];
                string FIRST_RETRIEVE    = lines[8];
                string FULLNAME_RETRIEVE = FIRST_RETRIEVE + "_" + LAST_RETRIEVE;
                dbo.RETRIEVE_REMOTE_IMAGES(FULLNAME_RETRIEVE);

                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/" + FIRST_RETRIEVE + "_" + LAST_RETRIEVE + ".avt"))
                {
                    PersonnelImage = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/" + FIRST_RETRIEVE + "_" + LAST_RETRIEVE + ".avt");

                    try
                    {
                        Image imageIn = PersonnelImage;
                        PersonnelImage = resizeImageRemote(PersonnelImage, new Size(80, 80));
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }

            else
            {
                PersonnelImage = new Bitmap(Properties.Resources.avatar_image);
                try
                {
                    Image imageIn = PersonnelImage;
                    PersonnelImage = resizeImageRemote(PersonnelImage, new Size(80, 80));
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            //}
            return(PersonnelImage);
        }
Exemple #3
0
        // Load default user's image.
        protected void LoadImage()
        {
            string[] lines = File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration");

            if (lines[14] != null)
            {
                DATABASE_OPERATIONS dbo  = new DATABASE_OPERATIONS();
                string LAST_RETRIEVE     = lines[9];
                string FIRST_RETRIEVE    = lines[8];
                string FULLNAME_RETRIEVE = FIRST_RETRIEVE + "_" + LAST_RETRIEVE;
                dbo.RETRIEVE_IMAGE_FILE(FULLNAME_RETRIEVE);

                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/" + "avatar"))
                {
                    PersonnelImage = new Bitmap(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/" + "avatar");
                    try
                    {
                        Image imageIn = PersonnelImage;
                        PersonnelImage = resizeImage(PersonnelImage, new Size(display_Panel1.pib_1.panel_PersonnelImage.Width, display_Panel1.pib_1.panel_PersonnelImage.Height));
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }

                else
                {
                    PersonnelImage = new Bitmap(Properties.Resources.avatar_image);
                    try
                    {
                        Image imageIn = PersonnelImage;
                        PersonnelImage = resizeImage(PersonnelImage, new Size(display_Panel1.pib_1.panel_PersonnelImage.Width, display_Panel1.pib_1.panel_PersonnelImage.Height));
                    }

                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemple #4
0
        public void ADDRemoteUsers()
        {
            MonolithConsole("Add Remote Users");
            int User2  = 0;
            int User3  = 0;
            int User4  = 0;
            int User5  = 0;
            int User6  = 0;
            int User7  = 0;
            int User8  = 0;
            int User9  = 0;
            int User10 = 0;

            int[]    NameArrayInt;
            string[] FirstNamesArrayString;
            string[] LastNamesArrayString;

            //Copy all user information from remote database to local database.
            DATABASE_OPERATIONS dbo = new DATABASE_OPERATIONS();

            dbo.RETRIEVE_REMOTE_USERS();

            int fileCount = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration", "*.cfg").Length;

            string[] DirectoryFiles = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration", "*.cfg");


            for (int x = 0; x < fileCount; x++)
            {
                string   SingleConfig = DirectoryFiles[x];
                string[] lines        = File.ReadAllLines(SingleConfig);

                using (StreamReader reader = File.OpenText(SingleConfig))
                {
                    if (SingleConfig != AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/avatar")
                    {
                        string FUllName = lines[8] + " " + lines[9];
                        if ((lines[8] == "Rob" || lines[8] == "Robert" || lines[8] == "R") && lines[9] == "Fleischacker")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User2          = 2;
                                FIRST_NAME_ROB = lines[8];
                                LAST_NAME_ROB  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Lou" || lines[8] == "Louis" || lines[8] == "L") && lines[9] == "Vicente")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User3          = 3;
                                FIRST_NAME_LOU = lines[8];
                                LAST_NAME_LOU  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Kevin" || lines[8] == "Kev" || lines[8] == "K") && lines[9] == "Keller")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User4          = 4;
                                FIRST_NAME_KEV = lines[8];
                                LAST_NAME_KEV  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Copeland" || lines[8] == "Cope" || lines[8] == "C") && lines[9] == "Lanier")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User5          = 5;
                                FIRST_NAME_COP = lines[8];
                                LAST_NAME_COP  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Jeff" || lines[8] == "Jeffrey" || lines[8] == "J") && lines[9] == "Friedman")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User6          = 6;
                                FIRST_NAME_JEF = lines[8];
                                LAST_NAME_JEF  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Tim" || lines[8] == "Timothy" || lines[8] == "T") && lines[9] == "Mocilan")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User7          = 7;
                                FIRST_NAME_TIM = lines[8];
                                LAST_NAME_TIM  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Anthony" || lines[8] == "Tony" || lines[8] == "A") && lines[9] == "Martano")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User8          = 8;
                                FIRST_NAME_ANT = lines[8];
                                LAST_NAME_ANT  = lines[9];
                            }
                        }

                        else if ((lines[8] == "Christine" || lines[8] == "Christina" || lines[8] == "C") && lines[9] == "Bautista")
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User9          = 9;
                                FIRST_NAME_CHR = lines[8];
                                LAST_NAME_CHR  = lines[9];
                            }
                        }

                        else
                        {
                            if (lines[8] + " " + lines[9] != display_Panel1.pib_1.label_PImageName.Text)
                            {
                                User10          = 10;
                                FIRST_NAME_USER = lines[8];
                                LAST_NAME_USER  = lines[9];
                            }
                        }
                    }
                }
            }

            FirstNamesArrayString = new string[] { FIRST_NAME_ROB, FIRST_NAME_LOU, FIRST_NAME_KEV, FIRST_NAME_COP, FIRST_NAME_JEF, FIRST_NAME_TIM, FIRST_NAME_ANT, FIRST_NAME_CHR, FIRST_NAME_USER };

            LastNamesArrayString = new string[] { LAST_NAME_ROB, LAST_NAME_LOU, LAST_NAME_KEV, LAST_NAME_COP, LAST_NAME_JEF, LAST_NAME_TIM, LAST_NAME_ANT, LAST_NAME_CHR, LAST_NAME_USER };

            NameArrayInt = new int[] { User2, User3, User4, User5, User6, User7, User8, User9, User10 };

            Logic_Arrangement la = new Logic_Arrangement();

            la.ArrangeColumns(NameArrayInt, FirstNamesArrayString, LastNamesArrayString);
        }
        private void SettingsButton_Next_Click(object sender, EventArgs e)
        {
            // Perform error check on form.
            ErrorFormCheck();

            // If duplicate is found FoundDuplicateTrigger = 1.
            int FoundDuplicateTrigger = 0;

            if (ErrorTrigger == 0)
            {
                MonolithConsole("Trigger is 0");
                string SAVE_INTERNAL = AppDomain.CurrentDomain.BaseDirectory + "database_internal.db";

                // Check if there are duplicate names in the external database connected.
                using (var db = new LiteDatabase(SAVE_INTERNAL))
                {
                    var EmployeeCollection = db.GetCollectionNames();
                    dialog_duplicate.listBox_Duplicate.Items.Clear();

                    for (int x = 0; x < EmployeeCollection.Count(); x++)
                    {
                        if (EmployeeCollection.ElementAt(x) == textBoxSettings_FirstName.Text + "_" + textBoxSettings_LastName.Text)
                        {
                            FoundDuplicateTrigger = 1;
                            dialog_duplicate.listBox_Duplicate.Items.Add(EmployeeCollection.ElementAt(x));
                            this.Hide();
                            dialog_duplicate.DuplicateButton_Next.Enabled = false;
                            dialog_duplicate.Show();
                            break;
                        }
                    }

                    // Trigger if duplicate record not found.
                    if (FoundDuplicateTrigger == 0)
                    {
                        FoundDuplicateName = 0;
                    }
                }
            }

            // Set default background image if no avatar was selected.
            if (FoundDuplicateName == 0)
            {
                if (panelSettings_ImageBox.BackgroundImage == null)
                {
                    PersonnelImage = Properties.Resources.avatar_image_sm;
                    imgResize();
                }

                // Write to DATABASE Globals
                DATABASE_EXTERNAL             = dialog_database.selected_DATABASE_Path;
                DATABASE_NAME                 = dialog_database.entered_DATABASE_Name;
                FIRST_NAME                    = textBoxSettings_FirstName.Text;
                LAST_NAME                     = textBoxSettings_LastName.Text;
                JOB_TITLE                     = textBoxSettings_JobTitle.Text;
                COMPUTER_USERNAME             = Environment.UserName;
                EMAIL                         = maskedTextBox_Email.Text;
                PHONE                         = maskedTextBox_Phone.Text;
                AVATAR_LOCAL                  = ImageTransfer;
                AVATAR_DB                     = @"images/" + FIRST_NAME + "_" + LAST_NAME + "/" + FIRST_NAME + "_" + LAST_NAME + ".avt";
                THEME                         = ThemeTransfer;
                display_Panel1.ExpandBGImage1 = ThemeImage;
                display_Panel1.pib_1.panel_PersonnelImage.BackgroundImage = new Bitmap(ImageAvatar, 80, 80);
                display_Panel1.Panel_DayControlHolder.Controls.Add(display_Panel1.day_Control_1);
                display_Panel1.pib_1.label_PImageName.Text = FIRST_NAME + " " + LAST_NAME;
                FIRSTRUN_SWITCH = true;

                // Relay Globals to other forms
                dialog_internalsettings.textBoxSettings_FirstName.Text         = FIRST_NAME;
                dialog_internalsettings.textBoxSettings_LastName.Text          = LAST_NAME;
                dialog_internalsettings.maskedTextBox_Email.Text               = EMAIL;
                dialog_internalsettings.maskedTextBox_Phone.Text               = PHONE;
                dialog_internalsettings.textBoxSettings_JobTitle.Text          = JOB_TITLE;
                dialog_internalsettings.panelSettings_ImageBox.BackgroundImage = new Bitmap(ImageAvatar, dialog_internalsettings.panelSettings_ImageBox.Width, dialog_internalsettings.panelSettings_ImageBox.Height);
                //

                // Add file watchers
                fileSystemWatcher_WebUpload.Path                     = AppDomain.CurrentDomain.BaseDirectory + "Web_Upload";
                fileSystemWatcher_Config.Path                        = AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration";
                fileSystemWatcher_RemoteDB.Path                      = DATABASE_EXTERNAL;
                fileSystemWatcher_Config.EnableRaisingEvents         = true;
                fileSystemWatcher_RemoteDB.EnableRaisingEvents       = true;
                fileSystemWatcher_WebUpload.EnableRaisingEvents      = true;
                backgroundWorker_Listener.WorkerReportsProgress      = true;
                backgroundWorker_Listener.WorkerSupportsCancellation = true;

                // Write to generic configuration file
                using (StreamWriter SW_Config = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Calendar_Configuration/configuration"))
                {
                    SW_Config.WriteLine("Normal");
                    SW_Config.WriteLine(FIRSTRUN_SWITCH);
                    SW_Config.WriteLine("*** COMPUTER INFORMATION");
                    SW_Config.WriteLine(Environment.MachineName);
                    SW_Config.WriteLine(Environment.OSVersion);
                    SW_Config.WriteLine(Environment.UserDomainName);
                    SW_Config.WriteLine(COMPUTER_USERNAME);
                    SW_Config.WriteLine("*** ID INFORMATION");
                    SW_Config.WriteLine(FIRST_NAME);
                    SW_Config.WriteLine(LAST_NAME);
                    SW_Config.WriteLine(EMAIL);
                    SW_Config.WriteLine(PHONE);
                    SW_Config.WriteLine(JOB_TITLE);
                    SW_Config.WriteLine(THEME);
                    SW_Config.WriteLine(AVATAR_DB);
                    SW_Config.WriteLine("*** DATABASE INFORMATION");
                    SW_Config.WriteLine(AVATAR_LOCAL);
                    SW_Config.WriteLine(DATABASE_NAME);
                    SW_Config.WriteLine(DATABASE_EXTERNAL);
                    SW_Config.WriteLine("*** FTP INFORMATION");
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_Host);
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_User);
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_Password);
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_Port);
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_Passive);
                    SW_Config.WriteLine(dialog_ftpsettings.FTP_Folder);
                }

                // Write to Web Data (.web) file
                using (StreamWriter SW_WebUpload = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "Web_Upload/" + FIRST_NAME + "_" + LAST_NAME + ".web"))
                {
                    SW_WebUpload.WriteLine("Normal");
                    SW_WebUpload.WriteLine("***ID INFORMATION");
                    SW_WebUpload.WriteLine(FIRST_NAME);
                    SW_WebUpload.WriteLine(LAST_NAME);
                    SW_WebUpload.WriteLine(JOB_TITLE);
                    SW_WebUpload.WriteLine(THEME);
                }

                DATABASE_OPERATIONS DATABASE_WRITE = new DATABASE_OPERATIONS();
                DATABASE_WRITE.CREATE_DATABASE_LOCAL();

                using (StreamWriter SW_TempX = new StreamWriter(DATABASE_EXTERNAL + "temp.x", true))
                {
                    SW_TempX.WriteLine(FIRST_NAME + " " + LAST_NAME);
                    SW_TempX.Close();
                }

                this.Hide();
            }
        }