public StateTermGroup Copy()
 {
     StateTermGroup stateTermGroup = new StateTermGroup(TermGroupID);
     foreach (Role role in Editors)
     {
         stateTermGroup.Editors.Add(role.Copy());
     }
     foreach (Role role in Viewers)
     {
         stateTermGroup.Viewers.Add(role.Copy());
     }
     foreach (Role role in AttachmentRemovers)
     {
         stateTermGroup.AttachmentRemovers.Add(role.Copy());
     }
     foreach (Role role in ScannedAttachmentRemovers)
     {
         stateTermGroup.ScannedAttachmentRemovers.Add(role.Copy());
     }
     return stateTermGroup;
 }
 //The 'roles' variable can be generated from the call 'Role.FromNames(List<string> names)';
 public static void SetStateTermGroupRoles(Template template, StateTermGroup.StateTermGroupRoleType stateTermGroupRoleType, List<Role> roles) 
 {
     foreach (Workflow workflow in template.Workflows)
     {
         foreach (State state in workflow.States)
         {
             state.SetGroupRoles(stateTermGroupRoleType, roles);
         }
     }
 }
Beispiel #3
0
        public void SetGroupRoles(StateTermGroup.StateTermGroupRoleType stateTermGroupRoleType, List<Role> roles) 
        {
            foreach (StateTermGroup stateTermGroup in _stateTermGroups)
            {
                switch (stateTermGroupRoleType)
                {
                    case StateTermGroup.StateTermGroupRoleType.Viewer:
                        stateTermGroup.Viewers = new List<Role>(roles);
                        break;

                    case StateTermGroup.StateTermGroupRoleType.Editor:
                        stateTermGroup.Editors = new List<Role>(roles);
                        break;

                    case StateTermGroup.StateTermGroupRoleType.AttachmentRemover:
                        stateTermGroup.AttachmentRemovers = new List<Role>(roles);
                        break;

                    case StateTermGroup.StateTermGroupRoleType.ScannedAttachmentRemover:
                        stateTermGroup.ScannedAttachmentRemovers = new List<Role>(roles);
                        break;

                    default:
                        throw new Exception(string.Format("StateTermGroupRoleType {0} is not handled", stateTermGroupRoleType.ToString()));
                }
            }
        }
Beispiel #4
0
 public void AddTermGroup(Guid termGroupID, bool copyRoles)
 {
     StateTermGroup stateTermGroup = new StateTermGroup(termGroupID);
     if (copyRoles && _stateTermGroups.Count > 0)
     {
         stateTermGroup.Editors = _stateTermGroups[0].Editors;
         stateTermGroup.Viewers = _stateTermGroups[0].Viewers;
         stateTermGroup.AttachmentRemovers = _stateTermGroups[0].AttachmentRemovers;
         stateTermGroup.ScannedAttachmentRemovers = _stateTermGroups[0].ScannedAttachmentRemovers;
     }
     _stateTermGroups.Add(stateTermGroup);
 }
Beispiel #5
0
		public State(XmlNode termNode, Template template, Workflow workflow)
		{
			_name = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_Name);

            _id = Guid.Empty;
            string id = Utility.XMLHelper.GetAttributeString(termNode, 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();

			_status = Utility.XMLHelper.GetAttributeString(termNode, XMLNames._A_Status);
			_isDraft = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_IsDraft);
			_isBase = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_IsBase);
			_isExit = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_IsExit);
			_requiresValidation = Utility.XMLHelper.GetAttributeBool(termNode, XMLNames._A_RequiresValidation);

            _stateTermGroups = new List<StateTermGroup>();
            XmlNodeList listStateTermGroups = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_StateTermGroups, XMLNames._E_StateTermGroup));
            bool bInitializeStateTermGroups = false;
            try
            {
                bInitializeStateTermGroups = listStateTermGroups.Count == 0;
            }
            catch
            {
                bInitializeStateTermGroups = true;
            }

            if (bInitializeStateTermGroups)
            {
                //Read in the old version - list of editor roles
                List<Role> editors = new List<Role>();
                XmlNodeList listEditors = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Editors, XMLNames._E_Editor));
                if (listEditors != null)
                {
                    foreach (XmlNode nodeEditor in listEditors)
                    {
                        Role role = new Role();
                        role.Name = Utility.XMLHelper.GetAttributeString(nodeEditor, XMLNames._A_Role);
                        editors.Add(role);
                    }
                }
                StateTermGroup stateTermGroup = new StateTermGroup(template.BasicSecurityTermGroupID);
                stateTermGroup.Editors = editors;
                ITATSystem system = ITATSystem.Get(template.SystemID);
                stateTermGroup.Viewers = system.Roles;
                stateTermGroup.AttachmentRemovers = editors;
                stateTermGroup.ScannedAttachmentRemovers = Role.FromNames(system.AllowedRoles(Business.XMLNames._AF_EditAttachment));
                _stateTermGroups.Add(stateTermGroup);
            }
            else
            {
                foreach (XmlNode nodeStateTermGroup in listStateTermGroups)
                {
                    StateTermGroup stateTermGroup = new StateTermGroup(nodeStateTermGroup);
                    _stateTermGroups.Add(stateTermGroup);
                }
            }
 
			XmlNodeList listActions = termNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Actions,XMLNames._E_Action));
			if (listActions != null)
			{
				_actions = new List<Action>(listActions.Count);
				foreach (XmlNode nodeAction in listActions)
				{
                    Action action = new Action(nodeAction, workflow);
					_actions.Add(action);
				}
			}
			else
			{
				_actions = new List<Action>();
			}

		}
Beispiel #6
0
		public State(Template template)
		{
            _id = Guid.NewGuid();
            _actions = new List<Action>();
            _stateTermGroups = new List<StateTermGroup>();
            foreach (TermGroup termGroup in template.TermGroups)
            {
                StateTermGroup stateTermGroup = new StateTermGroup(termGroup.ID);
                _stateTermGroups.Add(stateTermGroup);
            }
		}