예제 #1
0
 protected void Application_Start(object sender, EventArgs e)
 {
     SessionManager.StartManager();
     MessageCodeManager.SMSCodeManager();    //管理验证码
     WebProc.Init();
     RDSConfig.Init();
     PageLicense.Init();
 }
예제 #2
0
        private DataTable GetUserCars(string sysflag, string uid)
        {
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@uid", uid) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_App_GetUserCars"), Parameters).Tables[0];

            return(dt);
        }
예제 #3
0
        private DataTable GetAppAlarmAlert(string sysflag, string cid, string uid, DateTime st, DateTime et)
        {
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@cid", cid), new SqlParameter("@uid", uid),
                                          new SqlParameter("@st",  st),  new SqlParameter("@et",  et) };
            DataTable      dt = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_App_GetAppAlarmAlert"), Parameters).Tables[0];

            return(dt);
        }
예제 #4
0
        public ResponseAppResult AppGetCarStatues(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }


            try
            {
                string sysflag = inparams["sysflag"];

                long    cid = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                monitor mon = new monitor();
                WebGIS.RealtimeDataServer.CarRealData[] RealData = mon.CarRealDataByCids(WebProc.GetAppSysflagKey(sysflag), new long[] { cid });
                if (RealData.Length > 0)
                {
                    alarmcarstatuesalarm wd = new alarmcarstatuesalarm();
                    wd.cid          = RealData[0].Carid.ToString();
                    wd.lat          = RealData[0].Lati.ToString();
                    wd.longt        = RealData[0].Long.ToString();
                    wd.onlinestatus = RealData[0].OnlineStatus.ToString();
                    wd.tdatetime    = RealData[0].TDateTime.ToString("yyyy-MM-dd HH:mm:ss");
                    wd.tno          = RealData[0].TNO.ToString();


                    if (RealData[0].sPositionAdditionalInfo != null)
                    {
                        wd = analyzeStatues(wd, RealData[0].sPositionAdditionalInfo);

                        Result = new ResponseAppResult(ResState.Success, "操作成功", wd);
                    }
                    else
                    {
                        SendOrderHander.Send_CTS_TermSearchRequest(WebProc.GetAppSysflagKey(sysflag), "", cid, long.Parse(wd.tno));
                        Result = new ResponseAppResult(ResState.Success, "操作失败,无车辆状态数据!", null);
                    }
                }

                else
                {
                    Result = new ResponseAppResult(ResState.Success, "操作失败,车辆不在线!", null);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppGetCarLastTrack调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #5
0
        private long GetCarCIDBySimCode(string sysflag, string sim)
        {
            long         cid = long.Parse(sim);
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@SIMCode", sim) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_App_GetCidBySimcode"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                cid = long.Parse(dt.Rows[0]["CID"].ToString());
            }
            return(cid);
        }
예제 #6
0
        private long GetCidByTno(string sysflag, string tno)
        {
            long         cid = -1;
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@tno", tno) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWCProc_LT_GetCidByTno"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                cid = long.Parse(dt.Rows[0]["cid"].ToString());
            }
            return(cid);
        }
예제 #7
0
        private string GetCarCarno(string sysflag, string cid)
        {
            string       carno = "";
            ComSqlHelper csh   = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@cid", cid) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_SC_GetTnoByCid"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                carno = dt.Rows[0]["carno"].ToString();
            }
            return(carno);
        }
예제 #8
0
        private string GetCarSIMCode(string sysflag, string cid)
        {
            string       simcode = "";
            ComSqlHelper csh     = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@cid", cid) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWCProc_LC_GetSimTnoByCid"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                simcode = dt.Rows[0]["SimCode"].ToString();
            }
            return(simcode);
        }
예제 #9
0
        private long GetCarCID(string sysflag, string carno)
        {
            long         cid = -1;
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@carno", carno), new SqlParameter("@lpc", "") };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QSProc_Car_SelectByCno"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                cid = long.Parse(dt.Rows[0]["CID"].ToString());
            }
            return(cid);
        }
예제 #10
0
        private long GetCarTNO(string sysflag, string cid)
        {
            long         tno = 0;
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@cid", cid) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_SC_GetTnoByCid"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                tno = long.Parse(dt.Rows[0]["tno"].ToString());
            }
            return(tno);
        }
예제 #11
0
        public ResponseAppResult AppGetAppAlarmAlert(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("st") || inparams["st"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少st或st为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("et") || inparams["et"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少et或et为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("uid") || inparams["uid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少uid或uid为空!", null);
                return(Result);
            }
            try
            {
                string    sysflag = inparams["sysflag"];
                long      uid     = long.Parse(inparams["uid"]);
                long      cid     = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                DateTime  st      = DateTime.Parse(inparams["st"]);
                DateTime  et      = DateTime.Parse(inparams["et"]);
                DataTable dt      = GetAppAlarmAlert(WebProc.GetAppSysflagKey(sysflag), cid.ToString(), uid.ToString(), st, et);

                ResList res = new ResList();
                res.isallresults = 1;
                res.records      = dt;
                res.total        = dt.Rows.Count;
                res.size         = 0;
                res.page         = 0;

                Result = new ResponseAppResult(ResState.Success, "操作成功", res);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppGetCarLastTrack调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #12
0
        public ResponseAppResult AppGetOBDDriverResult(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }


            try
            {
                string         sysflag = inparams["sysflag"];
                long           cid     = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                AlertorResolve ar      = new AlertorResolve();
                RDSConfigModel rc      = RDSConfig.GetRDS(WebProc.GetAppSysflagKey(sysflag));
                RealtimeDataServer.WCFServiceClient df = new RealtimeDataServer.WCFServiceClient();
                df.Endpoint.Address = new System.ServiceModel.EndpointAddress(rc.WCFUrl);
                RealtimeDataServer.CarTransmissionProtocolInfo ctf = df.GetCarTransData(WebProc.GetAppSysflagKey(sysflag), cid);
                byte[] spai = null;

                if (ctf != null && ctf.TransData != null && ctf.TransData.ContainsKey(0x0FC8))
                {
                    spai = ctf.TransData[0x0FC8];// date[0].TransmissionProtocolInfo;
                    List <OBDDriver> res = ar.analyzeOBDDriver(spai);

                    Result = new ResponseAppResult(ResState.Success, "操作成功", res);
                }

                else
                {
                    Result = new ResponseAppResult(ResState.RetryAfter, "未收到ODB行车数据,请稍候重试!", "");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppGetOBDDriverResult调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #13
0
        public DataTable GetTracksFromDB(string sysflag, string cid, string st, string et)
        {
            try
            {
                ComSqlHelper   csh = new ComSqlHelper();
                SqlParameter[] oaPara;
                //参数构建
                oaPara    = new SqlParameter[3];
                oaPara[0] = new SqlParameter("@cid", cid);
                oaPara[1] = new SqlParameter("@BEGINTime", st);
                oaPara[2] = new SqlParameter("@ENDTime", et);

                DataTable dt = new DataTable();
                return(csh.FillDataSet(sysflag, WebProc.Proc("QWGProc_App_StoryTrack"), oaPara).Tables[0]);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        private carinfo GetCarCID(string sysflag, string carno)
        {
            carinfo      ci  = new carinfo();
            long         cid = -1;
            ComSqlHelper csh = new ComSqlHelper();

            SqlParameter[] Parameters = { new SqlParameter("@carno", carno) };
            DataTable      dt         = csh.FillDataSet(WebProc.GetAppSysflagKey(sysflag), WebProc.Proc("QWGProc_App_GetCarInfoByCarno"), Parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                ci.cid   = long.Parse(dt.Rows[0]["CID"].ToString());
                ci.carno = dt.Rows[0]["CarNo"].ToString();
                ci.owner = dt.Rows[0]["CarOwnName"].ToString();
            }
            else
            {
                return(null);
            }
            return(ci);
        }
예제 #15
0
        public ResponseAppResult AppVINUpload(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("vins") || inparams["vins"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少vins或vins为空!", null);
                return(Result);
            }

            try
            {
                string       sysflag    = inparams["sysflag"];
                string       cid        = inparams["cid"];
                string       vins       = inparams["vins"];
                string       uploaddate = inparams["uploaddate"];
                string[]     rtarray    = vins.Split(',');
                ComSqlHelper csh        = new ComSqlHelper();

                foreach (string vin in rtarray)
                {
                    SqlParameter[] Parameters2 = { new SqlParameter("@cid", cid)
                                                   ,                        new SqlParameter("@vin", vin)
                                                   ,                        new SqlParameter("@uploaddate", uploaddate) };
                    csh.ExecuteSPNoQuery(sysflag, WebProc.Proc("QWGProc_App_ExtVINUpload"), Parameters2, false);
                }
                Result = new ResponseAppResult(ResState.Success, "操作成功", null);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppVINUpload调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #16
0
        /// <summary>
        /// 用户退出系统时记录日志到数据库
        /// </summary>
        /// <param name="sm"></param>
        private static void logoutForDb(SessionModel sm)
        {
            string key = sm.sysflag;
            string uid = sm.uid.ToString();

            string ip       = sm.userIP;
            string usertype = "";

            if (sm.onecaruser) //单车用户
            {
                usertype = "0";
            }
            else//系统用户
            {
                usertype = "1";
            }
            SqlParameter[] ParametersLogout = new SqlParameter[3];
            ParametersLogout[0] = new SqlParameter("@UserType", usertype);
            ParametersLogout[1] = new SqlParameter("@UserIP", ip);
            ParametersLogout[2] = new SqlParameter("@userID", uid);
            csh.ExecuteSPNoQuery(key, WebProc.Proc("QWGProc_M_InsertCancelLogin"), ParametersLogout, false);
        }
예제 #17
0
        public ResponseAppResult AlarmGetCarTrack(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("st") || inparams["st"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少st或st为空!", null);
                return(Result);
            }
            if (!inparams.Keys.Contains("et") || inparams["et"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少et或et!", null);
                return(Result);
            }

            try
            {
                string sysflag = inparams["sysflag"];

                long   cid = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                string st  = inparams["st"];
                string et  = inparams["et"];


                DataTable dt = GetTracksFromDB(WebProc.GetAppSysflagKey(sysflag), cid.ToString(), st, et);

                List <alarmcartrack> tracks = new List <alarmcartrack>();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    alarmcartrack vv = new alarmcartrack();
                    double        sp = double.Parse(dt.Rows[i]["T_Speed"].ToString());


                    //经纬度纠偏
                    double[] s = CarDataConvert.ConvertCoordToGCJ02(double.Parse(dt.Rows[i]["T_Long"].ToString()), double.Parse(dt.Rows[i]["T_Lati"].ToString()));

                    vv.lng = (int)(Math.Round(s[0], 8) * 1000000);
                    vv.lat = (int)(Math.Round(s[1], 8) * 1000000);
                    vv.sp  = (int)sp * 10;
                    vv.dt  = (int)(DateTime.Parse(dt.Rows[i]["T_DateTime"].ToString()) - DateTime.Parse("1970-01-01 00:00:00")).TotalSeconds;
                    tracks.Add(vv);
                }
                ResList res = new ResList();
                res.isallresults = 1;
                res.records      = tracks.ToArray();
                res.total        = tracks.Count;
                res.size         = 0;
                res.page         = 0;

                Result = new ResponseAppResult(ResState.Success, "操作成功", res);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AlarmGetCarTrack调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #18
0
        public void ProcessRequest(HttpContext context)
        {
            SessionModel sm         = new SessionModel();
            string       token      = "";
            string       sid        = "";
            string       sysuid     = "0";
            string       sysflag    = "";
            string       onecaruser = "******";

            SysService.LogModel logmodel = new SysService.LogModel();
            //写入操作日志
            sys_log           slog   = new sys_log();
            ResponseAppResult Result = null;

            context.Response.ContentType = "text/plain";
            try
            {
                Dictionary <string, string> inparams = GetParams(context);
                if (inparams == null || inparams.Count == 0)
                {
                    Result = new ResponseAppResult(ResState.ParamsImperfect, "参数错误!格式为JSON格式数据,详见服务接口文档。", null);
                }
                else
                {
                    if (BaseParamsCheck(inparams, out Result))
                    {
                        if (inparams.ContainsKey("sysflag"))
                        {
                            inparams["sysflag"] = WebProc.GetAppSysflagKey(inparams["sysflag"]);
                            sysflag             = inparams["sysflag"];
                        }
                        sid              = inparams["sid"];
                        sysuid           = inparams.Keys.Contains(sysuid) ? inparams["sysuid"] : "0";
                        logmodel.LogType = (int)SysService.LogType.LogTypeEnum.AppWebService;
                        AlarmProess ap    = new AlarmProess();
                        AppProess   app   = new AppProess();
                        AppvdProess appvd = new AppvdProess();
                        ExtYQWL     ey    = new ExtYQWL();
                        switch (sid)
                        {
                            #region APP基本公共接口
                        case "app-car-getallonline":
                            Result = app.AppGetAllOnline(inparams);
                            break;

                        case "app-user-register":
                            Result = app.AppUserRegister(inparams);
                            break;

                        case "app-user-smscheckcode":           //获取短信验证码
                            Result = app.AppSMSCode(inparams);
                            break;

                        case "app-user-login":
                            Result = app.AppUserLogin(inparams);
                            break;

                        case "app-user-login2":
                            Result = app.AppUserLogin2(inparams);
                            break;

                        case "app-user-changepwd":
                            Result = app.AppUserChangePwd(inparams);
                            break;

                        case "app-car-bind":
                            Result = app.AppUserCarBind(inparams);      //用户车辆绑定
                            break;

                        case "app-user-update":
                            Result = app.AppUserUpdate(inparams);
                            break;

                        case "app-car-usercars":
                            Result = app.AppGetUserCars(inparams);
                            break;

                        case "app-car-seachusercars":
                            Result = app.AppSeachUserCars(inparams);        //获取车辆列表
                            break;

                        case "app-car-unwrap":
                            Result = app.AppUnwrapUserCars(inparams);
                            break;

                        case "app-car-lasttrack":
                            Result = app.AppGetCarLastTrack(inparams);
                            break;

                        case "app-car-track":
                            Result = app.AppGetCarTrack(inparams);
                            break;

                        case "app-user-resetpwd":            //重置密码
                            Result = app.AppUserResetPwd(inparams);
                            break;

                        case "app-car-seachforpages":            //用户车辆检索 带分页
                            Result = app.AppSeachForPages(inparams);
                            break;

                        case "app-car-onlinecount":            //用户车辆在线状态统计
                            Result = app.AppCarOnlineCount(inparams);
                            break;

                            #endregion
                            #region 报警器专用接口
                        case "alarm-car-track":
                            Result = ap.AlarmGetCarTrack(inparams);
                            break;

                        case "alarm-car-find":
                            Result = ap.AppSendFindCar(inparams);
                            break;

                        case "alarm-car-status":
                            Result = ap.AppGetCarStatues(inparams);
                            break;

                        case "alarm-car-remotecontrol":
                            Result = ap.AppSendControl(inparams);
                            break;

                        case "alarm-car-alertview":
                            Result = ap.AppGetAppAlarmAlert(inparams);
                            break;

                        case "alarm-obd-sendobddiagn":
                            Result = ap.AppSendOBDDiagn(inparams);
                            break;

                        case "alarm-obd-sendobddriver":
                            Result = ap.AppSendOBDDriver(inparams);
                            break;

                        case "alarm-obd-getobddiagn":
                            Result = ap.AppGetOBDDiagnResult(inparams);
                            break;

                        case "alarm-obd-getobddriver":
                            Result = ap.AppGetOBDDriverResult(inparams);
                            break;

                            #endregion
                            #region 外部专用接口
                        case "ext-yqwl-vinupload":
                            Result = ey.AppVINUpload(inparams);
                            break;

                        case "ext-yqwl-carowner":
                            Result = ey.AppGetCarInfoByCarno(inparams);
                            break;

                            #endregion
                            #region APP应用端接口
                        case "appvd-user-register":         //用户注册
                            Result = appvd.AppvdUserRegister(inparams);
                            break;

                        case "appvd-user-login":            //用户登录
                            Result = appvd.AppUserLogin(inparams);
                            break;

                        case "appvd-user-update":           //用户修改信息
                            Result = appvd.AppvdUserUpdate(inparams);
                            break;

                        case "appvd-apk-version":            //获取APK指定版本
                            Result = appvd.AppvdGetApkVersion(inparams);
                            break;
                            #endregion
                        }
                    }
                    else
                    {
                        Result = new ResponseAppResult(ResState.ParamsImperfect, "参数错误!参数不完整,详见服务接口文档。", null);
                    }
                    Result.sid  = inparams.Keys.Contains("sid") ? inparams["sid"] : "";
                    Result.sequ = inparams.Keys.Contains("sequ") ? inparams["sequ"] : "";
                    //定位监控定时取最新轨迹不记录日志,因操作太频繁
                    if (sid != "" && !sid.Equals("alarm-car-lasttrack") && sysflag != "")
                    {
                        logmodel.SysFlag = sysflag;
                        logmodel.SysName = "AppService";
                        logmodel.UserId  = Int32.Parse(sysuid);
                        if ((ResState)Result.state == ResState.Success)
                        {
                            logmodel.LogResult  = "成功";
                            logmodel.LogContent = "操作成功";
                        }
                        else
                        {
                            logmodel.LogResult  = "失败";
                            logmodel.LogContent = ((ResState)Result.state).ToString() + "-" + Result.msg;
                        }
                        logmodel.OneCarUser = onecaruser;
                        slog.WriteSysLog(logmodel);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("执行异常:", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, "");

                //logmodel.LogContent = LogType.GetEnumName(LogType.LogTypeEnum.excepetion) + ex.Message;
                if (!string.IsNullOrEmpty(sysuid))
                {
                    logmodel.UserId = Int32.Parse(sysuid);
                }
                else
                {
                    logmodel.UserId = -1;
                }
                logmodel.SysFlag    = sysflag;
                logmodel.SysName    = "WebGISAppService";
                logmodel.LogContent = ((ResState)Result.state).ToString() + "-" + ex.Message;
                logmodel.LogResult  = "失败";
                logmodel.OneCarUser = onecaruser;
                //slog.WriteSysLog(logmodel);
            }

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();

            timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
            Result.msg = Result.msg.Replace("\"", "");
            string strRes = JsonConvert.SerializeObject(Result, timeConverter);
            if (Result.state != 200)
            {
                LogHelper.WriteInfo("AppService Response:" + strRes);
            }
            context.Response.Write(strRes.Replace("null", "\"\""));
        }
예제 #19
0
        public ResponseAppResult AppSendOBDDriver(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }


            try
            {
                string  sysflag = inparams["sysflag"];
                monitor mon     = new monitor();
                long    cid     = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                WebGIS.RealtimeDataServer.CarRealData[] RealData = mon.CarRealDataByCids(WebProc.GetAppSysflagKey(sysflag), new long[] { cid });
                if (RealData.Length > 0)
                {
                    if (RealData[0].OnlineStatus == 1 && RealData[0].sPositionAdditionalInfo != null && RealData[0].sPositionAdditionalInfo.Length > 0)
                    {
                        alarmcarstatuesalarm act = new alarmcarstatuesalarm();
                        act = analyzeStatues(act, RealData[0].sPositionAdditionalInfo);


                        KeyValuePair <int, int> accstates = (KeyValuePair <int, int>)act.carstatues.GetValue(13);
                        if (accstates.Value == 1)
                        {
                            long tno = GetCarTNO(WebProc.GetAppSysflagKey(sysflag), cid.ToString());

                            AlertorResolve ar   = new AlertorResolve();
                            byte[]         data = new byte[0];
                            bool           w    = SendOrderHander.Send_CTS_TransmissionProtocol(WebProc.GetAppSysflagKey(sysflag), "", cid, tno, 0x8fc8, data);
                            if (w)
                            {
                                Result = new ResponseAppResult(ResState.Success, "操作成功", "");
                            }
                            else
                            {
                                Result = new ResponseAppResult(ResState.OperationFailed, "操作失败,后台服务中断!", "");
                            }
                        }
                        else
                        {
                            Result = new ResponseAppResult(ResState.OperationFailed, "操作失败,请将钥匙置为ON档!", null);
                        }
                    }
                    else
                    {
                        Result = new ResponseAppResult(ResState.OperationFailed, "车辆已经离线,无法发送指令!", null);
                        return(Result);
                    }
                }
                else
                {
                    Result = new ResponseAppResult(ResState.OperationFailed, "车辆已经离线,无法发送指令!", null);
                    return(Result);
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppSendOBDDriver调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }
예제 #20
0
        public ResponseAppResult AppGetOBDDiagnResult(Dictionary <string, string> inparams)
        {
            ResponseAppResult Result = null;

            if (!inparams.Keys.Contains("cid") || inparams["cid"] == "")
            {
                Result = new ResponseAppResult(ResState.ParamsImperfect, "缺少cid或cid为空!", null);
                return(Result);
            }


            try
            {
                string         sysflag = inparams["sysflag"];
                long           cid     = GetCarCIDBySimCode(sysflag, inparams["cid"]);
                AlertorResolve ar      = new AlertorResolve();
                RDSConfigModel rc      = RDSConfig.GetRDS(WebProc.GetAppSysflagKey(sysflag));
                RealtimeDataServer.WCFServiceClient df = new RealtimeDataServer.WCFServiceClient();
                df.Endpoint.Address = new System.ServiceModel.EndpointAddress(rc.WCFUrl);
                RealtimeDataServer.CarTransmissionProtocolInfo ctf = df.GetCarTransData(WebProc.GetAppSysflagKey(sysflag), cid);
                byte[] spai = null;

                //OBDDiagn res = new OBDDiagn();
                //res.VIN = "aa12345678935";
                //res.NormalUnitCount = 2;
                //res.FaultyUnitList = new List<OBDDiagn.diagn>();
                //OBDDiagn.diagn rrr = new OBDDiagn.diagn();
                //rrr.FaultyCodes = "12412";
                //rrr.UnitCode = 0x5;
                //rrr.UnitName = "允许进入/启动";
                //rrr.AsmName = "车身系统";
                //res.FaultyUnitList.Add(rrr);
                //OBDDiagn.diagn rrr2 = new OBDDiagn.diagn();
                //rrr2.FaultyCodes = "27452";
                //rrr2.UnitCode = 0x16;
                //rrr2.UnitName = "方向盘";
                //rrr2.AsmName = "车身系统";
                //res.FaultyUnitList.Add(rrr2);
                //res.NormalUnitList = new List<OBDDiagn.diagn>();
                //OBDDiagn.diagn rrr3 = new OBDDiagn.diagn();
                //rrr3.FaultyCodes = "00000";
                //rrr3.UnitCode = 0x1;
                //rrr3.UnitName = "发动机";
                //rrr3.AsmName = "动力总成系统";
                //res.NormalUnitList.Add(rrr3);
                //OBDDiagn.diagn rrr4 = new OBDDiagn.diagn();
                //rrr4.FaultyCodes = "00000";
                //rrr4.UnitCode = 0x3;
                //rrr3.AsmName = "底盘系统";
                // rrr4.UnitName = "ABS制动";
                //res.NormalUnitList.Add(rrr4);
                //Result = new ResponseAppResult(ResState.Success, "操作成功", res);


                if (ctf != null && ctf.TransData != null && ctf.TransData.ContainsKey(0x0FC7))
                {
                    spai = ctf.TransData[0x0FC7];// date[0].TransmissionProtocolInfo;
                    OBDDiagn res = ar.analyzeOBDDiagn(spai);
                    if (res != null)
                    {
                        Result = new ResponseAppResult(ResState.Success, "操作成功", res);
                    }
                    else
                    {
                        Result = new ResponseAppResult(ResState.RetryAfter, "未收到OBD诊断数据,请稍候重试!", "");
                    }
                }

                else
                {
                    Result = new ResponseAppResult(ResState.RetryAfter, "未收到OBD诊断数据,请稍候重试!", "");
                }
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("AppSendOBDDiagn调用异常", ex);
                Result = new ResponseAppResult(ResState.OperationFailed, ex.Message, null);
            }
            return(Result);
        }