示例#1
0
        /// <summary>
        /// 采集器----GetXiti
        /// </summary>
        public static string GetXitiResult(bool bClear = false)
        {
            Log.Debug("GetXitiResult()_1 ");
            string ret = "";

            if (Global.isHDPassive())
            {
                Log.Info("GetXitiResult()_2 ");
                string url       = Global.url_recv;
                string url_param = "action=xiti.get";
                url_param += "&classid=0";
                url_param += "&courseid=0";
                url_param += "&lessonid=0";
                if (bClear)
                {
                    Thread thread = new Thread(delegate()
                    {
                        ret = HTTPReq.HttpGet(url + url_param);
                        Log.Info("HD_Async_Xiti: " + url + url_param + ", ret=" + ret);
                    });
                    thread.Start();
                }
                else
                {
                    string json = HTTPReq.HttpGet(url + url_param);
                    Log.Info("HD_Xiti_Passive: " + url + url_param + ", json=" + json);

                    CBInfo cb = JsonOper.DeserializeJsonToObject <CBInfo>(json.Replace("(", "").Replace(")", ""));
                    if (cb != null && cb.data.Length > 0)
                    {
                        string data = cb.data;

                        for (int i = 0; i < data.Split('|').Length - 1; i++)
                        {
                            int    num    = Convert.ToInt16(data.Split('|')[i].Split(':')[0].ToString().Replace("-", ""));
                            string answer = data.Split('|')[i].Split(':')[1];
                            //57A299E5,A;57A299E5,B;57A299E6,C;57A299E6,D;57A299E6,S
                            string[]           szKey  = answer.Split(';');
                            SortedSet <string> keySet = new SortedSet <string>();
                            for (int k = 0; k < szKey.Length; k++)
                            {
                                string _answer = szKey[k].Split(',')[1];
                                if (_answer == "S")
                                {
                                    continue;
                                }
                                if (!keySet.Contains(_answer))
                                {
                                    keySet.Add(_answer);
                                }
                            }
                            string keys = "";
                            foreach (string key in keySet)
                            {
                                keys += key;
                            }
                            if (keys.Length == 0)
                            {
                                continue;
                            }
                            string context = num + ":" + keys;
                            ret += (ret.Length > 0 ? "|" : "") + context;
                        }
                    }
                }
            }
            else
            {
                if (bClear)
                {
                    Log.Debug("GetXitiResult()_2, Clear...");
                    string data = Httpd.ClearMQ_Xiti();
                    if (data.Length > 0)
                    {
                        Common.uploadInvalidXitiResult(data);
                    }
                }
                else
                {
                    Log.Debug("GetXitiResult()_3_1, Pop...");
                    ret = Httpd.PopMQ_Xiti();
                    Log.Debug("GetXitiResult()_3_2, Pop..." + ret);
                }
            }
            return(ret);
        }