public CranFilter getCranTasks(CranFilter Filter) {
			return CranTaskInfo.LoadCranTasks(Filter);
		}
示例#2
0
		public static CranFilter LoadCranTasks(CranFilter Filter = null) {
			Logger.info("Получение списка заявок на кран", Logger.LoggerSource.server);
			if (Managers == null)
				ReadManagers();
			if (Filter == null) {
				Filter = new CranFilter();
				Filter.DateStart = DateTime.Now.Date;
				Filter.DateEnd = DateTime.Now.Date.AddDays(10);
			}
			Filter.Managers = Managers;
			VotGESOrdersEntities eni = new VotGESOrdersEntities();
			List<CranTaskInfo> result = new List<CranTaskInfo>();
			IQueryable<CranTask> data = from t in eni.CranTask
																	where
																		t.NeedDateStart > Filter.DateStart && t.NeedDateStart < Filter.DateEnd ||
																		t.NeedDateEnd > Filter.DateStart && t.NeedDateEnd < Filter.DateEnd ||
																		t.NeedDateStart < Filter.DateStart && t.NeedDateEnd > Filter.DateEnd ||
																		(t.Allowed &&
																		t.AllowedDateStart > Filter.DateStart && t.AllowedDateStart < Filter.DateEnd ||
																		t.AllowedDateEnd > Filter.DateStart && t.AllowedDateEnd < Filter.DateEnd ||
																		t.AllowedDateStart < Filter.DateStart && t.AllowedDateEnd > Filter.DateEnd)
																		orderby t.CranNumber,t.NeedDateStart
																	select t;
			foreach (CranTask tbl in data) {
				result.Add(new CranTaskInfo(tbl));
			}
			foreach (CranTaskInfo task in result) {
				task.hasCrossTasks = false;
				task.crossTasks = "";
				foreach (CranTaskInfo crossTask in result) {
					if (crossTask.Number == task.Number)
						continue;
					if (crossTask.CranNumber != task.CranNumber)
						continue;
					if (task.Denied || crossTask.Denied || task.Cancelled ||crossTask.Cancelled ||task.Finished || crossTask.Finished)
						continue;
					bool crossed = false;

					//Logger.info(String.Format("{0} - {1}",task.Number,crossTask.Number), Logger.LoggerSource.server);
					if (task.Allowed && crossTask.Allowed) {
						if (DatesCross(task.AllowDateStart, task.AllowDateEnd, crossTask.AllowDateStart, crossTask.AllowDateEnd)) {
							crossed = true;
						}

					}
					if (!task.Allowed && crossTask.Allowed) {
						if (DatesCross(task.NeedStartDate, task.NeedEndDate, crossTask.AllowDateStart, crossTask.AllowDateEnd)) {
							crossed = true;
						}
					}
					if (task.Allowed && !crossTask.Allowed) {
						if (DatesCross(task.AllowDateStart, task.AllowDateEnd, crossTask.NeedStartDate, crossTask.NeedEndDate)) {
							crossed = true;
						}
					}
					if (!task.Allowed && !crossTask.Allowed) {
						if (DatesCross(task.NeedStartDate, task.NeedEndDate, crossTask.NeedStartDate, crossTask.NeedEndDate)) {
							crossed = true;
						}
					}
					if (crossed) {
						task.hasCrossTasks = true;
						task.crossTasks += string.IsNullOrEmpty(task.crossTasks) ? crossTask.Number.ToString() : "," + crossTask.Number.ToString();
					}
				}
			}
			Filter.Data = result;
			return Filter;
		}
示例#3
0
		public ActionResult PrintCranTasks(int year1, int month1, int day1, int year2, int month2, int day2) {
			Logging.Logger.info("Печать списка заявок на кран",Logging.Logger.LoggerSource.server);
			DateTime Date1 = new DateTime(year1, month1, day1);
			DateTime Date2 = new DateTime(year2, month2, day2);
			CranFilter filter = new CranFilter();
			filter.DateStart = Date1;
			filter.DateEnd = Date2;
			CranFilter Result = CranTaskInfo.LoadCranTasks(filter);
			ViewResult view = View("PrintCranTasks", Result);
			return view;

		}