コード例 #1
0
 //TODO: Удалить после удаления всех старых операций
 /// <summary>
 /// Установить вагон на станцию на путь
 /// </summary>
 /// <param name="wir"></param>
 /// <param name="id_station"></param>
 /// <param name="id_way"></param>
 /// <param name="date_start"></param>
 /// <param name="position"></param>
 /// <param name="note"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static WagonInternalRoutes SetStationWagon_old(this WagonInternalRoutes wir, int id_station, int id_way, DateTime date_start, int position, string note, string user)
 {
     if (wir != null && wir.close == null)
     {
         WagonInternalMovement wim = wir.GetLastMovement();
         // Исключим попытку поставить дублирования записи постановки на путь
         if (wim == null || (wim != null && (wim.id_station != id_station || wim.id_way != id_way || wim.position != position)))
         {
             WagonInternalMovement wim_new = new WagonInternalMovement()
             {
                 id = 0,
                 //id_wagon_internal_routes = wir.id,
                 id_station = id_station,
                 //station_start = date_start,
                 id_way          = id_way,
                 way_start       = date_start,
                 id_outer_way    = null,
                 outer_way_start = null,
                 outer_way_end   = null,
                 position        = position,
                 create          = DateTime.Now,
                 create_user     = user,
                 note            = note,
                 parent_id       = wim.CloseMovement(date_start, null, user)
             };
             wir.WagonInternalMovement.Add(wim_new);
         }
     }
     return(wir);
 }
コード例 #2
0
        public static WagonInternalMovement SetStationWagon(this WagonInternalRoutes wir, int id_station, int id_way, DateTime date_start, int position, string note, string user, bool check_replay)
        {
            WagonInternalMovement wim_new = null;

            if (wir != null && wir.close == null)
            {
                // Получим последнее положение
                WagonInternalMovement wim = wir.GetLastMovement();
                // Исключим попытку поставить дублирования записи постановки на путь
                if (wim == null || (wim != null && (wim.id_station != id_station || wim.id_way != id_way || wim.position != position || wim.id_outer_way != null)))
                {
                    wim_new = new WagonInternalMovement()
                    {
                        id              = 0,
                        id_station      = id_station,
                        id_way          = id_way,
                        way_start       = date_start,
                        way_end         = null,
                        position        = position,
                        id_outer_way    = null,
                        outer_way_start = null,
                        outer_way_end   = null,
                        create          = DateTime.Now,
                        create_user     = user,
                        num_sostav      = null,
                        note            = note,
                        parent_id       = wim.CloseMovement(date_start, null, user),
                    };
                    wir.WagonInternalMovement.Add(wim_new);
                }
            }
            return(wim_new);
        }
コード例 #3
0
        /// <summary>
        /// Закрыть запись позиции вагона
        /// </summary>
        /// <param name="wim"></param>
        /// <param name="date_end"></param>
        /// <param name="note"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static long?CloseMovement(this WagonInternalMovement wim, DateTime date_end, string note, string user)
        {
            if (wim == null)
            {
                return(null);
            }
            if (wim.close == null)
            {
                // Определим какой путь закрывать Внутрений или внешний
                if (wim.id_outer_way == null)
                {
                    // Закроем внутрений
                    wim.way_end = wim.way_end == null ? date_end : wim.way_end;
                    //wim.station_end = wim.station_end == null ? date_end : wim.station_end;
                }
                else
                {
                    // Закроем внешний путь
                    wim.outer_way_end = wim.outer_way_end == null ? date_end : wim.outer_way_end;
                }

                wim.note       = note != null ? note : wim.note;
                wim.close      = DateTime.Now;
                wim.close_user = user;
            }
            return(wim.id);
        }
コード例 #4
0
 // TODO: Удалить
 /// <summary>
 /// Установить вагон на путь отправки
 /// </summary>
 /// <param name="wir"></param>
 /// <param name="id_outer_ways"></param>
 /// <param name="date_start"></param>
 /// <param name="position"></param>
 /// <param name="note"></param>
 /// <param name="user"></param>
 /// <returns></returns>
 public static WagonInternalRoutes SetSendingWagon_old(this WagonInternalRoutes wir, int id_outer_ways, DateTime date_start, int position, string note, string user)
 {
     if (wir != null && wir.close == null)
     {
         // Получим последнее положение
         WagonInternalMovement wim = wir.GetLastMovement();
         // Исключим попытку поставить дублирования записи постановки на путь
         if (wim != null && wim.id_outer_way != id_outer_ways)
         {
             WagonInternalMovement wim_new = new WagonInternalMovement()
             {
                 id              = 0,
                 id_station      = wim.id_station,
                 id_way          = wim.id_way,
                 way_start       = wim.way_start,
                 way_end         = wim.way_end == null ? date_start : wim.way_end,
                 id_outer_way    = (int?)id_outer_ways,
                 outer_way_start = date_start,
                 outer_way_end   = null,
                 position        = position,
                 create          = DateTime.Now,
                 create_user     = user,
                 note            = note,
                 parent_id       = wim.CloseMovement(date_start, null, user),
             };
             wir.WagonInternalMovement.Add(wim_new);
         }
     }
     return(wir);
 }
コード例 #5
0
        /// <summary>
        /// Вернуть станцию на которой стоит вагон
        /// </summary>
        /// <param name="wir"></param>
        /// <returns></returns>
        public static int?GetCurrentStation(this WagonInternalRoutes wir)
        {
            if (wir == null || wir.WagonInternalMovement == null)
            {
                return(null);
            }
            WagonInternalMovement wim = wir.GetLastMovement();

            return(wim != null ? (int?)wim.id_station : null);
        }
コード例 #6
0
 public IHttpActionResult GetWagonInternalMovementOfID(long id)
 {
     try
     {
         WagonInternalMovement wim = this.ef_ids
                                     .Context
                                     .Where(s => s.id == id)
                                     .ToList()
                                     .Select(c => c.GetWagonInternalMovement()).FirstOrDefault();
         return(Ok(wim));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }