예제 #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            E = new ControlAddEx(AddR);

            R = new ControlAddR(AddR);

            Thread thread1 = new Thread(() =>
            {
                while (true)
                {
                    ProcessData();
                    Thread.Sleep(50000);
                }
            });

            thread1.Start();

            //_dateTime = DateTime.Now;
            //Thread thread2 = new Thread(() =>
            //{
            //    while (true)
            //    {
            //        if (DateTime.Now.Hour == 20)
            //        {
            //            try
            //            {
            //                string sql = "select 内部编号  " +
            //                      "                                 from tblRouteBusStatus" +
            //                      "     where convert(varchar(10), UpdateTime, 120) < '" + DateTime.Now.ToString("yyyy-MM-dd") + "'" +
            //                      "     and  convert(varchar(10),时刻,120) < '" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
            //                var routeData1 = SqlHelper.ExecuteDataTable(sql);
            //                foreach (DataRow row in routeData1.Rows)
            //                {

            //                    sql = "insert into tblRouteRFormD_bak2019 " +
            //                        "  select  * from tblRouteRFormD " +
            //                        "  where  内部编号='" + Convert.ToString(row["内部编号"]) + "' " +
            //                        "  and  日期='" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
            //                    SqlHelper.ExuteNonQuery(sql);
            //                    sql = " delete  from tblRouteRFormD  " +
            //                         "   where  内部编号='" + Convert.ToString(row["内部编号"]) + "' " +
            //                         "    and    日期='" + DateTime.Now.ToString("yyyy-MM-dd") + "'   ";
            //                    SqlHelper.ExuteNonQuery(sql);
            //                }
            //            }
            //            catch (Exception ex)
            //            {
            //                LogHelper.WriteLog(ex.Message);
            //            }

            //        }
            //        if (_dateTime.Date < DateTime.Now.Date)
            //            DelFormD();
            //        Thread.Sleep(100000);
            //    }
            //});
            //thread2.Start();
        }
예제 #2
0
파일: Form1.cs 프로젝트: MrChenJH/fuwu
        private void Form1_Load(object sender, EventArgs e)
        {
            E = AddR;
            Thread thread1 = new Thread(() =>
            {
                Parallel.Invoke(new Action[] { () => {
                                                   计算距离();
                                               },
                                               () => {
                                                   while (true)
                                                   {
                                                       SqlHelper.ExuteNonQuery("DELETE tblRouteArrivalVehicle where 更新时间<'" + DateTime.Now.AddMinutes(-5).ToString("yyyy-MM-dd HH:mm:ss") + "'");
                                                       Thread.Sleep(1000);
                                                   }
                                               } });
            });

            thread1.Start();
        }
예제 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            E = new ControlAddEx(AddR);

            R = new ControlAddR(AddR);

            _routeS = (from p in SqlHelper.ExecuteDataTable(@"select 线路ID,'上行' as 方向,ISNULL(CAST(上行长度 as varchar),'0')  as 长度 from tblRoute  
                                                                  union all 
                                                                 select 线路ID,'下行' as 方向,ISNULL(CAST(下行长度 as varchar),'0')  as 长度 from tblRoute    ").AsEnumerable()
                       select new Route
            {
                线路 = p.Field <string>("线路ID"),
                方向 = p.Field <string>("方向"),
                长度 = p.Field <string>("长度")
            }).ToList();


            var data = SqlHelper.ExecuteDataTable(@"select 线路id,线路内序号,'上行始发'  as 类型,站名  from  tblrouted  where 上行始发=1
                                                                  union all
                                                   select 线路id, 线路内序号,'上行终点'  as 类型,站名   from tblrouted  where 上行终点 = 1
                                                                  union all
                                                   select 线路id, 线路内序号,'下行始发'  as 类型,站名   from tblrouted  where 下行始发 = 1
                                                                   union all
                                                   select 线路id, 线路内序号,'下行终点'  as 类型,站名   from tblrouted  where 下行终点 = 1");

            foreach (DataRow row in data.Rows)
            {
                _routeSRangeS.Add(new RouteSRange
                {
                    线路    = Convert.ToString(row["线路id"]),
                    线路内序号 = Convert.ToInt32(row["线路内序号"]),
                    类型    = Convert.ToString(row["类型"]),
                    站名    = Convert.ToString(row["站名"]),
                });
            }


            ///处理非营运路单
            Thread threadNonFormD = new Thread(() =>
            {
                while (true)
                {
                    ProcessNonFormD();
                    Thread.Sleep(10000);
                }
            });

            threadNonFormD.IsBackground = true;
            threadNonFormD.Start();


            ///更新 实际发,实际到,单边里程
            Thread Formd = new Thread(() =>
            {
                while (true)
                {
                    ProcessData();
                    Thread.Sleep(50000);
                }
            });

            Formd.IsBackground = true;
            Formd.Start();

            DateTime excuteTime = DateTime.Now.AddDays(-1).Date;

            ///处理 ,最后路单的实际到
            Thread threadLastForm = new Thread(() =>
            {
                while (true)
                {
                    if (!excuteTime.Equals(DateTime.Now.Date))
                    {
                        if (DateTime.Now.Hour > 4)
                        {
                            isexcute = true;
                        }
                    }
                    if (isexcute)
                    {
                        string sql      = "select 替换车号,ActualRoute,convert(varchar,max(isnull(调整时刻,计划发车时间)),108) 发车时间 from tbldailyplan1_bak where 日期=convert(varchar(10),dateadd(day,-1,getdate()),121) group by 替换车号,ActualRoute";
                        DataTable data1 = SqlHelper.ExecuteDataTable(sql);
                        if (data1.Rows.Count > 0)
                        {
                            foreach (DataRow row in data1.Rows)
                            {
                                try
                                {
                                    string rformdsql = "select 流水号,状态 from tblRouteRFormD where 线路id='" + Convert.ToString(row["ActualRoute"]) + "' and 内部编号='" + Convert.ToString(row["替换车号"]) + "' and convert(varchar, 计划发车时刻,108)='" + Convert.ToString(row["发车时间"]) + "'  and 日期=convert(varchar(10),dateadd(day,-1,getdate()),121)";
                                    DataTable formD  = SqlHelper.ExecuteDataTable(rformdsql);
                                    if (formD.Rows.Count > 0)
                                    {
                                        if (!formD.Rows[0]["状态"].ToString().Equals("2"))
                                        {
                                            string formSql       = "select top 1 CONVERT(varchar(19), 到达时刻,121) 到达时刻 from tblRouteRFormX" + DateTime.Now.ToString("yyyyMMdd") + "  where 内部编号='" + Convert.ToString(row["替换车号"]) + "' and 线路id='" + Convert.ToString(row["ActualRoute"]) + "'      order by 流水号 desc";
                                            DataTable rFormXData = SqlHelper.ExecuteDataTable(formSql);
                                            if (rFormXData.Rows.Count > 0)
                                            {
                                                string updateSql = "update  tblRouteRFormD set 实际到达时刻='" + Convert.ToString(rFormXData.Rows[0]["到达时刻"]) + "' where 流水号=" + Convert.ToString(formD.Rows[0]["流水号"]);
                                                SqlHelper.ExuteNonQuery(updateSql);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                        isexcute   = false;
                        excuteTime = DateTime.Now.Date;
                    }
                    Thread.Sleep(100000);
                }
            });

            threadLastForm.IsBackground = true;
            threadLastForm.Start();


            _dateTime = DateTime.Now;

            ///更新 ,第一班路单驾驶员信息
            Thread FormDUpdateJsy = new Thread(() =>
            {
                while (true)
                {
                    RunJsy();
                    Thread.Sleep(100000);
                }
            });

            FormDUpdateJsy.IsBackground = true;
            FormDUpdateJsy.Start();


            string maxsql = "select convert(varchar(10), dateadd( DAY,1,max(日期)),21) 日期  from   tblDailyReport";

            _cTime = Convert.ToDateTime(SqlHelper.ExecuteDataTable(maxsql).Rows[0]["日期"].ToString());


            ///备份大日报
            Thread DailyReportBak = new Thread(() =>
            {
                while (true)
                {
                    if (_cTime.Date < DateTime.Now.Date)
                    {
                        BuildDailyReport();
                    }
                    Thread.Sleep(10000);
                }
            });

            DailyReportBak.IsBackground = true;
            DailyReportBak.Start();
        }
예제 #4
0
파일: RouteForm.cs 프로젝트: MrChenJH/fuwu
        private void Form1_Load(object sender, EventArgs e)
        {
            E = new ControlAddEx(AddR);

            R = new ControlAddR(AddR);

            _routeS = (from p in SqlHelper.ExecuteDataTable(@"select 线路ID,'上行' as 方向,ISNULL(CAST(上行长度 as varchar),'0')  as 长度 from tblRoute  
                                                                  union all 
                                                                 select 线路ID,'下行' as 方向,ISNULL(CAST(下行长度 as varchar),'0')  as 长度 from tblRoute    ").AsEnumerable()
                       select new Route
            {
                线路 = p.Field <string>("线路ID"),
                方向 = p.Field <string>("方向"),
                长度 = p.Field <string>("长度")
            }).ToList();


            var data = SqlHelper.ExecuteDataTable(@"select 线路id,线路内序号,'上行始发'  as 类型,站名  from  tblrouted  where 上行始发=1
                                                                  union all
                                                   select 线路id, 线路内序号,'上行终点'  as 类型,站名   from tblrouted  where 上行终点 = 1
                                                                  union all
                                                   select 线路id, 线路内序号,'下行始发'  as 类型,站名   from tblrouted  where 下行始发 = 1
                                                                   union all
                                                   select 线路id, 线路内序号,'下行终点'  as 类型,站名   from tblrouted  where 下行终点 = 1");

            foreach (DataRow row in data.Rows)
            {
                _routeSRangeS.Add(new RouteSRange
                {
                    线路    = Convert.ToString(row["线路id"]),
                    线路内序号 = Convert.ToInt32(row["线路内序号"]),
                    类型    = Convert.ToString(row["类型"]),
                    站名    = Convert.ToString(row["站名"]),
                });
            }

            ///更新 实际发,实际到,单边里程

            Thread Formd = new Thread(() =>
            {
                while (true)
                {
                    ProcessData();
                    Thread.Sleep(50000);
                }
            });

            Formd.IsBackground = true;
            Formd.Start();

            Thread FormdXXX = new Thread(() =>
            {
                while (true)
                {
                    ProcessXXX();
                    Thread.Sleep(5000);
                }
            });

            FormdXXX.IsBackground = true;
            FormdXXX.Start();

            Doss();
            Dow();
        }
예제 #5
0
        private void Form1_Load(object sender, EventArgs e)
        {
            E = new ControlAddEx(AddR);

            R = new ControlAddR(AddR);

            _routeS = (from p in SqlHelper.ExecuteDataTable(@"select 线路ID,'上行' as 方向,ISNULL(CAST(上行长度 as varchar),'0')  as 长度 from tblRoute  
                                                                  union all 
                                                                 select 线路ID,'下行' as 方向,ISNULL(CAST(下行长度 as varchar),'0')  as 长度 from tblRoute    ").AsEnumerable()
                       select new Route
            {
                线路 = p.Field <string>("线路ID"),
                方向 = p.Field <string>("方向"),
                长度 = p.Field <string>("长度")
            }).ToList();


            var data = SqlHelper.ExecuteDataTable(@"select 线路id,线路内序号,'上行始发'  as 类型,站名  from  tblrouted  where 上行始发=1
                                                                  union all
                                                   select 线路id, 线路内序号,'上行终点'  as 类型,站名   from tblrouted  where 上行终点 = 1
                                                                  union all
                                                   select 线路id, 线路内序号,'下行始发'  as 类型,站名   from tblrouted  where 下行始发 = 1
                                                                   union all
                                                   select 线路id, 线路内序号,'下行终点'  as 类型,站名   from tblrouted  where 下行终点 = 1");

            foreach (DataRow row in data.Rows)
            {
                _routeSRangeS.Add(new RouteSRange
                {
                    线路    = Convert.ToString(row["线路id"]),
                    线路内序号 = Convert.ToInt32(row["线路内序号"]),
                    类型    = Convert.ToString(row["类型"]),
                    站名    = Convert.ToString(row["站名"]),
                });
            }

            Thread thread1SS = new Thread(() =>
            {
                while (true)
                {
                    ProcessNonFormD();
                    Thread.Sleep(10000);
                }
            });

            thread1SS.Start();


            ///更新实际发实际到单边里程
            Thread Formd = new Thread(() =>
            {
                while (true)
                {
                    ProcessData();
                    Thread.Sleep(50000);
                }
            });

            Formd.Start();



            _dateTime = DateTime.Now;

            ///去掉没有到离站的车辆路单
            Thread FormDDelMore = new Thread(() =>
            {
                while (true)
                {
                    RunJsy();
                    Thread.Sleep(100000);
                }
            });

            FormDDelMore.Start();


            string maxsql = "select convert(varchar(10), dateadd( DAY,1,max(日期)),21) 日期  from   tblDailyReport";

            _cTime = Convert.ToDateTime(SqlHelper.ExecuteDataTable(maxsql).Rows[0]["日期"].ToString());
            ///备份大日报
            Thread DailyReportBak = new Thread(() =>
            {
                while (true)
                {
                    if (_cTime.Date < DateTime.Now.Date)
                    {
                        BuildDailyReport();
                    }
                    Thread.Sleep(10000);
                }
            });

            DailyReportBak.Start();
        }
예제 #6
0
파일: Form1.cs 프로젝트: MrChenJH/fuwu
        private void Form1_Load(object sender, EventArgs e)
        {
            E = AddR;
            new Thread(() =>
            {
                string bz = "0";
                while (true)
                {
                    Thread.Sleep(5000);
                    string bzsql = "select 标记 from tblRouteFormDBag where 日期 ='" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
                    var bzData   = SqlHelper.ExecuteDataTable(bzsql);
                    if (bzData.Rows.Count == 0)
                    {
                        string insertSql = "insert into  tblRouteFormDBag(日期,标记)VALUES('" + DateTime.Now.ToString("yyyy-MM-dd") + "',0)";
                        SqlHelper.ExuteNonQuery(insertSql);
                    }
                    else
                    {
                        bz = bzData.Rows[0][0].ToString();
                    }

                    string formx = "select 流水号,CONVERT(varchar(10),日期,120) 日期,线路ID," +
                                   "内部编号,驾驶员,行号,方向,站点名称,CONVERT(varchar,到达时刻,108) 到达时刻," +
                                   "CONVERT(varchar,驶离时刻,108) 驶离时刻," +
                                   "里程表数  from  tblRouteRFormX" + DateTime.Now.ToString("yyyyMMdd") + "  where 线路ID!='' and 流水号>" + bz;

                    DataTable dtFormx = SqlHelper.ExecuteDataTable(formx);
                    if (dtFormx.Rows.Count == 0)
                    {
                        continue;
                    }
                    var formxSet = (from t in dtFormx.AsEnumerable()
                                    select new
                    {
                        流水号 = t.Field <long>("流水号"),
                        日期 = t.Field <string>("日期"),
                        线路ID = t.Field <string>("线路ID"),
                        内部编号 = t.Field <string>("内部编号"),
                        驾驶员 = t.Field <string>("驾驶员"),
                        站点名称 = t.Field <string>("站点名称"),
                        方向 = t.Field <string>("方向"),
                        到达时刻 = t.Field <string>("到达时刻"),
                        驶离时刻 = t.Field <string>("驶离时刻"),
                        里程表数 = t.Field <Single>("里程表数")
                    }).ToList();

                    bz = formxSet.Max(t => t.流水号).ToString();
                    string updatesql = "update tblRouteFormDBag set  标记=" + bz + " where  日期='" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
                    SqlHelper.ExuteNonQuery(updatesql);
                    var nbbhSet = formxSet.Select(t => new { t.内部编号, t.线路ID }).Where(p => p.线路ID != null && p.线路ID != string.Empty).Distinct();
                    Parallel.ForEach(nbbhSet, (item, pls, longs) =>
                    {
                        //    foreach (var item in nbbhSet)
                        //{

                        var formxSetCj = formxSet.Where(t => t.内部编号 == item.内部编号).OrderBy(t => t.流水号);

                        foreach (var itemcj in formxSetCj)
                        {
                            E("内部编号:" + itemcj.内部编号);
                            Process(itemcj.线路ID, itemcj.内部编号, itemcj.驾驶员, itemcj.日期, itemcj.站点名称, itemcj.站点名称, itemcj.驶离时刻.Equals("00:00:00") ? itemcj.到达时刻 : itemcj.驶离时刻, itemcj.驶离时刻.Equals("00:00:00") ? itemcj.到达时刻 : itemcj.驶离时刻, itemcj.到达时刻, itemcj.到达时刻, itemcj.方向, itemcj.里程表数, itemcj.里程表数);
                        }
                        //}
                    });
                }
            }).Start();
        }