//打卡:http://117.34.118.23:9101/mediaplayer/Driver/reportDriverClockInfo?jsonStr=

        //司机:http://117.34.118.23:9101/mediaplayer/Driver/reportDriverInfo?jsonStr=

        private async void push()
        {
            try
            {
                log.Info($"API do timers {timers++}");
                DateTime     current = DateTime.Now;
                string       sql     = $"select t.bus_card_no 车牌, t.DRIVER_ID,t.driver_name, t.tRADE_DATE|| t.TRADE_TIME tradeTime, t.DUTY_FLAG from MANAGE_REC_DRIVER_TOLED@ytiic t where  t.tRADE_DATE='{current.ToString("yyyyMMdd")}' and t.TRADE_TIME<='{current.ToString("HHmmss")}'";
                DataTable    dt      = new DataTable();
                ORACLEHelper context = new ORACLEHelper();
                dt = context.QueryTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <DriverClock> dataList = TableToList_DriverClock(dt);
                    HttpClient         client   = new HttpClient()
                    {
                        BaseAddress = new Uri(ConstInfo.URL_ZhongHangXun)
                    };
                    var jsonStr = JsonConvert.SerializeObject(dataList);
                    Dictionary <string, string> dict = new Dictionary <string, string>();
                    dict.Add("jsonStr", jsonStr);//bmpm/Driver/reportDriverClockInfo
                    var response = await client.PostAsync("mediaplayer/Driver/reportDriverClockInfo", new FormUrlEncodedContent(dict));

                    var result = await response.Content.ReadAsAsync <HttpError>();

                    if (response.StatusCode == HttpStatusCode.OK && result.code == "200")
                    {
                        sql = $"insert into gj_driverclock select * from MANAGE_REC_DRIVER_TOLED@ytiic t where t.tRADE_DATE='{current.ToString("yyyyMMdd")}' and t.TRADE_TIME<='{current.ToString("HHmmss")}'";
                        context.ExecuteSql(sql);
                        sql = $"delete from MANAGE_REC_DRIVER_TOLED@ytiic t where  t.TRADE_TIME<='{current.ToString("HHmmss")}'";
                        int count = context.ExecuteSql(sql);
                        log.Info($"推送成功,删除记录{count}条");
                    }
                    else
                    {
                        log.Error("调用接口失败:" + result.code + result.message);
                    }
                }
            }
            catch (Exception err)
            {
                log.Error(err);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 根据时间 判断数据库中是否存在当天数据,
 /// 如果存在,删除
 /// </summary>
 /// <param name="entityList"></param>
 public void deleteSameData(List <OpenRecord> entityList, ref bool ERRFLAG)
 {
     if (entityList.Count > 0)
     {
         try
         {
             string recordDate = DateTime.Parse(entityList.First().recordTime, new DateTimeFormatInfo()
             {
                 FullDateTimePattern = "yyyy-MM-dd HH:mi:ss"
             }).ToString("yyyy-MM-dd");
             string sql_delete = "delete gj_opencaserecords t where to_char(t.记录时间,'yyyy-MM-dd') = '" + recordDate + "'";
             int    count      = ORACLEHelper.ExecuteSql(sql_delete);
         }
         catch (Exception err)
         {
             ERRFLAG = true;
             AppInfo.WriteLogs(err.Message);
         }
     }
 }
Ejemplo n.º 3
0
        private async void push()
        {
            ORACLEHelper context = new ORACLEHelper();
            DateTime     current = DateTime.Now;
            string       sql     = $"select lpad(OPER_ID,5,'0') 员工号,trim(OPER_NAME) 姓名,-1 线路id,flag isWork from DRIVER_INFO_CHANGE_TOLED@ytiic where UPDATE_TIME<=to_date('{current.ToString("yyyyMMdd HH:mm:ss")}','yyyy-MM-dd HH24:mi:ss')";
            DataTable    dt      = new DataTable();

            try
            {
                dt = context.QueryTable(sql);
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <Driver> dataList = TableToList(dt);
                    HttpClient    client   = new HttpClient()
                    {
                        BaseAddress = new Uri(ConstInfo.URL_ZhongHangXun)
                    };
                    var jsonStr = JsonConvert.SerializeObject(dataList);
                    Dictionary <string, string> dict = new Dictionary <string, string>();
                    dict.Add("jsonStr", jsonStr);//bmpm/Driver/reportDriverInfo
                    var response = await client.PostAsync("/mediaplayer/Driver/reportDriverInfo", new FormUrlEncodedContent(dict));

                    var result = await response.Content.ReadAsAsync <HttpError>();

                    if (response.StatusCode == HttpStatusCode.OK && result.code == "200")
                    {
                        sql = $"delete from DRIVER_INFO_CHANGE_TOLED@ytiic t where  t.UPDATE_TIME<to_date('{current.ToString("yyyy-MM-dd HH:mm:ss")}','yyyy-MM-dd HH24:mi:ss')";
                        context.ExecuteSql(sql);
                    }
                    else
                    {
                        log.Error("调用接口失败:" + result.code + result.message);
                    }
                }
            }
            catch (Exception err)
            {
                log.Error(err);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 向数据库插入数据
        /// </summary>
        /// <param name="entityList"></param>
        private void insertDataToDataBase(List <OpenRecord> entityList, ref bool ERRFLAG)
        {
            if (ERRFLAG)
            {
                return;
            }
            int minCount = 0;

            try
            {
                while (minCount < entityList.Count)
                {
                    int           maxCount = entityList.Count > 30 + minCount ? 30 + minCount : entityList.Count;
                    StringBuilder sql      = new StringBuilder("insert into gj_opencaserecords (线路名称,车牌号,持卡人,换出内胆编号,换入内胆编号,记录时间) select * from ( ");
                    for (int i = minCount; i < maxCount; i++)
                    {
                        OpenRecord entity = entityList[i];
                        sql.Append("select '").Append(entity.lineName + "' 线路名称,'").Append(entity.carNum + "' 车牌号,'").Append(entity.owiner + "' 持卡人,'").Append(entity.ouCardNum + "' 换出内胆编号,'").Append(entity.inCardNum + " ' 换入内胆编号,to_date('").Append(entity.recordTime).Append("','yyyy-MM-dd HH24:mi:ss') 记录时间 from dual ");
                        if (i < maxCount - 1)
                        {
                            sql.Append(" union all ");
                        }
                    }
                    sql.Append(" )");
                    //AppInfo.WriteLogs(sql.ToString());
                    //ORACLEHelper helper = new ORACLEHelper();
                    ORACLEHelper.ExecuteSql(sql.ToString());
                    //bool result = RCD.RCDB.Execute(sql.ToString());
                    minCount += 30;
                }
            }
            catch (Exception err)
            {
                ERRFLAG = true;
                AppInfo.WriteLogs(err.Message);
            }
        }