public void Execute(Guid taskId) { _starttime = DateTime.Now; try { Mds = new MongoDataService(); var task = Mds.GetCollectionQueryModel<RoverTask>(Query.EQ("_id", taskId)).FirstOrDefault(); if (task != null) switch (task.TaskType) { case RoverTaskType.Execute: break; case RoverTaskType.Train: RoverTrainProperties trainprops = task.TrainingProperties; RobotContol c = new RobotContol(_starttime,taskId); c.BuildNetwork(trainprops.StartPosition.X,trainprops.StartPosition.Y,trainprops.DestinationPosition.X,trainprops.DestinationPosition.Y); break; } else { this.RaiseOnErrorOccured(new OnErrorArgs(){Error="Task Not Found!",TaskId=taskId}); this.RaiseOnProgress(new OnProgressArgs(){CurrentTime=DateTime.Now,PercentComplete=0,Status=TaskStatus.Failed,TaskId=taskId,StartTime = _starttime}); } } catch (Exception err) { RaiseOnErrorOccured(new OnErrorArgs() { TaskId = taskId, Error = err.Message }); } }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { SetWindowTitle(); Mds = new MongoDataService(); InitConnection(); RC = new RobotContol(DateTime.Now, Guid.Empty); SourceData = new DataSource(); SourceData.ModeMap = MapMode.ShipMode; SourceData.Simulation = new RobotSimulator(new Position(0, 0), new Position(40, 60)); SourceData.Warehouse = Mds.GetCollectionQueryModel<Rover.Models.Warehouse>().FirstOrDefault(); if (SourceData.Warehouse == null) SourceData.Warehouse = new Rover.Models.Warehouse { Id = Guid.NewGuid(), Positions = new ObservableCollection<Position>() }; else DrawMap(); DataContext = SourceData; //ModeGrid.DataContext = SourceData; //maptb.DataContext = this; BuidMenu(); }