private void ProAddBtn_Click(object sender, EventArgs e)
        {
            XmlOperator    xmlOperator = new XmlOperator();
            OpenFileDialog fileDialog  = new OpenFileDialog();

            //fileDialog.Multiselect = true;
            if (fileDialog.ShowDialog() == DialogResult.OK)
            {
                //MessageBox.Show(fileDialog.FileName);
                SerializableDictionary <int, StructureOfProblem> p = xmlOperator.readXML(fileDialog.FileName);
                if (this.Main_TreeView.Nodes.Count == 0 || this.Main_TreeView.SelectedNode == null)
                {
                    //this.Main_TreeView.Nodes.Add(NewProblemName);
                    foreach (int key in p.Keys)
                    {
                        TreeNode minnode = new TreeNode();
                        minnode.Text = ProblemList.GetProblem(key).QuestionName;
                        this.Main_TreeView.Nodes.Add(minnode);
                        ProblemList.Add(ProblemList.GetProblem(key));
                    }
                }
                else
                {
                    //this.Main_TreeView.SelectedNode.Nodes.Add(NewProblemName);
                    foreach (int key in p.Keys)
                    {
                        TreeNode minnode = new TreeNode();
                        minnode.Text = ProblemList.GetProblem(key).QuestionName;
                        this.Main_TreeView.SelectedNode.Nodes.Add(minnode);
                        ProblemList.Add(ProblemList.GetProblem(key));
                    }
                }
            }
        }
Esempio n. 2
0
        private void updateElectButton_Click(object sender, EventArgs e)
        {
            try {
                this.label4.Text = GlobalData.user.RoomId + "";
                if (GlobalData.user.RoomId.Equals(0))
                {
                    MessageBox.Show("更新失败,未完善宿舍号");
                    return;
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("更新失败,未完善宿舍号");
                return;
            }
            InvokeExe invokeExe        = new InvokeExe();
            string    filePath         = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\getElect.exe";
            string    workingDirectory = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\";

            string[] param = { GlobalData.user.RoomId + "" };
            string   res   = "";

            try
            {
                res = invokeExe.invoke(filePath, workingDirectory, param);
                this.label5.Text = res.Substring(16, 7);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("更新失败");
                return;
            }
            String time = DateTime.Now.ToString();

            this.dateTimePicker1.Text = time;
            ElectInfo info = new ElectInfo();

            info.Time  = time;
            info.Elect = res.Substring(16, 7);
            XmlOperator <ElectInfo> xmlOperator = new XmlOperator <ElectInfo>();
            string infoPath = "";

            try
            {
                infoPath = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml";
                xmlOperator.saveXML(infoPath, info);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog(typeof(ElectricityCharges), ex);
                MessageBox.Show("读取宿舍号失败");
            }
            string path = Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt";

            drawCurve(path);
            LogHelper.WriteLog(typeof(ElectricityCharges), "  " + info.ToString());
            MessageBox.Show("电费更新成功!");
        }
Esempio n. 3
0
 public ElectricityCharges()
 {
     this.Location      = new System.Drawing.Point(500, 500);
     this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
     InitializeComponent();
     //本地存在电费信息的文档 读取并展示
     if (File.Exists(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt"))
     {
         drawCurve(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\dist\\" + "ElectInfo.txt");
     }
     try
     {
         if (File.Exists(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml"))
         {
             XmlOperator <ElectInfo> xmlOperator = new XmlOperator <ElectInfo>();
             ElectInfo info = xmlOperator.readXML(Application.StartupPath.Substring(0, Application.StartupPath.Length - 10) + "\\Properties\\Search_Electricity\\" + GlobalData.user.RoomId + "Info.xml");
             this.label5.Text          = info.Elect;
             this.dateTimePicker1.Text = info.Time;
         }
         this.label4.Text = GlobalData.user.RoomId + "";
     }
     catch (Exception e)
     {
         LogHelper.WriteLog(typeof(ElectricityCharges), e);
         MessageBox.Show("请先完善信息");
     }
 }
        public void Test_InjectElementWithTexts_ErrorPath()
        {
            Exception withAttributes =
                XmlOperator.InjectElementWithTexts("", _rootXPath, _targetXPath, _injectElement, _attributes);

            Assert.NotNull(withAttributes);
            TLogException(withAttributes);
        }
Esempio n. 5
0
        public void XmlreadTest()
        {
            XmlOperator xmlOperator = new XmlOperator();
            SerializableDictionary <int, StructureOfProblem> p = xmlOperator.readXML("Problem//Problem.xml");

            Assert.IsTrue(p.ContainsKey(1));
            Assert.AreEqual("testing", p[1].QuestionDescription);
        }
Esempio n. 6
0
 private static void LoadXmlFile(string filePath)
 {
     using (var xmlOperator = new XmlOperator(filePath))
     {
         //Console.WriteLine(xmlOperator.GetNodeAttributeValue("Books","Category"));
         //Console.WriteLine(xmlOperator.GetXmlNodeValue("detail"));
         var node = xmlOperator.GetXmlNode(x => x.Name == "Books");
         Console.WriteLine(node.OuterXml);
     }
 }
        private void ProExportBtn_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog path = new FolderBrowserDialog();

            if (path.ShowDialog() == DialogResult.OK)
            {
                // MessageBox.Show(path.SelectedPath);
                SerializableDictionary <int, StructureOfProblem> problems = ProblemList.GetAll();
                XmlOperator xmlOperator = new XmlOperator();

                xmlOperator.XMLSerialized(path.SelectedPath + "//Problem.xml", problems);
            }
        }
        public void Test_InjectElementWithTexts()
        {
            Exception withAttributes =
                XmlOperator.InjectElementWithTexts(_defaultXML, _rootXPath, _targetXPath, _injectElement,
                                                   _attributes);

            if (withAttributes != null)
            {
                TLogException(withAttributes);
            }

            Assert.Null(withAttributes);
        }
Esempio n. 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //读取配置文件,初始化页面
            XmlOperator xo = new XmlOperator(_filePath);

            if (!xo.HasDocument)
            {
                CommonManager.Web.RegJs(this, "alert('本功能尚未开通,请稍候再尝试进入此页。');history.back();", false);
                return;
            }
            MinMoney     = xo.GetNodeValue("MinMoney");
            ChangeType   = xo.GetNodeValue("Type") == "0" ? "固定额" : "百分比";
            ProcedureFee = xo.GetNodeValue("Type") == "0" ? xo.GetNodeValue("StaticValue") : "(交易额×" + xo.GetNodeValue("PercentValue") + "%)";
        }
Esempio n. 10
0
        public void XmlwriteTest()
        {
            XmlOperator        xmlOperator = new XmlOperator();
            StructureOfProblem p           = new StructureOfProblem();

            p.QuestionDescription = "testing";
            p.QuestionName        = "test";
            p.ProblemID           = 1;
            SerializableDictionary <int, StructureOfProblem> problemlist = new SerializableDictionary <int, StructureOfProblem>();

            problemlist.Add(p.ProblemID, p);
            xmlOperator.XMLSerialized("Problem//Problem.xml", problemlist);
            Directory.Exists("Problem//Problem.xml");
        }
Esempio n. 11
0
 private static void TestCreateXmlString()
 {
     using (var xmloper = new XmlOperator())
     {
         xmloper.CreateRootElement("Envelope", "soap", "http://schemas.xmlsoap.org/soap/envelope/");
         var bodyNode        = xmloper.RootNode.AppendChild(xmloper.CreateNode("Body", true));
         var faultNode       = bodyNode.AppendChild(xmloper.CreateNode("Fault", true));
         var faultCodeNode   = faultNode.AppendChild(xmloper.CreateNode("faultcode"));
         var faultStringNode = faultNode.AppendChild(xmloper.CreateNode("faultstring"));
         var detailNode      = faultNode.AppendChild(xmloper.CreateNode("detail"));
         faultCodeNode.AppendChild(xmloper.XmlDoc.CreateTextNode("soap:Client"));
         faultStringNode.AppendChild(xmloper.XmlDoc.CreateTextNode("Error message."));
         detailNode.AppendChild(xmloper.XmlDoc.CreateTextNode("Error details."));
         xmloper.SaveAs("D:\\TestExportFile\\TestXml.xml", true);
     }
 }
Esempio n. 12
0
        private void export_status_Click_1(object sender, EventArgs e)
        {
            SerializableDictionary <int, StructureOfProblem> problems    = ProblemList.GetAll();
            SerializableDictionary <int, StructureOfProblem> problemlist = new SerializableDictionary <int, StructureOfProblem>();
            XmlOperator xmlOperator = new XmlOperator();

            foreach (int key in problems.Keys)
            {
                StructureOfProblem p = new StructureOfProblem();
                p.AcceptsRate  = ProblemList.GetProblem(key).AcceptsRate;
                p.QuestionName = ProblemList.GetProblem(key).QuestionName;
                p.ProblemID    = ProblemList.GetProblem(key).ProblemID;
                problemlist.Add(p.ProblemID, p);
            }
            xmlOperator.XMLSerialized("Problem//ProblemStatus.xml", problemlist);
            //MessageBox.Show("导出成功");
        }
        public void XMLSerializedTest()
        {
            if (Directory.Exists("User//"))
            {
                DirectoryInfo di = new DirectoryInfo("User//");
                di.Delete(true);
            }

            User user = new User();

            user.Name = "卓裕轩";
            //user.StudentId = 2016052355;
            user.Jwxtpassword = "******";
            user.Major        = "软件工程";
            XmlOperator p = new XmlOperator();

            p.XMLSerialized(user);
            Assert.IsTrue(File.Exists("User//User.xml"));
        }
Esempio n. 14
0
        public void InformationManageTest()
        {
            XmlOperator <User> xmlOperator = new XmlOperator <User>();
            User user = new User();

            user.Name         = "张锦亮";
            user.StudentId    = 2016052355;
            user.Jwxtpassword = "******";
            user.Major        = "软件工程";
            string   filename = "User//User" + user.StudentId.ToString() + ".xml";
            checkDir check    = new checkDir();

            check.check("User//");
            xmlOperator.saveXML(filename, user);
            Assert.IsTrue(File.Exists(filename));
            User resUser = xmlOperator.readXML(filename);

            Assert.AreEqual(user.Name, resUser.Name);
            Assert.AreEqual(user.Jwxtpassword, resUser.Jwxtpassword);
            Assert.AreEqual(user.Major, resUser.Major);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string      userId = Session["login_card_id"] as string;
            XmlOperator xo     = new XmlOperator();
            if (String.IsNullOrEmpty(userId))
            {
                Response.Write("<meta http-equiv=\"refresh\" content=\"0; URL=default.aspx\">");
                return;
            }
            String userMenuPath = Server.MapPath("~/admin/img/userMenu/");
            userMenuPath = userMenuPath + userId + "\\";
            if (!System.IO.Directory.Exists(userMenuPath))
            {
                //create folder for the user.
                Directory.CreateDirectory(userMenuPath);
            }

            if (!System.IO.File.Exists(userMenuPath + "p.xml"))
            {
                //create xml file

                xo.CreateXmlFile(userMenuPath);
            }

            string menuId = Request.Form["menuId"];
            if (menuId != "-1")
            {
                //copy default image to here
                string sourceFile = Server.MapPath("~/admin/img/menu/menuItem/4.png");
                string targetFile = userMenuPath + menuId + ".png";
                File.Copy(sourceFile, targetFile, true);
                xo.AddNewMenu(userMenuPath, menuId, userMenuPath + menuId + ".png");
            }
        }catch (Exception ex)
        {
        }
        Response.Redirect("Shortcut.aspx");
    }
Esempio n. 16
0
        private static void CreateXmlFile(string filePath)
        {
            using (var xmlOperator = new XmlOperator())
            {
                xmlOperator.CreateRootElement("XmlSimple", "lwr", "XmlHelper");
                var booksNode = xmlOperator.AppendNode("Books",
                                                       new Tuple <string, object>("Category", "Sicence"),
                                                       new Tuple <string, object>("DateTime", DateTime.Now.ToShortDateString()));

                for (int i = 0; i < 10; i++)
                {
                    var bookNode = xmlOperator.AppendNodeToExitsNode(booksNode, "Book",
                                                                     new Tuple <string, object>("BookName", $"Book_{i}"),
                                                                     new Tuple <string, object>("Author", $"Author_{i}")
                                                                     );
                }
                xmlOperator.SaveAs(filePath);
                xmlOperator.AppendNode("Photos", new Tuple <string, object>("Name", "照片"));
                xmlOperator.Save();
            }
            System.Diagnostics.Process.Start(filePath);
        }
Esempio n. 17
0
        private static void LoadXmlString()
        {
            StringBuilder errorMessageFormatter = new StringBuilder();

            errorMessageFormatter.AppendLine("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
            errorMessageFormatter.AppendLine("   <soap:Body>");
            errorMessageFormatter.AppendLine("      <soap:Fault>");
            errorMessageFormatter.AppendLine("         <faultcode>soap:Client</faultcode>");
            errorMessageFormatter.AppendLine("         <faultstring>Error message!</faultstring>");
            errorMessageFormatter.AppendLine("         <detail>Error details</detail>");
            errorMessageFormatter.AppendLine("      </soap:Fault>");
            errorMessageFormatter.AppendLine("   </soap:Body>");
            errorMessageFormatter.AppendLine("</soap:Envelope>");
            using (var xmlOperator = new XmlOperator())
            {
                xmlOperator.LoadFromString(errorMessageFormatter.ToString());
                var node = xmlOperator.GetXmlNode(x => x.Name == "faultcode");
                Console.WriteLine(xmlOperator.GetXmlNode(x => x.Name == "faultstring")?.FirstChild.Value);
                Console.WriteLine(xmlOperator.GetXmlNode(x => x.Name == "detail")?.FirstChild.Value);
                xmlOperator.SaveAs("D:\\TestExportFile\\TestXml.xml", true);
            }
        }
        public void readXMLTest()
        {
            if (Directory.Exists("User//"))
            {
                DirectoryInfo di = new DirectoryInfo("User//");
                di.Delete(true);
            }
                
            User user = new User();

            user.Name = "卓裕轩";
            //user.StudentId = 2016052355;
            user.Jwxtpassword = "******";
            user.Major        = "软件工程";
            XmlOperator p = new XmlOperator();

            p.XMLSerialized(user);
            User resUser = p.readXML("");

            Assert.AreEqual(user.Name, resUser.Name);
            Assert.AreEqual(user.Jwxtpassword, resUser.Jwxtpassword);
            Assert.AreEqual(user.Major, resUser.Major);
        }
        private void ExportStatusBtn_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog path = new FolderBrowserDialog();

            if (path.ShowDialog() == DialogResult.OK)
            {
                // MessageBox.Show(path.SelectedPath);
                SerializableDictionary <int, StructureOfProblem> problemsStatus = new SerializableDictionary <int, StructureOfProblem>();
                foreach (int key in problems.Keys)
                {
                    StructureOfProblem problem = new StructureOfProblem();
                    problem.ProblemID = ProblemList.GetProblem(key).ProblemID;
                    if (this.Main_TreeView.SelectedNode.Text == ProblemList.GetProblem(key).QuestionName)
                    {
                        problem.Problemcode = this.problemcode.Text;
                    }
                    problem.QuestionName = ProblemList.GetProblem(key).QuestionName;
                    problem.AcceptsRate  = ProblemList.GetProblem(key).AcceptsRate;
                    problemsStatus.Add(problem.ProblemID, problem);
                }
                XmlOperator xmlOperator = new XmlOperator();
                xmlOperator.XMLSerialized(path.SelectedPath + "//ProblemStatus.xml", problemsStatus);
            }
        }
Esempio n. 20
0
 public ActionResult Monitor()
 {
     if (Request.InputStream.Length > 0)
     {
         string xml = string.Empty;
         using (StreamReader reader = new StreamReader(Request.InputStream))
         {
             xml = reader.ReadToEnd();
         }
         WeiXinPayRequestXML request = XmlOperator.Derialize <WeiXinPayRequestXML>(xml);
         if (request.result_code.ToUpper() != "SUCCESS")
         {
             return(Content(""));
         }
         int    splitIndex = request.out_trade_no.IndexOf("_");
         string orderID    = request.out_trade_no;
         if (splitIndex > 0)
         {
             orderID = request.out_trade_no.Substring(0, splitIndex);
         }
         string where = string.Format("OrderID='{0}'", orderID);
         IList <Model.TD_Order_WeiXinPay> payList = weiXinPayBLL.GetList(where, "PayTime desc", null);
         int count = payList.Count((model) => { return(model.Status == 1); });
         if (count > 0)
         {
             return(PayOK());
         }
         var config = WeiXinConfig.GetConfig();
         count = payList.Count((model) => {
             if (model.OrderID == orderID &&
                 model.NonceStr == request.nonce_str &&
                 config.AppID == request.appid &&
                 config.ShopID == request.mch_id)
             {
                 return(true);
             }
             return(false);
         });
         if (count > 0)
         {
             Model.TD_Order_WeiXinPay pay = new Model.TD_Order_WeiXinPay();
             pay.OrderID       = orderID;
             pay.NonceStr      = request.nonce_str;
             pay.WeiXinOrderID = request.transaction_id;
             pay.OrderFee      = request.total_fee;
             pay.CashFee       = request.cash_fee;
             pay.Status        = 1;
             pay.CallBackTime  = DateTime.ParseExact(request.time_end, "yyyyMMddHHmmss", System.Globalization.CultureInfo.CurrentCulture);
             int result = weiXinPayBLL.Sync(pay, orderID);
             if (result > 0)
             {
                 return(PayOK());
             }
             else
             {
                 return(PayFail());
             }
         }
         else
         {
             return(PayFail());
         }
     }
     return(Content(""));
 }
Esempio n. 21
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!CommonManager.Web.CheckPostSource())
            {
                return;
            }
            if (!IsValid)
            {
                return;
            }

            //0、服务端校验
            #region  务端校验
            //读取配置文件
            XmlOperator xo = new XmlOperator(_filePath);
            if (!xo.HasDocument)
            {
                CommonManager.Web.RegJs(this, "alert('本功能尚未开通,请稍候再尝试进入此页。');history.back();", false);
                return;
            }
            if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('请输入您的当前密码!');", false);
                return;
            }
            TUsers user = DbSession.Default.Get <TUsers>(TUsers._.UserID == UserLoginInfo.UserID);
            if (user.Pass != CommonManager.String.EncryptMD5SystemDefaultMethod(txtPassword.Text.Trim(), false, true))
            {
                CommonManager.Web.RegJs(this, "alert('您输入的密码不正确,请重新输入。');", false);
                return;
            }
            if (string.IsNullOrEmpty(txtAgent.Text.Trim()) || string.IsNullOrEmpty(txtAgent2.Text.Trim()) || txtAgent.Text.Trim() != txtAgent2.Text.Trim())
            {
                CommonManager.Web.RegJs(this, "alert('请正确输入代理商帐号');", false);
                return;
            }
            else if (!DbSession.Default.Exists <Web_Agent>(Web_Agent._.LoginName == txtAgent.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('代理商帐号不存在,请重新核对!');", false);
                return;
            }
            if (string.IsNullOrEmpty(txtMoney.Text.Trim()) || !CommonManager.String.IsInteger(txtMoney.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('请正确输入要转帐的金币!');", false);
                return;
            }
            #endregion
            //1、检查用户输入的金额
            #region 检查用户输入的金额
            int        money  = int.Parse(txtMoney.Text.Trim());
            BLL.Member m      = new BLL.Member();
            Int64      bmoney = m.GetBankMoney(user.UserID.ToString());
            if (money > bmoney)
            {
                CommonManager.Web.RegJs(this, "alert('您的银行金币余额只有" + bmoney.ToString() == "0" ? "0" : bmoney.ToString() + UiCommon.StringConfig.AddZero() + ",请重新输入。');", false);
                return;
            }
            int minmoney = int.Parse(xo.GetNodeValue("MinMoney"));
            if (money <= minmoney)
            {
                CommonManager.Web.RegJs(this, "alert('每次兑换金币数量必须大于" + minmoney.ToString() + "00!');", false);
                return;
            }
            #endregion
            //2、取得代理商游戏帐户
            #region 取得代理商游戏帐户
            Web_VAgentUserInfo agent = DbSession.Default.Get <Web_VAgentUserInfo>(Web_VAgentUserInfo._.LoginName == txtAgent.Text.Trim());
            if (agent == null)
            {
                CommonManager.Web.RegJs(this, "alert('代理商帐号不存在,请重新核对!');", false);
                return;
            }
            #endregion
            //3、转帐
            //3.1、检测玩家帐号是否在游戏中
            #region 检测玩家帐号是否在游戏中
            if (m.IsInRoomOrGame(UserLoginInfo.UserName))
            {
                CommonManager.Web.RegJs(this, "alert('您的帐号正在游戏中,请先退出游戏再进行操作。');", false);
                return;
            }
            #endregion
            //3.2、检测代理商帐号是否在游戏中
            #region 检测代理商帐号是否在游戏中
            if (m.IsInRoomOrGame(agent.UserName))
            {
                CommonManager.Web.RegJs(this, "alert('代理商帐号正在游戏中,本次兑换不能进行,请稍后尝试。');", false);
                return;
            }
            #endregion
            //3.3、开始转账
            #region 开始转账
            //3.3.1、计算实际到账金币,读取配置文件中的手续费方式
            string type = xo.GetNodeValue("Type");
            //3.3.2、计算手续费
            int profee = type == "0" ? int.Parse(xo.GetNodeValue("StaticValue")) : (int)((float)money * (float.Parse(xo.GetNodeValue("PercentValue")) / 100));
            //3.3.3、计算实际到账金币
            int amoney = money - profee;


            //3.3.4、转帐
            //if( m.BankTransfer( UserLoginInfo.UserName, agent.UserName, amoney, CommonManager.Web.GetIP() ) )
            //{
            //    //3.4、记录转帐日志
            //    Web_AgentMoneyLog log = new Web_AgentMoneyLog();
            //    log.ActuallyMoney = amoney;
            //    log.AgentID = agent.ID;
            //    log.InputDate = DateTime.Now;
            //    log.Money = money;
            //    log.ProcedureFee = profee;
            //    log.UserID = int.Parse( UserLoginInfo.UserID );
            //    DbSession.Default.Save<Web_AgentMoneyLog>( log );
            //    //4、提示信息,转向日志记录页面
            //    CommonManager.Web.RegJs( this, "alert('兑换成功!');location.href='ExchangeMoneyLog.aspx';", false );
            //}
            //else
            //{
            //    //4、提示信息
            //    CommonManager.Web.RegJs( this, "alert('兑换失败,可能是网络原因,请稍后尝试。');", false );
            //}
            #endregion
        }
Esempio n. 22
0
        //如果收到机器人指令,发给track
        private void parserRobotMsg(String msg)
        {
            if (null == msg)
            {
                return;
            }
            // string xmlString = "<?xml version=\"1.0\" encoding=\"UTF - 8\"?><snd ts=\"xxxx\" rts=\"xxxx\"><lon n=\"123\"/></snd>";
            XmlOperator xmlOperator = new XmlOperator(msg);

            string[] command = xmlOperator.GetFirstChildNodeByTagName("snd");
            //for (int i = 0; i < command.Length; i++)
            //{
            //    if (command[i] != null)
            //        Console.WriteLine("{0}={1}", i, command[i]);
            //}

            try
            {
                if (command[0] == "elsr")
                {
                    startTrackerClient();
                    label10.Text = "断开";
                    laserstatus  = 0;
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'e';
                    toRobot[23] = (byte)'l';
                    toRobot[24] = (byte)'s';
                    toRobot[25] = (byte)'r';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                    // Console.WriteLine(ts);
                }
                else if (command[0] == "lon")
                {
                    trackerOpenLaser();
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'l';
                    toRobot[23] = (byte)'o';
                    toRobot[24] = (byte)'n';
                    toRobot[25] = (byte)' ';
                    toRobot[26] = (byte)'r';
                    toRobot[27] = (byte)'=';
                    toRobot[28] = (byte)'"';
                    toRobot[29] = (byte)'1';
                    toRobot[30] = (byte)'"';
                    toRobot[31] = (byte)'/';
                    toRobot[32] = (byte)'>';
                    toRobot[33] = (byte)'<';
                    toRobot[34] = (byte)'/';
                    toRobot[35] = (byte)'r';
                    toRobot[36] = (byte)'e';
                    toRobot[37] = (byte)'p';
                    toRobot[38] = (byte)'>';
                    sendMsg(robotStream, toRobot, 39);
                }
                else if (command[0] == "selj")
                {
                    trackerSetMode(Convert.ToInt32(command[1]));
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'s';
                    toRobot[23] = (byte)'e';
                    toRobot[24] = (byte)'l';
                    toRobot[25] = (byte)'j';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                }
                else if (command[0] == "btrk")
                {
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'b';
                    toRobot[23] = (byte)'t';
                    toRobot[24] = (byte)'r';
                    toRobot[25] = (byte)'k';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                }
                else if (command[0] == "gcp")
                {
                    Console.WriteLine("gcp");
                    trackerGetStatus();
                    Console.WriteLine("444444444");
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();

                    char[] str_x   = x_finlly.ToCharArray();   //推荐
                    char[] str_z   = z_finlly.ToCharArray();   //推荐
                    char[] str_gap = gap_finlly.ToCharArray(); //推荐
                    Console.WriteLine("5555555");
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'g';
                    toRobot[23] = (byte)'c';
                    toRobot[24] = (byte)'p';

                    toRobot[25] = (byte)' ';
                    toRobot[26] = (byte)'r';
                    toRobot[27] = (byte)'=';
                    toRobot[28] = (byte)'"';
                    toRobot[29] = (byte)'1';
                    toRobot[30] = (byte)'"';
                    toRobot[31] = (byte)'/';
                    toRobot[32] = (byte)'>';

                    toRobot[33] = (byte)'<';
                    toRobot[34] = (byte)'t';
                    toRobot[35] = (byte)'p';
                    toRobot[36] = (byte)' ';

                    toRobot[37] = (byte)'x';
                    toRobot[38] = (byte)'=';
                    toRobot[39] = (byte)'"';
                    toRobot[40] = (byte)str_x[0];
                    toRobot[41] = (byte)str_x[1];
                    toRobot[42] = (byte)str_x[2];
                    toRobot[43] = (byte)str_x[3];
                    toRobot[44] = (byte)str_x[4];
                    toRobot[45] = (byte)str_x[5];
                    toRobot[46] = (byte)'"';
                    toRobot[47] = (byte)' ';

                    toRobot[48] = (byte)'y';
                    toRobot[49] = (byte)'=';
                    toRobot[50] = (byte)'"';
                    toRobot[51] = (byte)'0';
                    toRobot[52] = (byte)'0';
                    toRobot[53] = (byte)'0';
                    toRobot[54] = (byte)'.';
                    toRobot[55] = (byte)'0';
                    toRobot[56] = (byte)'0';
                    toRobot[57] = (byte)'"';
                    toRobot[58] = (byte)' ';

                    toRobot[59] = (byte)'z';
                    toRobot[60] = (byte)'=';
                    toRobot[61] = (byte)'"';
                    toRobot[62] = (byte)str_z[0];
                    toRobot[63] = (byte)str_z[1];
                    toRobot[64] = (byte)str_z[2];
                    toRobot[65] = (byte)str_z[3];
                    toRobot[66] = (byte)str_z[4];
                    toRobot[67] = (byte)str_z[5];
                    toRobot[68] = (byte)'"';
                    toRobot[69] = (byte)' ';

                    toRobot[70] = (byte)'a';
                    toRobot[71] = (byte)'=';
                    toRobot[72] = (byte)'"';
                    toRobot[73] = (byte)'0';
                    toRobot[74] = (byte)'0';
                    toRobot[75] = (byte)'0';
                    toRobot[76] = (byte)'.';
                    toRobot[77] = (byte)'0';
                    toRobot[78] = (byte)'0';
                    toRobot[79] = (byte)'"';
                    toRobot[80] = (byte)' ';

                    toRobot[81] = (byte)'b';
                    toRobot[82] = (byte)'=';
                    toRobot[83] = (byte)'"';
                    toRobot[84] = (byte)'0';
                    toRobot[85] = (byte)'0';
                    toRobot[86] = (byte)'0';
                    toRobot[87] = (byte)'.';
                    toRobot[88] = (byte)'0';
                    toRobot[89] = (byte)'0';
                    toRobot[90] = (byte)'"';
                    toRobot[91] = (byte)' ';

                    toRobot[92]  = (byte)'c';
                    toRobot[93]  = (byte)'=';
                    toRobot[94]  = (byte)'"';
                    toRobot[95]  = (byte)'0';
                    toRobot[96]  = (byte)'0';
                    toRobot[97]  = (byte)'0';
                    toRobot[98]  = (byte)'.';
                    toRobot[99]  = (byte)'0';
                    toRobot[100] = (byte)'0';
                    toRobot[101] = (byte)'"';
                    toRobot[102] = (byte)' ';

                    toRobot[103] = (byte)'/';
                    toRobot[104] = (byte)'>';
                    toRobot[105] = (byte)'<';
                    toRobot[106] = (byte)'g';
                    toRobot[107] = (byte)'p';
                    toRobot[108] = (byte)' ';
                    toRobot[109] = (byte)'a';
                    toRobot[110] = (byte)'r';
                    toRobot[111] = (byte)'e';
                    toRobot[112] = (byte)'a';
                    toRobot[113] = (byte)'=';
                    toRobot[114] = (byte)'"';
                    toRobot[115] = (byte)'0';
                    toRobot[116] = (byte)'0';
                    toRobot[117] = (byte)'0';
                    toRobot[118] = (byte)'.';
                    toRobot[119] = (byte)'0';
                    toRobot[120] = (byte)'0';
                    toRobot[121] = (byte)'"';
                    toRobot[122] = (byte)' ';

                    toRobot[123] = (byte)'g';
                    toRobot[124] = (byte)'a';
                    toRobot[125] = (byte)'p';
                    toRobot[126] = (byte)'=';
                    toRobot[127] = (byte)'"';
                    toRobot[128] = (byte)str_gap[0];
                    toRobot[129] = (byte)str_gap[1];
                    toRobot[130] = (byte)str_gap[2];
                    toRobot[131] = (byte)str_gap[3];
                    toRobot[132] = (byte)str_gap[4];
                    toRobot[133] = (byte)str_gap[5];
                    toRobot[134] = (byte)'"';
                    toRobot[135] = (byte)' ';

                    toRobot[136] = (byte)'m';
                    toRobot[137] = (byte)'i';
                    toRobot[138] = (byte)'s';
                    toRobot[139] = (byte)'m';
                    toRobot[140] = (byte)'=';
                    toRobot[141] = (byte)'"';
                    toRobot[142] = (byte)'0';
                    toRobot[143] = (byte)'0';
                    toRobot[144] = (byte)'0';
                    toRobot[145] = (byte)'.';
                    toRobot[146] = (byte)'0';
                    toRobot[147] = (byte)'0';
                    toRobot[148] = (byte)'"';
                    toRobot[149] = (byte)'/';
                    toRobot[150] = (byte)'>';



                    toRobot[151] = (byte)'<';
                    toRobot[152] = (byte)'/';
                    toRobot[153] = (byte)'g';
                    toRobot[154] = (byte)'c';
                    toRobot[155] = (byte)'p';
                    toRobot[156] = (byte)'>';

                    toRobot[157] = (byte)'<';
                    toRobot[158] = (byte)'/';
                    toRobot[159] = (byte)'r';
                    toRobot[160] = (byte)'e';
                    toRobot[161] = (byte)'p';
                    toRobot[162] = (byte)'>';

                    sendMsg(robotStream, toRobot, 163);
                    Console.WriteLine("66666666666");
                }
                else if (command[0] == "etrk")
                {
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'e';
                    toRobot[23] = (byte)'t';
                    toRobot[24] = (byte)'r';
                    toRobot[25] = (byte)'k';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                }
                else if (command[0] == "loff")
                {
                    trackerCLoseLaser();
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'l';
                    toRobot[23] = (byte)'o';
                    toRobot[24] = (byte)'f';
                    toRobot[25] = (byte)'f';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                }
                else if (command[0] == "dlsr")
                {
                    stopTrackerClient();
                    label10.Text = "连接";
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'d';
                    toRobot[23] = (byte)'l';
                    toRobot[24] = (byte)'s';
                    toRobot[25] = (byte)'r';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';
                    toRobot[32] = (byte)'/';
                    toRobot[33] = (byte)'>';
                    toRobot[34] = (byte)'<';
                    toRobot[35] = (byte)'/';
                    toRobot[36] = (byte)'r';
                    toRobot[37] = (byte)'e';
                    toRobot[38] = (byte)'p';
                    toRobot[39] = (byte)'>';
                    sendMsg(robotStream, toRobot, 40);
                }
                else if (command[0] == "ere")
                {
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();
                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';
                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'e';
                    toRobot[23] = (byte)'r';
                    toRobot[24] = (byte)'e';
                    toRobot[25] = (byte)' ';
                    toRobot[26] = (byte)'r';
                    toRobot[27] = (byte)'=';
                    toRobot[28] = (byte)'"';
                    toRobot[29] = (byte)'1';
                    toRobot[30] = (byte)'"';
                    toRobot[31] = (byte)'/';
                    toRobot[32] = (byte)'>';
                    toRobot[33] = (byte)'<';
                    toRobot[34] = (byte)'/';
                    toRobot[35] = (byte)'r';
                    toRobot[36] = (byte)'e';
                    toRobot[37] = (byte)'p';
                    toRobot[38] = (byte)'>';
                    sendMsg(robotStream, toRobot, 39);
                }
                else if (command[0] == "gets")
                {
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts              = (int)tr;
                    string str             = ts.ToString();
                    char[] st              = str.ToCharArray();
                    char[] str_pokou       = pokou.ToString().PadLeft(3, '0').ToCharArray();//推荐
                    char[] str_laserOn     = (laserOn.ToString()).ToCharArray();
                    char[] str_laserstatus = (laserstatus.ToString()).ToCharArray();


                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';

                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'g';
                    toRobot[23] = (byte)'e';
                    toRobot[24] = (byte)'t';
                    toRobot[25] = (byte)'s';
                    toRobot[26] = (byte)' ';
                    toRobot[27] = (byte)'r';
                    toRobot[28] = (byte)'=';
                    toRobot[29] = (byte)'"';
                    toRobot[30] = (byte)'1';
                    toRobot[31] = (byte)'"';

                    toRobot[32] = (byte)' ';
                    toRobot[33] = (byte)'s';
                    toRobot[34] = (byte)'t';
                    toRobot[35] = (byte)'a';
                    toRobot[36] = (byte)'t';
                    toRobot[37] = (byte)'u';
                    toRobot[38] = (byte)'s';

                    toRobot[39] = (byte)'=';
                    toRobot[40] = (byte)'"';
                    toRobot[41] = (byte)'1';
                    toRobot[42] = (byte)str_pokou[0];
                    toRobot[43] = (byte)str_pokou[1];
                    toRobot[44] = (byte)str_pokou[2];
                    toRobot[45] = (byte)str_laserOn[0];
                    toRobot[46] = (byte)str_laserstatus[0];
                    toRobot[47] = (byte)'"';
                    toRobot[48] = (byte)'/';
                    toRobot[49] = (byte)'>';
                    toRobot[50] = (byte)'<';
                    toRobot[51] = (byte)'/';
                    toRobot[52] = (byte)'r';
                    toRobot[53] = (byte)'e';
                    toRobot[54] = (byte)'p';
                    toRobot[55] = (byte)'>';
                    sendMsg(robotStream, toRobot, 56);
                }
                else if (command[0] == "ack")
                {
                    TimeSpan t1 = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    double   tr = t1.TotalSeconds;
                    // string[] str = new string[10];
                    int    ts  = (int)tr;
                    string str = ts.ToString();
                    char[] st  = str.ToCharArray();

                    toRobot[0]  = (byte)'<';
                    toRobot[1]  = (byte)'r';
                    toRobot[2]  = (byte)'e';
                    toRobot[3]  = (byte)'p';
                    toRobot[4]  = (byte)' ';
                    toRobot[5]  = (byte)'t';
                    toRobot[6]  = (byte)'s';
                    toRobot[7]  = (byte)'=';
                    toRobot[8]  = (byte)'"';
                    toRobot[9]  = (byte)st[0];
                    toRobot[10] = (byte)st[1];
                    toRobot[11] = (byte)st[2];
                    toRobot[12] = (byte)st[3];
                    toRobot[13] = (byte)st[4];
                    toRobot[14] = (byte)st[5];
                    toRobot[15] = (byte)st[6];
                    toRobot[16] = (byte)st[7];
                    toRobot[17] = (byte)st[8];
                    toRobot[18] = (byte)st[9];
                    toRobot[19] = (byte)'"';
                    toRobot[20] = (byte)'>';

                    toRobot[21] = (byte)'<';
                    toRobot[22] = (byte)'a';
                    toRobot[23] = (byte)'c';
                    toRobot[24] = (byte)'k';
                    toRobot[25] = (byte)' ';
                    toRobot[26] = (byte)'r';
                    toRobot[27] = (byte)'=';
                    toRobot[28] = (byte)'"';
                    toRobot[29] = (byte)'1';
                    toRobot[30] = (byte)'"';
                    toRobot[31] = (byte)'/';
                    toRobot[32] = (byte)'>';
                    toRobot[33] = (byte)'<';
                    toRobot[34] = (byte)'/';
                    toRobot[35] = (byte)'r';
                    toRobot[36] = (byte)'e';
                    toRobot[37] = (byte)'p';
                    toRobot[38] = (byte)'>';
                    sendMsg(robotStream, toRobot, 39);
                }
            }


            catch (Exception e)
            {
                showErrorMessage("Paser Robot Message fail:" + e.ToString());
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 取任务列表
        /// </summary>
        /// <returns></returns>
        private List <TaskModel> GetTaskListOfURL()
        {
            List <TaskModel> tasks = XmlOperator.GetXmlTaskList();

            return(tasks);
        }
Esempio n. 24
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!CommonManager.Web.CheckPostSource())
                return;
            if (!IsValid)
                return;

            //0���������
            #region �������
            //��ȡ�����ļ�
            XmlOperator xo = new XmlOperator(_filePath);
            if (!xo.HasDocument)
            {
                CommonManager.Web.RegJs(this, "alert('��������δ��ͨ�����Ժ��ٳ��Խ����ҳ��');history.back();", false);
                return;
            }
            if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('���������ĵ�ǰ���룡');", false);
                return;
            }
            TUsers user = DbSession.Default.Get<TUsers>(TUsers._.UserID == UserLoginInfo.UserID);
            if (user.Pass != CommonManager.String.EncryptMD5SystemDefaultMethod(txtPassword.Text.Trim(), false, true))
            {
                CommonManager.Web.RegJs(this, "alert('����������벻��ȷ�����������롣');", false);
                return;
            }
            if (string.IsNullOrEmpty(txtAgent.Text.Trim()) || string.IsNullOrEmpty(txtAgent2.Text.Trim()) || txtAgent.Text.Trim() != txtAgent2.Text.Trim())
            {
                CommonManager.Web.RegJs(this, "alert('����ȷ����������ʺ�');", false);
                return;
            }
            else if (!DbSession.Default.Exists<Web_Agent>(Web_Agent._.LoginName == txtAgent.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('�������ʺŲ����ڣ������º˶ԣ�');", false);
                return;
            }
            if (string.IsNullOrEmpty(txtMoney.Text.Trim()) || !CommonManager.String.IsInteger(txtMoney.Text.Trim()))
            {
                CommonManager.Web.RegJs(this, "alert('����ȷ����Ҫת�ʵĽ�ң�');", false);
                return;
            }
            #endregion
            //1������û�����Ľ��
            #region ����û�����Ľ��
            int money = int.Parse(txtMoney.Text.Trim());
            BLL.Member m = new BLL.Member();
            Int64 bmoney = m.GetBankMoney(user.UserID.ToString());
            if (money > bmoney)
            {
                CommonManager.Web.RegJs(this, "alert('�������н�����ֻ��" + bmoney.ToString() == "0" ? "0" : bmoney.ToString() + UiCommon.StringConfig.AddZero() + "�����������롣');", false);
                return;
            }
            int minmoney = int.Parse(xo.GetNodeValue("MinMoney"));
            if (money <= minmoney)
            {
                CommonManager.Web.RegJs(this, "alert('ÿ�ζһ���������������" + minmoney.ToString() + "00��');", false);
                return;
            }
            #endregion
            //2��ȡ�ô�������Ϸ�ʻ�
            #region ȡ�ô�������Ϸ�ʻ�
            Web_VAgentUserInfo agent = DbSession.Default.Get<Web_VAgentUserInfo>(Web_VAgentUserInfo._.LoginName == txtAgent.Text.Trim());
            if (agent == null)
            {
                CommonManager.Web.RegJs(this, "alert('�������ʺŲ����ڣ������º˶ԣ�');", false);
                return;
            }
            #endregion
            //3��ת��
            //3.1���������ʺ��Ƿ�����Ϸ��
            #region �������ʺ��Ƿ�����Ϸ��
            if (m.IsInRoomOrGame(UserLoginInfo.UserName))
            {
                CommonManager.Web.RegJs(this, "alert('�����ʺ�������Ϸ�У������˳���Ϸ�ٽ��в�����');", false);
                return;
            }
            #endregion
            //3.2�����������ʺ��Ƿ�����Ϸ��
            #region ���������ʺ��Ƿ�����Ϸ��
            if (m.IsInRoomOrGame(agent.UserName))
            {
                CommonManager.Web.RegJs(this, "alert('�������ʺ�������Ϸ�У����ζһ����ܽ��У����Ժ��ԡ�');", false);
                return;
            }
            #endregion
            //3.3����ʼת��
            #region ��ʼת��
            //3.3.1������ʵ�ʵ��˽�ң���ȡ�����ļ��е������ѷ�ʽ
            string type = xo.GetNodeValue("Type");
            //3.3.2������������
            int profee = type == "0" ? int.Parse(xo.GetNodeValue("StaticValue")) : (int)((float)money * (float.Parse(xo.GetNodeValue("PercentValue")) / 100));
            //3.3.3������ʵ�ʵ��˽��
            int amoney = money - profee;

            //3.3.4��ת��
            //if( m.BankTransfer( UserLoginInfo.UserName, agent.UserName, amoney, CommonManager.Web.GetIP() ) )
            //{
            //    //3.4����¼ת����־
            //    Web_AgentMoneyLog log = new Web_AgentMoneyLog();
            //    log.ActuallyMoney = amoney;
            //    log.AgentID = agent.ID;
            //    log.InputDate = DateTime.Now;
            //    log.Money = money;
            //    log.ProcedureFee = profee;
            //    log.UserID = int.Parse( UserLoginInfo.UserID );
            //    DbSession.Default.Save<Web_AgentMoneyLog>( log );
            //    //4����ʾ��Ϣ��ת����־��¼ҳ��
            //    CommonManager.Web.RegJs( this, "alert('�һ��ɹ���');location.href='ExchangeMoneyLog.aspx';", false );
            //}
            //else
            //{
            //    //4����ʾ��Ϣ
            //    CommonManager.Web.RegJs( this, "alert('�һ�ʧ�ܣ�����������ԭ�����Ժ��ԡ�');", false );
            //}
            #endregion
        }
Esempio n. 25
0
 protected void Page_Load(object sender, EventArgs e)
 {
     //��ȡ�����ļ�����ʼ��ҳ��
     XmlOperator xo = new XmlOperator(_filePath);
     if (!xo.HasDocument)
     {
         CommonManager.Web.RegJs(this, "alert('��������δ��ͨ�����Ժ��ٳ��Խ����ҳ��');history.back();", false);
         return;
     }
     MinMoney = xo.GetNodeValue("MinMoney");
     ChangeType = xo.GetNodeValue("Type") == "0" ? "�̶���" : "�ٷֱ�";
     ProcedureFee = xo.GetNodeValue("Type") == "0" ? xo.GetNodeValue("StaticValue") : "(���׶��" + xo.GetNodeValue("PercentValue") + "%)";
 }