コード例 #1
0
        int adnum = 0;                                  //广告的数量

        #endregion
        #region 广告及状态处理方法
        /// <summary>
        /// 取得广告列表
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public List <AdStruct> getAdList(string url, Dictionary <string, string> dic)
        {
            HttpBLL         httpbll = new HttpBLL();
            List <AdStruct> list    = new List <AdStruct>();

            string str = httpbll.GetResponseString(httpbll.CreatePostHttpResponse(url, dic));

            if (str != null)
            {
                JObject jo = JsonConvert.DeserializeObject <JObject>(str);


                if (jo["code"].ToString() == "200")
                {
                    var ja = jo["ad"];
                    foreach (var a in ja)
                    {
                        AdStruct adstruct = new AdStruct();
                        adstruct.adStopTime = int.Parse(a["adStopTime"].ToString());
                        adstruct.url        = a["adUrl"].ToString();
                        list.Add(adstruct);
                    }
                    return(list);
                }
                else
                {
                    return(list);
                }
            }
            else
            {
                return(list);
            }
        }
コード例 #2
0
        /// <summary>
        /// 得到打印信息新
        /// </summary>
        private List <detail_m> getPrintJobList()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", textBox1.Text);
            dic.Add("universityCode", ConfigurationManager.AppSettings["universityCode"]);
            dic.Add("universityId", textBox.Text);

            HttpBLL httpbll = new HttpBLL();
            JSONBLL jsonbll = new JSONBLL();
            JObject jo;
            //得到Json字符串
            string printstr = httpbll.GetResponseString(httpbll.CreatePostHttpResponse(ConfigurationManager.AppSettings["apply_detail"], dic));

            if (printstr != null)
            {
                jsonbll.jsonToJobject(printstr, out jo);//得到反序列化实例JObject

                if (jo["code"].ToString() == "200")
                {
                    Apply_m apply = new Apply_m();
                    apply = JsonConvert.DeserializeObject <Apply_m>(jo["apply"].ToString());//得到detail信息

                    //App.psta.studentName = apply.userName;

                    List <detail_m> printdetails = new List <detail_m>();

                    List <detail_m> printTypes = JsonConvert.DeserializeObject <List <detail_m> >(jo["detail"].ToString());//得到detail信息
                    return(printTypes);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// 列出本校的可打印类型
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private List <print_type_m> getPrintTypeList()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("universityCode", ConfigurationManager.AppSettings["universityCode"]);
            dic.Add("universityId", textBox.Text);
            List <print_type_m> printTypes = new List <print_type_m>();

            HttpBLL httpbll = new HttpBLL();
            JSONBLL jsonbll = new JSONBLL();
            JObject jo;

            string printstr = httpbll.GetResponseString(httpbll.CreatePostHttpResponse(ConfigurationManager.AppSettings["type_list"], dic));

            jsonbll.jsonToJobject(printstr, out jo);//得到反序列化实例JObject
            if (jo != null && jo["code"].ToString() == "200")
            {
                printTypes = JsonConvert.DeserializeObject <List <print_type_m> >(jo["types"].ToString());
            }

            return(printTypes);
        }
コード例 #4
0
        private void Button_Click_4(object sender, RoutedEventArgs e)
        {
            configbll.SaveConfig("remainPageNum", slider.Value.ToString());
            App.set = new Models.SettingModel();

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("code", ConfigurationManager.AppSettings["code"]);
            dic.Add("universityCode", ConfigurationManager.AppSettings["universityCode"]);
            dic.Add("printedPageNum", ConfigurationManager.AppSettings["printedPageNum"]);
            dic.Add("remainPageNum", ConfigurationManager.AppSettings["remainPageNum"]);

            HttpBLL httpbll = new HttpBLL();
            JSONBLL jsonbll = new JSONBLL();
            JObject jo;
            //得到Json字符串
            string printstr = httpbll.GetResponseString(httpbll.CreatePostHttpResponse(ConfigurationManager.AppSettings["updatePaperAddNum"], dic));

            if (printstr != null)
            {
                jsonbll.jsonToJobject(printstr, out jo);//得到反序列化实例JObject

                if (jo["code"].ToString() == "200")
                {
                    MessageBox.Show("当前打印机剩余纸张:" + ConfigurationManager.AppSettings["remainPageNum"], "纸张记录成功");
                }
                else
                {
                    MessageBox.Show(jo["code"].ToString() + ":" + jo["msg"].ToString(), "上传失败,请重试");
                }
            }
            else
            {
                MessageBox.Show("上传失败,请重试");
            }
        }
コード例 #5
0
        /// <summary>
        /// 状态检测方法
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void stadtimer_Tick(object sender, EventArgs e)
        {
            System.Net.NetworkInformation.Ping        p       = new System.Net.NetworkInformation.Ping();
            System.Net.NetworkInformation.PingOptions options = new System.Net.NetworkInformation.PingOptions();
            options.DontFragment = true;
            string data = "Test Data!";

            byte[] buffer  = Encoding.ASCII.GetBytes(data);
            int    timeout = 2000; // Timeout 时间,单位:毫秒

            //检查网络连接
            try
            {
                System.Net.NetworkInformation.PingReply reply = p.Send("baidu.com", timeout, buffer, options);
                if (reply.Status == System.Net.NetworkInformation.IPStatus.Success)
                {
                    stat.line          = true;
                    netLine.Text       = "网络已连接";
                    netLine.Foreground = Brushes.Green;
                }
                else
                {
                    stat.line          = false;
                    netLine.Text       = "网络连接已断开";
                    netLine.Foreground = Brushes.Red;
                }
            }
            catch
            {
                stat.line          = false;
                netLine.Text       = "网络异常,请联系管理员";
                netLine.Foreground = Brushes.Red;
            }

            if (stat.line == true)
            {
                //从网络获取机器状态
                HttpBLL httpbll = new HttpBLL();
                JSONBLL jsonbll = new JSONBLL();

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("id", ConfigurationManager.AppSettings["id"]);

                string str = httpbll.GetResponseString(httpbll.CreatePostHttpResponse(ConfigurationManager.AppSettings["machine"], dic));

                if (str != null)
                {
                    JObject jo = JsonConvert.DeserializeObject <JObject>(str);

                    if (jo["code"].ToString() == "200")
                    {
                        JObject jo1;
                        string  str1 = jo["machine"].ToString();
                        if (str1 != null)
                        {
                            jsonbll.jsonToJobject(str1, out jo1);
                            stat.stat = jo1["nowStatus"].ToString();
                        }
                        else
                        {
                            stat.stat = "查无此机,若要正常使用,请检查配置文件与服务器";
                        }
                    }
                    else
                    {
                        stat.stat = "意外错误,未能与服务器正常通信";
                    }
                }
                else
                {
                    stat.stat = "意外错误,通信失败";
                }
            }
            else
            {
                stat.stat = "连接失败";
            }

            pageRemain.Text = App.set.remainPageNum.ToString();

            try
            {
                PrintServer ps    = new PrintServer();
                PrintQueue  queue = ps.GetPrintQueue(ConfigurationManager.AppSettings["printer"]);
                printerStaTxt.Text = queue.QueueStatus.ToString();
                ps.Dispose();
                queue.Dispose();
            }
            catch
            {
                printerStaTxt.Text = "打印服务未启动";
            }
        }