コード例 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates the view model data and sends update command back
        /// to the solution builder.</summary>
        ///--------------------------------------------------------------------------------
        protected override void OnUpdate()
        {
            // send update for any updated children
            foreach (EntityReferenceViewModel item in EntityReferences)
            {
                if (item.IsEdited == true)
                {
                    item.Update();
                }
            }
            // send update for any new children
            foreach (EntityReferenceViewModel item in ItemsToAdd.OfType <EntityReferenceViewModel>())
            {
                item.Update();
                EntityReferences.Add(item);
            }
            ItemsToAdd.Clear();

            // send delete for any deleted children
            foreach (EntityReferenceViewModel item in ItemsToDelete.OfType <EntityReferenceViewModel>())
            {
                item.Delete();
                EntityReferences.Remove(item);
            }
            ItemsToDelete.Clear();

            // reset modified for children
            foreach (EntityReferenceViewModel item in EntityReferences)
            {
                item.ResetModified(false);
            }
        }
コード例 #2
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates the view model data and sends update command back
        /// to the solution builder.</summary>
        ///--------------------------------------------------------------------------------
        protected override void OnUpdate()
        {
            // send update for any updated children
            foreach (StageTransitionViewModel item in StageTransitions)
            {
                if (item.IsEdited == true)
                {
                    item.Update();
                }
            }
            // send update for any new children
            foreach (StageTransitionViewModel item in ItemsToAdd.OfType <StageTransitionViewModel>())
            {
                item.Update();
                StageTransitions.Add(item);
            }
            ItemsToAdd.Clear();

            // send delete for any deleted children
            foreach (StageTransitionViewModel item in ItemsToDelete.OfType <StageTransitionViewModel>())
            {
                item.Delete();
                StageTransitions.Remove(item);
            }
            ItemsToDelete.Clear();

            // reset modified for children
            foreach (StageTransitionViewModel item in StageTransitions)
            {
                item.ResetModified(false);
            }
        }
コード例 #3
0
        private async void OnAdd()
        {
            OnInfoRequested(LanguageChanger.Instance["AddItemsVm_Code1"]);
            await Task.Run(() =>
            {
                var result = _ioSecurity.RetrieveData();
                if (result.MainResult.Success)
                {
                    List <ProcessModel> list = (from item in ItemsToAdd
                                                select _ioSecurity.CreateProcessModel(item).Data).ToList();
                    int itemsAdded = 0;
                    foreach (ProcessModel model in list)
                    {
                        if (!result.Data.Any(x => x.ProcessName.Equals(model.ProcessName, StringComparison.InvariantCultureIgnoreCase)))
                        {
                            result.Data.Add(model);
                            itemsAdded++;
                        }
                    }
                    if (itemsAdded > 0)
                    {
                        var addResult = _ioSecurity.StoreData(result.Data);
                        if (addResult.Success)
                        {
                            OnInfoRequested(LanguageChanger.Instance["AddItemsVm_Code2"]);
                            var refreshResult = _serviceLifetimeController.RefreshService();
                            if (refreshResult.Success)
                            {
                                OnInfoRequested(LanguageChanger.Instance["AddItemsVm_Code3"]);
                            }
                            else
                            {
                                OnError(refreshResult.ErrorMessage);
                            }
                        }
                        else
                        {
                            OnError(addResult.ErrorMessage);
                        }
                    }
                    else
                    {
                        OnInfoRequested(LanguageChanger.Instance["AddItemsVm_Code4"]);
                    }
                }
                else
                {
                    OnError(LanguageChanger.Instance["AddItemsVm_Code5"]);
                }
            });

            ItemsToAdd.Clear();
        }
コード例 #4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method resets the items.</summary>
 ///--------------------------------------------------------------------------------
 public void ResetItems()
 {
     if (ItemsToAdd.Count > 0)
     {
         foreach (WorkspaceViewModel item in ItemsToAdd)
         {
             Items.Remove(item);
             item.Dispose();
         }
         ItemsToAdd.Clear();
     }
     if (ItemsToDelete.Count > 0)
     {
         foreach (WorkspaceViewModel item in ItemsToDelete)
         {
             Items.Add(item);
         }
         ItemsToDelete.Clear();
     }
     foreach (WorkspaceViewModel item in Items)
     {
         item.Reset();
     }
 }
コード例 #5
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method updates the view model data and sends update command back
        /// to the solution builder.</summary>
        ///--------------------------------------------------------------------------------
        protected override void OnUpdate()
        {
            // set up reverse engineering instance if not present
            if (Feature.ReverseInstance == null && Feature.IsAutoUpdated == true)
            {
                Feature.ReverseInstance = new Feature();
                Feature.ReverseInstance.TransformDataFromObject(Feature, null, false);

                // perform the update of EditFeature back to Feature
                Feature.TransformDataFromObject(EditFeature, null, false);
                Feature.IsAutoUpdated = false;
            }
            else if (Feature.ReverseInstance != null)
            {
                EditFeature.ResetModified(Feature.ReverseInstance.IsModified);
                if (EditFeature.Equals(Feature.ReverseInstance))
                {
                    // perform the update of EditFeature back to Feature
                    Feature.TransformDataFromObject(EditFeature, null, false);
                    Feature.IsAutoUpdated = true;
                }
                else
                {
                    // perform the update of EditFeature back to Feature
                    Feature.TransformDataFromObject(EditFeature, null, false);
                    Feature.IsAutoUpdated = false;
                }
            }
            else
            {
                // perform the update of EditFeature back to Feature
                Feature.TransformDataFromObject(EditFeature, null, false);
                Feature.IsAutoUpdated = false;
            }
            Feature.ForwardInstance = null;
            if (FeatureNameCustomized || DescriptionCustomized || TagsCustomized)
            {
                Feature.ForwardInstance           = new Feature();
                Feature.ForwardInstance.FeatureID = EditFeature.FeatureID;
                Feature.SpecSourceName            = Feature.DefaultSourceName;
                if (FeatureNameCustomized)
                {
                    Feature.ForwardInstance.FeatureName = EditFeature.FeatureName;
                }
                if (DescriptionCustomized)
                {
                    Feature.ForwardInstance.Description = EditFeature.Description;
                }
                if (TagsCustomized)
                {
                    Feature.ForwardInstance.Tags = EditFeature.Tags;
                }
            }
            EditFeature.ResetModified(false);
            OnUpdated(this, null);

            // send update back to solution builder
            SendEditFeaturePerformed();

            // send update for any updated Entities
            foreach (EntityViewModel item in Entities)
            {
                if (item.IsEdited == true)
                {
                    item.Update();
                }
            }
            // send update for any new Entities
            foreach (EntityViewModel item in ItemsToAdd.OfType <EntityViewModel>())
            {
                item.Update();
                Entities.Add(item);
            }

            // send delete for any deleted Entities
            foreach (EntityViewModel item in ItemsToDelete.OfType <EntityViewModel>())
            {
                item.Delete();
                Entities.Remove(item);
            }

            // reset modified for Entities
            foreach (EntityViewModel item in Entities)
            {
                item.ResetModified(false);
            }
            ItemsToAdd.Clear();
            ItemsToDelete.Clear();
        }