示例#1
0
        private static void TestForAllInOneInterface(object obj)
        {
            string     extSql = (string)obj;
            MySqlDrive mySql  = new MySqlDrive("Server=192.168.200.152;UserId=root;Password=xpsh;Database=huala_goods");

            //MySqlDrive mySql = new MySqlDrive("Server=192.168.200.24;UserId=qa;Password=123456;Database=xinyunlian_member");
            mySql.OnDriveStateChange += mySql_OnDriveStateChange;
            mySql.OnGetErrorMessage  += mySql_OnGetErrorMessage;
            mySql.OnGetInfoMessage   += mySql_OnGetInfoMessage;

            //DataTable myTable = mySql.ExecuteQuery("select store_name , SUID,UUID from store limit 100 , 50");
            DataTable myTable = mySql.ExecuteQuery(extSql);

            if (myTable != null)
            {
                foreach (DataRow rows in myTable.Rows)
                {
                    bool isDataOk = true;
                    foreach (var filed in rows.ItemArray)
                    {
                        if (filed == null)
                        {
                            isDataOk = false;
                            break;
                        }
                    }
                    if (!isDataOk)
                    {
                        Console.WriteLine("find Error data");
                        break;
                    }
                    int ThreadId = Thread.CurrentThread.ManagedThreadId;
                    Console.WriteLine(String.Format("【ThreadId:{1}】{0} :开始同步.......", rows[0].ToString(), ThreadId));
                    //string tempRespans = MyCommonHelper.NetHelper.MyWebTool.MyHttp.SendData(String.Format("https://wxv4.huala.com/huala/seller/login/AllInOneNative?suid={0}&uuid={1}", rows[1].ToString(), rows[2].ToString()));
                    string tempRespans = myHttp.SendData(String.Format("https://wxwyjtest.huala.com/huala/seller/login/AllInOneNative?suid={0}&uuid={1}", rows[1].ToString(), rows[2].ToString()));
                    if (tempRespans.Contains("\"success\":true"))
                    {
                        Console.WriteLine("同步完成");
                    }
                    else
                    {
                        Console.WriteLine("同步错误");
                    }
                    System.Diagnostics.Debug.WriteLine("--------------------------------------------------------------------------------");
                    System.Diagnostics.Debug.WriteLine(String.Format("https://wxwyjtest.huala.com/huala/seller/login/AllInOneNative?suid={0}&uuid={1}", rows[1].ToString(), rows[2].ToString()));
                    System.Diagnostics.Debug.WriteLine(tempRespans);
                }
            }
            else
            {
                Console.WriteLine(mySql.NowError);
            }


            mySql.OnDriveStateChange -= mySql_OnDriveStateChange;
            mySql.OnGetErrorMessage  -= mySql_OnGetErrorMessage;
            mySql.OnGetInfoMessage   -= mySql_OnGetInfoMessage;
            mySql.Dispose();
        }
示例#2
0
        public void RunTest()
        {
            Console.WriteLine("ConnectDataBase");
            Console.WriteLine(mySql.ConnectDataBase().ToString());
            DataTable myTable = mySql.ExecuteQuery("select * from h_order limit 10");

            //foreach(DataColumn column in table.Columns)
            foreach (DataRow rows in myTable.Rows)
            {
                Console.WriteLine("");
                foreach (var filed in rows.ItemArray)
                {
                    Console.Write(filed.ToString());
                }
            }

            Console.WriteLine("__________________________________________________");
            myTable = mySql.ExecuteQuery("select * from h_order where seller_id=?id and order_amount>?amt limit 10", new Dictionary <string, string> {
                { "?id", "562" }, { "?amt", "100" }
            });
            //foreach(DataColumn column in table.Columns)
            foreach (DataRow rows in myTable.Rows)
            {
                Console.WriteLine("");
                foreach (var filed in rows.ItemArray)
                {
                    Console.Write(filed.ToString());
                }
            }

            Console.WriteLine("++++++++++++++++++++++++++select null data++++++++++++++++++++++++++++");
            myTable = mySql.ExecuteQuery("select * from h_order where seller_id=?id and order_amount>?amt limit 10", new Dictionary <string, string> {
                { "?id", "56200000" }, { "?amt", "100" }
            });
            //foreach(DataColumn column in table.Columns)
            foreach (DataRow rows in myTable.Rows)
            {
                Console.WriteLine("");
                foreach (var filed in rows.ItemArray)
                {
                    Console.Write(filed.ToString());
                }
            }

            Console.WriteLine("++++++++++++++++++++++++++updata data++++++++++++++++++++++++++++");
            myTable = mySql.ExecuteQuery("update  h_order set order_status = 'no_pay' where order_sn = 170724185537912003");
            //foreach(DataColumn column in table.Columns)
            foreach (DataRow rows in myTable.Rows)
            {
                Console.WriteLine("");
                foreach (var filed in rows.ItemArray)
                {
                    Console.Write(filed.ToString());
                }
            }

            Console.WriteLine("__________________________________________________");
            Console.WriteLine("__________________________________________________");
            Console.WriteLine("__________________________________________________");
            mySql.CreateNewAliveTask("TestIn", string.Format("select * from h_order  where mobile ='{0}' and order_status='no_pay' order by add_time desc", "15158155511"), 2000, new delegateGetAliveTaskDataTableInfoEventHandler((obj, table) => {
                foreach (DataRow rows in table.Rows)
                {
                    Console.WriteLine("");
                    foreach (var filed in rows.ItemArray)
                    {
                        Console.Write(filed.ToString());
                    }
                }
            }));

            Console.WriteLine("__________________________________________________");
            Console.WriteLine("__________________________________________________");
            Console.WriteLine("__________________________________________________");
            mySql.CreateNewMonitorTask("m1", "select* from h_sso_log order by id desc limit 20 ", 1, 2, 4000, new delegateGetMonitorTaskDataTableInfoEventHandler((sender, str) => {
                Console.WriteLine("+++++++++++++++++++++++++++++++++++++++");
                Console.WriteLine(str);
            }));



            //mySql.DelAliveTask("TestIn");
            //GC.Collect();
            //return;
            mySql.StartAliveTask("TestIn");
            mySql.StartMonitorTask("m1");
        }
示例#3
0
        public MyExecutionDeviceResult ExecutionDeviceRun(ICaseExecutionContent yourExecutionContent, CaseActionActuator.delegateGetExecutiveData yourExecutiveDelegate, string sender, ActuatorStaticDataCollection yourActuatorStaticDataCollection, int caseId)
        {
            List <string>           errorList = new List <string>();
            string                  tempError = null;
            MyExecutionDeviceResult myResult  = new MyExecutionDeviceResult();

            myResult.staticDataResultCollection = new System.Collections.Specialized.NameValueCollection();

            //向UI推送执行过程信息
            Action <string, CaseActuatorOutPutType, string> ExecutiveDelegate = (innerSender, outType, yourContent) =>
            {
                if (yourExecutiveDelegate != null)
                {
                    yourExecutiveDelegate(innerSender, outType, yourContent);
                }
            };

            //处理执行错误(执行器无法执行的错误)
            Action <string> DealExecutiveError = (errerData) =>
            {
                if (errerData != null)
                {
                    ExecutiveDelegate(sender, CaseActuatorOutPutType.ExecutiveError, errerData);
                    errorList.Add(errerData);
                }
            };

            if (yourExecutionContent.MyCaseProtocol == CaseProtocol.mysql)
            {
                //在调用该函数前保证nowExecutionContent.ErrorMessage为空,且as一定成功
                MyMySqlExecutionContent nowExecutionContent = yourExecutionContent as MyMySqlExecutionContent;
                myResult.caseProtocol = CaseProtocol.mysql;
                myResult.caseTarget   = nowExecutionContent.MyExecutionTarget;
                myResult.startTime    = DateTime.Now.ToString("HH:mm:ss");
                StringBuilder tempCaseOutContent = new StringBuilder();

                System.Diagnostics.Stopwatch myWatch = new System.Diagnostics.Stopwatch();
                myWatch.Start();

                ExecutiveDelegate(sender, CaseActuatorOutPutType.ExecutiveInfo, string.Format("【ID:{0}】[mysql]Executive···", caseId));

                string nowSqlCmd = nowExecutionContent.sqlContent.GetTargetContentData(yourActuatorStaticDataCollection, myResult.staticDataResultCollection, out tempError);
                if (tempError != null)
                {
                    DealExecutiveError(string.Format("this case get static data errer with [{0}]", nowExecutionContent.sqlContent.GetTargetContentData()));
                    tempCaseOutContent.AppendLine("error with static data");
                }
                else
                {
                    if (nowExecutionContent.isPosition)
                    {
                        string sqlResult = mySqlDrive.ExecuteQuery(nowSqlCmd, nowExecutionContent.rowIndex, nowExecutionContent.columnIndex);
                        if (sqlResult == null)
                        {
                            tempCaseOutContent.AppendLine(string.Format("error in [ExecuteQuery] :{0}", mySqlDrive.NowError));
                            DealExecutiveError(mySqlDrive.NowError);
                        }
                        else
                        {
                            tempCaseOutContent.AppendLine(sqlResult);
                            ExecutiveDelegate(sender, CaseActuatorOutPutType.ExecutiveInfo, sqlResult);
                        }
                    }
                    else
                    {
                        System.Data.DataTable sqlResult = mySqlDrive.ExecuteQuery(nowSqlCmd);
                        if (sqlResult == null)
                        {
                            tempCaseOutContent.AppendLine(string.Format("error in [ExecuteQuery] :{0}", mySqlDrive.NowError));
                            DealExecutiveError(mySqlDrive.NowError);
                        }
                        else
                        {
                            string json = Newtonsoft.Json.JsonConvert.SerializeObject(sqlResult, Newtonsoft.Json.Formatting.Indented);
                            ExecutiveDelegate(sender, CaseActuatorOutPutType.ExecutiveInfo, json);
                            tempCaseOutContent.AppendLine(json);
                        }
                    }
                }

                myWatch.Stop();
                myResult.spanTime = myResult.requestTime = myWatch.ElapsedMilliseconds.ToString();

                myResult.backContent = tempCaseOutContent.ToString();
            }
            else
            {
                myResult.backContent = "error:your CaseProtocol is not Matching RunTimeActuator";
                DealExecutiveError(myResult.backContent);
            }


            if (errorList.Count > 0)
            {
                myResult.additionalError = errorList.MyToString("\r\n");
            }

            return(myResult);
        }