Exemplo n.º 1
0
		private static bool IsDraftState(State state)
		{
			return (state.IsDraft ?? false);
		}
Exemplo n.º 2
0
		private static bool IsExitState(State state)
		{
			return (state.IsExit ?? false);
		}
Exemplo n.º 3
0
		private static bool IsBaseState(State state)
		{
			return (state.IsBase ?? false);
		}
Exemplo n.º 4
0
		public Workflow(XmlNode nodeWorkflow, bool IsManagedItem, Template template)
		{
			_isManagedItem = IsManagedItem;
			_name = Utility.XMLHelper.GetAttributeString(nodeWorkflow, XMLNames._A_Name);
			if (string.IsNullOrEmpty(_name))
				_name = "New Workflow";
			_id = Guid.Empty;
			string id = Utility.XMLHelper.GetAttributeString(nodeWorkflow, XMLNames._A_ID);
			if (!string.IsNullOrEmpty(id))
			{
				try
				{
					_id = new Guid(id);
				}
				catch
				{
				}
			}
			//If an ID was not assigned before, assign it now....
			if (_id == Guid.Empty)
				_id = Guid.NewGuid();

			_useFunction = Utility.XMLHelper.GetAttributeBool(nodeWorkflow, XMLNames._A_UseFunction);
			_daysAfterWorkflowEntry = Utility.XMLHelper.GetAttributeInt(nodeWorkflow, XMLNames._A_DaysAfterWorkflowEntry);

			//DateExitedBaseState
			XmlNode nodeDateExitedBaseState = nodeWorkflow.SelectSingleNode(XMLNames._E_DateExitedBaseState);
			if (nodeDateExitedBaseState != null)
			{
				_dateExitedBaseState = Utility.XMLHelper.GetValueDate(nodeDateExitedBaseState);
			}

			XmlNodeList listStates = nodeWorkflow.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_States, XMLNames._E_State));

			if (listStates != null)
			{
				_states = new List<State>(listStates.Count);
				foreach (XmlNode nodeState in listStates)
				{
                    State state = new State(nodeState, template, this);
					_states.Add(state);
				}

                foreach (State state in _states)
                {
                    foreach (Action action in state.Actions)
                    {
                        if (!action.TargetStateIDDefined)
                        {
                            State targetState = FindState(action.TargetState);
                            if (targetState == null)
                                throw new Exception(string.Format("Target State not found for action {0} of Workflow {1}, State {2}", action.ButtonText, _name, state.Name));
                            action.TargetStateID = targetState.ID;
                        }
                    }
                }
			}

			//RR - 12/10/2007 - added code (revertToDraftEventSet) to prevent loading of multiple RevertToDraft events for a workflow
			_events = new List<Event>();
			bool revertToDraftEventSet = false;
			XmlNodeList nodeNotifications = nodeWorkflow.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Events, XMLNames._E_Event));
			if (nodeNotifications != null)
			{
				foreach (XmlNode nodeNotification in nodeNotifications)
				{
					Event notification = new Event(nodeNotification, IsManagedItem);
					if (notification.EventType == EventType.WorkflowRevertToDraft)
					{
						if (!revertToDraftEventSet)
						{
							_events.Add(notification);
							revertToDraftEventSet = true;
						}
					}
					else
						_events.Add(notification);
				}
			}
		}
Exemplo n.º 5
0
		public Workflow(string sName, bool IsManagedItem, Template template)
		{
			_isManagedItem = IsManagedItem;
			_name = sName;
			_id = Guid.NewGuid();
			_states = new List<State>();
            State baseState = new State(template);
			baseState.Name = "BaseState";
			baseState.Status = "BaseState Status";
			baseState.IsBase = true;
			baseState.IsDraft = true;
			baseState.IsExit = true;
			_states.Add(baseState);
			_events = new List<Event>();
		}
Exemplo n.º 6
0
        public State Copy(Template sourceTemplate, Workflow destinationWorkflow)
		{
            State state = new State(sourceTemplate);
			state.Name = Name;
			state.Status = Status;
			state.IsDraft = IsDraft;
			state.IsBase = IsBase;
			state.IsExit = IsExit;
			state.RequiresValidation = RequiresValidation;
            state.StateTermGroups.Clear();
            foreach (StateTermGroup stateTermGroup in StateTermGroups)
			{
                state.StateTermGroups.Add(stateTermGroup.Copy());
			}
			state.Actions.Clear();
			foreach (Action action in Actions)
			{
                state.Actions.Add(action.Copy(destinationWorkflow));
			}
			return state;
		}