123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- using cuidian.Sql;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using WangToTempDb;
- namespace TaskSchedule
- {
- public class Realize
- {
- //public static bool ______flag=true;
- /// <summary>
- /// 按天遍历
- /// </summary>
- /// <param name="dic" iup="iup"></param>
- public static void GetDaysAndExecute(Dictionary<string, string> dic, IUpLoad iup, string entity)
- {
- //保存最末时间
- string endTimeStr = dic["end_time"];
- //两个时间间隔
- double end = Convert.ToDateTime(dic["end_time"]).Subtract(Convert.ToDateTime(dic["start_time"])).TotalDays;
- //判断间隔是否大于30天,是则一天一天遍历
- if (end > 30)
- {
- for (int i = 0; i <= end; i++)
- {
- if (i == (int)end)
- {
- dic["end_time"] = endTimeStr;
- iup.UpLoad(dic);
- if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- }
- else
- {
- dic["start_time"] = (Convert.ToDateTime(dic["start_time"])).ToString();
- //给endTime//天数加1
- dic["end_time"] = (Convert.ToDateTime(dic["start_time"]).AddDays(1)).ToString();
- //旺店通到中间
- iup.UpLoad(dic);
- if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- }
- Console.WriteLine("---------------");
- Console.WriteLine(dic["start_time"]);
- Console.WriteLine(dic["end_time"]);
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
- dic["end_time"],
- entity),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- //实现后更新遍历时间
- dic["start_time"] = (Convert.ToDateTime(dic["end_time"]).AddSeconds(1)).ToString();
- }
- }
- else
- {
- iup.UpLoad(dic);
- if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- Console.WriteLine("------------------");
- Console.WriteLine(dic["start_time"]);
- Console.WriteLine(dic["end_time"]);
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
- dic["end_time"],
- entity),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- }
- }
- /// <summary>
- /// 按小时遍历
- /// </summary>
- /// <param name="dic" iup="iup"></param>
- public static void GetHoursAndExecute(Dictionary<string, string> dic, IUpLoad iup, string entity)
- {
- //保存最末时间
- string endTimeStr = dic["end_time"];
- //两个时间间隔
- double end = Convert.ToDateTime(dic["end_time"]).Subtract(Convert.ToDateTime(dic["start_time"])).TotalHours;
- //判断间隔是否大于1个小时,是则按小时遍历
- if (end > 1)
- {
- for (int i = 0; i <= end; i++)
- {
- if (i == (int)end)
- {
- dic["end_time"] = endTimeStr;
- iup.UpLoad(dic);
- if (entity == "销售出库")
- {
- IUpLoad iupTwo = new DispatchListSendUpLoad();
- iupTwo.UpLoad(dic);
- }
- else if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- }
- else
- {
- dic["start_time"] = (Convert.ToDateTime(dic["start_time"])).ToString();
- //给endTime//天数加1
- dic["end_time"] = (Convert.ToDateTime(dic["start_time"]).AddHours(1)).ToString();
- //旺店通到中间
- iup.UpLoad(dic);
- if (entity == "销售出库")
- {
- IUpLoad iupTwo = new DispatchListSendUpLoad();
- iupTwo.UpLoad(dic);
- }
- else if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- }
- Console.WriteLine("---------------");
- Console.WriteLine(dic["start_time"]);
- Console.WriteLine(dic["end_time"]);
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
- dic["end_time"],
- entity),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- //实现后更新遍历时间
- dic["start_time"] = (Convert.ToDateTime(dic["end_time"]).AddSeconds(1)).ToString();
- }
- }
- else
- {
- iup.UpLoad(dic);
- if (entity == "销售出库")
- {
- IUpLoad iupTwo = new DispatchListSendUpLoad();
- iupTwo.UpLoad(dic);
- }
- else if (entity == "其他入库")
- {
- IUpLoad iupThree = new StockinUpLoad();
- dic.Add("status", "60");
- dic.Add("order_type", "2");
- iupThree.UpLoad(dic);
- dic.Remove("status");
- dic.Remove("order_type");
- }
- Console.WriteLine("------------------");
- Console.WriteLine(dic["start_time"]);
- Console.WriteLine(dic["end_time"]);
- //并更新表时间,旺店通时间跨度为闭区间,所以把秒数+1以便明天10点再次取值
- DbUtils.ExecuteNonQuery(string.Format("update transtime set lasttime=DATEADD(SECOND,+1,'{0}') where entitytype='{1}'",
- dic["end_time"],
- entity),
- ConnectionUtils.Instance.GetConnection("TempDB"));
- }
- }
- }
- }
|