Ejemplo n.º 1
0
        public void GetActivityByNameAndParent()
        {
            SequentialWorkflowActivity sq = new SequentialWorkflowActivity();
            IfElseActivity             ifelse_activity = new IfElseActivity();
            IfElseBranchActivity       branch1         = new IfElseBranchActivity();
            CodeActivity         code_branch1          = new CodeActivity();
            CodeActivity         code_branch2          = new CodeActivity();
            IfElseBranchActivity branch2 = new IfElseBranchActivity();
            Activity             activity;

            code_branch1.Name    = "Code1";
            code_branch2.Name    = "Code2";
            ifelse_activity.Name = "IfElse";
            sq.Name = "Root";
            branch1.Activities.Add(code_branch1);
            branch2.Activities.Add(code_branch2);
            ifelse_activity.Activities.Add(branch1);
            ifelse_activity.Activities.Add(branch2);
            sq.Activities.Add(ifelse_activity);

            // Getting Code1 activity from root
            activity = sq.GetActivityByName("Code1", true);
            Assert.AreEqual(code_branch1, activity, "C1#1");

            activity = sq.GetActivityByName("Code1", false);
            Assert.AreEqual(code_branch1, activity, "C1#2");

            // Getting Root activity from IfElse
            activity = ifelse_activity.GetActivityByName("Root", true);
            Assert.AreEqual(null, activity, "C1#3");

            activity = ifelse_activity.GetActivityByName("Root", false);
            Assert.AreEqual(sq, activity, "C1#4");

            // Getting Root activity from Code1
            activity = code_branch1.GetActivityByName("Root", true);
            Assert.AreEqual(null, activity, "C1#5");

            activity = code_branch1.GetActivityByName("Root", false);
            Assert.AreEqual(sq, activity, "C1#6");

            // Getting Ifelse activity from Code1
            activity = code_branch1.GetActivityByName("IfElse", true);
            Assert.AreEqual(null, activity, "C1#7");

            activity = code_branch2.GetActivityByName("IfElse", false);
            Assert.AreEqual(ifelse_activity, activity, "C1#8");

            // Parent checks
            Assert.AreEqual(ifelse_activity, branch1.Parent, "C1#9");
            Assert.AreEqual(ifelse_activity, branch2.Parent, "C1#10");
            Assert.AreEqual(null, sq.Parent, "C1#11");
        }
Ejemplo n.º 2
0
		/// <summary>
		/// Handles the Click event of the btnDelete control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		void btnDelete_Click(object sender, ImageClickEventArgs e)
		{
			SequentialWorkflowActivity root = this.CurrentContainer.CurrentRootActivity;
			Activity ac = root.GetActivityByName(CurrentActivity.Name);
			if (ac.Parent != null)
			{
				ac.Parent.Activities.Remove(ac);
			}

			CurrentContainer.CurrentRootActivity = root;
			this.CurrentContainer.PerformControls();
		} 
Ejemplo n.º 3
0
        /// <summary>
        /// Binds the value.
        /// </summary>
        private void BindValue()
        {
            EntityObject eo = BusinessManager.Load(WorkflowDefinitionEntity.ClassName, PrimaryKeyId.Parse(WorkflowId));
            SequentialWorkflowActivity root = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(((WorkflowDefinitionEntity)eo).Xaml);
            Activity ac = root.GetActivityByName(ActivityName);

            if (ac is CreateAssignmentAndWaitResultActivity)
            {
                AssignmentPrototypePropertyEntityCollection props = ((CreateAssignmentAndWaitResultActivity)ac).PrototypeUserProperties;
                if (props.Contains("Assignment.Properties.Subject"))
                {
                    tbSubject.Text = props.GetValue("Assignment.Properties.Subject").ToString();
                }
                else
                {
                    props.SetValue("Assignment.Properties.Subject", string.Empty);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the Click event of the btnOk control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnOk_Click(object sender, EventArgs e)
        {
            EntityObject eo = BusinessManager.Load(WorkflowDefinitionEntity.ClassName, PrimaryKeyId.Parse(WorkflowId));
            SequentialWorkflowActivity root = McWorkflowSerializer.GetObject <SequentialWorkflowActivity>(((WorkflowDefinitionEntity)eo).Xaml);
            Activity ac = root.GetActivityByName(ActivityName);

            if (ac is CreateAssignmentAndWaitResultActivity)
            {
                AssignmentPrototypePropertyEntityCollection props = ((CreateAssignmentAndWaitResultActivity)ac).PrototypeUserProperties;
                props.SetValue("Assignment.Properties.Subject", tbSubject.Text);
            }

            string xaml = McWorkflowSerializer.GetString <SequentialWorkflowActivity>(root);

            ((WorkflowDefinitionEntity)eo).Xaml = xaml;
            BusinessManager.Update(eo);

            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "window.opener.__doPostBack('', ''); window.close();", true);
            //BusinessManager.Update(((CreateAssignmentAndWaitResultActivity)ac);
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Handles the Click event of the btnCreate control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
		void btnCreate_Click(object sender, EventArgs e)
		{
			//throw new NotImplementedException();
			SequentialWorkflowActivity root = this.CurrentContainer.CurrentRootActivity;
			Activity ac = root.GetActivityByName(CurrentActivity.Name);

			CreateAssignmentAndWaitResultActivity newAct = new CreateAssignmentAndWaitResultActivity();
			newAct.Name = String.Format("test dvs {0}", Guid.NewGuid().ToString("N"));
			//newAct.Subject = " Subject Here ";

			if (ac.Parent != null || ac is System.Workflow.ComponentModel.CompositeActivity)
			{
				((System.Workflow.ComponentModel.CompositeActivity)ac).Activities.Add(newAct);
			}
			else
			{
				root.Activities.Add(newAct);
			}

			CurrentContainer.CurrentRootActivity = root;

			this.CurrentContainer.PerformControls();
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Performs the move.
		/// </summary>
		/// <param name="direction">The direction.</param>
		private void PerformMove(int direction)
		{
			SequentialWorkflowActivity root = this.CurrentContainer.CurrentRootActivity;
			Activity ac = root.GetActivityByName(CurrentActivity.Name);
			System.Workflow.ComponentModel.CompositeActivity parent = ac.Parent;

			if (parent != null && parent.Activities.Count > 1)
			{
				int index = parent.Activities.IndexOf(ac);

				if (direction == 0)
				{
					//move up
					if (index > 0)
					{
						parent.Activities.Remove(ac);
						index--;
						parent.Activities.Insert(index, ac);
					}

				}
				else
				{
					//movedown
					if (index != parent.Activities.Count - 1)
					{
						parent.Activities.Remove(ac);
						index++;
						parent.Activities.Insert(index, ac);
					}
				}
			}

			CurrentContainer.CurrentRootActivity = root;
			this.CurrentContainer.PerformControls();
		}