/// <summary>
        /// Button event. Creates all the inputs from the excel data
        /// from each selected column and extract data based on the selected actions
        /// then displays the 'Generate form'
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ExecuteBtn_Click(object sender, EventArgs e)
        {
            ColumnIndexes.Clear();

            if (relevantLb.Items.Count == 0)
            {
                MessageBox.Show("You haven't selected any columns that are relevant", "Error");
                return;
            }

            // Adds all the columns selected into a list
            for (int i = 0; i < relevantLb.Items.Count; i++)
            {
                ColumnIndexes.Add(GetColumnIndex(relevantLb.Items[i].ToString()));
            }

            // Objects
            TextAnalyticClient textAnalysisClient = new TextAnalyticClient();

            // Lists
            List <MultiLanguageInput> MultiInput = new List <MultiLanguageInput>();
            List <Input> Inputs = new List <Input>();

            // Variables
            int count = 0;

            // Loop through all rows in the selected columns and extract data into a 'Input'
            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                for (int i = 0; i < ColumnIndexes.Count; i++)
                {
                    if (row.Cells[ColumnIndexes[i]].Value != null)
                    {
                        count++;
                        Input Input = new Input
                        {
                            Id   = Convert.ToString(count),
                            Text = Convert.ToString(row.Cells[ColumnIndexes[i]].Value)
                        };
                        Inputs.Add(Input);
                    }
                }
            }

            // Converts from Input to MultiInput
            for (int i = 0; i < Inputs.Count; i++)
            {
                MultiLanguageInput Input = new MultiLanguageInput
                {
                    Language = "En",
                    Id       = Inputs[i].Id,
                    Text     = Inputs[i].Text
                };
                MultiInput.Add(Input);
            }

            Generate GenerateFrm = new Generate(SelectedActions, Inputs, MultiInput);

            GenerateFrm.ShowDialog();
        }
Пример #2
0
        /// <summary>
        /// Main method. Creates objects, assigns to global objects and lists
        /// Creates a background thread
        /// </summary>
        /// <param name="SelectedActions"></param>
        /// <param name="Inputs"></param>
        /// <param name="MultiInput"></param>
        public Generate(List <string> SelectedActions, List <Input> Inputs, List <MultiLanguageInput> MultiInput)
        {
            this.InitializeComponent();
            this.textAnalyticClient = new TextAnalyticClient();
            this.SelectedActions    = SelectedActions;
            this.Inputs             = Inputs;
            this.MultiInput         = MultiInput;

            worker                     = new BackgroundWorker();
            worker.DoWork             += Worker_DoWork;
            worker.RunWorkerCompleted += Worker_RunWorkerCompleted;
            worker.RunWorkerAsync();
        }
Пример #3
0
        /// <summary>
        /// Menu item on click. Test the Text Analstic
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TextAnalyticClient textAnalysisClient = new TextAnalyticClient();

            textAnalysisClient.Test();
        }