Esempio n. 1
0
        private void ApplicationSetupAsync()
        {
            // Setup the Dna Framework
            Framework.Construct <DefaultFrameworkConstruction>()
            .AddPosTicketViewModels()
            .Build();
            if (File.Exists("PosTicket.ark") == false)
            {
                try
                {
                    SQLiteConnection connection = (SQLiteConnection)DatabaseContext.GetConnection();
                    SQLiteConnection.CreateFile("PosTicket.ark");
                    connection.Open();
                    string        sql_table = "create table config (id INTEGER PRIMARY KEY AUTOINCREMENT, server_url varchar(100), pos_printer varchar(100), ticket_printer varchar(100), current_ip varchar(100), api_key varchar(100), session_data text)";
                    SQLiteCommand command   = new SQLiteCommand(sql_table, connection);
                    command.ExecuteNonQuery();
                    command.Dispose();
                    connection.Close();
                    writeConfig = new WriteConfig();
                    writeConfig.CreateInitData();
                }
                catch (Exception sqlException)
                {
                    MessageBox.Show("Terjadi kesalahan inisialisasi data: " + sqlException.Message, "SQL Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            Login loginWindow = new Login();

            loginWindow.Show();
            Thread thread = new Thread(() => PingPong());

            thread.IsBackground = true;
            thread.Priority     = ThreadPriority.Highest;
            thread.Start();
        }
Esempio n. 2
0
        public void UpdateSession(Session updatedSession)
        {
            writeConfig = new WriteConfig();
            string        session_field = "session_data";
            StringBuilder session_data  = new StringBuilder();
            string        user_id       = updatedSession.user_id;
            string        user_name     = updatedSession.user_name;
            string        user_login    = updatedSession.user_login;
            string        token         = updatedSession.token;
            string        refresh_token = updatedSession.refresh_token;
            string        token_live    = updatedSession.token_live;
            long          t             = Convert.ToInt64(token_live);

            t += DateTimeOffset.UtcNow.ToUnixTimeSeconds();
            session_data.AppendLine(user_id);
            session_data.AppendLine("|");
            session_data.AppendLine(user_name);
            session_data.AppendLine("|");
            session_data.AppendLine(user_login);
            session_data.AppendLine("|");
            session_data.AppendLine(token);
            session_data.AppendLine("|");
            session_data.AppendLine(refresh_token);
            session_data.AppendLine("|");
            session_data.AppendLine(t.ToString());
            SecurityModule.EncDec enc = new SecurityModule.EncDec();
            string encrypted_session  = enc.Encrypt(session_data.ToString());

            writeConfig.UpdateConfigByField(session_field, encrypted_session);
        }
Esempio n. 3
0
        private void Button_Click_New(object sender, RoutedEventArgs e)
        {
            string newName = DialogMessage.DialogString();

            if (!string.IsNullOrEmpty(newName))
            {
                _ProjectList.Items.Add(newName);
                TableGlobalConfig.Instance.ProjectFileNames.Add(newName);
                WriteConfig.WriteProjectConfig(newName);

                ChangePage(PAGE_NAME_CONSTRUCT, ITEM_NAME_CONSTRUCT_SETTING);
            }
        }
Esempio n. 4
0
        //Removes an entry that is currently selected
        public void button_RemoveSelectedDomain_Click(object sender, EventArgs e)
        {
            if (comboBox_ListOfDomains.SelectedIndex == 0)    //Don't allow user to delete the "Create new" option.
            {
                MessageBox.Show("Cannot remove this entry."); //Notify user: cannot delete "Create new."
                return;                                       //exits
            }
            else
            {
                //Call method to remove the entry from the configfile.xml given the unique ID name.
                WriteConfig.RemoveDomainSetting(comboBox_ListOfDomains.GetItemText(comboBox_ListOfDomains.SelectedItem));

                ComboBoxRefresh();                                            //Reset combo box so deleted entry does not appear any longer.
                comboBox_ListOfDomains.SelectedIndex = 0;                     //Reset selection in combobox.

                MessageBox.Show("Domain removed and user settings updated."); //Notify user: domain removal successful.
            }
        }
Esempio n. 5
0
        private void SaveConfigClick(object sender)
        {
            List <string> updatedConfig = new List <string>();

            writeConfig = new WriteConfig();
            updatedConfig.Add("server_url");
            updatedConfig.Add("pos_printer");
            updatedConfig.Add("ticket_printer");
            updatedConfig.Add("current_ip");
            if (ApiKeyValue != null)
            {
                updatedConfig.Add("api_key");
                writeConfig.UpdateConfigByField(updatedConfig[4], ApiKeyValue);
            }
            writeConfig.UpdateConfigByField(updatedConfig[0], ServerURLValue);
            writeConfig.UpdateConfigByField(updatedConfig[1], SelectedPosPrinter);
            writeConfig.UpdateConfigByField(updatedConfig[2], SelectedTicketPrinter);
            writeConfig.UpdateConfigByField(updatedConfig[3], IpAddressValue);
            ShowLoginWindow();
            CloseWindow(sender);
        }
        private void button_LaunchPriorConfig_Click(object sender, EventArgs e)
        {
            if ((directoryPath != "") || (label_CurrentFileName.Text != "No file currently loaded..."))
            {
                WriteConfig.CreateXMLConfigFile();

                //Make sure the files can be accessed despite the current privileges.
                File.SetAttributes("configfile.xml", FileAttributes.Normal);
                File.SetAttributes(directoryPath, FileAttributes.Normal);
                File.SetAttributes(directoryPathNoFile, FileAttributes.Normal);

                MessageBox.Show(directoryPath);
                File.Copy(directoryPath, "configfile.xml", true);                                                                               //Copy the file the user gave and use it to overwrite the config made by the program in the root location.

                MessageBox.Show("Config import successful. Re-launch in order for changes to take effect.\n\nEnjoy,\n-The Flatline DDNS Team"); //Welcome the user.
                Application.Exit();                                                                                                             //Close app so changes can take effect.
            }
            else
            {
                MessageBox.Show("No config file has been loaded in.");
            }
        }
Esempio n. 7
0
        public void DeSerialize()
        {
            if (Directory.Exists($"{HaEConstants.pluginFolder}\\{HaEConstants.StorageFolder}"))
            {
                try
                {
                    using (var writer = new StreamReader($"{HaEConstants.pluginFolder}\\{HaEConstants.StorageFolder}\\{configurationWriter.fileName}"))
                    {
                        var x = new XmlSerializer(typeof(WriteConfig));
                        configurationWriter = (WriteConfig)x.Deserialize(writer);
                        writer.Close();
                    }
                }
                catch (FileNotFoundException e)
                {
                    //nom
                }
            }

            foreach (var command in configurationWriter.BoundCommands)
            {
                BindFromBoundCommand(command);
            }
        }
Esempio n. 8
0
 public Importer(WriteConfig writeConfig)
 {
     this.writeConfig     = writeConfig;
     cardGenerator        = new CardGenerator();
     transactionGenerator = new TransactionGenerator(writeConfig.NumberOfCardBulk * writeConfig.CardBulkSize);
 }
Esempio n. 9
0
        //When an entry is updated or created
        private void button_SaveChangesToDomain_Click(object sender, EventArgs e)
        {
            if (comboBox_ListOfDomains.Text == "(Create a new domain)") //exception handling stuff. User has to enter at least something into the fields.
            {
                if (textBox_Username.Text == "")
                {
                    MessageBox.Show("Please enter a Username.");
                    return;
                }
                if (textBox_Password.Text == "")
                {
                    MessageBox.Show("Please enter a Password.");
                    return;
                }
                if (textBox_Domain.Text == "")
                {
                    MessageBox.Show("Please enter a Domain.");
                    return;
                }
                if (textBox_EnterAName.Text == "")
                {
                    MessageBox.Show("Please enter a Name for this domain entry.");
                    return;
                }

                //Try to add a new domain into our configfile.xml.
                //Save result to bool.
                bool successfulSetting = WriteConfig.NewDomainSetting(textBox_EnterAName.Text, textBox_Username.Text, textBox_Password.Text, textBox_Domain.Text, comboBox_ListOfProviders.Text, (checkBox1.Checked ? 1 : 0).ToString());

                //If setting was written, refresh the combobox of domain settings and inform the user.
                if (successfulSetting == true)
                {
                    ComboBoxRefresh();                                         //Show the domain that was just added.
                    MessageBox.Show("Entry added and user settings updated."); //Notify user: Entry addition successful.
                    comboBox_ListOfDomains.SelectedIndex = 0;                  //Reset selection in combobox.
                }
                else //If it fails, inform the user no new domain setting was written.
                {
                    MessageBox.Show("A saved domain setting with that unique name already exists.\nPlease enter a different unique name."); //Notify user: Entry addition successful.
                }
            }
            else //Info is added to new place in generic list.
            {
                //exception handling stuff. User has to enter at least something into the fields when editing an entry.
                if (textBox_Username.Text == "")
                {
                    MessageBox.Show("Please enter a Username");
                    return;
                }
                if (textBox_Password.Text == "")
                {
                    MessageBox.Show("Please enter a Password");
                    return;
                }
                if (textBox_Domain.Text == "")
                {
                    MessageBox.Show("Please enter a Domain");
                    return;
                }
                if (textBox_EnterAName.Text == "")
                {
                    MessageBox.Show("Please enter a Name for this domain entry");
                    return;
                }

                //Write the new setting to the configfile.xml. The checkbox is converted to a 1 or 0 based on the checked state. 1 for true. 0 for false.
                WriteConfig.UpdateDomainSetting(textBox_EnterAName.Text, textBox_Username.Text, textBox_Password.Text, textBox_Domain.Text, comboBox_ListOfProviders.Text, (checkBox1.Checked ? 1 : 0).ToString());

                MessageBox.Show("Entry has been updated."); //Notify user: Entry edit successful.
            }
        }
		internal ObjectDirectoryInserter(FileObjectDatabase dest, Config cfg)
		{
			db = dest;
			config = cfg.Get(WriteConfig.KEY);
		}
Esempio n. 11
0
 public HaEConsoleCommandBinder()
 {
     configurationWriter = new WriteConfig();
     DeSerialize();
     RegisterCommands();
 }
 private void button_LaunchNewConfig_Click(object sender, EventArgs e)
 {
     WriteConfig.CreateXMLConfigFile();
     this.Close(); //Close form and continue to app.
 }