示例#1
0
        private void RenderStep(TutorialEntity tutorial, int index, StepEntity step)
        {
            using (new GUILayout.HorizontalScope()) {
                string displayName    = ParseDisplayNameFromStep(tutorial.id, step.id);
                string newDisplayName = displayName;
                if (index == 0)
                {
                    EditorGUILayout.LabelField(stepIdGUIContent, EditorStyles.miniLabel, GUILayout.Width(k_ColumnWidth));
                }
                else
                {
                    EditorGUILayout.LabelField("", GUILayout.Width(k_ColumnWidth));
                }
                RestrictInputCharacters();
                newDisplayName = EditorGUILayout.TextField(displayName);
                if (newDisplayName != displayName)
                {
                    UpdateStep(step.id, ConstructStepIdFromDisplayName(tutorial.id, newDisplayName));
                }
                if (index == tutorial.steps.Count - 1)
                {
                    bool plusEnabled  = index < k_MaxSteps - 1;
                    bool minusEnabled = index > 0;

                    var prevColor = GUI.backgroundColor;
                    GUI.backgroundColor = Color.clear;
                    EditorGUI.BeginDisabledGroup(!plusEnabled);

                    if (GUILayout.Button(addStepButtonGUIContent, addButtonStyle, GUILayout.MaxWidth(20f)))
                    {
                        CreateStep(tutorial.id);
                    }
                    EditorGUI.EndDisabledGroup();
                    EditorGUI.BeginDisabledGroup(!minusEnabled);
                    if (GUILayout.Button(deleteStepButtonGUIContent, addButtonStyle, GUILayout.MaxWidth(20f)))
                    {
                        DestroyStep(step.id);
                    }
                    EditorGUI.EndDisabledGroup();
                    GUI.backgroundColor = prevColor;
                }
            }
            var textId = step.id + "-text";

            if (showContent && TMModel.TMData.contentTable.ContainsKey(textId))
            {
                var  contentEntity = TMModel.TMData.contentTable[textId];
                bool wrap          = EditorStyles.textField.wordWrap;
                EditorStyles.textField.wordWrap = true;
                var options = new GUILayoutOption[] {
                    GUILayout.ExpandHeight(true),
                    GUILayout.MaxHeight(50f),
                    GUILayout.Width(EditorGUIUtility.currentViewWidth - 30f)
                };
                EditorGUI.BeginDisabledGroup(true);
                EditorGUILayout.TextArea(contentEntity.text, options);
                EditorGUI.EndDisabledGroup();
                EditorStyles.textField.wordWrap = wrap;
            }
        }
 public static ParticipationAggregate Restore(ParticipationId id, TeamEntity team,
                                              TournamentEntity tournamentEntity,
                                              StepEntity stepEntity, DateTime startDate, DateTime?endDate, decimal calculatedScore,
                                              IList <FunctionEntity> functions)
 {
     return(new(id, team, tournamentEntity, stepEntity, startDate, endDate, calculatedScore,
                functions));
 }
示例#3
0
 public Step(StepEntity entity)
 {
     Id             = entity.Id;
     StepNumber     = entity.StepNumber;
     RecipeId       = entity.RecipeId;
     Text           = entity.Text;
     TimeToNextStep = entity.TimeToNextStep;
     AdditionalText = entity.AdditionalText;
 }
 public JobDetailsSessionView()
 {
     ContractsTemplates = new List<ContractTemplateEntity>();
     FunctionalLevel = new FunctionalLevelEntity();
     OrganisationalUnit = new OrganizationalUnitView();
     Grade = new GradeEntity();
     Step = new StepEntity();
     Job = new JobTitleView();
     IsGenerated = false;
 }
示例#5
0
 public JobDetailsSessionView()
 {
     ContractsTemplates = new List <ContractTemplateEntity>();
     FunctionalLevel    = new FunctionalLevelEntity();
     OrganisationalUnit = new OrganizationalUnitView();
     Grade       = new GradeEntity();
     Step        = new StepEntity();
     Job         = new JobTitleView();
     IsGenerated = false;
 }
示例#6
0
 /// <summary>
 /// 工艺流程中工步双击事件。
 /// </summary>
 private void tvRoute_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
 {
     if (tvRoute.Nodes[0].Nodes.Count > 0 && tvRoute.SelectedNode != null && tvRoute.SelectedNode.Tag != null)
     {
         StepEntity step = (StepEntity)tvRoute.SelectedNode.Tag;
         step.Status = _route.Status;
         StepDialog stepDialog = new StepDialog(step);
         stepDialog.ShowDialog();
     }
 }
        /// <inheritdoc />
        public override void Deserialize(StepEntity step)
        {
            if (step == null)
            {
                throw new CorruptedFileException();
            }

            if (((DrumStepEntity)step).On)
            {
                Toggle();
            }
        }
 protected ParticipationAggregate(ParticipationId id, TeamEntity team, TournamentEntity tournamentEntity,
                                  StepEntity stepEntity,
                                  DateTime startDate, DateTime?endDate, decimal calculatedScore, IList <FunctionEntity> functions) : base(id)
 {
     Team             = team;
     TournamentEntity = tournamentEntity;
     StepEntity       = stepEntity;
     _functions       = new List <FunctionEntity>(functions);
     StartDate        = startDate;
     EndDate          = endDate;
     CalculatedScore  = calculatedScore;
 }
示例#9
0
        protected void ProceedButton_Click(object sender, EventArgs e)
        {
            JobDetailsSessionView jbs = new JobDetailsSessionView();

            FunctionalLevelEntity flentity = new FunctionalLevelEntity();

            flentity.Id         = Convert.ToInt32(FunctionalLevelDropDownList.SelectedValue);
            flentity            = new FunctionalLevelMapper().Get(flentity);
            jbs.FunctionalLevel = flentity;

            OrganizationalUnitEntity ouentity = new OrganizationalUnitEntity();

            ouentity.Id = Convert.ToInt32(OrganisationalUnitDropDownList.SelectedValue);
            OrganizationalUnitView ouView = new OrganizationalUnitMapper().Get(ouentity);

            jbs.OrganisationalUnit = ouView;

            GradeEntity gentity = new GradeEntity();

            gentity.Id = GradeDropDownList.SelectedValue;
            gentity    = new GradeMapper().Get(gentity);
            jbs.Grade  = gentity;

            JobTitleEntity job = new JobTitleEntity();

            job.JobCode = JobDetailsDropDownList.SelectedValue;
            JobTitleView jobview = new JobTitleMapper().Get(job);

            jbs.Job = jobview;

            StepEntity sentity = new StepEntity();

            sentity.Id = StepDropDownList.SelectedValue;
            sentity    = new StepMapper().Get(sentity);
            jbs.Step   = sentity;


            foreach (ListItem item in ContractsCheckBoxList.Items)
            {
                if (item.Selected == true)
                {
                    jbs.ContractsTemplates.Add(new ContractTemplateEntity()
                    {
                        Id = Convert.ToInt32(item.Value), Title = item.Text
                    });
                }
            }

            Session.Add("JobDetails", jbs);
            Response.Redirect("Contract.aspx?EmployeeId=" + Request.QueryString["EmployeeId"] + "&ContractTemplateId=" + jbs.ContractsTemplates[0].Id);
        }
        public void ReadFromFile_WorksWhenFileExists()
        {
            PostTestCleanup();

            //Test set up - generate a model and save it out so it can be retreived by the middleware
            var tutorialName = "tutorial 1";
            var stepName = "step 1";
            var genreName = "myGenre";
            var stepLookupName = ConstructID(tutorialName, stepName);
            var textLookupName = ConstructID(stepLookupName, "text");
            var actualModel = new TutorialManagerModel();
            var tutorial = new TutorialEntity(tutorialName);
            tutorial.steps.Add(stepName);
            var step = new StepEntity(stepLookupName);
            step.messaging.isActive = true;
            var text = new ContentEntity(textLookupName, "text", "yooo what's up! I work!");
            step.messaging.content.Add(text.id);
            actualModel.genre = genreName;
            actualModel.tutorials.Add(tutorial);
            actualModel.steps.Add(step);
            actualModel.content.Add(text);

            BinaryFormatter binaryFormatter = new BinaryFormatter();
            FileStream file = File.Create(GetModelSavePath());

            binaryFormatter.Serialize(file, actualModel);
            file.Close();

            //Actual test code
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            Assert.That(genreName, Is.EqualTo(modelMiddleware.TMData.genre), string.Format("genre should be {0}", genreName));
            Assert.IsNotEmpty(modelMiddleware.TMData.tutorials, "tutorials should be populated");
            Assert.IsNotEmpty(modelMiddleware.TMData.steps, "steps should be populated");
            Assert.IsNotEmpty(modelMiddleware.TMData.content, "content should be populated");
            Assert.AreEqual(1, modelMiddleware.TMData.tutorials.Count, "there should only be one tutorial");
            Assert.AreEqual(1, modelMiddleware.TMData.steps.Count, "there should only be one step");
            Assert.AreEqual(1, modelMiddleware.TMData.content.Count, "there should only be one conent");
            Assert.That(tutorialName, Is.EqualTo(modelMiddleware.TMData.tutorials[0].id), string.Format("the tutorial should be named {0}", tutorialName));
            Assert.That(stepLookupName, Is.EqualTo(modelMiddleware.TMData.steps[0].id), string.Format("the step should be named {0}", stepLookupName));
            Assert.That(textLookupName, Is.EqualTo(modelMiddleware.TMData.content[0].id), string.Format("the content should be named {0}", textLookupName));

            Assert.IsTrue(modelMiddleware.TMData.tutorialTable.ContainsKey(tutorialName), string.Format("tutorial table should contain {0}", tutorialName));
            Assert.IsTrue(modelMiddleware.TMData.stepTable.ContainsKey(stepLookupName), string.Format("steps table should contain {0}", stepLookupName));
            Assert.IsTrue(modelMiddleware.TMData.contentTable.ContainsKey(textLookupName), string.Format("content table should contain {0}", textLookupName));

            PostTestCleanup();
        }
        /// <summary>
        /// Restore either <see cref="IWorkplanStep.Inputs"/> or <see cref="IWorkplanStep.Outputs"/>.
        /// </summary>
        private static IConnector[] RestoreReferences(StepEntity stepEntity, ConnectorRole role, IDictionary <long, IConnector> connectors)
        {
            var referenceEntities = stepEntity.Connectors.Where(c => c.Role == role).ToList();

            var references = new IConnector[referenceEntities.Count];

            for (int index = 0; index < referenceEntities.Count; index++)
            {
                var referenceEntity = referenceEntities.First(f => f.Index == index);
                if (referenceEntity.ConnectorId.HasValue)
                {
                    references[index] = connectors[referenceEntity.ConnectorId.Value];
                }
            }

            return(references);
        }
        /// <inheritdoc />
        public override void Deserialize(StepEntity step)
        {
            if (step == null)
            {
                throw new CorruptedFileException();
            }

            var note = (step as MonoStepEntity)?.Note;

            if (note != null)
            {
                MidiEvent = new NoteEvent(0, 1,
                                          MidiCommandCode.NoteOn, note.Value, 100);
            }
            if (((MonoStepEntity)step).On)
            {
                Toggle();
            }
        }
示例#13
0
 /// <summary>
 /// Привязка поля ddlBigStep
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void ddlBigStep_DataBound(object sender, EventArgs e)
 {
     if (fvStepProject.CurrentMode == FormViewMode.Edit)
     {
         StepEntity se = base.ctemplatessteps.GetCultureStepsProject((int)this.idstep);
         if (se == null)
         {
             return;
         }
         DropDownList ddlBigStep = base.fmc.GetDropDownList(fvStepProject, "ddlBigStep");
         if (ddlBigStep != null)
         {
             if (se.Id != null)
             {
                 ddlBigStep.SelectedValue = se.IdBigStep.ToString();
             }
             else
             {
                 ddlBigStep.SelectedIndex = 0;
             }
         }
     }
     if (fvStepProject.CurrentMode == FormViewMode.Insert)
     {
         DropDownList ddlBigStep = base.fmc.GetDropDownList(fvStepProject, "ddlBigStep");
         if (ddlBigStep != null)
         {
             if (this.insert_idbigstep != -1)
             {
                 ddlBigStep.SelectedValue = this.insert_idbigstep.ToString();
                 ddlBigStep.Enabled       = false;
                 base.fmc.SetEnableButton(fvStepProject, "btBigStep", false);
             }
             else
             {
                 ddlBigStep.SelectedIndex = -1;
                 ddlBigStep.Enabled       = true;
                 base.fmc.SetEnableButton(fvStepProject, "btBigStep", true);
             }
         }
     }
 }
        public void UpdateStepWhenNoContent()
        {
            SetupTutorial();
            SetupSteps();
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            var tutorial1 = modelMiddleware.TMData.tutorials[0];

            modelMiddleware.UpdateStepEntity(t1Step1LookupID, t1step1v2LookupID);

            Assert.AreEqual(2, tutorial1.steps.Count, "tutorial 1 should still have 2 steps");
            Assert.IsFalse(tutorial1.steps.Contains(t1step1), "the old t1S1 key should be gone from the Tutorial steps");
            Assert.IsFalse(modelMiddleware.TMData.stepTable.ContainsKey(t1step1), "the old t1S1 key should be gone from the stepTable");
            Assert.IsTrue(tutorial1.steps.Contains(t1step1v2LookupID), "the new t1step1v2 key should be in from the Tutorial steps");
            Assert.IsTrue(modelMiddleware.TMData.stepTable.ContainsKey(t1step1v2LookupID), "there should be a new t1step1v2 key in the stepTable");

            StepEntity stepEntity = modelMiddleware.TMData.stepTable[t1step1v2LookupID];
            Assert.That(t1step1v2LookupID, Is.EqualTo(stepEntity.id), string.Format("step id should be {0}", t1step1v2LookupID));
            Assert.That(t1Step2LookupID, Is.EqualTo(modelMiddleware.TMData.stepTable[t1Step2LookupID].id), "other step t1step2 should be unchanged");

            EnsureUnaffectedSteps();

            PostTestCleanup();
        }
示例#15
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            StepEntity step = new StepEntity();

            step.Id          = StepTextBox.Text;
            step.GradeId     = GradeStepDropDownList.SelectedValue;
            step.Description = "";
            try
            {
                new StepMapper().Insert(step);
                Response.Redirect("DefineGrade.aspx?jobCode=" + Request.QueryString["jobCode"]);
            }
            catch (Exception)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("<script language='javascript'>displayNoty('Please write another Step name beacuse this Step name already exists.');</script>");

                // if the script is not already registered
                if (!Page.ClientScript.IsClientScriptBlockRegistered(Page.GetType(), "HeyPopup"))
                {
                    ClientScript.RegisterClientScriptBlock(Page.GetType(), "HeyPopup", sb.ToString());
                }
            }
        }
        /// <inheritdoc />
        public override void Deserialize(StepEntity step)
        {
            if (step == null)
            {
                throw new CorruptedFileException();
            }

            if (((PolyStepEntity)step).Notes.Length != 0)
            {
                foreach (var note in ((PolyStepEntity)step).Notes)
                {
                    if (note != null)
                    {
                        _midiEvents.Add(new NoteEvent(0, 1,
                                                      MidiCommandCode.NoteOn, note.Value, 100));
                    }
                }
            }

            if (((PolyStepEntity)step).On)
            {
                Toggle();
            }
        }
        public static ParticipationAggregate CreateNew(ParticipationId id, TeamEntity team,
                                                       TournamentEntity tournamentEntity,
                                                       StepEntity stepEntity, DateTime startDate)
        {
            var errors = new List <string>();

            if (!stepEntity.TournamentIds.Contains(tournamentEntity.Id))
            {
                errors.Add(
                    $"Cannot create new participation on step {stepEntity.Id} and tournament {tournamentEntity.Id} because step is not linked to tournament");
            }
            if (!tournamentEntity.IsPublished)
            {
                errors.Add($"Cannot create participation on not published tournament {tournamentEntity.Id}");
            }

            if (errors.Any())
            {
                throw new DomainException(errors);
            }

            return(new ParticipationAggregate(id, team, tournamentEntity, stepEntity, startDate, null, 0,
                                              new List <FunctionEntity>()));
        }
示例#18
0
 /// <summary>
 /// 构造函数。
 /// </summary>
 public StepDialog(StepEntity step)
     : base(StringParser.Parse("${res:FanHai.Hemera.Addins.FMM.StepDialog.Title}"))
 {
     InitializeComponent();
     _step = step;
 }
        /// <summary>
        /// Update either inputs or outputs in the database
        /// </summary>
        private static void UpdateConnectors(IConnectorReferenceRepository referenceRepo, StepEntity stepEntity, IWorkplanStep step, ConnectorRole role, IDictionary <long, ConnectorEntity> connectors)
        {
            // Update inputs first
            var connectorArray = role == ConnectorRole.Input ? step.Inputs : step.Outputs;

            for (int index = 0; index < connectorArray.Length; index++)
            {
                var connector          = connectorArray[index];
                var connectorReference = stepEntity.Connectors.FirstOrDefault(c => c.Role == role && c.Index == index);
                if (connectorReference == null && connector != null)
                {
                    // Reference not yet stored in database
                    connectorReference           = referenceRepo.Create(index, role);
                    connectorReference.Step      = stepEntity;
                    connectorReference.Connector = connectors[connector.Id];
                }
                else if (connectorReference != null && connector != null)
                {
                    // Reference possible modified
                    connectorReference.Connector = connectors[connector.Id];
                }
                else if (connectorReference != null)
                {
                    // Reference removed
                    connectorReference.Connector = null;
                }
                else
                {
                    // Connector null and no entity exists
                    connectorReference      = referenceRepo.Create(index, role);
                    connectorReference.Step = stepEntity;
                }
            }
        }
        public void CreateStep()
        {
            SetupTutorial();
            var modelMiddleware = TutorialManagerModelMiddleware.GetInstance();
            var tutorial1 = modelMiddleware.TMData.tutorials[0];
            var tutorial2 = modelMiddleware.TMData.tutorials[1];
            var tutorial3 = modelMiddleware.TMData.tutorials[2];

            Assert.IsEmpty(tutorial1.steps, "tutorial 1 should exist but have no steps");
            Assert.IsEmpty(tutorial2.steps, "tutorial 2 should exist but have no steps");
            Assert.IsEmpty(tutorial3.steps, "tutorial 3 should exist but have no steps");

            // Add first step to t1
            modelMiddleware.CreateStepEntity(t1step1, tutorial1.id);


            Assert.AreEqual(1, tutorial1.steps.Count, "tutorial 1 should have one step");
            Assert.IsEmpty(tutorial2.steps, "tutorial 2 should still have no steps");
            Assert.IsEmpty(tutorial3.steps, "tutorial 3 should still have no steps");
            Assert.AreEqual(1, modelMiddleware.TMData.stepTable.Count, "model should have 1 step");

            StepEntity t1S1FromList = modelMiddleware.TMData.steps[0];
            StepEntity t1S1FromTable = modelMiddleware.TMData.stepTable[t1Step1LookupID];
            Assert.IsNotNull(t1S1FromList, "new step should be in list");
            Assert.IsNotNull(t1S1FromTable, "new step should be in table");
            Assert.AreSame(t1S1FromList, t1S1FromTable, "the two entities should represent the same step");



            Assert.That(t1Step1LookupID, Is.EqualTo(t1S1FromList.id), string.Format("step id should be {0}", t1Step1LookupID));
            Assert.That(t1Step1LookupID, Is.EqualTo(tutorial1.steps[0]), string.Format("first step in tutorial 1 should be {0}", t1Step1LookupID));

            // Add second step to t1
            modelMiddleware.CreateStepEntity(t1step2, tutorial1.id);

            Assert.AreEqual(2, tutorial1.steps.Count, "tutorial 1 should have 2 steps");
            Assert.IsEmpty(tutorial2.steps, "tutorial 2 should still have no steps");
            Assert.IsEmpty(tutorial3.steps, "tutorial 3 should still have no steps");
            Assert.AreEqual(2, modelMiddleware.TMData.stepTable.Count, "model should have 2 steps");

            StepEntity t1S2FromList = modelMiddleware.TMData.steps[1];
            StepEntity t1S2FromTable = modelMiddleware.TMData.stepTable[t1Step2LookupID];
            Assert.IsNotNull(t1S2FromList, "new step t1S2 should be in list");
            Assert.IsNotNull(t1S2FromTable, "new step t1S2 should be in table");
            Assert.AreSame(t1S2FromList, t1S2FromTable, "the two entities should represent the same step");


            Assert.That(t1Step2LookupID, Is.EqualTo(t1S2FromList.id), string.Format("step id should be {0}", t1Step2LookupID));
            Assert.That(t1Step2LookupID, Is.EqualTo(tutorial1.steps[1]), string.Format("second step in tutorial 1 should be {0}", t1Step2LookupID));

            // Add first step to t2
            modelMiddleware.CreateStepEntity(t2step1, tutorial2.id);

            Assert.AreEqual(2, tutorial1.steps.Count, "tutorial 1 should have 2 steps");
            Assert.AreEqual(1, tutorial2.steps.Count, "tutorial 2 should have 1 step");
            Assert.IsEmpty(tutorial3.steps, "tutorial 3 should still have no steps");
            Assert.AreEqual(3, modelMiddleware.TMData.stepTable.Count, "model should have 3 steps");

            StepEntity t2S1FromList = modelMiddleware.TMData.steps[2];
            StepEntity t2S1FromTable = modelMiddleware.TMData.stepTable[t2step1LookupID];
            Assert.IsNotNull(t2S1FromList, "new step t2S1 hould be in list");
            Assert.IsNotNull(t2S1FromTable, "new step t2S1 should be in table");
            Assert.AreSame(t2S1FromList, t2S1FromTable, "the two entities should represent the same step");

            Assert.That(t2step1LookupID, Is.EqualTo(t2S1FromList.id), string.Format("step id should be {0}", t2step1LookupID));
            Assert.That(t2step1LookupID, Is.EqualTo(tutorial2.steps[0]), string.Format("first step in tutorial 2 should be {0}", t2step1LookupID));

            // Add second step to t2
            modelMiddleware.CreateStepEntity(t2step2, tutorial2.id);

            Assert.AreEqual(2, tutorial1.steps.Count, "tutorial 1 should have 2 steps");
            Assert.AreEqual(2, tutorial2.steps.Count, "tutorial 2 should have 2 steps");
            Assert.IsEmpty(tutorial3.steps, "tutorial 3 should still have no steps");
            Assert.AreEqual(4, modelMiddleware.TMData.stepTable.Count, "model should have 4 steps");

            StepEntity t2S2FromList = modelMiddleware.TMData.steps[3];
            StepEntity t2S2FromTable = modelMiddleware.TMData.stepTable[t2step2LookupID];
            Assert.IsNotNull(t2S2FromList, "new step t2S2 should be in list");
            Assert.IsNotNull(t2S2FromTable, "new step t2S2 should be in table");
            Assert.AreSame(t2S2FromList, t2S2FromTable, "the two entities should represent the same step");

            Assert.That(t2step2LookupID, Is.EqualTo(t2S2FromList.id), string.Format("step id should be {0}", t2step2LookupID));
            Assert.That(t2step2LookupID, Is.EqualTo(tutorial2.steps[1]), string.Format("second step in tutorial 1 should be {0}", t2step2LookupID));

            PostTestCleanup();
        }
示例#21
0
 /// <inheritdoc />
 public override void Deserialize(StepEntity step)
 {
     throw new NotImplementedException();
 }
示例#22
0
        /// <summary>
        /// 拖拽在工艺流程列表上放下。
        /// </summary>
        private void tvRoute_DragDrop(object sender, DragEventArgs e)
        {
            // Retrieve the client coordinates of the drop location.
            Point targetPoint = tvRoute.PointToClient(new Point(e.X, e.Y));
            // Retrieve the node at the drop location.
            TreeNode targetNode  = tvRoute.GetNodeAt(targetPoint);
            TreeNode draggedNode = new TreeNode();

            if (_route.Status == EntityStatus.Active || _route.Status == EntityStatus.Archive || targetNode == null)
            {
                return;
            }

            draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
            if (draggedNode != null)
            {
                StepEntity updateStep = (StepEntity)draggedNode.Tag;
                if (updateStep.OperationAction != OperationAction.New)
                {
                    updateStep.OperationAction = OperationAction.Modified;
                }
            }

            OperationEntity operation = (OperationEntity)e.Data.GetData(typeof(OperationEntity));

            if (operation != null)
            {
                StepEntity   newStep = new StepEntity(operation);
                ListViewItem lstItem = new ListViewItem(newStep.StepName, 0);
                draggedNode             = new TreeNode(lstItem.SubItems[0].Text);
                newStep.OperationAction = OperationAction.New;
                draggedNode.Tag         = newStep;
            }
            // Confirm that the node at the drop location is not
            // the dragged node or a descendant of the dragged node.
            if (!draggedNode.Equals(targetNode))
            {
                // If it is a move operation, remove the node from its current
                // location and add it to the node at the drop location.
                if (e.Effect == DragDropEffects.Move)
                {
                    draggedNode.Remove();
                    if (targetNode.Parent == null)
                    {
                        targetNode.Nodes.Add(draggedNode);
                    }
                    else
                    {
                        targetNode.Parent.Nodes.Insert(targetNode.Index + 1, draggedNode);
                    }
                }
                // If it is a copy operation, clone the dragged node
                // and add it to the node at the drop location.
                else if (e.Effect == DragDropEffects.Copy)
                {
                    if (targetNode.Parent == null)
                    {
                        targetNode.Nodes.Add((TreeNode)draggedNode.Clone());
                    }
                    else
                    {
                        targetNode.Parent.Nodes.Insert(targetNode.Index + 1, (TreeNode)draggedNode.Clone());
                    }
                }

                // Expand the node at the location
                // to show the dropped node.
                targetNode.Expand();
            }
        }
示例#23
0
 /// <summary>
 ///     Deserializes passed entity by applying it's values to this instance of Step.
 /// </summary>
 /// <param name="step">Serialized Step.</param>
 public abstract void Deserialize(StepEntity step);
示例#24
0
        /// <summary>
        /// 验证并收集工艺流程数据。
        /// </summary>
        private void MapControlsToRoute()
        {
            if (null == _route)
            {
                throw (new Exception("Error Route Set"));
            }
            _route.RouteName             = txtRouteName.Text;
            _route.RouteEffectivityStart = dtBeginTime.Text;
            _route.RouteEffectivityEnd   = dtEndTime.Text;
            _route.RouteDescription      = mmDescription.Text;

            _route.Editor       = PropertyService.Get(PROPERTY_FIELDS.USER_NAME);
            _route.EditTimeZone = PropertyService.Get(PROPERTY_FIELDS.TIMEZONE);

            TreeNode parentNode = tvRoute.Nodes[0];
            bool     blFlag     = false;

            foreach (TreeNode node in parentNode.Nodes)
            {
                blFlag = false;
                StepEntity step = (StepEntity)node.Tag;
                if (_route.StepList.Count > 0)
                {
                    foreach (StepEntity item in _route.StepList)
                    {
                        if (step.StepKey == item.StepKey)
                        {
                            blFlag = true;
                            if (node.Index.ToString() != item.StepSeqence)
                            {
                                item.StepSeqence     = node.Index.ToString();
                                item.OperationAction = OperationAction.Modified;
                            }
                            break;
                        }
                    }
                }
                //if not found the key in the list ,add this step to the route
                if (blFlag == false)
                {
                    step.StepSeqence = node.Index.ToString();
                    _route.StepList.Add(step);
                }
            }

            foreach (StepEntity item in _route.StepList)
            {
                blFlag = false;
                foreach (TreeNode node in parentNode.Nodes)
                {
                    StepEntity step = (StepEntity)node.Tag;
                    if (item.StepKey == step.StepKey)
                    {
                        blFlag = true;
                        break;
                    }
                }
                if (blFlag == false)
                {
                    item.OperationAction = OperationAction.Delete;
                }
            }
        }