예제 #1
0
        public bool loadNetPorxyFromTianLuServer(List <CNetProxy> netProxyList)
        {
            //
            string errorMessage            = string.Empty;
            string httpRequestErrorMessage = string.Empty;
            string netProxyContent         = string.Empty;
            string serverUrl = @"http://office.tianluweiye.com:8008/service/proxies?speed=10000&num=30";

            netProxyContent = CHttpRequest.GetHttpWebRequest(serverUrl, out errorMessage);
            if (netProxyContent == null)
            {
                errorMessage = string.Format("Load from server<{0}>,error message<{1}> faild.", serverUrl, httpRequestErrorMessage);
                return(false);
            }

            string afterConvert = CPublic.unicode_js_GBK(netProxyContent);
            JArray items        = JArray.Parse(afterConvert);

            if ((items == null) || (items.Count == 0))
            {
                errorMessage = string.Format("Convert to JObject faild, content<{0}>.", afterConvert);
                return(false);
            }

            return(parseNetProxyFromTianLu(netProxyList, items));
        }
예제 #2
0
        private string getSystemLogFile()
        {
            DateTime currentDate = DateTime.Now;

            return(string.Format("{0}/{1}/{2}.log",
                                 CPublic.getAppStartPath(),
                                 _LogStorePath,
                                 currentDate.ToString("yyyyMMdd")));
        }
예제 #3
0
        public bool loadNetProxyFromServer(List <CNetProxy> netProxyTable, out string errorMessage)
        {
            string       httpRequestErrorMessage = string.Empty;
            string       netProxyContent         = string.Empty;
            string       serverUrl = _SystemConfig.getConfigItem("NetProxyManagementServiceUrl").ToString();
            UTF8Encoding encoder   = new UTF8Encoding();

            if ((serverUrl == null) || (serverUrl == string.Empty))
            {
                errorMessage = string.Format("Not config<{0}>, please check it.", "NetProxyManagementServiceUrl");
                return(false);
            }

            netProxyContent = CHttpRequest.getHttpWebRequest(serverUrl, "func=QUERY_NO_BASE64", encoder, out httpRequestErrorMessage);
            if (netProxyContent == null)
            {
                errorMessage = string.Format("Load from server<{0}>,error message<{1}> faild.", serverUrl, httpRequestErrorMessage);
                return(false);
            }

            string  afterConvert = CPublic.unicode_js_GBK(netProxyContent);
            JObject jobject      = JObject.Parse(afterConvert);

            if (jobject == null)
            {
                errorMessage = string.Format("Convert to JObject faild, content<{0}>.", afterConvert);
                return(false);
            }

            int errorCode = jobject["error_code"].Value <int>();

            if (errorCode != 0)
            {
                errorMessage = string.Format("Load net proxy data from server<{0}> faild, error code<{1}>,error message<{2}>.", serverUrl,
                                             errorCode,
                                             jobject["message"].Value <string>());
                return(false);
            }

            errorMessage = "";

            return(parseNetProxyList(jobject["data"].ToArray <JToken>(), netProxyTable));
        }
예제 #4
0
        public List <CDbParameter> convert2DbParameterList()
        {
            //,,,
            List <CDbParameter> recordParameters = new List <CDbParameter>();
            CDbParameter        idParameter      = new CDbParameter()
            {
                ParameterName = ID, ParameterValue = Id
            };

            recordParameters.Add(idParameter);

            /*
             * " VALUES(@ID,@NAME,@HAS_CAMER,@RTSP_ADDRESS,"+
             * "@LAST_MODIFY_TIME,@DEVICE_TYPE,@DEVICE_STATE,@LONGITUDE,@LATITUDE,@ALTITUDE,@ORGANIZATION_CODE,@LAST_LOCATE_TIME,"+
             * "@LONGITUDE_DIRECTION,@LATITUDE_DIRECTION,@AVERAGE_SPEED,@IS_DELETED,@DESCRIPTION)";
             * */

            CDbParameter nameParameter = new CDbParameter()
            {
                ParameterName = NAME, ParameterValue = Name
            };

            recordParameters.Add(nameParameter);

            CDbParameter hasCameraParameter = new CDbParameter()
            {
                ParameterName = HAS_CAMER, ParameterValue = Convert.ToInt16(HasCamer)
            };

            recordParameters.Add(hasCameraParameter);

            CDbParameter rtspAddressParameter = new CDbParameter()
            {
                ParameterName = RTSP_ADDRESS, ParameterValue = RtspAddress
            };

            recordParameters.Add(rtspAddressParameter);

            CDbParameter lastModifyTimeParameter = new CDbParameter()
            {
                ParameterName = LAST_MODIFY_TIME, ParameterValue = CPublic.getDateTimeString(LastModifyTime)
            };

            recordParameters.Add(lastModifyTimeParameter);

            CDbParameter deviceTypeParameter = new CDbParameter()
            {
                ParameterName = DEVICE_TYPE, ParameterValue = (int)DeviceType
            };

            recordParameters.Add(deviceTypeParameter);

            CDbParameter deviceStateParameter = new CDbParameter()
            {
                ParameterName = DEVICE_STATE, ParameterValue = DeviceState
            };

            recordParameters.Add(deviceStateParameter);

            CDbParameter longitudeParameter = new CDbParameter()
            {
                ParameterName = LONGITUDE, ParameterValue = Longitude
            };

            recordParameters.Add(longitudeParameter);

            CDbParameter latitudeParameter = new CDbParameter()
            {
                ParameterName = LATITUDE, ParameterValue = Latitude
            };

            recordParameters.Add(latitudeParameter);

            CDbParameter altitudeParameter = new CDbParameter()
            {
                ParameterName = ALTITUDE, ParameterValue = Altitude
            };

            recordParameters.Add(altitudeParameter);

            CDbParameter organizationCodeParameter = new CDbParameter()
            {
                ParameterName = ORGANIZATION_CODE, ParameterValue = OrganizationCode
            };

            recordParameters.Add(organizationCodeParameter);

            CDbParameter lastLocateTimeParameter = new CDbParameter()
            {
                ParameterName = LAST_LOCATE_TIME, ParameterValue = LastLocateTime
            };

            recordParameters.Add(lastLocateTimeParameter);

            CDbParameter longitudeDirectionParameter = new CDbParameter()
            {
                ParameterName = LONGITUDE_DIRECTION, ParameterValue = LongitudeDirection
            };

            recordParameters.Add(longitudeDirectionParameter);

            CDbParameter latitudeDirectionParameter = new CDbParameter()
            {
                ParameterName = LATITUDE_DIRECTION, ParameterValue = LatitudeDirection
            };

            recordParameters.Add(latitudeDirectionParameter);

            CDbParameter averageSpeedParameter = new CDbParameter()
            {
                ParameterName = AVERAGE_SPEED, ParameterValue = AverageSpeed
            };

            recordParameters.Add(averageSpeedParameter);

            CDbParameter isDeletedParameter = new CDbParameter()
            {
                ParameterName = IS_DELETED, ParameterValue = Convert.ToInt16(IsDeleted)
            };

            recordParameters.Add(isDeletedParameter);

            CDbParameter descriptionParameter = new CDbParameter()
            {
                ParameterName = DESCRIPTION, ParameterValue = Description
            };

            recordParameters.Add(descriptionParameter);

            return(recordParameters);
        }
예제 #5
0
        static int Main(string[] args)
        {
            string message = string.Empty;

            _SystemConfig = new CSystemConfig();
            if (_SystemConfig.getErrorCode() != 0)
            {
                return(1);
            }

            E_ERROR_CODE errorCode = loadConfigData();

            if (errorCode != E_ERROR_CODE.OK)
            {
                return((int)errorCode);
            }

            _DbConnection = new CDbConnection(_DbConnectStr, _SystemLog);
            if (!_DbConnection.testConnect())
            {
                _SystemLog.disposeLogWriter();
                return((int)E_ERROR_CODE.ERROR_CONNECT_DB_FAILED);
            }

            initLocalVaribles();

            while (true)
            {
                _BeiDouDeviceManager.processBeiDevice();
                message = string.Format("Run cycle <{0}>, Next run time <{1}>....", _RequestCycle, CPublic.getDateTimeString(DateTime.Now.AddSeconds(_RequestCycle)));
                _SystemLog.writeLog(LOG_LEVEL.WARNING, message);
                Thread.Sleep(TimeSpan.FromSeconds(_RequestCycle));
            }
        }