Ejemplo n.º 1
0
        public ActionResult Edit(FormCollection collection)
        {
            try
            {
                var model = new DelayModel();
                UpdateModel(model);

                using (var delayRepo = new DelayRepository())
                {
                    var entity = delayRepo.GetDelay();

                    entity.IterationHour   = model.IterationHour;
                    entity.IterationMinute = model.IterationMinute;
                    entity.IterationSecond = model.IterationSecond;
                    entity.PageHour        = model.PageHour;
                    entity.PageMinute      = model.PageMinute;
                    entity.PageSecond      = model.PageSecond;

                    delayRepo.SaveChanges();
                }


                return(RedirectToAction("Edit"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public long InsertDelay(DelayModel delay)
        {
            long lastInsertedId = -1;

            try
            {
                //@DelayTime,@TrainLineId,@StartDelayStationId,@EndDelayStationId,@TimeStamp
                using (var sqliteConnection = new SQLiteConnection(this.DatabasePath))
                {
                    sqliteConnection.Open();
                    using (SQLiteCommand mCmd = new SQLiteCommand(INSERT_DELAY, sqliteConnection))
                    {
                        mCmd.Parameters.AddWithValue("@DelayTime", delay.DelayTime);
                        mCmd.Parameters.AddWithValue("@TrainLineId", delay.TrainLineId);
                        mCmd.Parameters.AddWithValue("@StartDelayStationId", delay.StartDelayStationId);
                        mCmd.Parameters.AddWithValue("@EndDelayStationId", delay.EndDelayStationId);
                        mCmd.Parameters.AddWithValue("@TimeStamp", delay.TimeStamp);
                        mCmd.ExecuteNonQuery();
                        lastInsertedId = sqliteConnection.LastInsertRowId;
                    }
                }
                return(lastInsertedId);
            }
            catch (Exception e)
            {
                return(lastInsertedId);
            }
        }
Ejemplo n.º 3
0
        public ActionResult SetReleaseDelay(DelayModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Save();
            return(RedirectToAction("Index", "Artifact", new { id = model.SortMainId }));
        }
Ejemplo n.º 4
0
        private void TypeComboBox_Selected(object sender, RoutedEventArgs e)
        {
            if (!IsLoaded)
            {
                return;
            }

            if (TypeComboBox.SelectedIndex < 1)
            {
                MainPresenter.Content = null;
                return;
            }

            if (!IsEditing)
            {
                //Create a new model.
                switch ((DefaultTaskModel.TaskTypeEnum)TypeComboBox.SelectedIndex)
                {
                case DefaultTaskModel.TaskTypeEnum.MouseClicks:
                    CurrentTask = MouseClicksModel.Default();
                    break;

                case DefaultTaskModel.TaskTypeEnum.KeyStrokes:
                    CurrentTask = KeyStrokesModel.Default();
                    break;

                case DefaultTaskModel.TaskTypeEnum.Delay:
                    CurrentTask = DelayModel.Default();
                    break;
                }
            }

            switch ((DefaultTaskModel.TaskTypeEnum)TypeComboBox.SelectedIndex)
            {
            case DefaultTaskModel.TaskTypeEnum.MouseClicks:
                MainPresenter.Content = new MouseClicksPanel {
                    DataContext = CurrentTask
                };
                break;

            case DefaultTaskModel.TaskTypeEnum.KeyStrokes:
                MainPresenter.Content = new KeyStrokesPanel {
                    DataContext = CurrentTask
                };
                break;

            case DefaultTaskModel.TaskTypeEnum.Delay:
                MainPresenter.Content = new DelayPanel {
                    DataContext = CurrentTask
                };
                break;
            }
        }
Ejemplo n.º 5
0
        public ActionResult SetReleaseDelay(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var model = new DelayModel(id.Value);

            if (!model.UserHasWriteAccess)
            {
                return(RedirectToAction("Index", "Home"));
            }

            return(View(model));
        }
Ejemplo n.º 6
0
 /// <summary>
 /// forward the packet to the NEXT
 /// </summary>
 /// <param name="packet"></param>
 /// <param name="next"></param>
 public void RelayPacket(Packet packet, VehicleUi next)
 {
     Dispatcher.Invoke((Action) delegate
     {
         packet.PathWaitingTimes += packet.HopWaitingTimes; // save the path waiting time and clear the hop.
         packet.HopWaitingTimes   = 0;                      // re-intilize the hop-waiting.
         packet.PropagationAndTransmissionDelay += DelayModel.Delay(this, next);
         packet.HopsVehicles    += 1;
         packet.RoutingDistance += Computations.Distance(InstanceLocation, next.InstanceLocation);
         packet.VehiclesString  += "-" + next.VID;
         next.RecievePacket(packet);
         PacketQueueTimer.Interval = TimeSpan.FromSeconds(PublicParamerters.PacketQueueTimerInterval); // retry after...
         next.SetNotationSign(NotationsSign.HasPacket);
         SetNotationSign(NotationsSign.HasNoPacket);
     });
 }
Ejemplo n.º 7
0
 public void DeleteDelay(DelayModel delay)
 {
     try
     {
         using (var sqliteConnection = new SQLiteConnection(this.DatabasePath))
         {
             sqliteConnection.Open();
             using (SQLiteCommand mCmd = new SQLiteCommand(DELETE_DELAY, sqliteConnection))
             {
                 mCmd.Parameters.AddWithValue("@Id", delay.Id);
                 mCmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 8
0
        //// GET: DelayAdmin
        //public ActionResult Index()
        //{
        //    return View();
        //}

        //// GET: DelayAdmin/Details/5
        //public ActionResult Details(int id)
        //{
        //    return View();
        //}

        //// GET: DelayAdmin/Create
        //public ActionResult Create()
        //{
        //    return View();
        //}

        //// POST: DelayAdmin/Create
        //[HttpPost]
        //public ActionResult Create(FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add insert logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        // GET: DelayAdmin/Edit/5
        public ActionResult Edit()
        {
            using (var delayRepo = new DelayRepository())
            {
                var entity = delayRepo.GetDelay();

                var model = new DelayModel
                {
                    IterationHour   = entity.IterationHour,
                    IterationMinute = entity.IterationMinute,
                    IterationSecond = entity.IterationSecond,
                    PageHour        = entity.PageHour,
                    PageMinute      = entity.PageMinute,
                    PageSecond      = entity.PageSecond
                };

                return(View(model));
            }
        }
Ejemplo n.º 9
0
 private void AddDelayButton_Click(object sender, EventArgs e)
 {
     if (!this.CheckIfValidInput(this.DelayStartStaionComboBox.Text) && !this.CheckIfValidInput(this.DelayFinishComboBox.Text) && !this.CheckIfValidInput(this.DelayTimeBox.Text))
     {
         var startStation  = this.TrainLineToEdit.Stations.Where(x => x.StationName == this.DelayStartStaionComboBox.Text).FirstOrDefault();
         var finishStation = this.TrainLineToEdit.Stations.Where(x => x.StationName == this.DelayFinishComboBox.Text).FirstOrDefault();
         if (startStation != null && finishStation != null)
         {
             var delayObject = new DelayModel()
             {
                 DelayTime = long.Parse(this.DelayTimeBox.Text), StartDelayStationId = startStation.Id, EndDelayStationId = finishStation.Id, TrainLineId = this.TrainLineToEdit.Id, TimeStamp = DateTime.Now.Ticks
             };
             var delayId = this.MainRepo.InsertDelay(delayObject);
             delayObject.Id = delayId;
             this.Delays.Add(delayObject);
             this.listView1.Items.Add(new ListViewItem(new[] { this.DelayStartStaionComboBox.Text, this.DelayFinishComboBox.Text, this.DelayTimeBox.Text }));
             this.DelayStartStaionComboBox.Text = string.Empty;
             this.DelayFinishComboBox.Text      = string.Empty;
             this.DelayTimeBox.Text             = string.Empty;
         }
     }
 }
Ejemplo n.º 10
0
 public void UpdateDelay(DelayModel delay)
 {
     try
     {
         using (var sqliteConnection = new SQLiteConnection(this.DatabasePath))
         {
             sqliteConnection.Open();
             using (SQLiteCommand mCmd = new SQLiteCommand(UPDATE_DELAY, sqliteConnection))
             {
                 mCmd.Parameters.AddWithValue("@DelayTime", delay.DelayTime);
                 mCmd.Parameters.AddWithValue("@TrainLineId", delay.TrainLineId);
                 mCmd.Parameters.AddWithValue("@StartDelayStationId", delay.StartDelayStationId);
                 mCmd.Parameters.AddWithValue("@EndDelayStationId", delay.EndDelayStationId);
                 mCmd.Parameters.AddWithValue("@TimeStamp", delay.TimeStamp);
                 mCmd.Parameters.AddWithValue("@Id", delay.Id);
                 mCmd.ExecuteNonQuery();
             }
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }