Example #1
0
        public void HandleCarLocation(CarLocation cl)
        {
            try
            {
                //Save Database
                // DBCarLocation db = new DBCarLocation();
                //20160802 修改人:朱星汉 修改内容:速度字符串过长
                cl.SD = Math.Round((Decimal)cl.SD, 2);
                IDBCarLocation db = DataAccess.DataAccess.GetDBCarLocation();
                db.Add(cl);

                CarLocationManagerDelegateClient client = new CarLocationManagerDelegateClient();
                client.addCarLocationCompleted += new EventHandler <addCarLocationCompletedEventArgs>(Service_Completed);
                CredentialSoapHeader header = new CredentialSoapHeader();
                header.Username = SysParameters.AppAPIUsername;
                header.Password = SysParameters.AppAPIPassword;
                string strJson = ConvertModelToJson(cl);

                WebserviceUserState UserState = new WebserviceUserState();
                UserState.TIMES   = 1;
                UserState.MESSAGE = strJson;

                client.addCarLocationAsync(header, strJson, UserState);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("", ex);
            }
        }
Example #2
0
        /// <summary>
        /// 重发消息
        /// </summary>
        /// <param name="UserState"></param>
        private void ReSendCarLocation(WebserviceUserState UserState)
        {
            try
            {
                Thread.Sleep(SysParameters.APIErrorReSendInterval * 1000);

                string strJson = UserState.MESSAGE;

                CarLocationManagerDelegateClient client = new CarLocationManagerDelegateClient();
                client.addCarLocationCompleted += new EventHandler <addCarLocationCompletedEventArgs>(Service_Completed);
                CredentialSoapHeader header = new CredentialSoapHeader();
                header.Username = SysParameters.AppAPIUsername;
                header.Password = SysParameters.AppAPIPassword;

                client.addCarLocationAsync(header, strJson, UserState);
            }
            catch (Exception ex)
            {
                LogHelper.WriteLog("", ex);
            }
        }