public EditScheduleForm(Schedule schedule) { InitializeComponent(); try { DS_Schedule.DataSource = this.schedule; this.schedule = schedule; buildingQuery = new BuildingQuery(_SERVER.ServerName.Database); sequenceQuery = new SequenceQuery(_SERVER.ServerName.Database); ScheduleQuery = new ScheduleQuery(_SERVER.ServerName.Database); ScheduleLine = PoLine = buildingQuery.GetProductionLines(); DS_Schedule.DataSource = this.schedule; DS_Line.DataSource = ScheduleLine; DS_OriginalPoLine.DataSource = PoLine; var temp1 = buildingQuery.GetProductionLine(schedule.ProductionLine_Id); if (temp1 != null) { comboBox1.SelectedItem = ScheduleLine.Where(i => i.id == temp1.id).First(); } var pos = sequenceQuery.GetOriginalPos(schedule); if (pos != null) { DS_OriginalPo.DataSource = pos; } } catch { } }
public RespSchedule(IDbName database, string line, int month, string poNumber) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } DateTime SearchTime = new DateTime(DateTime.Now.Year, month, DateTime.Now.Day); var scheduleclass = ScheduleQuery.GetScheduleClass(SearchTime); if (scheduleclass == null) { Exception = new RespException(true, "Invalid schedule time", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(poNumber); if (schedules == null) { Exception = new RespException(true, "Sequence have no item", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } //var temp = schedules.Where(i => i.ScheduleClass_Id == scheduleclass.id); //if (temp.Count() > 0) // schedules = temp.ToList(); List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { schedules.Where(i => i.ProductionLine_Id == item.id); if (schedules.Count() > 0) { newSchedule.AddRange(schedules.ToList()); } } newSchedule = newSchedule.Take(15).ToList(); ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }
public RespSchedule(IDbName database, int machineId, int workerid) { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var orders = BeamCutQuery.GetBDeviceOrder(machineId, workerid, DateTime.Now.ToString("dd/MM/yyyy")); if (orders == null) { Exception = new RespException(true, "Order is empty", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> schedules = new List <Schedule>(); foreach (var item in orders) { var temp = ScheduleQuery.GetSchedule(item); if (temp != null) { schedules.Add(temp); } } ScheduleList = new List <Schedule_t>(); foreach (var item in schedules) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get Order: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); }
// stop cut public RespCutting(IDbName database, int binterfaceId, int beamCounter) { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); try { var bInterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); return; } bInterface.Finish = true; bInterface.BeamCutCounter = beamCounter; bInterface.StopCutTime = DateTime.Now; if (!BeamCutQuery.UpdateBeamInterface(bInterface)) { Exception = new RespException(true, "Can not update BInterface", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); return; } Exception = new RespException(false, "Stop cutting: OK", EKB_SYS_REQUEST.BEAM_STOP_CUTTING); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_STOP_CUTTING); } }
public void Execute(JobExecutionContext context) { JobDataMap map = context.MergedJobDataMap; ScheduleQuery details = (ScheduleQuery)map["Details"]; ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[details.DatabaseName]; if (connectionStringSettings != null) { var nextRunDate = GetNextRunDate(context.Trigger); AdoTemplate template = CreateTemplate(connectionStringSettings); DateTime startTime = DateTime.Now; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); try { int numResults = RunQuery(template, details.QueryText); stopwatch.Stop(); PublishSuccessEvent(details, numResults, startTime, nextRunDate, stopwatch.Elapsed); } catch (Exception ex) { PublishFailEvent(details, startTime, nextRunDate, ex); } } }
public (List <SysSchedule>, int) GetScheduleJobByPage(ScheduleQuery scheduleQuery) { var query = ExpressionBuilder.True <SysSchedule>(); int Total = _scheduleRepositoty.Count(query); var list = _scheduleRepositoty.PageBy(scheduleQuery.PageIndex, scheduleQuery.PageSize, query).ToList(); return(list, Total); }
public async Task <List <Movie> > SelectShowingMoiveAsync(Guid cinemaId) { var screens = await ScheduleQuery.SelectAsync(new ScheduleQueryParameter { CinemaId = cinemaId }); var movieIds = screens.Select(e => e.MovieId).ToArray(); var movies = await MovieQuery.SelectAsync(movieIds); return(movies); }
public RespComponent(IDbName _database, int _scheduleId, int originalPoId) { try { ComponentQuery componentQuery = new ComponentQuery(_database); ScheduleQuery scheduleQuery = new ScheduleQuery(_database); SequenceQuery SequenceQuery = new SequenceQuery(_database); var schedule = scheduleQuery.GetSchedule(_scheduleId); var originalPo = SequenceQuery.GetOriginalPo(originalPoId); if (schedule == null) { if (originalPo == null) { Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } schedule = scheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } } var components = componentQuery.GetModelComponents(schedule.Model); if (components == null) { Exception = new RespException(true, "Can not find component list", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); return; } components = components.OrderByDescending(i => i.CuttingType.id).ToList(); ComponentList = new List <Component_t>(); foreach (var item in components) { ComponentList.Add(new Component_t(item)); } Exception = new RespException(false, "Get component: Ok", EKB_SYS_REQUEST.BEAM_GET_COMPONENT); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_COMPONENT); } }
public async Task <IActionResult> GetSchedule(ScheduleQuery query) { if (User.PatrolIds().Any(x => x == query.PatrolId)) { var shiftAssignments = await _shiftRepository.GetScheduledShiftAssignments(query.PatrolId, query.UserId, query.From, query.To, query.Status, null, query.NoOverlapWithUserId); return(MapScheduledShiftAssessments(shiftAssignments)); } else { return(Forbid()); } }
public MessageModel <PageModel <SysSchedule> > GetSchedulePage([FromQuery] ScheduleQuery scheduleQuery) { var list = _scheduleServer.GetScheduleJobByPage(scheduleQuery); return(new MessageModel <PageModel <SysSchedule> >() { success = true, msg = "数据获取成功", response = new PageModel <SysSchedule>() { TotalCount = list.Item2, data = list.Item1, } }); }
private void PublishFailEvent(ScheduleQuery details, DateTime startDate, DateTime?nextRunDate, Exception exception) { var result = bus.CreateInstance <IQueryResult>(x => { x.StartDate = startDate; x.Name = details.Name; x.NextRun = nextRunDate; x.Success = false; x.ErrorMessage = exception.Message; x.AlertIfAboveThreshold = details.AlertIfAboveThreshold; x.AlertEmailTo = details.AlertEmailTo; }); bus.Publish(result); }
public RespSchedule(IDbName database, string line, string poNumber) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(poNumber); if (schedules == null) { Exception = new RespException(true, "Sequence have no item", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { schedules.Where(i => i.ProductionLine_Id == item.id); if (schedules.Count() > 0) { newSchedule.AddRange(schedules.ToList()); } } newSchedule = newSchedule.Take(15).ToList(); ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { ScheduleList.Add(new Schedule_t(database, item)); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }
private void PublishSuccessEvent(ScheduleQuery details, int numResults, DateTime startDate, DateTime?nextRunDate, TimeSpan elapsed) { var result = bus.CreateInstance <IQueryResult>(x => { x.Success = true; x.Duration = elapsed; x.StartDate = startDate; x.Name = details.Name; x.NumberOfResults = numResults; x.NextRun = nextRunDate; x.ThresholdMilliseconds = details.ThresholdMilliseconds; x.AlertIfAboveThreshold = details.AlertIfAboveThreshold; x.AlertEmailTo = details.AlertEmailTo; }); bus.Publish(result); }
public static async Task <DayScheduleVM> CreateFull(ScheduleQuery query, DayOfWeek day, int subGroup) { DayScheduleVM result = new DayScheduleVM(day); var pairs = await Loader.LoadPairsFull(query, day, subGroup); if (pairs == null) { return(result); } foreach (var pair in pairs) { result.Pairs.Add(new PairVM(pair)); } return(result); }
public static async Task <ChartDayScheduleVM> Create(ScheduleQuery query, DateTime date, int subGroup) { ChartDayScheduleVM result = new ChartDayScheduleVM(date); var pairs = await Loader.LoadPairs(query, date, subGroup); if (pairs == null) { return(result); } foreach (var pair in pairs) { result.Pairs.Add(new ChartPairVM(pair)); } return(result); }
public BeamInterface(BeamCutInterface BInterface, int place) { InitializeComponent(); try { lbStartTime.Text = BInterface.StartCutTime.ToString(); lbStopTime.Text = BInterface.StopCutTime.ToString(); BeamCutQuery beamCutQuery = new BeamCutQuery(_SERVER.ServerName.Database); ScheduleQuery scheduleQuery = new ScheduleQuery(_SERVER.ServerName.Database); SequenceQuery sequenceQuery = new SequenceQuery(_SERVER.ServerName.Database); BuildingQuery buildingQuery = new BuildingQuery(_SERVER.ServerName.Database); var clone_po = beamCutQuery.GetBeamCutPo(BInterface.BeamCutPo_Id); lbTotalPoCutQty.Text = clone_po.CuttingQuantity.ToString(); lbComponent.Text = clone_po.ComponentRef; var po = sequenceQuery.GetOriginalPo(ShareFuncs.GetInt(BInterface.OriginalPo_Id)); var schedule = scheduleQuery.GetSchedule(ShareFuncs.GetInt(BInterface.Schedule_Id)); if (schedule == null) { if (po != null) { schedule = scheduleQuery.GetSchedule(po); } if (schedule == null) { this.Hide(); Error = true; return; } } lbPlace.Text = place.ToString(); DS_Interface.DataSource = BInterface; DS_Po.DataSource = schedule; lbLine.Text = buildingQuery.GetProductionLine(ShareFuncs.GetInt(schedule.ProductionLine_Id)).LineName; } catch { this.Hide(); Error = true; return; } }
public static async System.Threading.Tasks.Task SQLWriter(string group) // Метод записи/изменения группы в базе данных { if (!IsGroup(group)) { throw new Exception("You entered the group number incorrectly.Check the entered data and try again."); } await ScheduleQuery.SQuery("Понедельник", "1", group); HttpClient httpClient = new HttpClient(); string request = "https://api.telegram.org/bot1331699621:AAGdIFGkECZe-jbElPy8ikN8hefs9IqCbbk/getUpdates"; // Делаем запрос для получения сообщения, которое отправил пользователь HttpResponseMessage response = (await httpClient.GetAsync(request)).EnsureSuccessStatusCode(); string responseBody = await response.Content.ReadAsStringAsync(); var rootObject = JObject.Parse(responseBody); string connstr = $"server=localhost;user=root;database=TelegramBot;password={Environment.GetEnvironmentVariable("password")};"; MySqlConnection conn = new MySqlConnection(connstr); conn.Open(); string chat_id = rootObject["result"][rootObject["result"].ToArray().Length - 1]["message"]["chat"]["id"].ToString(); string sql1 = $"SELECT EXISTS(SELECT group_num FROM users WHERE chat_id = {chat_id} LIMIT 1);"; // Команда для проверки, известна ли группа пользователя, написавшего боту MySqlCommand command1 = new MySqlCommand(sql1, conn); string NumberOfGroup1 = command1.ExecuteScalar().ToString(); if (NumberOfGroup1 != "1") // Блок кода, выполняющийся при неустановленной пользователем группы { string sql = $"INSERT users(chat_id, group_num, name) VALUES({chat_id}, {group}, '{rootObject["result"][rootObject["result"].ToArray().Length - 1]["message"]["chat"]["first_name"]}'); "; // Команда привязки номера группы к chat id текущего пользователя и telegram-бота MySqlCommand command = new MySqlCommand(sql, conn); command.ExecuteScalar(); conn.Close(); } else if (NumberOfGroup1 == "1") // Блок кода, выполняющийся в случае перезаписи номера группы пользователем { string sql = $"UPDATE `telegrambot`.`users` SET `group_num` = '{group}' WHERE (`chat_id` = '{chat_id}');"; // Строка с командой перезаписи группы в базе данных MySqlCommand command = new MySqlCommand(sql, conn); command.ExecuteScalar(); conn.Close(); } else { throw new Exception("We don't know your group number. Please, specify your group number or set it using the command /setgroup"); // Исключение, в случае неустановленной пользователем группы } }
public RespPoInfo(IDbName _database, int scheduleId, int originalPoId, int componentId) { try { ScheduleQuery scheduleQuery = new ScheduleQuery(_database); SequenceQuery sequenceQuery = new SequenceQuery(_database); BeamCutQuery beamCutQuery = new BeamCutQuery(_database); SequenceQuery SequenceQuery = new SequenceQuery(_database); ComponentQuery componentQuery = new ComponentQuery(_database); var schedule = scheduleQuery.GetSchedule(scheduleId); var originalPo = SequenceQuery.GetOriginalPo(originalPoId); var shoeComponent = componentQuery.GetShoeComponent(componentId); if (schedule == null) { if (originalPo == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); return; } schedule = scheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); return; } } if (shoeComponent == null) { Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); return; } PoInfo = new PoInfo(_database, schedule); if (originalPo == null) { Exception = new RespException(true, "Empty sequence file", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); return; } var clonePo = beamCutQuery.FindClonePo(originalPo.id, componentId); if (clonePo != null) { ClonePoId = clonePo.id; SeqList = new List <SeqInfo>(); foreach (var item in clonePo.BeamCutSeqs) { SeqList.Add(new SeqInfo { id = item.id, CuttingQty = ShareFuncs.GetInt(item.CutQty), SeqNo = ShareFuncs.GetInt(item.SequenceNo), SeqQty = ShareFuncs.GetInt(item.SequenceQty), Finish = item.Finish == true ? true : false, }); } } else { var bClonePo = beamCutQuery.CloneOriginalPo(originalPo, shoeComponent); if (bClonePo == null) { Exception = new RespException(true, "An error occured while requesting po information", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); return; } ClonePoId = bClonePo.id; SeqList = new List <SeqInfo>(); foreach (var item in bClonePo.BeamCutSeqs) { SeqList.Add(new SeqInfo { id = item.id, CuttingQty = ShareFuncs.GetInt(item.CutQty), SeqNo = ShareFuncs.GetInt(item.SequenceNo), SeqQty = ShareFuncs.GetInt(item.SequenceQty), Finish = item.Finish == true ? true : false, }); } } Exception = new RespException(false, "Get Poinfo: OK", EKB_SYS_REQUEST.BEAM_GET_PO_INFO); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_PO_INFO); } }
// start cutting construction public RespCutting(IDbName database, int deviceId, int workerId, int clonePoId, int seq1Id, int seq2Id, int binterfaceId) { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); try { var worker = EmployeeQuery.GetEmployee(workerId); if (worker == null) { Exception = new RespException(true, "Invalid worker Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var bdevice = BeamCutQuery.GetBeamCutDevice(deviceId); if (bdevice == null) { Exception = new RespException(true, "Invalid device Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var clonePo = BeamCutQuery.GetBeamCutPo(clonePoId); if (clonePo == null) { Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var originalPo = SequenceQuery.GetOriginalPo(clonePo.OriginalPo_Id); if (originalPo == null) { Exception = new RespException(true, "Can not find original po", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var component = ComponentQuery.GetShoeComponent(clonePo.Component_Id); if (component == null) { Exception = new RespException(true, "Can not find component", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var schedule = ScheduleQuery.GetSchedule(originalPo); if (schedule == null) { Exception = new RespException(true, "Can not find schedule", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } var order = BeamCutQuery.GetBDeviceOrder(originalPo, deviceId); var startSeq = BeamCutQuery.GetBeamCutSeq(seq1Id); var stopSeq = BeamCutQuery.GetBeamCutSeq(seq2Id); if (startSeq == null || stopSeq == null) { Exception = new RespException(true, "Invalid clone Seq Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } int[] qty = BeamCutQuery.GetTotalSelectSequenceQty(startSeq, stopSeq); if (qty == null) { qty = new int[] { 0, 0 } } ; int bId = binterfaceId; BeamCutInterface binterface = BeamCutQuery.GetBeamInterfaceById(binterfaceId); int scheduleId = 0; if (schedule != null) { scheduleId = schedule.id; } if (binterface == null) { binterface = new BeamCutInterface { Employee_Id = workerId, BeamCutDevice_Id = deviceId, BeamCutPo_Id = clonePoId, OriginalPo_Id = clonePo.OriginalPo_Id, BeamCutStartSeq_Id = seq1Id, BeamCutStopSeq_Id = seq2Id, TotalSelectedQty = qty[0], TotalSelectCutQty = qty[1], Schedule_Id = scheduleId, StartSeqNo = startSeq.SequenceNo, StopSeqNo = stopSeq.SequenceNo, StartCutTime = DateTime.Now, CuttingQty = 0, BeamCutCounter = 0, BDeviceOrder_Id = order != null ? order.id : 0, }; var beamInterface = BeamCutQuery.AddNewBeamCutInterface(binterface); if (beamInterface == null) { Exception = new RespException(true, "Add new BInterface error", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } bId = beamInterface.id; } StockMeasure stockMeasure = StockQuery.GetStockMeasure(schedule); if (stockMeasure == null) { var stock = StockQuery.AddNewStockMeasure(schedule); } Exception = new RespException(false, "Start cutting: OK", EKB_SYS_REQUEST.BEAM_START_CUTTING); InterfaceId = bId; } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_START_CUTTING); } }
public RespSchedule(IDbName database, string line, int month, int startId) { try { BeamCutQuery = new BeamCutQuery(database); ScheduleQuery = new ScheduleQuery(database); BuildingQuery = new BuildingQuery(database); var productionLine = BuildingQuery.FindProductionLine(line); DateTime SearchTime = new DateTime(DateTime.Now.Year, month, DateTime.Now.Day); if (productionLine == null) { Exception = new RespException(true, "Line name is not found", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } var schedules = ScheduleQuery.GetSchedules(SearchTime); if (schedules == null) { Exception = new RespException(true, $"Can not find the schedule for month:{month}", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); return; } List <Schedule> newSchedule = new List <Schedule>(); foreach (var item in productionLine) { var temp = schedules.Where(i => i.ProductionLine_Id == item.id); if (temp.Count() > 0) { newSchedule.AddRange(temp.ToList()); } } ScheduleList = new List <Schedule_t>(); var tempSch = newSchedule.Where(i => i.id > startId).Take(15).ToList(); if (tempSch.Count() > 0) { newSchedule = newSchedule.Where(i => i.id > startId).Take(15).ToList(); } else { newSchedule = newSchedule.Take(15).ToList(); } ScheduleList = new List <Schedule_t>(); foreach (var item in newSchedule) { var bInterface = BeamCutQuery.GetBeamInterfaceByScheduleId(item.id); var sch = new Schedule_t(database, item); if (bInterface != null) { sch.Cutting = true; } ScheduleList.Add(sch); } Exception = new RespException(false, "Get schedule: OK", EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_SCHEDULE); } }
public async Task <QueryResult <ScheduleQueryRow> > QuerySchedule( ScheduleQueryFilter filter = null, ScheduleQuerySort sort = null, ScheduleQueryProjection projection = null, ScheduleQueryPaging paging = null, ScheduleQueryOptions options = null) { var conn = context.Database.GetDbConnection(); var openConn = conn.OpenAsync(); var query = ScheduleQuery.CreateDynamicSql(); #region General if (filter != null) { query = query.SqlFilter(filter); } if (projection != null) { query = query.SqlJoin(projection); } DynamicSql countQuery = null; int?totalCount = null; Task <int> countTask = null; if (options != null && options.count_total) { countQuery = query.SqlCount("*"); } if (projection != null) { query = query.SqlProjectFields(projection); } #endregion await openConn; if (options != null && !options.single_only) { #region List query if (sort != null) { query = query.SqlSort(sort); } if (paging != null && (!options.load_all || !ScheduleQueryOptions.IsLoadAllAllowed)) { query = query.SqlSelectPage(paging.page, paging.limit); } #endregion #region Count query if (options.count_total) { countTask = conn.ExecuteScalarAsync <int>( sql: countQuery.PreparedForm, param: countQuery.DynamicParameters); } #endregion } if (projection != null) { query = query.SqlExtras(projection); } var multipleResult = await conn.QueryMultipleAsync( sql : query.PreparedForm, param : query.DynamicParameters); using (multipleResult) { var queryResult = multipleResult.Read( types: query.GetTypesArr(), map: (objs) => ProcessMultiResults(query, objs), splitOn: string.Join(',', query.GetSplitOns())); if (projection != null) { var extraKeys = projection.GetFieldsArr() .Where(f => ScheduleQueryProjection.Extras.ContainsKey(f)); IEnumerable <ScheduleDetail> details = null; foreach (var key in extraKeys) { switch (key) { case ScheduleQueryProjection.DETAILS: details = multipleResult.Read <ScheduleDetail>().ToList(); break; } } ProcessExtras(queryResult, details); } if (options != null && options.single_only) { var single = queryResult.FirstOrDefault(); if (single == null) { return(null); } return(new QueryResult <ScheduleQueryRow> { SingleResult = single }); } if (options != null && options.count_total) { totalCount = await countTask; } return(new QueryResult <ScheduleQueryRow> { Results = queryResult, TotalCount = totalCount }); } }
public RespFinishAll(IDbName database, int bInterfaceId, int cutCounter) { BeamCutQuery BeamCutQuery = new BeamCutQuery(database); StockQuery StockQuery = new StockQuery(database); EmployeeQuery EmployeeQuery = new EmployeeQuery(database); SequenceQuery SequenceQuery = new SequenceQuery(database); ScheduleQuery ScheduleQuery = new ScheduleQuery(database); ComponentQuery ComponentQuery = new ComponentQuery(database); try { var bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.FINISH_ALL); return; } var clonePo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id)); if (clonePo == null) { Exception = new RespException(true, "Invalid clone Po Id", EKB_SYS_REQUEST.BEAM_START_CUTTING); return; } int addQty = 0; foreach (var seq in clonePo.BeamCutSeqs) { var currentSeq = BeamCutQuery.GetBeamCutSeq(seq.id); if (currentSeq.SequenceNo < bInterface.SequenceNo + bInterface.TotalSequence) { foreach (var size in seq.BeamCutSizes) { addQty += ShareFuncs.GetInt(size.SizeQty - size.CutQty); size.CutQty = size.SizeQty; size.Finished = true; size.LastUpdate = DateTime.Now; BeamCutQuery.UpdateBeamSize(size); } currentSeq.CutQty += addQty; currentSeq.LastUpdate = DateTime.Now; currentSeq.Finish = true; BeamCutQuery.UpdateBeamCutSeq(currentSeq); } } bInterface.BeamCutCounter += cutCounter; bInterface.CuttingQty += addQty; bInterface.StopCutTime = DateTime.Now; if (!BeamCutQuery.UpdateBeamInterface(bInterface)) { Exception = new RespException(true, "Can not update BInterface", EKB_SYS_REQUEST.FINISH_ALL); return; } } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.FINISH_ALL); } }
public BLastCut(IDbName database, int bdeviceId, int bInterfaceId) { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); try { var bInterface = BeamCutQuery.GetLastInterface(bdeviceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); bInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId); if (bInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } } var bpo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(bInterface.BeamCutPo_Id)); if (bpo == null) { Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } var originalPo = SequenceQuery.GetOriginalPo(ShareFuncs.GetInt(bInterface.OriginalPo_Id)); if (originalPo == null) { Exception = new RespException(true, "Can not find Po", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); return; } BinterfaceId = bInterface.id; PoNumber = originalPo.PoNumber; StartSeq = ShareFuncs.GetInt(bInterface.StartSeqNo); StopSeq = ShareFuncs.GetInt(bInterface.StopSeqNo); if (bInterface.StartCutTime != null) { StartTime = ((DateTime)bInterface.StartCutTime).ToString("hh:mm tt, dd/MM/yyyy"); } if (bInterface.StopCutTime != null) { StopTime = ((DateTime)bInterface.StopCutTime).ToString("hh:mm tt, dd/MM/yyyy"); } CutQty = ShareFuncs.GetInt(bInterface.CuttingQty); CutTime = ShareFuncs.GetInt(bInterface.BeamCutCounter); Employee_Id = ShareFuncs.GetInt(bInterface.Employee_Id); Schedule_Id = ShareFuncs.GetInt(bInterface.Schedule_Id); BeamCutPo_Id = ShareFuncs.GetInt(bInterface.BeamCutPo_Id); BeamCutStartSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStartSeq_Id); Component_Id = ShareFuncs.GetInt(bpo.Component_Id); BeamCutStopSeq_Id = ShareFuncs.GetInt(bInterface.BeamCutStopSeq_Id); Finish = bInterface.Finish != null ? (bool)bInterface.Finish : false; PoQty = ShareFuncs.GetInt(originalPo.Quantity); OriginalPo_Id = ShareFuncs.GetInt(bInterface.OriginalPo_Id); var component = ComponentQuery.GetShoeComponent(ShareFuncs.GetInt(bpo.Component_Id)); if (component != null) { string comp = ShareFuncs.ConvertToUnSign(component.Reference); Component = comp; } Exception = new RespException(false, "Get last cut: OK", EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_GET_LAST_CUT); } }
static void Main(string[] args) { IDbName database = new RealDb(); SequenceQuery sequenceQuery = new SequenceQuery(database); ScheduleQuery ScheduleQuery = new ScheduleQuery(database); var po = sequenceQuery.GetOriginalPo(3987); var schedule = ScheduleQuery.GetSchedule(po); //IDbName database = new FakeDb(); while (true) { string s = Console.ReadLine().ToLower(); if (s.Contains("update-database")) { SERVER_INITIALIZE.DbSeed DB = new SERVER_INITIALIZE.DbSeed(database); DB.Runing(); } if (s.Contains("update-schedule")) { Console.WriteLine("Start checking..."); AutoScheule AutoSchedule = new AutoScheule(database); AutoSchedule.Update(); Console.WriteLine("Stop checking..."); } if (s.Contains("get-schedule")) { ScheduleQuery scheduleQuery = new ScheduleQuery(database); var schedules = scheduleQuery.GetSchedules("012").Take(5); foreach (var item in schedules) { Console.WriteLine($"Id:{item.id}, Number: {item.PoNumber}"); } Console.WriteLine("Please select scheule to clone"); string num = Console.ReadLine(); int scheduleId = 0; int.TryParse(num, out scheduleId); BeamCutQuery beamCutQuery = new BeamCutQuery(database); var results = beamCutQuery.CloneOriginalPo(scheduleId); if (results != null) { foreach (var item in results) { Console.WriteLine($"Original Id: {item.OriginalPo_Id}, Comp Id: {item.Component_Id}"); foreach (var seq in item.BeamCutSeqs) { Console.WriteLine($"Seq Id: {seq.id}, Seq No: {seq.SequenceNo}, Seq Qty: {seq.SequenceQty}"); foreach (var size in seq.BeamCutSizes) { Console.WriteLine($"Size Id: {size.SizeId},Beam Po Id: {size.BeamCutPo_Id}, Beam Seq Id: {size.BeamCutSeq_Id}"); } } } } } if (s.Contains("request-schedule")) { var schedules = new RespSchedule(database, "L3", 12, 0); Console.WriteLine(JsonConvert.SerializeObject(schedules)); } if (s.Contains("request-poinfo")) { //var schedules = new EKB_WEBSERVER.API.RuntimeModels.RespPoInfo(database, 2541 ,341); } if (s.Contains("request-size")) { var sizes = new RespSize(database, 3, 9, 341); Console.WriteLine(JsonConvert.SerializeObject(sizes)); } if (s.Contains("request-lastcut")) { //Console.WriteLine(JsonConvert.SerializeObject(new BLastCut(database, 4))); } if (s.Contains("info")) { //var sizes = new EKB_WEBSERVER.API.RuntimeModels.RespPoInfo(database, 2540, 322); //Console.WriteLine(JsonConvert.SerializeObject(sizes)); } if (s.Contains("cuttime")) { var temp = new BDeviceCutTime(database, 1, 6); } } }
public ConfirmResponse(IDbName _database, int _ekanbanDeviceId, int _confirmQty) { try { EKanbanTaskQuery eKanbanTaskQuery = new EKanbanTaskQuery(_database); SequenceQuery sequenceQuery = new SequenceQuery(_database); ComponentQuery componentQuery = new ComponentQuery(_database); StockQuery stockQuery = new StockQuery(_database); ScheduleQuery scheduleQuery = new ScheduleQuery(_database); SysHistoryQuery sysHistoryQuery = new SysHistoryQuery(_database); var Interface = eKanbanTaskQuery.GetLastEKanbanInterface(_ekanbanDeviceId); var his = sysHistoryQuery.GetEKanbanHistory(Interface); if (Interface.SysActionCode == (int)SYS_MODELS._ENUM.SysActionCode.EKANBAN_CONFIRM_ITEM) { ConfirmSuccess = true; EMessage = "EKanban is already conform!"; return; } Interface.SysActionCode = (int)SYS_MODELS._ENUM.SysActionCode.EKANBAN_CONFIRM_ITEM; Interface.LastUpdate = DateTime.Now; if (!eKanbanTaskQuery.UpdateEKanbanInterface(Interface)) { ConfirmSuccess = false; EMessage = "EKanban is already conform!"; return; } List <Schedule> schedules = new List <Schedule>(); foreach (var item in Interface.EKanbanLoadings) { var sch = scheduleQuery.GetSchedule(ShareFuncs.GetInt(item.OriginalPo_Id)); var Seq = sequenceQuery.GetOriginalSequence(ShareFuncs.GetInt(item.OriginalSequence_Id)); if (sch != null) { var stock = stockQuery.GetPrepareStockMeasure(sch); if (stock != null) { StockConfirmSequence stockConfirm = new StockConfirmSequence { FinishTime = DateTime.Now, SequenceNo = Seq.SequenceNo, SequenceQty = Seq.Quantity, StockMeasure_Id = stock.id, }; StockMessage = "Update stock message successfully"; if (!stockQuery.AddNewStockConfirm(stockConfirm)) { StockMessage = "An error orcured while updating stock"; } stock.ConfirmUpdateTime = DateTime.Now; stock.EKanbanConfirmQty += Seq.Quantity; if (!stockQuery.UpdateStockMeasure(stock)) { StockMessage = "An error orcured while updating stock"; } } } item.SysActionCode = (int)SYS_MODELS._ENUM.SysActionCode.SEQUENCE_CONFORM; item.LastUpdate = DateTime.Now; item.ConfirmQty = _confirmQty; eKanbanTaskQuery.UpdateEKanbanLoading(item); string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(Interface); his.Data = jsonStr; his.DateTime = DateTime.Now; sysHistoryQuery.UpdateEKanbanHis(his); EKanbanConfirmHis eKanbanConfirmHis = new EKanbanConfirmHis { Conform = true, DateTime = DateTime.Now, EKanbanHis_Id = his.id, OriginalSequence_Id = Seq.id, SequenceNo = Seq.SequenceNo, SequenceQty = Seq.Quantity, }; sysHistoryQuery.AddNewConfirmHistory(eKanbanConfirmHis); } ConfirmSuccess = true; EMessage = "EKanban is conform successfully"; } catch (Exception e) { EMessage = e.Message; } }
public void Update() { IBuidingQuery = new BuildingQuery(database); IScheduleQuery = new ScheduleQuery(database); bool success = false; FilePath filePath = IScheduleQuery.GetFilePath("schedule"); if (filePath == null) { Console.WriteLine("File Path is null"); } IEnumerable <string> folderList = Directory.EnumerateDirectories(filePath.Path); foreach (var scheduleFilePath in folderList) { Console.WriteLine(scheduleFilePath); DateTime lastEditFolder = Directory.GetLastWriteTime(scheduleFilePath); DirectoryInfo Directorys = new DirectoryInfo(scheduleFilePath); //Assuming Test is your Folder FileInfo[] Files = Directorys.GetFiles("*.xlsm"); //Getting Text files if (Files.Length == 0) { Console.WriteLine("Folder is empty, Continue the next one"); continue; } FileInfo LastFile = Files[Files.Length - 1]; string folderName = GetScheduleClass(scheduleFilePath); // checking folder var scheduleClass = IScheduleQuery.GetScheduleClass(folderName);//CheckingFolder(folderName); if (scheduleClass != null) { Console.WriteLine("Schedule Class is not Null"); if (!CheckingFolderModified(scheduleClass, lastEditFolder)) { Console.WriteLine("Nothing changed, Countinue!"); continue; } scheduleClass.LastModified = lastEditFolder; Console.WriteLine($"Last file: modified time:{scheduleClass.LastModified.ToString()}"); var updateSchProperties = scheduleClass.UpdateSchProperty; if (updateSchProperties == null) { //update scheduleclass updateSchProperties = new UpdateSchProperty { FileName = LastFile.Name, CreatedDate = LastFile.CreationTime, ModifiedDate = LastFile.LastWriteTime, }; success = IScheduleQuery.AddNewScheduleProperties(updateSchProperties); if (success) { Console.WriteLine("Add new schedule class property successfull"); } else { Console.WriteLine("Add new schedule class property error"); } } else { string time1 = updateSchProperties.ModifiedDate.ToString("MM/dd/yyyy, hh:mm:"); string time2 = LastFile.LastWriteTime.ToString("MM/dd/yyyy, hh:mm:"); if (time1 == time2) { Console.WriteLine("Nothing changed, Continue!"); continue; } } Console.WriteLine("Update Excel file:{0}", LastFile); //update file UpdateScheduleFile(LastFile, scheduleClass); scheduleClass.UpdateSchProperties_Id = updateSchProperties.id; success = IScheduleQuery.UpdateScheuleClass(scheduleClass); if (success) { Console.WriteLine("Update schedule class successfully"); } else { Console.WriteLine("Update schedule class error"); } updateSchProperties.FileName = LastFile.Name; updateSchProperties.CreatedDate = LastFile.CreationTime; updateSchProperties.ModifiedDate = LastFile.LastWriteTime; success = IScheduleQuery.UpdateScheuleProperties(updateSchProperties); if (success) { Console.WriteLine("Update schedule class property successfully"); } else { Console.WriteLine("Update schedule class property error"); } Console.WriteLine("Finished add"); } else { Console.WriteLine("Schedule Class is null"); // add new folder add new file ScheduleClass schClass = new ScheduleClass { Name = folderName, LastModified = lastEditFolder }; success = IScheduleQuery.AddNewScheuleClass(schClass); if (success) { Console.WriteLine("Add new schedule class successfully"); } else { Console.WriteLine("Add new schedule class error"); } //update file UpdateScheduleFile(LastFile, schClass); UpdateSchProperty prop = new UpdateSchProperty { FileName = LastFile.Name, CreatedDate = LastFile.CreationTime, ModifiedDate = LastFile.LastWriteTime }; success = IScheduleQuery.AddNewScheduleProperties(prop); if (success) { Console.WriteLine("Add new schedule class property successfully"); } else { Console.WriteLine("Add new schedule class property error"); } schClass.UpdateSchProperties_Id = prop.id; success = IScheduleQuery.UpdateScheuleClass(schClass); if (success) { Console.WriteLine("Update schedule class successfully"); } else { Console.WriteLine("Update schedule class error"); } } } }
public RespConfirmSize(IDbName database, int bInterfaceId, int sizeId, int sizeQty) { try { BeamCutQuery = new BeamCutQuery(database); StockQuery = new StockQuery(database); EmployeeQuery = new EmployeeQuery(database); SequenceQuery = new SequenceQuery(database); ScheduleQuery = new ScheduleQuery(database); ComponentQuery = new ComponentQuery(database); var beamInterface = BeamCutQuery.GetBeamInterfaceById(bInterfaceId); if (beamInterface == null) { Exception = new RespException(true, "Can not find BInterface", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); return; } var bdevice = BeamCutQuery.GetBeamCutDevice(beamInterface.BeamCutDevice_Id); if (bdevice == null) { Exception = new RespException(true, "Can not find beam cut device", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); return; } var clonePo = BeamCutQuery.GetBeamCutPo(ShareFuncs.GetInt(beamInterface.BeamCutPo_Id)); if (clonePo == null) { Exception = new RespException(true, "Can not find clone Po", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); return; } var seq1 = BeamCutQuery.GetBeamCutSeq(ShareFuncs.GetInt(beamInterface.BeamCutStartSeq_Id)); var seq2 = BeamCutQuery.GetBeamCutSeq(ShareFuncs.GetInt(beamInterface.BeamCutStopSeq_Id)); int cutQty = 0; int totalQty = 0; int currentQty = 0; int addQty = 0; int seqTotalQty = 0; int seqQty = 0; foreach (var seq in clonePo.BeamCutSeqs) { if (seq.SequenceNo >= seq1.SequenceNo && seq.SequenceNo <= seq2.SequenceNo) { if (seq.Finish == false) { var sizes = BeamCutQuery.GetBeamCutSize(seq.id); int seqcutQty = ShareFuncs.GetInt(seq.CutQty); foreach (var size in sizes) { if (size.SizeId == sizeId) { if (size.Finished != true && sizeQty > 0) { int oldval = ShareFuncs.GetInt(size.CutQty); int addval = ShareFuncs.GetInt(size.SizeQty) - oldval; if (sizeQty >= addval) { addval = ShareFuncs.GetInt(size.SizeQty) - oldval; size.CutQty = size.SizeQty; size.Finished = true; seqcutQty += addval; sizeQty -= addval; addQty += addval; } else { size.CutQty += sizeQty; seqcutQty += sizeQty; addQty += sizeQty; sizeQty = 0; } size.BeamCutDevice_Id = beamInterface.BeamCutDevice_Id; size.Worker_Id = beamInterface.Employee_Id; size.LastUpdate = DateTime.Now; BeamCutQuery.UpdateBeamSize(size); } totalQty += ShareFuncs.GetInt(size.SizeQty); cutQty += ShareFuncs.GetInt(size.CutQty); } currentQty += ShareFuncs.GetInt(size.CutQty); } seq.BeamCutDevice_Id = beamInterface.BeamCutDevice_Id; seq.Worker_Id = beamInterface.Employee_Id; seq.CutQty = seqcutQty; seq.LastUpdate = DateTime.Now; seq.Finish = seq.CutQty == seq.SequenceQty ? true : false; BeamCutQuery.UpdateBeamCutSeq(seq); } seqTotalQty += ShareFuncs.GetInt(seq.CutQty); seqQty += ShareFuncs.GetInt(seq.SequenceQty); } } if (seqTotalQty == seqQty) { StopCutting = true; } int oldVal = beamInterface.CuttingQty != null ? (int)beamInterface.CuttingQty : 0; beamInterface.LastConfirmSize = DateTime.Now; beamInterface.CuttingQty = addQty + oldVal; BeamCutQuery.UpdateBeamInterface(beamInterface); clonePo.LastUpdate = DateTime.Now; clonePo.CuttingQuantity += addQty; if (clonePo.CuttingQuantity == clonePo.PoQuantity) { clonePo.Finish = true; clonePo.FinishTime = DateTime.Now; } BeamCutQuery.UpdateBeamCutPo(clonePo); var statistic = BeamCutQuery.GetBMachineStatistic(ShareFuncs.GetInt(beamInterface.BeamCutDevice_Id), DateTime.Now); if (statistic == null) { statistic = BeamCutQuery.AddNewBcutStatistic(ShareFuncs.GetInt(beamInterface.BeamCutDevice_Id), DateTime.Now); } BDeviceCutTimeRecord record = new BDeviceCutTimeRecord { TotalCutTime = 0, BeamCutDevice_Id = bdevice.id, ConfirmQuantity = addQty, BMachineStatistic_Id = statistic.id, }; if (!BeamCutQuery.AddNewBCutTimeRecord(record)) { Exception = new RespException(true, "Add new record failed", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); } int temp = statistic.TotalCutQty != null ? (int)statistic.TotalCutQty : 0; statistic.TotalCutQty = temp + addQty; BeamCutQuery.UpdateBStatistic(statistic); RespTotalCuttingQty = ShareFuncs.GetInt(beamInterface.CuttingQty); SizeId = sizeId; CutQty = cutQty; Finish = (totalQty == cutQty ? true : false); Exception = new RespException(false, "Confirm Size: OK", EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); } catch (Exception e) { Exception = new RespException(true, e.Message, EKB_SYS_REQUEST.BEAM_CONFIRM_SIZE); } }
static async Task BotOnMessageReceived(Message message) { if (message.Type != MessageType.Text) { return; } try { string cmd = message.Text.Split(' ')[0]; switch (cmd) { case ("/setgroup"): { await Commands.SetGroup(message.Text); await Bot.SendTextMessageAsync(message.Chat.Id, $"Group set successfully"); //отправляет сообщение break; } case ("/getschedule"): { await Commands.GetSchedule(message.Text); await ScheduleQuery.SQuery(Commands.parts[1], Commands.parts[2], Commands.parts[3]); // получение расписания await Bot.SendTextMessageAsync(message.Chat.Id, $"{ScheduleQuery.schedule}"); //отправляет сообщение Console.WriteLine($"Receive message type: {message.Type}"); // проверка на отправку break; } case ("/help"): { await Commands.Help(); await Bot.SendTextMessageAsync(message.Chat.Id, Commands.parts[0]); break; } case ("/start"): { await Commands.Start(); await Bot.SendTextMessageAsync(message.Chat.Id, Commands.parts[0]); break; } default: throw new Exception("Sorry, I don't understand you ;( Check the data you entered"); } } catch (Exception ex) { if (ex.Message.CompareTo("Этот хост неизвестен.") == 0 || ex.Message.CompareTo("Response status code does not indicate success: 503 (Service Unavailable).") == 0) { await Bot.SendTextMessageAsync(message.Chat.Id, "Error 504. IIS is not available."); } else if (ex.Message.CompareTo("Error reading JObject from JsonReader. Path '', line 0, position 0.") == 0) { await Bot.SendTextMessageAsync(message.Chat.Id, "The group you set does not exist.\nPlease change the group number with the /setgroup command"); } else { await Bot.SendTextMessageAsync(message.Chat.Id, ex.Message); //отправляет сообщение } Console.WriteLine(ex.Message); } }