示例#1
0
 private void ReadForData_EventHandler_1(object sender, DownEventArgs e)
 {
     try
     {
         CDownConf info = e.Value;
         //$60031G12000828
         string rawData = e.RawData;
         if (info == null)
         {
             return;
         }
         string stationid = rawData.Substring(1, 4);
         string type      = rawData.Substring(5, 4);
         string data      = rawData.Substring(9, 6);
         if (type == "1G12")
         {
             if (info.StorageWater.HasValue)
             {
                 if (readDataDic.ContainsKey(stationid))
                 {
                     readDataDic[stationid] = data;
                 }
                 readDataDic.Add(stationid, data);
             }
         }
     }
     catch (Exception exp) { Debug.WriteLine(exp.Message); }
 }
示例#2
0
        public void GetDtuList(int uID, string sID, string cmds, string gprsNum, bool isset)
        {
            try
            {
                DownRequest request = new DownRequest {
                    StationId = sID, Cmds = cmds, GprsNum = gprsNum, IsSet = isset
                };

                DownConf info = grpcClient.GetDownConf(request);

                downConfList = new CDictionary <int, DownConf>();

                if (info != null)
                {
                    if (downConfList.ContainsKey(uID))
                    {
                        downConfList[uID] = info;
                    }
                    else
                    {
                        downConfList.Add(uID, info);
                    }
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine("RPC failed" + exp);
                throw;
            }
        }
示例#3
0
        public void GetOLStatus(int uID, string subcenterId)
        {
            try
            {
                Subcenter sub = new Subcenter {
                    SubcenterdId = subcenterId
                };

                DtuList list = grpcClient.GetDtuList(sub);

                dtuList = new CDictionary <int, DtuList>();

                if (list != null)
                {
                    if (dtuList.ContainsKey(uID))
                    {
                        dtuList[uID] = list;
                    }
                    else
                    {
                        dtuList.Add(uID, list);
                    }
                }
            }
            catch (Exception exp)
            {
                Debug.WriteLine("RPC failed" + exp);
                throw;
            }
        }
示例#4
0
        private void ReadSDXml()
        {
            m_mapStationData     = new CDictionary <string, CEntityStation>();
            m_mapStationbeidouID = new CDictionary <string, string>();
            m_mapStationgprsID   = new CDictionary <string, string>();
            // 读取XML,初始化站点数据表
            List <CEntityStation> listSD = Deserialize();

            if (null == listSD)
            {
                return;
            }
            for (int i = 0; i < listSD.Count; ++i)
            {
                try
                {
                    if (!m_mapStationData.ContainsKey(listSD[i].StationID))
                    {
                        // 通知界面
                        m_mapStationData.Add(listSD[i].StationID, listSD[i]);
                        m_mapStationbeidouID.Add(listSD[i].StationID, listSD[i].BDSatellite);
                        m_mapStationgprsID.Add(listSD[i].StationID, listSD[i].GPRS);
                    }
                    else
                    {
                        // 位置站点,读取站点数据文件不匹配
                        System.Diagnostics.Debug.WriteLine(string.Format("站点数据中站点\"{0}\"已存在", listSD[i].StationID));
                    }
                }
                catch (Exception e)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("站点数据异常" + e));
                }
            }
        }
示例#5
0
 public static bool AddKeyUp(Keys key, KeyPressed callback)
 {
     if (!cdictionary_1.ContainsKey(key))
     {
         cdictionary_1.Add(key, callback);
         return(true);
     }
     return(false);
 }
示例#6
0
 public static bool AddKeyDown(Keys key, KeyPressed callback)
 {
     KeyDown = null;
     if (!cdictionary_0.ContainsKey(key))
     {
         cdictionary_0.Add(key, callback);
         return(true);
     }
     return(false);
 }
示例#7
0
 /// <summary>
 /// 添加一个键弹起的钩子处理
 /// </summary>
 /// <param name="key">弹起的键</param>
 /// <param name="callback">按键的处理事件函数</param>
 public static bool AddKeyUp(Keys key, KeyPressed callback)
 {
     if (!handledKeysUp.ContainsKey(key))
     {
         handledKeysUp.Add(key, callback);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#8
0
 /// <summary>
 /// 添加一个按下键的钩子处理
 /// </summary>
 /// <param name="key">按下的键</param>
 /// <param name="callback">按键的处理事件函数</param>
 public static bool AddKeyDown(Keys key, KeyPressed callback)
 {
     KeyDown = null;
     if (!handledKeysDown.ContainsKey(key))
     {
         handledKeysDown.Add(key, callback);
         return(true);
     }
     else
     {
         return(false);
     }
 }
 public void InitMap()
 {
     String[] rows = File.ReadAllLines("Config/map.txt");
     foreach (String row in rows)
     {
         String[] pieces = row.Split(',');
         if (pieces.Length == 2)
         {
             if (!HdProtocolMap.ContainsKey(pieces[0]))
             {
                 HdProtocolMap.Add(pieces[0], pieces[1]);
             }
             else
             {
                 HdProtocolMap[pieces[0]] = pieces[1];
             }
         }
     }
 }
示例#10
0
        private T DoExecute <T>(IRequest <T> request, string session, DateTime timestamp) where T : ResponseBase
        {
            long start = DateTime.Now.Ticks;

            // 提前检查业务参数
            try
            {
                request.Validate();
            }
            catch (CException e)
            {
                return(CreateErrorResponse <T>(e.ErrorCode, e.ErrorMsg));
            }

            CDictionary txtParams = new CDictionary(request.GetParameters());

            txtParams.Add(Constants.METHOD, request.GetApiName);
            InitParameters(txtParams);


            // 添加协议级请求参数
            //ACDictionary txtParams = new ACDictionary(request.GetParameters());
            //txtParams.Add(Constants.METHOD, request.GetApiName());
            //txtParams.Add(Constants.VERSION, "1.0");
            ////txtParams.Add(Constants.SIGN_METHOD, Constants.SIGN_METHOD_MD5);
            //txtParams.Add(Constants.APP_KEY, appKey);
            //txtParams.Add(Constants.FORMAT, format);
            //txtParams.Add(Constants.TIMESTAMP, timestamp);
            //txtParams.AddAll(this.systemParameters);


            //// 添加签名参数
            //txtParams.Add(Constants.SIGN, SignHelper.SignACRequest(txtParams, appSecret, Constants.SIGN_METHOD_MD5));

            // 添加头部参数
            if (this.useGzipEncoding)
            {
                request.GetHeaderParameters()[Constants.ACCEPT_ENCODING] = Constants.CONTENT_ENCODING_GZIP;
            }

            string realServerUrl = GetServerUrl(this.serverUrl, request.GetApiName, session);
            string reqUrl        = WebUtils.BuildRequestUrl(realServerUrl, txtParams);

            try
            {
                string body;
                if (request is IUploadRequest <T> ) // 是否需要上传文件
                {
                    IUploadRequest <T>             uRequest   = (IUploadRequest <T>)request;
                    IDictionary <string, FileItem> fileParams = SignHelper.CleanupDictionary(uRequest.GetFileParameters());
                    body = webUtils.DoPost(realServerUrl, txtParams, fileParams, request.GetHeaderParameters());
                }
                else
                {
                    body = webUtils.DoPost(realServerUrl, txtParams, request.GetHeaderParameters());
                }

                // 解释响应结果
                T rsp;
                if (disableParser)
                {
                    rsp = Activator.CreateInstance <T>();
                    rsp.ResponseBody = body;
                }
                else
                {
                    if (Constants.FORMAT_XML.Equals(format))
                    {
                        IParser <T> tp = new XmlParser <T>();
                        rsp = tp.Parse(body);
                    }
                    else
                    {
                        IParser <T> tp;
                        if (useSimplifyJson)
                        {
                            tp = new AcSimplifyJsonParser <T>();
                        }
                        else
                        {
                            tp = new JsonParser <T>();
                        }
                        rsp = tp.Parse(body);
                    }
                }

                // 追踪错误的请求
                if (!rsp.HaveError)
                {
                    TimeSpan latency = new TimeSpan(DateTime.Now.Ticks - start);
                    TraceApiError(AppKey, request.GetApiName, serverUrl, txtParams, latency.TotalMilliseconds, rsp.ResponseBody);
                }
                return(rsp);
            }
            catch (Exception e)
            {
                TimeSpan latency = new TimeSpan(DateTime.Now.Ticks - start);
                TraceApiError(AppKey, request.GetApiName, serverUrl, txtParams, latency.TotalMilliseconds, e.GetType() + ": " + e.Message);
                throw e;
            }
        }
示例#11
0
 public void Add(Key item)
 {
     m_This.Add(item, default);
 }