예제 #1
0
		/// <summary>
		/// Clears the states and connectors and reloads dataservice, stations and activities
		/// </summary>
		/// <param name="clearModel">specify 'true' to create a new model as well</param>
		public void ResetFPC(bool clearModel = false)
		{
			_lock = false;
			Message = new DependencyMessageBox();

			if (_uow == null)
			{
				fpcDataService = new FPCDataService();
				reworkDataService = new ReworkDataService();
			}
			else
			{
				fpcDataService = new FPCDataService(_uow);
				reworkDataService = new ReworkDataService(_uow);
			}

			//Stations
			Stations.Clear();
			var stations = fpcDataService.stationDataService.GetActives();
			foreach (var item in stations)
				Stations.Add(new StationVm(item));

			//ActivityGroups
			ActivityGroups.Clear();
			var actgs = fpcDataService.activityGroupDataService.GetActives();
			foreach (var item in actgs)
				ActivityGroups.Add(new ActivityGroupVm(item));

			//Drawing area
			States.Clear();
			Connectors.Clear();
			FocusedState = null;

			if (clearModel)
				Model = new Model.FPC();
		}
예제 #2
0
		/// <summary>
		/// Initialize Commands
		/// </summary>
		private void initCommands()
		{
			SaveAllCommand = new Commands.Command(o =>
			{
				try
				{
					foreach (var state in States)
					{
						state.PromptSave();
					}
					fpcDataService.ApplyChanges();

					//check for tracability
					Soheil.Core.PP.Smart.SmartJob.AutoRouteCheck(this.Id);
					//always throws, so no after lines
				}
				catch (SoheilExceptionBase exp)
				{
					string msg = "";
					if (exp.Level == ExceptionLevel.Error)
						msg += "FPC تعریف شده قابل مسیریابی نمی باشد.\nدر صورتی که می خواهید از قابلیت افزودن خودکار Job استفاده نمایید بایستی FPC را اصلاح کنید.\n";
					msg += exp.Message;
					Message = new DependencyMessageBox(msg, exp.Caption, MessageBoxButton.OK, exp.Level);
				}
				catch (Exception exp)
				{
					Message = new DependencyMessageBox(
						exp,
						"در ذخیره سازی خطای پیش آمد.",
						"خطا",
						MessageBoxButton.OK,
						ExceptionLevel.Error);
				}
			});
			ExpandAllCommand = new Commands.Command(o =>
			{
				var items = States.Where(x => x.StateType == StateType.Mid);
				foreach (var item in items)
				{
					item.ShowDetails = true;
				}
			});
			CollapseAllCommand = new Commands.Command(o =>
			{
				foreach (var item in States.Where(x => x.StateType == StateType.Mid))
				{
					item.ShowDetails = false;
				}
			});
			ResetZoomCommand = new Commands.Command(o => Zoom = 1d);
		}
예제 #3
0
			internal static Button No(DependencyMessageBox parent)		{ return new Button(parent) { Text = "No",		Result = MessageBoxResult.No }; }
예제 #4
0
		/// <summary>
		/// Updates ViewModel from Model
		/// </summary>
		public void ChangeFpcByModel()
		{
			try
			{
				//-----------
				//load basics
				//-----------
				IsDefault = Model.IsDefault;
				Product = new ProductVm(Model.Product);

				//load all product reworks
				var productReworkModels = fpcDataService.GetProductReworks(Model, includeMainProduct: false);
				ProductReworks.Clear();
				foreach (var prodrew in productReworkModels)
				{
					ProductReworks.Add(new ProductReworkVm(prodrew));
				}

				//Reworks
				Reworks.Clear();
				var rws = reworkDataService.GetActives();
				foreach (var item in rws)
				{
					Reworks.Add(new ReworkVm(item));
				}


				//-----------
				//load states
				//-----------
				fpcDataService.CorrectFPCStates(Model);
				//reload states
				var states = fpcDataService.stateDataService.GetStatesByFpcId(Id);
				//show all states
				foreach (var item in states)
				{
					States.Add(new StateVm(item, this));
				}

				//----------
				//load conns
				//----------
				var conns = fpcDataService.connectorDataService.GetByFpcId(Id);
				foreach (var item in conns)
				{
					Connectors.Add(new ConnectorVm(item,
						States.FirstOrDefault(x => x.Id == item.StartState.Id),
						States.FirstOrDefault(x => x.Id == item.EndState.Id),
						fpcDataService.connectorDataService));
				}
			}
			catch (SoheilExceptionBase exp)
			{
				string msg = "";
				if (exp.Level == ExceptionLevel.Error)
					msg += "مشکلی در خواندن اطلاعات پیش آمد";
				msg += exp.Message;
				Message = new DependencyMessageBox(msg, exp.Caption, MessageBoxButton.OK, exp.Level);

			}
			catch (Exception exp)
			{
				Message = new DependencyMessageBox(exp);
			}

			//select the first mid-state
			if (States.Count(x => x.StateType == StateType.Mid) > 0)
				FocusedState = States.Where(x => x.StateType == StateType.Mid).First();
		}
예제 #5
0
			internal static Button Yes(DependencyMessageBox parent)		{ return new Button(parent) { Text = "Yes",		Result = MessageBoxResult.Yes }; }
예제 #6
0
			internal static Button Cancel(DependencyMessageBox parent)	{ return new Button(parent) { Text = "Cancel",	Result = MessageBoxResult.Cancel }; }
예제 #7
0
			internal static Button OK(DependencyMessageBox parent)		{ return new Button(parent) { Text = "OK",		Result = MessageBoxResult.OK }; }
예제 #8
0
			public Button(DependencyMessageBox parent)
			{
				Clicked = new ClickCommand(this, parent);
			}
예제 #9
0
			public ClickCommand(Button button, DependencyMessageBox messageBox)
			{
				_button = button;
				_messageBox = messageBox;
			}