Example #1
0
        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 { }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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);
        }
Example #4
0
 public Unblock(IDbName _database)
 {
     database        = _database;
     BuildingQuery   = new BuildingQuery(database);
     SequenceQuery   = new SequenceQuery(database);
     SysHistoryQuery = new SysHistoryQuery(database);
     ComponentQuery  = new ComponentQuery(database);
 }
Example #5
0
        public PoInfo(IDbName _database, Schedule _schedule)
        {
            BuildingQuery buildingQuery = new BuildingQuery(_database);

            id        = _schedule.id;
            PoNumber  = _schedule.PoNumber;
            Model     = _schedule.Model;
            Article   = _schedule.Article;
            ModelName = _schedule.ModelName;
            Quantity  = _schedule.Quantity != null ? (int)_schedule.Quantity : 0;
            Line      = buildingQuery.GetProductionLine(ShareFuncs.GetInt(_schedule.ProductionLine_Id)).LineName;
        }
        public async Task <IActionResult> GetOne()
        {
            await Db.Connection.OpenAsync();

            var query  = new BuildingQuery(Db);
            var result = await query.getAllInterventionBuilding();

            await Db.Connection.CloseAsync();

            if (result is null)
            {
                return(new NotFoundResult());
            }
            return(new OkObjectResult(result));
        }
Example #7
0
        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);
            }
        }
Example #8
0
        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 async Task <IReadOnlyCollection <BuildingVm> > Handle(BuildingQuery query, CancellationToken cancellationToken)
        {
            var cacheKey = $"buildings-all";

            var buildingsFromCache = await _distributedCache
                                     .GetCacheAsync <IReadOnlyCollection <BuildingVm> >(cacheKey);

            if (buildingsFromCache != null)
            {
                return(buildingsFromCache);
            }

            var readingsFromDb = await _buildingService.GetBuildingsAsync();

            await _distributedCache
            .SetCacheAsStringAsync(cacheKey, readingsFromDb, 30);

            return(readingsFromDb);
        }
Example #10
0
        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);
            }
        }
Example #11
0
        public async Task <QueryResult <IDictionary <string, object> > > QueryBuildingDynamic(
            BuildingQueryProjection projection,
            BuildingQueryOptions options,
            BuildingQueryFilter filter = null,
            BuildingQuerySort sort     = null,
            BuildingQueryPaging paging = null)
        {
            var conn     = context.Database.GetDbConnection();
            var openConn = conn.OpenAsync();
            var query    = BuildingQuery.CreateDynamicSql();

            #region General
            if (filter != null)
            {
                query = query.SqlFilter(filter);
            }
            query = query.SqlJoin(projection);
            DynamicSql countQuery = null; int?totalCount = null; Task <int> countTask = null;
            if (options.count_total)
            {
                countQuery = query.SqlCount("*");
            }
            query = query.SqlProjectFields(projection);
            #endregion
            await openConn;
            if (!options.single_only)
            {
                #region List query
                if (sort != null)
                {
                    query = query.SqlSort(sort);
                }
                if (paging != null && (!options.load_all || !BuildingQueryOptions.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
            }
            var queryResult = await conn.QueryAsync(
                sql : query.PreparedForm,
                types : query.GetTypesArr(),
                map : (objs) => ProcessMultiResults(query, objs),
                splitOn : string.Join(',', query.GetSplitOns()),
                param : query.DynamicParameters);

            if (options.single_only)
            {
                var single = queryResult.FirstOrDefault();
                if (single == null)
                {
                    return(null);
                }
                var singleResult = GetBuildingDynamic(single, projection, options);
                return(new QueryResult <IDictionary <string, object> >()
                {
                    SingleResult = singleResult
                });
            }
            if (options.count_total)
            {
                totalCount = await countTask;
            }
            var result = GetBuildingDynamic(queryResult, projection, options, totalCount);
            return(result);
        }
Example #12
0
 public async Task <ActionResult <BuildingResponse> > SearchBuildings([FromBody] BuildingQuery query)
 {
     return(Ok(await mediator.Send(query)));
 }