コード例 #1
0
        /// <summary>
        /// 得到新的CusMac地址,该数据需要返回给测试客户端
        /// </summary>
        /// <returns>获取下一个Cusmac地址</returns>
        public string GetCusMac(string StartMacCur, string EndMacCur)
        {
            string NewCusMac = "";

            // string MaxCusMaxCurrent = Help.SelectMaxCusMac();//获取信息表中最大的CusMac地址
            NewCusMac = Help.AddOne(StartMacCur, EndMacCur);
            return(NewCusMac);
        }
コード例 #2
0
        public void InsertTestInfoAndReturnData(string MesId, string EspMac, string BtMac, string ModuleVer, string TestResult, int Status, string LabelContent, string ModuleType)
        {
            /*  string url=HttpContext.Current.Request.Url.ToString();//完整url   url= http://www.test.com/aaa/bbb.aspx?id=5&name=kelli
             * string rawurl = HttpContext.Current.Request.RawUrl;//站点名+页名+参数 url= /aaa/bbb.aspx?id=5&name=kelli
             * string rawurl2 = HttpContext.Current.Request.Url.AbsolutePath;//站点名+页名  url=aaa/bbb.aspx
             * string urlHost = HttpContext.Current.Request.Url.Host;//域名   url=www.test.com
             * string urlParam = HttpContext.Current.Request.Url.Query;//参数   url=?id=5&name=kelli
             *
             *
             *
             * //HttpContext.Current.Request.ServerVariables.getParameter();
             * string strt = HttpContext.Current.Request.ServerVariables.AsParallel().ToString();
             * HttpContext.Current.Request.ServerVariables.Get("User_Agent");
             * string Clientstr = HttpContext.Current.Request.ServerVariables.Get("Http_Referer");
             * string ClientPath = HttpContext.Current.Request.ServerVariables.Get("Path_Info").ToString();
             * string ClientIp= HttpContext.Current.Request.ServerVariables.Get("Remote_Addr").ToString();
             * string ClentHost=HttpContext.Current.Request.ServerVariables.Get("Remote_Host").ToString();
             * string ClientBrowser= HttpContext.Current.Request.Browser.Browser.ToString();
             *
             * //string str= HttpContext.Current.Request.UserAgent.ToString();
             * string str = HttpContext.Current.Request.ServerVariables.ToString();
             * string str2= HttpContext.Current.User.Identity.Name.ToString();
             * string str3= HttpContext.Current.Trace.ToString();
             * string str4= HttpContext.Current.Timestamp.ToString();
             * // string str5=HttpContext.Current.Session.ToString();
             * string str6= HttpContext.Current.ApplicationInstance.Context.Request.RequestContext.HttpContext.Request.RequestContext.RouteData.Values.Count.ToString();
             * //HttpSessionStateBase sessionStateBase= HttpSessionStateBase.ReferenceEquals.Session;
             * string ip=HttpContext.Current.Request.UserHostAddress;//获取ip地址
             * try
             * {
             *    Stream s = HttpContext.Current.Request.InputStream;//获取json字符流
             *    //还原数据流
             *    byte[] b = new byte[s.Length];
             *    s.Read(b,0,(int)s.Length);
             *    string jsontext = Encoding.UTF8.GetString(b);
             * }
             * catch
             * {
             *
             * }
             */


            //HttpContext.Current.Request.
            // HttpHelp httpHelp = new HttpHelp();
            // httpHelp.Listen();
            //string message = httpHelp.GetReciveData();
            // this.label1.Text = "客户端数据:" + message;
            // this.label2.Text = "客户端IP:" + httpHelp.GetIp();
            //this.label3.Text = "客户端IP:" + httpHelp.GetConnObj();
            //this.label4.Text = "客户端IP:" + httpHelp.GetExMessage();
            //this.label6.Text = "标志信息:" + httpHelp.GetFlag();
            // this.label6.Text = "标志信息:";



            //string ClientData=DealJsonData.GetJsonStr(message);
            //this.Label1.Text ="转换为Json"+ ClientData;
            // httpHelp.GetInfomation();
            /* //string url = "http://192.168.0.87:8088/Web/TestJson.aspx";*/
            //  MESXPT_ModuleMiscInfo mESXPT_ModuleMiscInfo = DealJsonData.AnalysisJsonStr(url);

            /* string MesId = HttpContext.Current.Request.Form["MesId"];
             * string EspMac = HttpContext.Current.Request.Form["EspMac"];
             * string BtMac = HttpContext.Current.Request.Form["BtMac"];
             * string ModuleVer = HttpContext.Current.Request.Form["ModuleVer"];
             * string TestResult = HttpContext.Current.Request.Form["TestResult"];
             * int Status = 1;
             * string LabelContent = HttpContext.Current.Request.Form["LabelContent"];
             * string ModuleType = HttpContext.Current.Request.Form["ModuleType"];*/
            string OperationTime = DateTime.Now.ToString();


            /*string MesId = "MesID";
             * string EspMac = "espmac";
             * string BtMac = "btMac";
             * string ModuleVer = "Ver";
             * string TestResult = "成功";
             * int Status = 1;
             * string LabelContent = "05065656";
             * string ModuleType = "WIFI";
             * string OperationTime = DateTime.Now.ToString();*/

            //按时间排序获取最近的起始地址和终止地址
            string StartMacEndMac = Help.GetCurrentStartMacAndEndMac();
            string StartMacCur    = StartMacEndMac.Split(',')[0];
            string EndMacCur      = StartMacEndMac.Split(',')[1];
            //GetCusMac(StartMacCur);
            // 每次请求从最近的的起始地址开始加“1”分配,当累计到大于终止地址时表示mac资源分配结束
            //同时把数据插入数据库
            string NextCusMac = Help.AddOne(StartMacCur, EndMacCur);//新的CusMac地址

            if (NextCusMac == "" || NextCusMac == null || NextCusMac == "资源已经使用完毕")
            {
                error.c = 3;
                // error.m = "资源已经使用完毕";
                error.m = "The resource has been used";
                flag    = true;
                //this.Label1.Text = "获取下一个新的NextCusMac地址失败,原因是资源已经使用完毕,请重新输入新的起始地址和终止地址进行分配新的资源!!";
                return;
            }

            if (NextCusMac == "生成新的CusMac地址异常")
            {
                flag    = true;
                error.c = 2;
                //  error.m = "生成新的CusMac地址时产生异常请联系服务端!!";
                error.m = "When generating a new cusmac address, please contact the administrator!!";
                // this.Label1.Text = "获取下一个新的NextCusMac地址失败,原因是分配时出现异常,请联系管理员!!";
                return;
            }
            if (Help.Vidate(NextCusMac))
            {
                NextCusMac = Help.AddOne(NextCusMac, EndMacCur);
                // Help.FindMaxCusMac();

                //return;
            }

            string nowCusMac = Help.FindMaxCusMac();


            if (Help.IsNewStartMacAndEndMac)
            {
                string StartMacAndEndMac = Help.GetCurrentStartMacAndEndMac();
                nowCusMac = StartMacAndEndMac.Split(',')[0];
                EndMacCur = StartMacAndEndMac.Split(',')[1];
                Help.IsNewStartMacAndEndMac = false;
            }
            int compare = Help.MacAddrCompare(nowCusMac, EndMacCur);

            if (compare > 0 || compare == 0)
            {
                error.c = 1;
                // error.m = "资源使用完毕,请重联系服务端!!";
                error.m = "Cusmac address assignment failed, please contact the administrator !! ";
                flag    = true;
                //.flag.Text = "资源已经分配结束,请请重新输入起始地址和终止地址添加!!!!!!!!!!,将给烧录端返回null";
                //Response.Write(null);
                return;
            }

            string[] newNexCusMac = NextCusMac.Split(':');
            NextCusMac = newNexCusMac[0] + newNexCusMac[1] + newNexCusMac[2] + newNexCusMac[3] + newNexCusMac[4] + newNexCusMac[5];

            if (Help.InsertInfoTable(NextCusMac, MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
            {
                error.c = 0;
                // error.m = "正常,分配新的CusMac地址成功!!";
                error.m = "Normal, assign new cusmac address successfully!! ";
                // this.Label1.Text = "已向信息表插入一条新的数据(包含测试结果,新生成CusMac地址)可用的CusMac地址为:" + NextCusMac;
            }


            // HttpUtils.Post(url, CusMac, "");//发送Json字符串

            /* if (StartMac != "" && EndMac != "")
             * {
             *   if (MacAddrCompare(StartMac, EndMac) > 0)//起始地址大于终止地址不符合要求
             *   {
             *       this.labflag.Text = "起始地址大于终止地址,向信息插入数据出错";
             *       return;
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)==0)//起始地址等于终止地址时向信息表添加一条数据
             *   {
             *       if(Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *       {
             *           this.labflag.Text = "起始地址等于终止地址,向信息表插入一条数据";
             *       }
             *
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)<0)
             *   {
             *       while(StartMac!=EndMac)
             *       {
             *           string CusMac = GetCusCode();
             *
             *           if (Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *           {
             *               this.labflag.Text = "起始地址小于终止地址,信息表添加多条数据"; ;
             *           }
             *           if (MacAddrCompare(CusMac, EndMac) == 0) break;//临界条件表示
             *
             *
             *       }
             *
             *   }
             *
             *
             * }*/
        }
コード例 #3
0
        /// <summary>
        /// 插入数据表MESXPT_ModuleMiscInfo(综合测试信息表),收到测试端请求后解析数据、生成新的CusMac地址,并把新的CusMac地址和请求信息插入到数据库
        /// </summary>
        /// <param name="StartMac"></param>
        /// <param name="EndMac"></param>
        public void InsertMESXPT_ModuleMiscInfo()
        {
            /* string url = "http://192.168.0.87:8088/Web/TestJson.aspx";
             * MESXPT_ModuleMiscInfo mESXPT_ModuleMiscInfo = DealJsonData.AnalysisJsonStr(url);
             * string MesId = mESXPT_ModuleMiscInfo.MesId1;
             * string EspMac = mESXPT_ModuleMiscInfo.EspMac1;
             * string BtMac = mESXPT_ModuleMiscInfo.EspMac1;
             * string ModuleVer = mESXPT_ModuleMiscInfo.ModuleVer1;
             * string TestResult = mESXPT_ModuleMiscInfo.TestResult1;
             * int Status = mESXPT_ModuleMiscInfo.Status1;
             * string LabelContent = mESXPT_ModuleMiscInfo.LabelContent1;
             * string ModuleType = mESXPT_ModuleMiscInfo.ModuleType1;
             * string OperationTime = DateTime.Now.ToString();*/
            string MesId         = "MesID";
            string EspMac        = "espmac";
            string BtMac         = "btMac";
            string ModuleVer     = "Ver";
            string TestResult    = "成功";
            int    Status        = 1;
            string LabelContent  = "05065656";
            string ModuleType    = "WIFI";
            string OperationTime = DateTime.Now.ToString();

            //按时间排序获取最近的起始地址和终止地址
            string StartMacEndMac = Help.GetCurrentStartMacAndEndMac();
            string StartMacCur    = StartMacEndMac.Split(',')[0];
            string EndMacCur      = StartMacEndMac.Split(',')[1];
            //GetCusMac(StartMacCur);
            // 每次请求从最近的的起始地址开始加“1”分配,当累计到大于终止地址时表示mac资源分配结束
            //同时把数据插入数据库
            string NextCusMac = Help.AddOne(StartMacCur, EndMacCur);//新的CusMac地址

            if (NextCusMac == "" || NextCusMac == null || NextCusMac == "资源已经使用完毕")
            {
                //this.labflag.Text = "获取下一个新的NextCusMac地址失败,原因是资源已经使用完毕,请重新输入新的起始地址和终止地址进行分配新的资源!!";
                return;
            }

            if (NextCusMac == "生成新的CusMac地址异常")
            {
                // this.labflag.Text = "获取下一个新的NextCusMac地址失败,原因是分配时出现异常,请联系管理员!!";
                return;
            }
            if (Help.Vidate(NextCusMac))
            {
                //this.labflag.Text = "该新的CusMac地址已经被分配过!!,已经存在,请确认!!";
                NextCusMac = Help.AddOne(NextCusMac, EndMacCur);
                // Help.FindMaxCusMac();

                //return;
            }
            if (Help.InsertInfoTable(NextCusMac, MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
            {
                //this.labflag.Text = "已向信息表插入一条新的数据(包含测试结果,新生成CusMac地址)可用的CusMac地址为:" + NextCusMac;
            }
            string Json = JsonConvert.SerializeObject(NextCusMac);

            //this.TextBox1.Text = Json;
            // SendJons(Json);
            Response.Write(Json);

            /* if (StartMac != "" && EndMac != "")
             * {
             *   if (MacAddrCompare(StartMac, EndMac) > 0)//起始地址大于终止地址不符合要求
             *   {
             *       this.labflag.Text = "起始地址大于终止地址,向信息插入数据出错";
             *       return;
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)==0)//起始地址等于终止地址时向信息表添加一条数据
             *   {
             *       if(Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *       {
             *           this.labflag.Text = "起始地址等于终止地址,向信息表插入一条数据";
             *       }
             *
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)<0)
             *   {
             *       while(StartMac!=EndMac)
             *       {
             *           string CusMac = GetCusCode();
             *
             *           if (Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *           {
             *               this.labflag.Text = "起始地址小于终止地址,信息表添加多条数据"; ;
             *           }
             *           if (MacAddrCompare(CusMac, EndMac) == 0) break;//临界条件表示
             *
             *
             *       }
             *
             *   }
             *
             *
             * }*/
        }
コード例 #4
0
        /// <summary>
        /// 插入数据表MESXPT_ModuleMiscInfo(综合测试信息表),收到测试端请求后解析数据、生成新的CusMac地址,并把新的CusMac地址和请求信息插入到数据库
        /// </summary>

        //  private string url = HttpUtils.GetClientUrl();
        public void InsertMESXPT_ModuleMiscInfo()
        {
            HttpHelp httpHelp = new HttpHelp();

            httpHelp.Listen();
            string message = httpHelp.GetReciveData();

            this.Label1.Text = "客户端数据:" + message;
            this.Label2.Text = "客户端IP:" + httpHelp.GetIp();
            this.Label3.Text = "客户端IP:" + httpHelp.GetConnObj();
            this.Label4.Text = "客户端IP:" + httpHelp.GetExMessage();
            this.Label6.Text = "标志信息:" + httpHelp.GetFlag();
            //string ClientData=DealJsonData.GetJsonStr(message);
            //this.Label1.Text ="转换为Json"+ ClientData;
            // httpHelp.GetInfomation();

            /* //string url = "http://192.168.0.87:8088/Web/TestJson.aspx";
             * MESXPT_ModuleMiscInfo mESXPT_ModuleMiscInfo = DealJsonData.AnalysisJsonStr(url);
             * string MesId = mESXPT_ModuleMiscInfo.MesId1;
             * string EspMac = mESXPT_ModuleMiscInfo.EspMac1;
             * string BtMac = mESXPT_ModuleMiscInfo.EspMac1;
             * string ModuleVer = mESXPT_ModuleMiscInfo.ModuleVer1;
             * string TestResult = mESXPT_ModuleMiscInfo.TestResult1;
             * int Status = mESXPT_ModuleMiscInfo.Status1;
             * string LabelContent = mESXPT_ModuleMiscInfo.LabelContent1;
             * string ModuleType = mESXPT_ModuleMiscInfo.ModuleType1;
             * string OperationTime = DateTime.Now.ToString();*/
            string MesId         = "MesID";
            string EspMac        = "espmac";
            string BtMac         = "btMac";
            string ModuleVer     = "Ver";
            string TestResult    = "成功";
            int    Status        = 1;
            string LabelContent  = "05065656";
            string ModuleType    = "WIFI";
            string OperationTime = DateTime.Now.ToString();

            //按时间排序获取最近的起始地址和终止地址
            string StartMacEndMac = Help.GetCurrentStartMacAndEndMac();
            string StartMacCur    = StartMacEndMac.Split(',')[0];
            string EndMacCur      = StartMacEndMac.Split(',')[1];
            //GetCusMac(StartMacCur);
            // 每次请求从最近的的起始地址开始加“1”分配,当累计到大于终止地址时表示mac资源分配结束
            //同时把数据插入数据库
            string NextCusMac = Help.AddOne(StartMacCur, EndMacCur);//新的CusMac地址

            if (NextCusMac == "" || NextCusMac == null || NextCusMac == "资源已经使用完毕")
            {
                //this.Label1.Text = "获取下一个新的NextCusMac地址失败,原因是资源已经使用完毕,请重新输入新的起始地址和终止地址进行分配新的资源!!";
                return;
            }

            if (NextCusMac == "生成新的CusMac地址异常")
            {
                // this.Label1.Text = "获取下一个新的NextCusMac地址失败,原因是分配时出现异常,请联系管理员!!";
                return;
            }
            if (Help.Vidate(NextCusMac))
            {
                //this.Label1.Text = "该新的CusMac地址已经被分配过!!,已经存在,请确认!!";
                NextCusMac = Help.AddOne(NextCusMac, EndMacCur);
                // Help.FindMaxCusMac();

                //return;
            }

            string nowCusMac = Help.FindMaxCusMac();

            if (Help.MacAddrCompare(nowCusMac, EndMacCur) == 0)
            {
                this.flag.Text = "资源已经分配结束,请请重新输入起始地址和终止地址添加!!!!!!!!!!,将给烧录端返回null";
                Response.Write(null);
                return;
            }


            if (Help.InsertInfoTable(NextCusMac, MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
            {
                // this.Label1.Text = "已向信息表插入一条新的数据(包含测试结果,新生成CusMac地址)可用的CusMac地址为:" + NextCusMac;
            }

            string CusMac = Help.GetCurCusMacJson();//转换为Json

            this.flag.Text = "返回给烧录客户端的CusMac地址为" + CusMac;
            Response.Write(CusMac);//
            // HttpUtils.Post(url, CusMac, "");//发送Json字符串

            /* if (StartMac != "" && EndMac != "")
             * {
             *   if (MacAddrCompare(StartMac, EndMac) > 0)//起始地址大于终止地址不符合要求
             *   {
             *       this.labflag.Text = "起始地址大于终止地址,向信息插入数据出错";
             *       return;
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)==0)//起始地址等于终止地址时向信息表添加一条数据
             *   {
             *       if(Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *       {
             *           this.labflag.Text = "起始地址等于终止地址,向信息表插入一条数据";
             *       }
             *
             *   }
             *   else if(MacAddrCompare(StartMac, EndMac)<0)
             *   {
             *       while(StartMac!=EndMac)
             *       {
             *           string CusMac = GetCusCode();
             *
             *           if (Help.InsertInfoTable(GetCusCode(), MesId, EspMac, BtMac, ModuleVer, TestResult, Status, LabelContent, ModuleType, OperationTime))
             *           {
             *               this.labflag.Text = "起始地址小于终止地址,信息表添加多条数据"; ;
             *           }
             *           if (MacAddrCompare(CusMac, EndMac) == 0) break;//临界条件表示
             *
             *
             *       }
             *
             *   }
             *
             *
             * }*/
        }