コード例 #1
0
        static void MatchOnly(DataTable dt, DataTable dt1, string Company, string StartDate, string EndDate, string ProcName, OdbcConnection Conn, int TableId)

        {
            string TestResult;
            string TestName = Company + "_" + StartDate + "_" + EndDate;
            string Today    = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");
            string RowName  = "RowCount";
            double SnowTime = Convert.ToDouble(dt1.Rows[0]["SnowTime"]);
            double SqlTime  = Convert.ToDouble(dt.Rows[0]["SqlTime"]);

            if (dt.Rows.Count == dt1.Rows.Count)
            {
                TestResult = "Pass";
            }

            else
            {
                TestResult = "Fail";
            }

            Console.WriteLine(TestResult);

            string OdbcComm = "Insert into UnitTests Values('" + TestName + "','" + RowName + "','" + dt1.Rows.Count + "','" + dt.Rows.Count + "','" + TestResult + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

            OdbcCommand Ins = new OdbcCommand(OdbcComm, Conn);

            Ins.ExecuteNonQuery();



            /*  var Inner = from Snow in dt1.AsEnumerable()
             *            join
             *      Sql in dt.AsEnumerable() on
             *      Snow.Field<string>("hash") equals Sql.Field<string>("hash")
             *            select Snow; */

            /*Snowflake only datarows*/

            var OnlySnow = from Snow in dt1.AsEnumerable()
                           join
                           Sql in dt.AsEnumerable() on
                           Snow.Field <string>("hash") equals Sql.Field <string>("hash")
                           into x
                           from Sql in x.DefaultIfEmpty()
                               where Sql == null
                           select Snow;



            foreach (var Snow in OnlySnow)
            {
                List <string> lists = new List <string>();

                foreach (DataColumn col in Snow.Table.Columns)
                {
                    if (col.ColumnName.Contains("DATE"))
                    {
                        string Data = Snow[col].ToString();
                        Console.WriteLine(Data + " " + Data.GetType());
                        string[] Dates = Data.ToString().Split(new char[0]);
                        string   Date  = Dates[0];
                        Console.WriteLine(Date);
                        lists.Add(Date);
                    }
                    else
                    {
                        lists.Add(Snow[col].ToString());
                    }
                }

                string Hash = Snow["hash"].ToString();

                lists.RemoveAt(lists.Count - 1);
                var rec = string.Join("','", lists);
                Console.WriteLine(rec);
                string InsertHash = "Insert into UnitTests Values('" + TestName + "','" + "RowHash" + "','" + Hash + "','" + " " + "','" + "Fail" + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

                OdbcCommand InsertH = new OdbcCommand(InsertHash, Conn);

                InsertH.ExecuteNonQuery();


                string Insert = "Insert into " + ProcName + " Values('" + rec + "','" + Today + "','" + TestName + "')";
                Console.WriteLine(Insert);
                OdbcCommand InsertData = new OdbcCommand(Insert, Conn);

                InsertData.ExecuteNonQuery();
            }

            /*Sql only datarows*/

            var OnlySql = from Sql in dt.AsEnumerable()
                          join
                          Snow in dt1.AsEnumerable()
                          on
                          Sql.Field <string>("hash") equals Snow.Field <string>("hash")
                          into x
                          from Snow in x.DefaultIfEmpty()
                              where Snow == null
                          select Sql;


            foreach (var Sql in OnlySql)
            {
                List <string> lists = new List <string>();


                foreach (DataColumn col in Sql.Table.Columns)
                {
                    if (col.ColumnName.Contains("Date") || col.ColumnName.Contains("DATE"))
                    {
                        string Data = Sql[col].ToString();
                        Console.WriteLine(Data + " " + Data.GetType());
                        string[] Dates = Data.ToString().Split(new char[0]);
                        string   Date  = Dates[0];


                        lists.Add(Date);
                    }

                    else
                    {
                        lists.Add(Sql[col].ToString());
                    }
                }
                string Hash = Sql["hash"].ToString();
                lists.RemoveAt(lists.Count - 1);
                var rec = string.Join("','", lists);
                Console.WriteLine(rec);
                string InsertHash = "Insert into UnitTests Values('" + TestName + "','" + "RowHash" + "','" + " " + "','" + Hash + "','" + "Fail" + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

                OdbcCommand InsertH = new OdbcCommand(InsertHash, Conn);

                InsertH.ExecuteNonQuery();

                string Insert = "Insert into " + ProcName + " Values('" + rec + "','" + Today + "','" + TestName + "')";

                OdbcCommand InsertData = new OdbcCommand(Insert, Conn);

                InsertData.ExecuteNonQuery();
            }
        }
コード例 #2
0
        static void MatchOnly(DataTable dt, DataTable dt1, string Company, string StartDate, string EndDate, string ProcName, OdbcConnection Conn, int TableId, double sfexec)

        {
            string TestResult;
            string TestName = Company + "_" + StartDate + "_" + EndDate;
            string Today    = DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss");
            string RowName  = "RowCount";
            double SnowTime = sfexec;
            double SqlTime  = Convert.ToDouble(dt.Rows[0]["SqlTime"]);

            if (dt.Rows.Count == dt1.Rows.Count)
            {
                TestResult = "Pass";
            }

            else
            {
                TestResult = "Fail";
            }

            Console.WriteLine(TestResult);

            string OdbcComm = "Insert into UnitTests Values('" + TestName + "','" + RowName + "','" + dt1.Rows.Count + "','" + dt.Rows.Count + "','" + TestResult + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

            OdbcCommand Ins = new OdbcCommand(OdbcComm, Conn);

            Ins.ExecuteNonQuery();



            /*  var Inner = from Snow in dt1.AsEnumerable()
             *            join
             *      Sql in dt.AsEnumerable() on
             *      Snow.Field<string>("hash") equals Sql.Field<string>("hash")
             *            select Snow; */

            /*Snowflake only datarows*/

            var OnlySnow = from Snow in dt1.AsEnumerable()
                           join
                           Sql in dt.AsEnumerable() on
                           Snow.Field <string>("hash") equals Sql.Field <string>("hash")
                           into x
                           from Sql in x.DefaultIfEmpty()
                               where Sql == null
                           select Snow;

            foreach (var Snow in OnlySnow)
            {
                string Hash = Snow["hash"].ToString();
                var    rec  = string.Join("','", Snow.ItemArray.ToArray());
                Console.WriteLine(Hash);

                string InsertHash = "Insert into UnitTests Values('" + TestName + "','" + "RowHash" + "','" + Hash + "','" + " " + "','" + "Fail" + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

                OdbcCommand InsertH = new OdbcCommand(InsertHash, Conn);

                InsertH.ExecuteNonQuery();


                string Insert = "Insert into " + ProcName + " Values('" + rec + "','" + Today + "','" + TestName + "')";

                OdbcCommand InsertData = new OdbcCommand(Insert, Conn);

                InsertData.ExecuteNonQuery();
            }

            /*Sql only datarows*/

            var OnlySql = from Sql in dt.AsEnumerable()
                          join
                          Snow in dt1.AsEnumerable()
                          on
                          Sql.Field <string>("hash") equals Snow.Field <string>("hash")
                          into x
                          from Snow in x.DefaultIfEmpty()
                              where Snow == null
                          select Sql;


            foreach (var Sql in OnlySql)
            {
                /*  foreach (DataColumn col in Sql.Table.Columns)
                 * {
                 *    Console.WriteLine(col.ColumnName + " " + Sql[col].GetType());
                 * } */

                string Hash = Sql["hash"].ToString();
                var    rec  = string.Join("','", Sql.ItemArray.ToArray());
                Console.WriteLine(Hash);

                string InsertHash = "Insert into UnitTests Values('" + TestName + "','" + "RowHash" + "','" + " " + "','" + Hash + "','" + "Fail" + "','" + Today + "','" + ProcName + "','" + TableId + "','" + SnowTime + "','" + SqlTime + "')";

                OdbcCommand InsertH = new OdbcCommand(InsertHash, Conn);

                InsertH.ExecuteNonQuery();

                string Insert = "Insert into " + ProcName + " Values('" + rec + "','" + Today + "','" + TestName + "')";

                OdbcCommand InsertData = new OdbcCommand(Insert, Conn);

                InsertData.ExecuteNonQuery();
            }
        }