Beispiel #1
0
        public static void GetMyPrediction()
        {
            var    pipeline = new LearningPipeline();
            string dataPath = AppDomain.CurrentDomain.BaseDirectory + "/datamodel/myMLData.txt";

            pipeline.Add(new TextLoader(dataPath).CreateFrom <myData>(separator: ' '));
            pipeline.Add(new Dictionarizer("Label"));
            pipeline.Add(new ColumnConcatenator("Features", "XCoord", "YCoord", "ZCoord"));
            pipeline.Add(new LogisticRegressionBinaryClassifier());
            pipeline.Add(new PredictedLabelColumnOriginalValueConverter()
            {
                PredictedLabelColumn = "PredictedLabel"
            });
            Console.WriteLine("\nStarting training\n");
            var    model     = pipeline.Train <myData, myPrediction>();
            var    testData  = new TextLoader(dataPath).CreateFrom <myData>(separator: ' ');
            var    evaluator = new BinaryClassificationEvaluator();
            var    metrics   = evaluator.Evaluate(model, testData);
            double acc       = metrics.Accuracy * 100;

            Console.WriteLine("Model accuracy = " + acc.ToString("F2") + "%");
            myData newPoint = new myData()
            {
                x = 9,
                y = 8,
                z = 10
            };
            myPrediction prediction = model.Predict(newPoint);
            string       result     = prediction.PredictedLabels;

            Console.WriteLine("Prediction = " + result);
            Console.WriteLine("\nEnd ML.NET demo");
            Console.ReadLine();
        }
Beispiel #2
0
        private void initParam()
        {
            pntList           = new List <myData>();
            pntInfo           = new myData();
            pntInfo.PlaceName = "温哥华";
            pntInfo.X         = -122.995850187958;
            pntInfo.Y         = 49.31925247766244;
            pntList.Add(pntInfo);

            pntInfo           = new myData();
            pntInfo.PlaceName = "华盛顿";
            pntInfo.X         = -76.96333753185513;
            pntInfo.Y         = 38.94447278589375;
            pntList.Add(pntInfo);

            pntInfo           = new myData();
            pntInfo.PlaceName = "巴西利亚";
            pntInfo.X         = -47.93359120189035;
            pntInfo.Y         = -15.786919655279648;
            pntList.Add(pntInfo);

            pntInfo           = new myData();
            pntInfo.PlaceName = "巴马科";
            pntInfo.X         = -8.007674098072965;
            pntInfo.Y         = 12.672907851195195;
            pntList.Add(pntInfo);

            pntInfo           = new myData();
            pntInfo.PlaceName = "莫斯科";
            pntInfo.X         = 37.695301337318895;
            pntInfo.Y         = 55.79601312718498;
            pntList.Add(pntInfo);
        }
Beispiel #3
0
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         dialog = GameObject.Find("tipBack");
         text   = dialog.GetComponentInChildren <Text>();
         if (this.gameObject.name == "point1")
         {
         }
         else if (this.gameObject.name == "point0")
         {
             attribute playAttri = collision.gameObject.GetComponent <createAttri>().xia;
             saveData.saveGame(new myData(playAttri, SceneManager.GetActiveScene().buildIndex + 1, "point1", 0f, SceneManager.GetActiveScene().buildIndex + 1), myData.user);
             SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
         }
         else
         {
             Vector2 ve = new Vector2(transform.position.x, transform.position.y + 1.1f);
             dialog.GetComponent <RectTransform>().position = Camera.main.WorldToScreenPoint(ve);
             text.text = "按E保存";
             if (Input.GetKeyDown(KeyCode.E))
             {
                 attribute playAttri = collision.gameObject.GetComponent <createAttri>().xia;
                 float     t         = GameObject.Find("timeText").GetComponent <timeCount>().t;
                 myData    mydata    = new myData(playAttri, SceneManager.GetActiveScene().buildIndex + 1, this.gameObject.name, t, SceneManager.GetActiveScene().buildIndex + 1);
                 saveData.saveGame(mydata, myData.user);
             }
         }
     }
 }
 public serverQueue()
 {
     waitTime      = new double[999];
     departureTime = new double[999];
     Data          = new myData();
     arrivalTime   = Data.arrivalTime;
     serviceTime   = Data.serviceTime;
 }
Beispiel #5
0
    public void readMyData()
    {
        string myReadText = File.ReadAllText(Application.dataPath + "/TestJson.json");
        myData myTest2    = JsonUtility.FromJson <myData>(myReadText);

        Debug.Log("hp : " + myTest2.hp);
        Debug.Log("mp : " + myTest2.mp);
    }
Beispiel #6
0
 public void AddDataPoint_ComX(myData data)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <myData>(this.AddDataPoint_ComX), new object[] { data });
     }
     else
     {
         veri_roll.Series["ComX"].Points.AddXY(data.t, data.y_comX);
     }
 }
Beispiel #7
0
 public void AddDataPoint_KalmanY(myData data)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <myData>(this.AddDataPoint_KalmanY), new object[] { data });
     }
     else
     {
         veri_pitch.Series["KalmanY"].Points.AddXY(data.t, data.y_kalmanY);
     }
 }
Beispiel #8
0
 public void AddDataPoint_lowPassZ(myData data)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <myData>(this.AddDataPoint_lowPassZ), new object[] { data });
     }
     else
     {
         yaw_grafik.Series["LowPassZ"].Points.AddXY(data.t, data.y_LowPassZ);
     }
 }
Beispiel #9
0
 public void AddDataPoint_Um7Yaw(myData data)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <myData>(this.AddDataPoint_Um7Yaw), new object[] { data });
     }
     else
     {
         um7_grafik.Series["Yaw"].Points.AddXY(data.t, data.um7_yaw);
     }
 }
Beispiel #10
0
 protected void Grd_RowDatabound(Object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         HyperLink lnkNavigate = (HyperLink)e.Row.FindControl("lnkNavigate");
         if (lnkNavigate != null)
         {
             myData obj = (myData)e.Row.DataItem;
             lnkNavigate.NavigateUrl = pageRequested + ".aspx?ProductCode=" + obj.Code;
         }
     }
 }
Beispiel #11
0
    public static bool saveGame(myData mydate, int index)
    {
        if (mydate == null)
        {
            return(false);
        }
        string directoryName = Application.persistentDataPath + "/Save";
        string filename      = "/GameData" + index + ".sav";

        Debug.Log(Application.persistentDataPath);
        controlData.SetData(directoryName, filename, mydate);
        Debug.Log("保存成功");
        return(true);
    }
Beispiel #12
0
        public IActionResult Post([FromBody] myData value)
        {
            var validationResult = value.Validate();

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }
            _memCache.Add(value);
            Log.Information("Adding information about serials");
            Log.Warning("Some warning");
            Log.Error("Here comes an error");
            Log.Information($"This information about serials have been added: {value}");
            return(Ok($"{value.ToString()} has been added"));
        }
Beispiel #13
0
        private Manager()
        {
            _list = new ObservableCollection <myData>();
            myData member1 = new myData();

            member1.Text = "Member 1";

            myData member2 = new myData();

            member2.Text = "Member 2";

            _list.Add(member1);
            _list.Add(member2);

            _currentData = _list[0];
        }
Beispiel #14
0
    public static myData newDate()
    {
        myData       mydate;
        attribute    player;
        attriControl attriCon = new attriControl();
        attriBuild   attriBu  = new xiaAttri();

        player = attriCon.construct(attriBu);
        int    sceneNum = 2;
        string point    = "point1";
        float  myTime   = 0;
        int    pNum     = 1;

        mydate = new myData(player, sceneNum, point, myTime, pNum);
        return(mydate);
    }
Beispiel #15
0
        public IActionResult Put(Guid id, [FromBody] myData value)
        {
            if (!_memCache.Has(id))
            {
                return(NotFound("No such"));
            }

            var validationResult = value.Validate();

            if (!validationResult.IsValid)
            {
                return(BadRequest(validationResult.Errors));
            }

            var previousValue = _memCache[id];

            _memCache[id] = value;

            return(Ok($"{previousValue.ToString()} has been updated to {value.ToString()}"));
        }
Beispiel #16
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            player = GameObject.Find("xia").GetComponent <createAttri>().xia;
            myData mydate = new myData(player, 1, "point1", Time.time, 1);

            Debug.Log(Application.persistentDataPath);
            //定义存档路径
            string dirpath = Application.persistentDataPath + "/Save";
            //创建存档文件夹
            controlData.CreateDirectory(dirpath);
            //定义存档文件路径
            string filename = "/GameData1.sav";
            //保存数据
            controlData.SetData(dirpath, filename, mydate);
            //读取数据
            myData t1 = (myData)controlData.GetData(filename, typeof(myData));
        }
    }
Beispiel #17
0
        static void Main(string[] args)
        {
            myData         data   = new myData();
            Treap <string> Treap1 = new Treap <string>();
            Treap <string> Treap2 = new Treap <string>();


            for (int i = 0; i < 20; i++)
            {
                if (i < 13)
                {
                    Treap1.Add(data.words[i]);
                }
                if (i > 10)
                {
                    Treap2.Add(data.words[i]);
                }
            }

            Treap1.Print();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Treap2.Print();

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            Treap <string> Treap12 = Treap1.Union(Treap1, Treap2);

            Treap12.Print();


            System.Console.ReadLine();
        }
Beispiel #18
0
        /// <summary>
        /// 处理导入的数据
        /// </summary>
        private bool DealDataImported(string fileName, out string msg)
        {
            System.Diagnostics.Debug.WriteLine("[HandlerImport]DealDataImported begin...");
            BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported begin...");
            bool success = true;

            msg = "";
            int sucYesCount = 0; //回访结果:是
            int sucNoCount  = 0; //回访结果:否
            int FailCount   = 0; //回写失败

            List <ExcelData> excelDataList = new List <ExcelData>();

            //(1)连接EXCEL文件
            string ext     = Path.GetExtension(fileName);
            string connStr = string.Empty;

            if (ext.ToLower() == ".xls")
            {
                connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @fileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            }
            else
            {
                //throw new Exception("上传文件应为xls或者xlsx格式的文件");
                throw new Exception("上传文件应为xls格式的文件");
            }

            using (OleDbConnection conn = new OleDbConnection(connStr))
            {
                conn.Open();

                //返回Excel的架构,包括各个sheet表的名称,类型,创建时间和修改时间等
                DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
                //包含excel中表名的字符串数组
                string firstSheetName = dtSheetName.Rows[0]["TABLE_NAME"].ToString();
                //读取第一个sheet填充数据sheetConfig.Name.Replace(".", "#") + "$"
                OleDbCommand command = new OleDbCommand("select * from [" + firstSheetName.Replace(".", "#") + "]", conn);
                IDataReader  idr     = command.ExecuteReader();

                string phone                = Constant.STRING_INVALID_VALUE;
                string IsReturnVisit        = Constant.STRING_INVALID_VALUE;
                GroupOrderDealHelper helper = new GroupOrderDealHelper();
                helper.userId = Convert.ToInt32(RequestUserID);

                List <myData> myDataList = new List <myData>();

                string whereYes = "";
                string whereNo  = "";

                int rowNum = 0;
                int ibatch = 0;
                while (idr.Read())
                {
                    if (!string.IsNullOrEmpty(idr[0].ToString().Trim()))
                    {
                        phone = idr[0].ToString().Trim();
                    }

                    if (!string.IsNullOrEmpty(idr[1].ToString().Trim()))
                    {
                        IsReturnVisit = idr[1].ToString().Trim();
                    }

                    if (phone != Constant.STRING_INVALID_VALUE && IsReturnVisit != Constant.STRING_INVALID_VALUE)
                    {
                        if (IsReturnVisit == "是")
                        {
                            whereYes += "'" + phone + "',";
                        }
                        else
                        {
                            whereNo += "'" + phone + "',";
                        }
                    }

                    rowNum++;

                    ibatch = rowNum / 1000;
                    int iremainder = rowNum % 1000;

                    if (ibatch > 0 && iremainder == 0)
                    {
                        if (whereYes.EndsWith(","))
                        {
                            whereYes = whereYes.Substring(0, whereYes.Length - 1);
                        }

                        if (whereNo.EndsWith(","))
                        {
                            whereNo = whereNo.Substring(0, whereNo.Length - 1);
                        }

                        myData mydataYes = new myData();
                        myData mydataNo  = new myData();

                        mydataYes.whereSql      = " AND CustomerTel IN(" + BLL.Util.SqlFilterByInCondition(whereYes) + ")";
                        mydataYes.IsReturnVisit = "是";
                        myDataList.Add(mydataYes);

                        mydataNo.whereSql      = " AND CustomerTel IN(" + BLL.Util.SqlFilterByInCondition(whereNo) + ")";
                        mydataNo.IsReturnVisit = "否";
                        myDataList.Add(mydataNo);

                        whereYes = "";
                        whereNo  = "";
                    }

                    BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported rowNum..." + rowNum + ",phone is:" + phone + "...");
                }

                if (whereYes != "")
                {
                    if (whereYes.EndsWith(","))
                    {
                        whereYes = whereYes.Substring(0, whereYes.Length - 1);
                    }
                    myData mydataYes = new myData();

                    mydataYes.whereSql      = " AND CustomerTel IN(" + BLL.Util.SqlFilterByInCondition(whereYes) + ")";
                    mydataYes.IsReturnVisit = "是";
                    myDataList.Add(mydataYes);
                }

                if (whereNo != "")
                {
                    if (whereNo.EndsWith(","))
                    {
                        whereNo = whereNo.Substring(0, whereNo.Length - 1);
                    }

                    myData mydataNo = new myData();

                    mydataNo.whereSql      = " AND CustomerTel IN(" + BLL.Util.SqlFilterByInCondition(whereNo) + ")";
                    mydataNo.IsReturnVisit = "否";
                    myDataList.Add(mydataNo);
                }

                int i = 0;
                foreach (myData item in myDataList)
                {
                    i++;
                    BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported myDataList..批次:" + i + ",数据:" + item.whereSql + "!");

                    DataTable dt = BLL.GroupOrder.Instance.GetGroupOrder(item.whereSql);

                    BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported myDataList..批次:" + i + ",匹配订单数量:" + dt.Rows.Count + "条!");
                    if (dt.Rows.Count > 0)
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            switch (item.IsReturnVisit)
                            {
                            case "是":
                                helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.Yes).ToString();
                                break;

                            case "否":
                                helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.No).ToString();
                                break;

                            default:
                                helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.UnKnown).ToString();
                                break;
                            }

                            helper.RequestTaskID = row["TaskID"].ToString().Trim();

                            try
                            {
                                helper.DealOrder(2, out msg);
                            }
                            catch (Exception ex)
                            {
                                msg = ex.Message;
                                BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported helper.DealOrder errorMessage is:" + ex.Message + "!");
                                BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported helper.DealOrder errorStackTrace is:" + ex.StackTrace + "!");
                            }

                            if (msg == "")
                            {
                                if (item.IsReturnVisit == "是")
                                {
                                    sucYesCount++;
                                }
                                else
                                {
                                    sucNoCount++;
                                }
                            }
                            else
                            {
                                FailCount++;
                                //失败任务,需生成对Excel文件
                                //字段:电话号码、处理结果、任务ID
                                ExcelData data = new ExcelData();
                                data.Phone  = row["CustomerTel"].ToString().Trim();
                                data.TaskID = helper.RequestTaskID;
                                data.Msg    = msg;

                                excelDataList.Add(data);

                                BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported FailCount..." + FailCount + ",phone is:" + data.Phone + ",TaskID is:" + data.TaskID + ",errorMsg is:" + data.Msg + "!");
                            }
                        }
                    }
                    else
                    {
                        //未找到订单的 电话号码
                        //noOrderCount++;
                        BLL.Loger.Log4Net.Info("[HandlerImport]未找到订单数据...批次:" + i + ",数据:" + item.whereSql + "!");
                    }
                }

                //msg = "{\"Result\":true,\"Msg\":\"成功回写处理结果:是,任务" + sucYesCount + "条!\n成功回写处理结果:否,任务" + sucNoCount + "条!\n失败任务" + FailCount + "条!\n未找到订单电话记录" + noOrderCount + "条!}";
                //msg = "{\"Result\":true,\"Msg\":\"成功回写处理结果:是,任务" + sucYesCount + "条!\"}";
                msg = "{\"Result\":true,\"Msg\":\"成功回写处理结果:是,任务" + sucYesCount + "条!\\n成功回写处理结果:否,任务" + sucNoCount + "条!\\n失败任务" + FailCount + "条!\",\"FailCount\":\"" + FailCount + "\"}";

                //查看是否有失败数据
                if (FailCount > 0)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (ExcelData item in excelDataList)
                    {
                        sb.Append(item.Phone + "," + item.TaskID + "," + item.Msg + ";");
                    }

                    string errorData = sb.ToString();
                    if (errorData != "")
                    {
                        errorData = errorData.Substring(0, errorData.Length - 1);
                        msg       = "{\"Result\":true,\"Msg\":\"成功回写处理结果:是,任务" + sucYesCount + "条!\\n成功回写处理结果:否,任务" + sucNoCount + "条!\\n失败任务" + FailCount + "条!\",\"FailCount\":\"" + FailCount + "\",\"ErrorData\":\"" + errorData + "\"}";
                    }
                }

                BLL.Loger.Log4Net.Info("[HandlerImport]DealDataImported bye...");
                return(success);
            }
        }
Beispiel #19
0
        private bool DealDataImported2(string fileName, out string msg)
        {
            System.Diagnostics.Debug.WriteLine("[Handler]DealDataImported begin...");
            bool success = true;

            msg = "";
            int sucYesCount  = 0; //回访结果:是
            int sucNoCount   = 0; //回访结果:否
            int FailCount    = 0; //回写失败
            int noOrderCount = 0; //未找到匹配订单的电话

            List <ExcelData> excelDataList = new List <ExcelData>();
            ExcelData        data          = new ExcelData();

            //(1)连接EXCEL文件
            string ext     = Path.GetExtension(fileName);
            string connStr = string.Empty;

            if (ext.ToLower() == ".xls")
            {
                connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + @fileName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            }
            else
            {
                //throw new Exception("上传文件应为xls或者xlsx格式的文件");
                throw new Exception("上传文件应为xls格式的文件");
            }

            using (OleDbConnection conn = new OleDbConnection(connStr))
            {
                conn.Open();

                //返回Excel的架构,包括各个sheet表的名称,类型,创建时间和修改时间等
                DataTable dtSheetName = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "Table" });
                //包含excel中表名的字符串数组
                string firstSheetName = dtSheetName.Rows[0]["TABLE_NAME"].ToString();
                //读取第一个sheet填充数据sheetConfig.Name.Replace(".", "#") + "$"
                OleDbCommand command = new OleDbCommand("select * from [" + firstSheetName.Replace(".", "#") + "]", conn);
                IDataReader  idr     = command.ExecuteReader();

                string phone                = Constant.STRING_INVALID_VALUE;
                string IsReturnVisit        = Constant.STRING_INVALID_VALUE;
                GroupOrderDealHelper helper = new GroupOrderDealHelper();
                helper.userId = Convert.ToInt32(RequestUserID);

                List <myData> myDataList = new List <myData>();
                myData        mydataYes  = new myData();
                myData        mydataNo   = new myData();
                string        whereYes   = "";
                string        whereNo    = "";

                int rowNum = 0;
                int ibatch = 0;
                while (idr.Read())
                {
                    if (!string.IsNullOrEmpty(idr[0].ToString().Trim()))
                    {
                        phone = idr[0].ToString().Trim();
                    }

                    if (!string.IsNullOrEmpty(idr[1].ToString().Trim()))
                    {
                        IsReturnVisit = idr[1].ToString().Trim();
                    }

                    if (phone != Constant.STRING_INVALID_VALUE && IsReturnVisit != Constant.STRING_INVALID_VALUE)
                    {
                        if (IsReturnVisit == "是")
                        {
                            whereYes += "'" + phone + "',";
                        }
                        else
                        {
                            whereNo += "'" + phone + "',";
                        }
                    }

                    rowNum++;

                    ibatch = rowNum / 1000;
                    int iremainder = rowNum % 1000;

                    if (ibatch > 0 && iremainder == 0)
                    {
                        if (whereYes.EndsWith(","))
                        {
                            whereYes = whereYes.Substring(0, whereYes.Length - 1);
                        }

                        if (whereNo.EndsWith(","))
                        {
                            whereNo = whereNo.Substring(0, whereNo.Length - 1);
                        }

                        mydataYes.whereSql      = whereYes;
                        mydataYes.IsReturnVisit = "是";
                        mydataNo.whereSql       = whereNo;
                        mydataNo.IsReturnVisit  = "否";

                        myDataList.Add(mydataYes);
                        myDataList.Add(mydataNo);

                        whereYes = "";
                        whereNo  = "";
                    }
                }

                if (whereYes != "")
                {
                    mydataYes.whereSql      = whereYes;
                    mydataYes.IsReturnVisit = "是";
                    myDataList.Add(mydataYes);
                }

                if (whereNo != "")
                {
                    mydataNo.whereSql      = whereNo;
                    mydataNo.IsReturnVisit = "否";
                    myDataList.Add(mydataNo);
                }

                foreach (myData item in myDataList)
                {
                }

                while (idr.Read())
                {
                    rowNum++;
                    System.Diagnostics.Debug.WriteLine("[Handler]DealDataImported rowNum..." + rowNum);
                    System.Diagnostics.Debug.WriteLine("[Handler]DealDataImported 电话号码..." + idr[0].ToString().Trim());


                    if (!string.IsNullOrEmpty(idr[0].ToString().Trim()))
                    {
                        phone = idr[0].ToString().Trim();
                    }

                    if (!string.IsNullOrEmpty(idr[1].ToString().Trim()))
                    {
                        IsReturnVisit = idr[1].ToString().Trim();
                    }


                    //先根据电话获取订单对应任务ID
                    if (phone != Constant.STRING_INVALID_VALUE && IsReturnVisit != Constant.STRING_INVALID_VALUE)
                    {
                        Entities.QueryGroupOrder query = new Entities.QueryGroupOrder();
                        query.CustomerTel = phone;
                        int       total = 0;
                        DataTable dt    = BLL.GroupOrder.Instance.GetGroupOrder(query, "", 1, 999999, out total);

                        if (dt.Rows.Count > 0)
                        {
                            foreach (DataRow row in dt.Rows)
                            {
                                long taskid = Constant.INT_INVALID_VALUE;

                                if (!string.IsNullOrEmpty(row["TaskID"].ToString().Trim()))
                                {
                                    taskid = Convert.ToInt32(row["TaskID"].ToString().Trim());
                                }

                                if (taskid == Constant.INT_INVALID_VALUE)
                                {
                                    msg = "{\"Result\":false,\"Msg\":\"任务不能为空!\"}";
                                    continue;
                                }

                                switch (IsReturnVisit)
                                {
                                case "是":
                                    helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.Yes).ToString();
                                    break;

                                case "否":
                                    helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.No).ToString();
                                    break;

                                default:
                                    helper.RequestIsReturnVisit = ((int)Entities.IsReturnVisit.UnKnown).ToString();
                                    break;
                                }

                                helper.RequestTaskID = row["TaskID"].ToString().Trim();
                                helper.DealOrder(2, out msg);

                                if (msg == "")
                                {
                                    if (IsReturnVisit == "是")
                                    {
                                        sucYesCount++;
                                    }
                                    else
                                    {
                                        sucNoCount++;
                                    }
                                }
                                else
                                {
                                    FailCount++;
                                    //失败任务,需生成对Excel文件
                                    //字段:电话号码、处理结果、任务ID
                                    //ExcelData data = new ExcelData();
                                    data.Phone  = phone;
                                    data.TaskID = helper.RequestTaskID;
                                    data.Msg    = msg;

                                    excelDataList.Add(data);
                                }
                            }
                        }
                        else
                        {
                            //未找到订单的 电话号码
                            noOrderCount++;
                        }
                    }
                }
                idr.Close();
                idr = null;
            }

            msg = "{\"Result\":true,\"Msg\":\"成功回写处理结果:是,任务" + sucYesCount + "条!\n成功回写处理结果:否,任务" + sucNoCount + "条!\n失败任务" + FailCount + "条!\n未找到订单电话记录" + noOrderCount + "条!}";

            if (FailCount > 0)
            {
                //ExcelHelper excelhelper = new ExcelHelper();
                //excelhelper.ExprotExcel(excelDataList);
            }

            return(success);
        }
 public MainWindow()
 {
     this.mylist = new myData();
     InitializeComponent();
 }
Beispiel #21
0
		public void Locktest()
		{
            Console.WriteLine("Locktest");

            myData data = new myData();
            data.message = ": 1 :";
            data._delay = 200;
            data._whichWork = 2;
            data._recache = false;
            Thread newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
            newThread.Start(data);
            Locking.InitialiseOrRefresh(sharedLock, FirstThreadWork, IsStringAssigned, false, null);
            newThread.Join();
            Assert.IsNotNull(syncstring, "String still null after initialisation");
            Assert.AreEqual("FirstThreadWork", syncstring, "Failed after first attempt");
            syncstring = null;

            data.message = ": 2 :";
            data._whichWork = 1;
            newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
            newThread.Start(data);
            Locking.InitialiseOrRefresh(sharedLock, SecondThreadWork, IsStringAssigned, false, null);
            newThread.Join();
            Assert.IsNotNull(syncstring, "String still null after initialisation");
            Assert.AreEqual("SecondThreadWork", syncstring, "Failed after second attempt");

            data.message = ": 3 :";
            syncstring = null;
            data._whichWork = 1;
            data._delay = 0;
            newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
            newThread.Start(data);
            Thread.Sleep(100);
            Locking.InitialiseOrRefresh(sharedLock, SecondThreadWork, IsStringAssigned, false, null);
            newThread.Join();
            Assert.IsNotNull(syncstring, "String still null after initialisation");
            Assert.AreEqual("FirstThreadWork", syncstring, "Failed after second attempt");

            Assert.AreEqual(2, _numFirst, "First should have only run twice");
            Assert.AreEqual(1, _numSecond, "Second shold only have run first");

            data.message = ": 4 :";
            data._whichWork = 1;
            data._delay = 0;
            newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
            newThread.Start(data);
            Thread.Sleep(100);
            Locking.InitialiseOrRefresh(sharedLock, SecondThreadWork, IsStringAssigned, false, null);
            newThread.Join();
            Assert.IsNotNull(syncstring, "String still null after initialisation");
            Assert.AreEqual("FirstThreadWork", syncstring, "Failed after second attempt");

            Assert.AreEqual(2, _numFirst, "First should have only run twice");
            Assert.AreEqual(1, _numSecond, "Second shold only have run first");

            data.message = ": 5 :";
            data._whichWork = 1;
            data._delay = 0;
            data._recache = true;
            newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
            newThread.Start(data);
            Thread.Sleep(1000);
            Console.WriteLine("Calling from first thread");
            Locking.InitialiseOrRefresh(sharedLock, SecondThreadWork, IsStringAssigned, true, null);
            Console.WriteLine("Finished from first thread");
            newThread.Join();
            Assert.IsNotNull(syncstring, "String still null after initialisation");
            Assert.AreEqual("SecondThreadWork", syncstring, "Failed after second attempt");

            Assert.AreEqual(3, _numFirst, "First should have only run twice");
            Assert.AreEqual(2, _numSecond, "Second shold only have run first");

            for (int j = 0; j < 1; j++)
            {
                _numFirst = 0;
                _numSecond = 0;
                //syncstring = null;
                Console.WriteLine(" -- first = {0}, second = {1}", _numFirst, _numSecond);
                data._whichWork = 3;
                data._delay = 0;
                data._recache = true;
                newThread = new Thread(new ParameterizedThreadStart(SecondThreadCode));
                newThread.Start(data);
                for (int i = 0; i < 10; i++)
                {
                    Locking.InitialiseOrRefresh(sharedLock, FourthThreadWork, IsStringAssigned, true, null);
                }
                Console.WriteLine("first = {0}, second = {1}", _numFirst, _numSecond);
                //Assert.IsTrue(99 < (_numFirst + _numSecond), "Too few items");
                //Assert.IsTrue(150 > (_numFirst + _numSecond), "Too many items");
                Console.WriteLine("first = {0}, second = {1}", _numFirst, _numSecond);
            }
		}
Beispiel #22
0
        static void Main(string[] args)
        {
            // TESTING search tree Insertion
            // 2643 adds
            Console.WriteLine(" Ternary Search Tree Add ");
            Stopwatch myStopWatch = new Stopwatch();
            myData    data        = new myData();
            TST <int> myTry       = new TST <int>();

            myStopWatch.Start();
            for (int i = 0; i < 3; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("3 Insertions: " + myStopWatch.Elapsed);

            // 1000 adds

            myStopWatch = new Stopwatch();
            data        = new myData();
            myTry       = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 9; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("9 Insertions: " + myStopWatch.Elapsed);
            // 100 adds

            myStopWatch = new Stopwatch();
            data        = new myData();
            myTry       = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 27; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("27 Insertions: " + myStopWatch.Elapsed);

            myStopWatch = new Stopwatch();
            data        = new myData();
            myTry       = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 81; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("81 Insertions: " + myStopWatch.Elapsed);
            // 100 adds

            myStopWatch = new Stopwatch();
            data        = new myData();
            myTry       = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 243; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("243 Insertions: " + myStopWatch.Elapsed);
            // 10 adds
            myStopWatch = new Stopwatch();
            data        = new myData();
            myTry       = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 729; i++)
            {
                myTry.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("729 Insertions: " + myStopWatch.Elapsed);
            // Testing Dictionary search tree Insertions
            // 977 adds
            Console.WriteLine(" Testing the Dictionary");
            myStopWatch = new Stopwatch();
            data        = new myData();
            Dictionary <string, int> myDictionary = new Dictionary <string, int>();

            myStopWatch.Start();
            for (int i = 0; i < 3; i++)
            {
                myDictionary.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("3 Insertions: " + myStopWatch.Elapsed);


            myStopWatch  = new Stopwatch();
            data         = new myData();
            myDictionary = new Dictionary <string, int>();
            myStopWatch.Start();
            for (int i = 0; i < 27; i++)
            {
                myDictionary.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("27 Insertions: " + myStopWatch.Elapsed);

            myStopWatch  = new Stopwatch();
            data         = new myData();
            myDictionary = new Dictionary <string, int>();
            myStopWatch.Start();
            for (int i = 0; i < 81; i++)
            {
                myDictionary.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("81 Insertions: " + myStopWatch.Elapsed);

            myStopWatch  = new Stopwatch();
            data         = new myData();
            myDictionary = new Dictionary <string, int>();
            myStopWatch.Start();
            for (int i = 0; i < 243; i++)
            {
                myDictionary.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("243 Insertions: " + myStopWatch.Elapsed);

            myStopWatch  = new Stopwatch();
            data         = new myData();
            myDictionary = new Dictionary <string, int>();
            myStopWatch.Start();
            for (int i = 0; i < 729; i++)
            {
                myDictionary.Add(data.words[i], i);
            }
            myStopWatch.Stop();
            Console.WriteLine("729 Insertions: " + myStopWatch.Elapsed);

            // TESTING // Contains// Partial Match // Autocomplete

            Console.WriteLine(" Ternary Search Tree Add ");

            data  = new myData();
            myTry = new TST <int>();
            myStopWatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                myTry.Add(data.words[i], i);
            }

            Boolean       value = myTry.Contains("chaos");
            List <string> list  = myTry.Autocomplete("ch");
            List <string> list2 = myTry.PartialMatch("ch***");
            List <string> list3 = myTry.PartialMatch("***b**");

            Console.WriteLine("List: AutoComplete ch ");
            foreach (string element in list)
            {
                Console.Write(element + " ");
            }
            Console.WriteLine();
            Console.WriteLine("List2: PartialMatch ch*** ");
            foreach (string element in list2)
            {
                Console.Write(element + " ");
            }
            Console.WriteLine();
            Console.WriteLine("List3: PartialMatch ***b** ");
            foreach (string element in list3)
            {
                Console.Write(element + " ");
            }


            Console.ReadLine();
        }
Beispiel #23
0
 public void saveMyData(myData Data)
 {
     File.WriteAllText(Application.dataPath + "/TestJson.json", JsonUtility.ToJson(Data));
 }