Exemple #1
0
        private void CreateAndDisplayBlank(int selectedfile)
        {
            //Create three new DataTables and DataSource objects for FileA, FileB and Merge.
            DataTable table = new DataTable();

            CreateViewColumnHeaders(table, selectedfile);

            // Create new DataRow objects and add to DataTable.
            DataRow row;

            // Create new DataRow objects and add to DataTable.
            for (int i = 0; i < 10; i++)
            {
                row = table.NewRow();
                table.Rows.Add(row);
            }

            // Create a DataView using the DataTable in gridview.
            DataView view = new DataView(table);

            // Set a DataGrid control's DataSource to the DataView.
            if (selectedfile == (int)Transform.FileA)
            {
                GrvDataFileA.DataSource = view;
                GrvDataFileA.DataBind();
            }
            else if (selectedfile == (int)Transform.FileB)
            {
                GrvDataFileB.DataSource = view;
                GrvDataFileB.DataBind();
            }
            else if (selectedfile == (int)Transform.Merge)
            {
                GrvDataMerge.DataSource = view;
                GrvDataMerge.DataBind();
            }
        }
Exemple #2
0
        private void CreateAndDisplayMerge()
        {
            //Create three new DataTables and DataSource objects for FileA, FileB and Merge.
            DataTable mergeTable = new DataTable();

            CreateViewColumnHeaders(mergeTable, (int)Transform.Merge);

            // Create new DataRow objects and add to merge DataTable.
            DataRow targetFileRow;

            foreach (GridViewRow sourceFileOneRow in GrvDataFileA.Rows)
            {
                targetFileRow = mergeTable.NewRow();

                //Get email component only from email address in FileA, exclude host component.
                //Apri search/user does not search @string

                string   csvFileEmail = Server.HtmlEncode(sourceFileOneRow.Cells[1].Text);
                string[] wordSplit    = csvFileEmail.Split('@');
                //First [0] part is email and second [1] is host.
                var searchEmail = wordSplit[0];

                var systemUID = string.Empty;
                //Use API to check email exists
                if (ExistsUser(searchEmail, ref systemUID))
                {
                    targetFileRow["user_id"] = systemUID;
                    targetFileRow["Marker"]  = "Found";
                }
                else
                {
                    targetFileRow["user_id"] = sourceFileOneRow.Cells[0].Text;
                }

                targetFileRow["email"] = sourceFileOneRow.Cells[1].Text;

                //Merge with file B
                foreach (GridViewRow sourceFileTwoRow in GrvDataFileB.Rows)
                {
                    if (sourceFileOneRow.Cells[0].Text == sourceFileTwoRow.Cells[0].Text) //UserId from A = B
                    {
                        targetFileRow["first_name"] = sourceFileTwoRow.Cells[1].Text;
                        targetFileRow["last_name"]  = sourceFileTwoRow.Cells[2].Text;
                    }
                }

                mergeTable.Rows.Add(targetFileRow);
            }

            // Create a DataView using the DataTable in gridview.
            DataView view = new DataView(mergeTable);

            // Sort by email, last name in descending order
            view.Sort = "email ASC, last_name ASC";

            // Set a DataGrid control's DataSource to the DataView.
            GrvDataMerge.DataSource = view;
            GrvDataMerge.DataBind();

            //Highlight changes made for inconsistent Uids.
            foreach (GridViewRow dataRow in GrvDataMerge.Rows)
            {
                if (dataRow.Cells[4].Text == "Found")
                {
                    dataRow.Cells[0].BackColor       = System.Drawing.Color.LightGreen;
                    dataRow.Cells[0].HorizontalAlign = HorizontalAlign.Center;
                }
                else
                {
                    dataRow.HorizontalAlign = HorizontalAlign.Left;
                }
            }
        }