Пример #1
0
        private void Save_Click(object sender, EventArgs e)
        {
            string path = @"E:\test_data_generator\ApiLoadTest\SaveData.xml";

            SaveData data = new SaveData();

            data.Path       = textBox6.Text;
            data.HeaderList = textBox5.Text;

            Headers newHeader  = new Headers();
            Request newRequest = new Request();

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null && row.Cells[2].Value != null)
                {
                    data.RequestList.Add(newRequest);
                    newRequest            = new Request();
                    newHeader             = new Headers();
                    newRequest.Url        = (string)row.Cells[0].Value;
                    newRequest.MethodType = (string)row.Cells[1].Value;
                    newRequest.Payload    = (string)row.Cells[2].Value;

                    newHeader.Name  = (string)row.Cells[3].Value;
                    newHeader.Value = (string)row.Cells[4].Value;
                }
                else
                {
                    newHeader       = new Headers();
                    newHeader.Name  = (string)row.Cells[3].Value;
                    newHeader.Value = (string)row.Cells[4].Value;
                }

                newRequest.Headers.Add(newHeader);
            }

            data.RequestList.Add(newRequest);

            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                if (row.Cells[0].Value != null && row.Cells[1].Value != null)
                {
                    Headers commonHeader = new Headers();
                    commonHeader.Name  = (string)row.Cells[0].Value;
                    commonHeader.Value = (string)row.Cells[1].Value;
                    data.CommonHeaders.Add(commonHeader);
                }
            }

            SaveXML.Savedata(data, path);
            //writing new values to XML

            MessageBox.Show("Successfully added ", "Success");
            //this.Close();
            dataGridView1.Rows.Clear();
            dataGridView2.Rows.Clear();
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string    path = @"E:\test_data_generator\ApiLoadTest\SaveData.xml";
            DataSet   ds   = new DataSet();
            DataTable dt   = new DataTable();



            SaveData test = new SaveData();

            test.Path       = textBox6.Text;
            test.HeaderList = textBox5.Text;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                Headers newHeader  = new Headers();
                Request newRequest = new Request();

                newRequest.Url        = (string)row.Cells[0].Value;
                newRequest.MethodType = (string)row.Cells[1].Value;
                newRequest.Payload    = (string)row.Cells[2].Value;

                newHeader.Name  = (string)row.Cells[3].Value;
                newHeader.Value = (string)row.Cells[4].Value;

                newRequest.Headers.Add(newHeader);

                test.RequestList.Add(newRequest);
            }



            foreach (DataGridViewRow row in dataGridView2.Rows)
            {
                Headers commonHeader = new Headers();
                commonHeader.Name  = (string)row.Cells[0].Value;
                commonHeader.Value = (string)row.Cells[1].Value;
                test.CommonHeaders.Add(commonHeader);
            }

            SaveXML.Savedata(test, path);
            //writing new values to XML

            MessageBox.Show("Successfully added ", "Success");
            //this.Close();
        }