Exemple #1
0
        private void btnWriteSync_Click(object sender, EventArgs e)
        {
           if (!double.IsNaN(double.Parse(txtNrThreads.Text.Trim())))
            {
                int total = Int32.Parse(txtNrThreads.Text.Trim());

                lblProcessing.Text = "Processing...";

                FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);

                TimeSpan inicio = new TimeSpan(DateTime.Now.Ticks);
                txtResult.Text += "==== Sync Output ==== Message size: " + cmbMessageSize.Text + " ==== # Threads: " + txtNrThreads.Text + "  \r\n";
                txtResult.Text += "Inicio: " + inicio.ToString() + "\r\n";


                string message = GetMessage();
                for (int i = 0; i < total; i++)
                {
                    f.Write(message, "Arquivo_" + i.ToString());
                }


                TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);

                txtResult.Text += "Fim: " + fim.ToString() + "\r\n";
                txtResult.Text += "Total: " + (fim - inicio).ToString() + "\r\n";

                lblProcessing.Text = "Completed.";

            }
        }
        /// <summary>
        /// Gets key value pair of setting name and value from app.config
        /// </summary>
        /// <returns>Dictionary of settings, key is name of the setting and value is value</returns>
        private static Dictionary <string, object> GetKeyValuesForConfig()
        {
            Dictionary <string, object> returnTemp = new Dictionary <string, object>();
            List <string> temp = new FileHandler.FileHandler().ReadData(APP_CONFIG_PATH);

            for (int i = 0; i < temp.Count; i++)
            {
                try
                {
                    if (temp[i].Trim() == "" || temp[i].Trim().Substring(0, 1) == "#" || temp[i].Trim().Substring(0, 2) == "\\")
                    {
                        continue;
                    }

                    string[] arrSplitter = temp[i].Split('=');

                    string key   = arrSplitter[0].Trim();
                    string value = arrSplitter[1].Trim();

                    returnTemp.Add(key, value);
                }
                catch (Exception)
                { continue; }
            }

            return(returnTemp);
        }
Exemple #3
0
        private async void btnOpen_Click(object sender, EventArgs e)
        {
            label1.Text = "Processing...";
            txtResult.Clear();
            if (txtId.Text.Trim() != String.Empty)
            {
                StringBuilder s = new StringBuilder();
                FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
                TimeSpan inicio = new TimeSpan(DateTime.Now.Ticks);
                string fileContent = await f.OpenFileAsync(txtId.Text.Trim());
                if (fileContent != String.Empty)
                {

                    TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);
                    s.Append("=================================\r\n");
                    s.Append("FILE OPENED...\r\n");
                    s.Append("=================================\r\n");
                    s.Append("Inicio: " + inicio.ToString() + "\r\n");
                    s.Append("=================================\r\n");
                    s.Append("Fim: " + fim.ToString() + "\r\n");
                    s.Append("=================================\r\n");
                    s.Append("Tempo Total: " + (fim - inicio).ToString() + "\r\n");
                    s.Append("=================================\r\n");
                    s.Append(fileContent);
                    txtResult.Text = s.ToString();
                }
            }

            label1.Text = "Completed...";
        }
Exemple #4
0
        private async void btnListQueue_Click(object sender, EventArgs e)
        {
            label1.Text = "Processing...";
            txtResult.Text = "";
            FileHandler.FileHandler fh = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
            StringBuilder s = new StringBuilder();

            TimeSpan inicio = new TimeSpan(DateTime.Now.Ticks);
            List<Tuple<string, string>> files = await fh.ListFileAsync();
            if (files.Count() > 0)
            {
                TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);
                s.Append("=================================\r\n");
                s.Append("LISTING...\r\n");
                s.Append("=================================\r\n");
                s.Append("Inicio: " + inicio.ToString() + "\r\n");
                s.Append("=================================\r\n");
                s.Append("Fim: " + fim.ToString() + "\r\n");
                s.Append("=================================\r\n");
                s.Append("Tempo Total: " + (fim - inicio).ToString() + "\r\n");
                s.Append("=================================\r\n");
                s.Append("Total Msg: " + files.Count() + "\r\n");
                s.Append("=================================\r\n");

                foreach (Tuple<string, string> t in files)
                {
                    s.Append(t.Item1 + " - at " + t.Item2 + "\r\n");
                }
                txtResult.Text = s.ToString();
            }
            label1.Text = "Completed...";
        }
        private void OnMessageArrived(Tuple<string, string, TimeSpan> tMessage)
        {

            FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
            f.WriteTask(tMessage.Item2, tMessage.Item1 + "_" + DateTime.Now.Ticks.ToString());

            //Tuple<string, string> tMessage = ActiveMQReader.ReadMessage(message.Item1, _activeMQListener.Consumer);
            //Tuple<string, string> tMessage = r.ReadMessage(messageID.Item1);

        }
Exemple #6
0
        private async void btnWriteTask_Click(object sender, EventArgs e)
        {
            if (!double.IsNaN(double.Parse(txtNrThreads.Text.Trim())))
            {
                int total = Int32.Parse(txtNrThreads.Text.Trim());

                lblProcessing.Text = "Processing...";


                string message = GetMessage();
                Task[] taskList = new Task[total];

                List<Tuple<string, string>> messageList = new List<Tuple<string, string>>();
                for (int i = 0; i < total; i++)
                {
                    Tuple<string, string> tm = Tuple.Create("Arquivo_" + i.ToString(), message);
                    messageList.Add(tm);
                }
                TimeSpan inicio = new TimeSpan(DateTime.Now.Ticks);
                FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
                await f.WriteListAsync(messageList);
                TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);


                txtResult.Text += "==== Async Output ==== Message size: " + cmbMessageSize.Text + " ==== # Threads: " + txtNrThreads.Text + "  \r\n";
                txtResult.Text += "Inicio: " + inicio.ToString() + "\r\n";

                //for (int i = 0; i < total; i++)
                //{
                //    taskList[i] = f.WriteAsync(message, "Arquivo_" + i.ToString());
                //}
                //await Task.WhenAll(taskList);
                //TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);

                txtResult.Text += "Fim: " + fim.ToString() + "\r\n";
                txtResult.Text += "Total: " + (fim - inicio).ToString() + "\r\n";

                lblProcessing.Text = "Completed.";
            }


        }
Exemple #7
0
        private async void btnDeleteAll_Click(object sender, EventArgs e)
        {
            label1.Text = "Processing...";
            StringBuilder s = new StringBuilder();
            FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
            TimeSpan inicio = new TimeSpan(DateTime.Now.Ticks);
            await f.DeleteAllAsync();
            TimeSpan fim = new TimeSpan(DateTime.Now.Ticks);
            s.Append("=================================\r\n");
            s.Append("ALL DELETED...\r\n");
            s.Append("=================================\r\n");
            s.Append("Inicio: " + inicio.ToString() + "\r\n");
            s.Append("=================================\r\n");
            s.Append("Fim: " + fim.ToString() + "\r\n");
            s.Append("=================================\r\n");
            s.Append("Tempo Total: " + (fim - inicio).ToString() + "\r\n");
            s.Append("=================================\r\n");
            txtResult.Text = s.ToString();


            label1.Text = "Completed...";
        }
Exemple #8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            FileHandler.FileHandler f = new FileHandler.FileHandler(System.Configuration.ConfigurationManager.AppSettings["FilesDir"]);
            f.DeleteAllAsync();


            txtResult.Clear();
        }