Esempio n. 1
0
        /// <summary>
        /// 支付订单检测
        /// </summary>
        /// <param name="context"></param>
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                DateTime begintime = DateTime.Now.Date;
                DateTime endtime   = begintime.AddHours(24);

                List <string> saasList = ConfigHelper.GetSaasList();
                foreach (string saas in saasList)
                {
                    try
                    {
                        MyWorkerRequest.CreateHttpContext(saas, "", "");

                        UserFinancialManager ufm = new UserFinancialManager();
                        UserInfoManager      uim = new UserInfoManager();
                        DataTable            dt  = ufm.GetUserFinancialList(null, begintime, endtime, Asiasofti.SmartVehicle.Common.Enum.UserFinancialState.NewSubmit, null);
                        foreach (DataRow dr in dt.Rows)
                        {
                            string  financial_id   = dr["ID"].ToString();
                            string  user_id        = dr["UserID"].ToString();
                            string  order_num      = dr["OrderNum"].ToString();
                            decimal changes_amount = 0.00m;
                            decimal.TryParse(dr["ChangesAmount"].ToString(), out changes_amount);
                            changes_amount = Math.Abs(changes_amount);
                            string order_payid  = dr["OrderPayID"].ToString();
                            string operator_way = dr["OperatorWay"].ToString();
                            string changes_type = dr["ChangesType"].ToString();
                            if (changes_type == UserFinancialChangesType.Deposit.GetHashCode().ToString())
                            {
                                DepositPay(user_id, financial_id, changes_amount, order_payid, operator_way);
                            }
                            else if (changes_type == UserFinancialChangesType.Recharge.GetHashCode().ToString())
                            {
                                RechargePay(user_id, financial_id, changes_amount, order_payid, operator_way);
                            }
                            else if (changes_type == UserFinancialChangesType.Consumption.GetHashCode().ToString())
                            {
                                OrderPay(user_id, financial_id, order_num, changes_amount, order_payid, operator_way);
                            }
                        }
                    }
                    catch
                    {
                        Logger.Info("支付订单检测任务(OrderPayQuery:" + saas + ")失败");
                    }
                }
            }
            catch
            {
                Logger.Info("支付订单检测任务(OrderPayQuery)失败");
            }
        }
Esempio n. 2
0
        //[HostType("ASP.NET")]
        //[UrlToTest("http://localhost/")]
        //[AspNetDevelopmentServerHost("E:\\WorkFiles\\Project\\GIT\\CMS\\Code\\CMS\\CMS.UnitTest", "/")]

        public void InitRequestTest()
        {
            Thread.GetDomain().SetData(".appPath", "E:\\WorkFiles\\Project\\GIT\\CMS\\Code\\CMS\\CMS.Web\\");
            Thread.GetDomain().SetData(".appVPath", "/");
            TextWriter        tw      = new StringWriter();
            String            address = "localhost";
            HttpWorkerRequest wr      = new MyWorkerRequest
                                            ("/", "", tw, address);

            HttpContext.Current = new HttpContext(wr);
            new RequestHelp().InitRequest(HttpContext.Current);
        }
Esempio n. 3
0
 public void Execute(IJobExecutionContext context)
 {
     try
     {
         int minutes = 10;
         int.TryParse(context.JobDetail.JobDataMap.Get("minutes").ToString(), out minutes);
         foreach (string saas in ConfigHelper.GetSaasList())
         {
             try
             {
                 MyWorkerRequest.CreateHttpContext(saas, "", "");
                 OrdersManager manager = new OrdersManager();
                 DataTable     dt      = manager.GetAwaitCancelOrder(minutes);
                 foreach (DataRow row in dt.Rows)
                 {
                     string ordernum = row["OrderNum"].ToString();
                     if (CancelOrder(ordernum, 1))
                     {
                         Logger.Info("超过" + minutes + "分钟自动取消订单成功, 订单号:" + ordernum + ",订单创建时间:" + row["CreateTime"].ToString());
                     }
                     else
                     {
                         Logger.Info("超过" + minutes + "分钟自动取消订单失败");
                     }
                 }
                 continue;
             }
             catch
             {
                 Logger.Info("超过" + minutes + "分钟自动取消订单(CancelOrders:" + saas + ")失败");
                 continue;
             }
         }
     }
     catch
     {
         Logger.Info("超时自动取消订单(CancelOrders)失败");
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 越界报警短信通知
        /// </summary>
        /// <param name="context"></param>
        public void Execute(IJobExecutionContext context)
        {
            ICache cache = null;
            string type  = "越界";

            try
            {
                foreach (string saas in ConfigHelper.GetSaasList())
                {
                    try
                    {
                        MyWorkerRequest.CreateHttpContext(saas, "", "");

                        SmsInfoManager      sim       = new SmsInfoManager();
                        OPUserManager       oum       = new OPUserManager();
                        DataTable           users     = oum.GetReceiveSMSUsers();
                        VehicleAlarmManager vam       = new VehicleAlarmManager();
                        VehicleManager      vm        = new VehicleManager();
                        DataTable           dataTable = vam.GetOutAreaList();
                        if (dataTable != null && dataTable.Rows.Count > 0)
                        {
                            cache = CacheFactory.GetCache();
                            foreach (DataRow row in dataTable.Rows)
                            {
                                string    vehicleID  = row[0].ToString();
                                Hashtable vehicle    = vm.GetVehicleInfoByID(vehicleID);
                                string    gpsNum     = SiteHelper.GetHashTableValueByKey(vehicle, "VehicleGPSNum").ToUpper();
                                string    name       = SiteHelper.GetHashTableValueByKey(vehicle, "Name").ToUpper();
                                string    alarmCount = row[1].ToString();
                                if (!string.IsNullOrEmpty(alarmCount))
                                {
                                    int count = 0;
                                    int.TryParse(alarmCount, out count);
                                    if (count >= 4)
                                    {
                                        if (users != null && users.Rows.Count > 0)
                                        {
                                            foreach (DataRow user in users.Rows)
                                            {
                                                string mobile     = user[0].ToString();
                                                string key        = "out_area_alarm_" + mobile + "_" + vehicleID;
                                                string code_value = cache.Get <string>(key);
                                                if (string.IsNullOrEmpty(code_value))
                                                {
                                                    bool sendResult = sim.SendAlarm(mobile, gpsNum, name, type);
                                                    if (sendResult)
                                                    {
                                                        Logger.Warn(string.Format("车辆{0},{1}发生{2}报警,发送给{3}成功。", name, gpsNum, type, mobile));
                                                        DateTime dt = DateTime.Now.AddMinutes(20);
                                                        cache.Set(key, 1, dt - DateTime.Now);
                                                    }
                                                    else
                                                    {
                                                        Logger.Warn(string.Format("车辆{0},{1}发生{2}报警,发送给{3}失败。", name, gpsNum, type, mobile));
                                                    }
                                                }
                                                else
                                                {
                                                    Logger.Warn(string.Format("车辆{0},{1}发生{2}报警,发送给{3}未超过1小时。", name, gpsNum, type, mobile));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (cache != null)
                            {
                                cache.Dispose();
                            }
                        }
                    }
                    catch
                    {
                        if (cache != null)
                        {
                            cache.Dispose();
                        }
                        Logger.Info("车辆越界报警发送短信失败");
                    }
                }
            }
            catch
            {
                if (cache != null)
                {
                    cache.Dispose();
                }
                Logger.Info("车辆越界报警发送短信失败");
            }
        }
Esempio n. 5
0
        public void Execute(IJobExecutionContext context)
        {
            //ICache Cache = null;
            try
            {
                foreach (string saas in ConfigHelper.GetSaasList())
                {
                    try
                    {
                        MyWorkerRequest.CreateHttpContext(saas, "", "");
                        //Cache = CacheFactory.GetCache();
                        VehicleManager vm = new VehicleManager();
                        DataTable      dt = vm.GetNoOrderUnlockVehicles();
                        foreach (DataRow row in dt.Rows)
                        {
                            string vid   = row["ID"].ToString();
                            string name  = row["Name"].ToString();
                            string carId = row["VehicleGPSNum"].ToString();

                            /*string keyid = "vehicle_" + carId;
                             * string json_car=Cache.Get<string>(keyid);
                             * string acc = "";
                             * if (!string.IsNullOrEmpty(json_car))
                             * {
                             *  dynamic jsonObj = DynamicJson.Parse(json_car);
                             *  if (jsonObj.IsDefined("data"))
                             *  {
                             *      foreach (var item in jsonObj.data)
                             *      {
                             *          if (item.IsDefined("acc"))
                             *              acc = item.acc;
                             *      }
                             *  }
                             * }*/

                            double speed = 0.00;
                            double.TryParse(row["CurrentSpeed"].ToString(), out speed);
                            //if (acc =="1"){
                            if (vm.CloseVehicle(vid))
                            {
                                Logger.Info("无单锁车成功,车辆号:" + name);
                            }
                            else
                            {
                                Logger.Info("无单锁车失败,车辆号:" + name);
                            }
                            //}
                        }
                        //Cache.Dispose();
                    }
                    catch
                    {
                        /*if (Cache != null)
                         * {
                         *  Cache.Dispose();
                         * }*/
                        continue;
                    }
                }
            }
            catch
            {
                /*if (Cache != null)
                 * {
                 *  Cache.Dispose();
                 * }*/
                Logger.Info("无单车进行断电锁车(NoOrderLock)失败");
            }
        }
Esempio n. 6
0
 /// <summary>
 /// 占用车辆超时还车通知
 /// </summary>
 /// <param name="context"></param>
 public void Execute(IJobExecutionContext context)
 {
     try
     {
         int           minutes_timeout = 60;
         List <string> saasList        = ConfigHelper.GetSaasList();
         int           i = 0;
         foreach (string saas in saasList)
         {
             if (i == 0)
             {
                 ICache cache = null;
                 try
                 {
                     MyWorkerRequest.CreateHttpContext(saas, "", "");
                     OrdersManager  om = new OrdersManager();
                     VehicleManager vm = new VehicleManager();
                     //DataTable dt = om.GetVehicleReturnOrderList(minutes_timeout);
                     DataTable dt = vm.GetInUseVehicles();
                     Logger.Debug(string.Format("开始车辆还车通知任务,车辆数:{0},saas:{1}", dt.Rows.Count, saas));
                     UserInfoManager um  = new UserInfoManager();
                     SmsInfoManager  sim = new SmsInfoManager();
                     cache = CacheFactory.GetCache();
                     foreach (DataRow dr in dt.Rows)
                     {
                         string vehicleID   = dr["ID"].ToString();
                         string lockState   = dr["LockState"].ToString();
                         string vehicleName = dr["VehicleName"].ToString();
                         //string userID = dr["UserID"].ToString();
                         //string orderNum = dr["OrderNum"].ToString();
                         if (!string.IsNullOrEmpty(vehicleID))
                         {
                             //Hashtable htVehicle = vm.GetVehicleInfoByID(vehicleID);
                             Hashtable htOrder = om.GetInUseOrder(vehicleID);
                             if (htOrder != null)
                             {
                                 string userID = SiteHelper.GetHashTableValueByKey(htOrder, "UserID");
                                 //string lockState = SiteHelper.GetHashTableValueByKey(htVehicle, "LockState");
                                 //string vehicleName = SiteHelper.GetHashTableValueByKey(htVehicle, "VehicleName");
                                 string   orderNum      = SiteHelper.GetHashTableValueByKey(htOrder, "OrderNum");
                                 string   createTimeStr = SiteHelper.GetHashTableValueByKey(htOrder, "CreateTime");
                                 DateTime createTime    = DateTime.Parse(createTimeStr);
                                 TimeSpan span          = DateTime.Now - createTime;
                                 if ("lock".Equals(lockState) && span.TotalMinutes > minutes_timeout)
                                 {
                                     Hashtable htUser = um.GetUserInfoByUserID(userID);
                                     if (htUser != null)
                                     {
                                         string mobile     = SiteHelper.GetHashTableValueByKey(htUser, "BindPhone");
                                         string key        = "Return_Vehicle_Message_" + mobile + "_" + vehicleID;
                                         string code_value = cache.Get <string>(key);
                                         if (string.IsNullOrEmpty(code_value))
                                         {
                                             bool sendResult = sim.SendReturn(mobile);
                                             if (sendResult)
                                             {
                                                 Logger.Warn(string.Format("订单号{0},车辆{1}还车提醒,发送给{2}成功。", orderNum, vehicleName, mobile));
                                                 DateTime dtDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                                                 cache.Set(key, 1, dtDay - DateTime.Now);
                                             }
                                             else
                                             {
                                                 Logger.Error(string.Format("订单号{0},车辆{1}还车提醒,发送给{2}失败。", orderNum, vehicleName, mobile));
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     if (cache != null)
                     {
                         cache.Dispose();
                     }
                 }
                 catch (Exception e)
                 {
                     if (cache != null)
                     {
                         cache.Dispose();
                     }
                     Logger.Error(string.Format("车辆还车通知任务(ReturnVehicleSendMessage:{0})失败,{1},{2}", saas, e.Message, e.StackTrace));
                 }
                 i++;
             }
         }
     }
     catch
     {
         Logger.Info("车辆还车通知任务(ReturnVehicleNotify)失败");
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 占用车辆超时还车通知
        /// </summary>
        /// <param name="context"></param>
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                int minutes_timeout = 30;
                int.TryParse(context.JobDetail.JobDataMap.Get("minutes_timeout").ToString(), out minutes_timeout);
                int ios_production = 0;
                int.TryParse(context.JobDetail.JobDataMap.Get("ios_production").ToString(), out ios_production);

                List <string> saasList = ConfigHelper.GetSaasList();
                foreach (string saas in saasList)
                {
                    try
                    {
                        MyWorkerRequest.CreateHttpContext(saas, "", "");

                        APPKEY       = SiteHelper.GetAppsetString("JPush_AppKey");
                        MASTERSECRET = SiteHelper.GetAppsetString("JPush_MasterSecret");

                        JPushClient pushClient = new JPushClient(APPKEY, MASTERSECRET);

                        OrdersManager om = new OrdersManager();
                        DataTable     dt = om.GetVehicleReturnOrders(minutes_timeout);
                        foreach (DataRow dr in dt.Rows)
                        {
                            string clientid = string.Empty;
                            if (dr["PushID"] != DBNull.Value)
                            {
                                clientid = dr["PushID"].ToString();
                            }
                            string licenseNumber = dr["LicenseNumber"].ToString();
                            if (!string.IsNullOrEmpty(clientid))
                            {
                                PushMessage pushMessage = new PushMessage();
                                pushMessage.code    = "0101";
                                pushMessage.message = "您当前占用的车辆已锁车停留较长时间,如不再使用请及时还车,避免不必要的浪费哟!";

                                PushPayload payload = new PushPayload();
                                payload.platform                = Platform.all();
                                payload.audience                = Audience.s_registrationId(new string[] { clientid });
                                payload.notification            = new Notification().setAlert(pushMessage.message);
                                payload.message                 = Message.content(Newtonsoft.Json.JsonConvert.SerializeObject(pushMessage));
                                payload.options                 = new Options();
                                payload.options.time_to_live    = 86400 * 10;
                                payload.options.apns_production = ios_production == 1 ? true : false;

                                MessageResult pushResult = pushClient.SendPush(payload);
                                if (pushResult.isResultOK())
                                {
                                    Logger.Info("车辆还车通知:" + pushResult + ",车辆:" + licenseNumber);
                                }
                                else
                                {
                                    Logger.Info("车辆还车通知失败");
                                }
                            }
                        }
                    }
                    catch
                    {
                        Logger.Info("车辆还车通知任务(ReturnVehicleNotify:" + saas + ")失败");
                    }
                }
            }
            catch
            {
                Logger.Info("车辆还车通知任务(ReturnVehicleNotify)失败");
            }
        }