Exemple #1
0
        public static string loadJsonStr(string url, string lang)
        {
            url = string.Format("{0}{1}", ConfigManagerService.GetInstance().LoadConfig().domain, url);
            HttpWebRequest request    = null;
            string         returnHtml = string.Empty;

            request           = (HttpWebRequest)WebRequest.Create(url);
            request.Method    = "GET";
            request.UserAgent = "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)";
            request.Accept    = "*/*";
            request.KeepAlive = true;
            request.Headers.Add("Accept-Language", string.Format("{0},;q=0.7,zh;q=0.3", lang));
            WebResponse  res           = null;
            Stream       receiveStream = null;
            StreamReader sr            = null;

            try
            {
                res           = request.GetResponse();
                receiveStream = res.GetResponseStream();
                Encoding encode = Encoding.UTF8;
                sr = new StreamReader(receiveStream, encode);
                char[] readbuffer = new char[256];
                int    n          = sr.Read(readbuffer, 0, 256);
                while (n > 0)
                {
                    string str = new string(readbuffer, 0, n);
                    returnHtml += str;
                    n           = sr.Read(readbuffer, 0, 256);
                }
            }
            catch
            {
                return(string.Empty);
            }
            finally
            {
                if (res != null)
                {
                    res.Close();
                }
                if (sr != null)
                {
                    sr.Dispose();
                }
                if (receiveStream != null)
                {
                    receiveStream.Dispose();
                }
            }
            return(returnHtml);
        }
Exemple #2
0
        /// <summary>
        /// 开始演示程序
        /// </summary>
        private void startDemo()
        {
            ConfigPara cpara = ConfigManagerService.GetInstance().LoadConfig();

            if (cpara == null || cpara.PlantsInfo.Count == 0 || cpara.TipsPlantsInfo.Count == 0)
            {
                MessageBoxResult mbResult;
                mbResult = MessageBox.Show("您尚未进行任何运行参数配置吗", "系统提示", MessageBoxButton.YesNo);
                if (mbResult.Equals(MessageBoxResult.Yes) == true)
                {
                    return;
                }
            }

            //启动电站详情页面程序
            startDetailExe();

            //启动页面播放控制中心
            cc = new ControlCenter();
            this.WindowState = WindowState.Minimized;
            cc.control();
        }
Exemple #3
0
        private static ControlCenter cc = null;   //控制中心单实例
        public ControlCenter()
        {
            try
            {
                pauseTime = DateTime.Now;
                isPause   = false;//是否中断标识
                //初始化页面记时数组
                pageCountDic.Add(PAGE_INDEX, 0);
                pageCountDic.Add(PAGE_DETAIL, 0);
                //页面播放时间设置
                pagePlaytimeDic.Add(PAGE_INDEX, int.Parse(ConfigManagerService.GetInstance().LoadConfig().MainInterval));

                hotPlants = ConfigManagerService.GetInstance().LoadConfig().TipsPlantsInfo;
                allPlants = ConfigManagerService.GetInstance().LoadConfig().PlantsInfo;
                //add by qhb in 20120116 for 添加对电站按照精度排序
                hotPlants = orderPlants(hotPlants, plantOrder);
                allPlants = orderPlants(allPlants, plantOrder);
                foreach (PlantInfoVo plantInfoVo in allPlants)
                {
                    plantmap.Add(plantInfoVo.plantId, plantInfoVo);
                }
                loadAcceptForm(this);

                //初始化页面
                loadHiddenMain();
                loadHiddenEarth();
                //休眠20s 用于地球加载
                if (loadearthTime == null)
                {
                    loadearthTime = "20";
                }
                Thread.Sleep(int.Parse(loadearthTime) * 1000);
            }
            catch (Exception ee) {
                LogUtil.error("ControlCenter error:" + ee.StackTrace);
            }
        }
Exemple #4
0
        /// <summary>
        /// 填充首页数据
        /// </summary>
        private void fixData()
        {
            TotalInfo total = new TotalInfo();

            try
            {
                ConfigPara cp = ConfigManagerService.GetInstance().LoadConfig();
                lblSysName.Content = cp.sysname;
                string root_url = cp.domain;
                string username = "";
                if (cp.CounterType == ConfigPara.currentUser)
                {
                    username = cp.CounterUser;
                }
                string json = JsonUtil.loadJsonStr(root_url + "/openapi/totalinfo?username="******"en-us");
                total = JsonUtil.Deserialize <TotalInfo>(json);
                if (total == null)
                {
                    return;
                }
            }
            catch (Exception ee)
            {
                Console.WriteLine(ee.StackTrace);
                return;
            }

            string[] items = config.displayItems.Split('|');
            int      index = 0;

            foreach (var item in items)
            {
                string data = string.Empty;
                string unit = string.Empty;
                if (string.IsNullOrEmpty(item))
                {
                    continue;
                }
                switch (item)//item 对应 configpara.displayItemsName 索引
                {
                case "0":
                    data = total.plantsCount.ToString();
                    unit = "";
                    break;

                case "1":
                    data = total.totalDayEnergy.ToString("0.00");
                    unit = total.totalDayEnergyUnit;
                    break;

                case "2":
                    data = total.totalEnergy.ToString("0.00");
                    unit = total.totalEnergyUnit;
                    break;

                case "3":
                    data = total.totalCO2Reduce.ToString("0.00");
                    unit = total.totalCO2ReduceUnit;
                    break;

                case "4":
                    unit = "rmb";
                    switch (config.currencyType)
                    {
                    case ConfigPara.MY:
                        unit = "my";
                        break;

                    case ConfigPara.LUBU:
                        unit = "lubu";
                        break;

                    case ConfigPara.HANYUAN:
                        unit = "hany";
                        break;

                    case ConfigPara.OUYUAN:
                        unit = "ouyuan";
                        break;

                    case ConfigPara.YBANG:
                        unit = "ybang";
                        break;

                    default:
                        break;
                    }
                    data = (total.totalEnergy * (double)config.incomeRate).ToString("0.00");
                    break;

                case "5":    //今日功率
                    data = total.totalTodayPower.ToString("0.00");
                    unit = total.totalTodayPowerUnit;
                    break;

                case "6":    //总装机容量
                    data = total.totalPower.ToString("0.00");
                    unit = total.totalPowerUnit;
                    break;

                case "7":
                    data = total.treeNum;
                    unit = "Ke";
                    break;
                }
                addDataImage(data, unit, index++, int.Parse(item), touchPad);
            }
            ////添置电站数量数据
            //addDataImage(total.plantsCount.ToString(), "", datatype_count, touchPad);
            ////添加电站日发电量
            //addDataImage(total.totalDayEnergy.ToString("0.00"), total.totalDayEnergyUnit, datatype_dayp, touchPad);
            ////添加电站总发电量
            //addDataImage(total.totalEnergy.ToString("0.00"), total.totalEnergyUnit, datatype_totalp, touchPad);
            ////添加电站co2减排
            //addDataImage(total.totalCO2Reduce.ToString("0.00"), total.totalCO2ReduceUnit, datatype_co2, touchPad);
            ////收益
            //string key = "rmb";
            //switch (config.currencyType)
            //{
            //    case ConfigPara.MY:
            //        key = "my";
            //        break;
            //    case ConfigPara.LUBU:
            //        key = "lubu";
            //        break;
            //    case ConfigPara.HANYUAN:
            //        key = "hany";
            //        break;
            //    case ConfigPara.OUYUAN:
            //        key = "ouyuan";
            //        break;
            //    case ConfigPara.YBANG:
            //        key = "ybang";
            //        break;
            //    default:
            //        break;

            //}
            //addDataImage((total.totalEnergy * (double)config.incomeRate).ToString("0.00"), key, datatype_income, touchPad);
        }