Пример #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 (DatabaseSourceViewModel item in DatabaseSources)
            {
                if (item.IsEdited == true)
                {
                    item.Update();
                }
            }
            // send update for any new children
            foreach (DatabaseSourceViewModel item in ItemsToAdd.OfType <DatabaseSourceViewModel>())
            {
                item.Update();
                DatabaseSources.Add(item);
            }
            ItemsToAdd.Clear();

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

            // reset modified for children
            foreach (DatabaseSourceViewModel item in DatabaseSources)
            {
                item.ResetModified(false);
            }
        }
Пример #2
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method loads specification sources into the view model.</summary>
 ///
 /// <param name="solution">The solution to load.</param>
 ///--------------------------------------------------------------------------------
 public void LoadSpecificationSources(Solution solution)
 {
     // attach the specification sources
     Items.Clear();
     if (DatabaseSources == null)
     {
         DatabaseSources = new EnterpriseDataObjectList <DatabaseSourceViewModel>();
     }
     if (XmlSources == null)
     {
         XmlSources = new EnterpriseDataObjectList <XmlSourceViewModel>();
     }
     foreach (DatabaseSource source in solution.DatabaseSourceList)
     {
         DatabaseSourceViewModel sourceView = new DatabaseSourceViewModel(source, solution);
         sourceView.Updated += new EventHandler(Children_Updated);
         DatabaseSources.Add(sourceView);
         Items.Add(sourceView);
     }
     foreach (XmlSource source in solution.XmlSourceList)
     {
         XmlSourceViewModel sourceView = new XmlSourceViewModel(source, solution);
         sourceView.Updated += new EventHandler(Children_Updated);
         XmlSources.Add(sourceView);
         Items.Add(sourceView);
     }
 }
Пример #3
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to copy/paste a new item.</summary>
        ///
        /// <param name="copyItem">The item to copy/paste.</param>
        /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param>
        ///--------------------------------------------------------------------------------
        public DatabaseSourceViewModel PasteDatabaseSource(DatabaseSourceViewModel copyItem, bool savePaste = true)
        {
            DatabaseSource newItem = new DatabaseSource();

            newItem.TransformDataFromObject(copyItem.DatabaseSource, null, false);
            newItem.SpecificationSourceID = Guid.NewGuid();
            newItem.Solution = Solution;
            DatabaseSourceViewModel newView = new DatabaseSourceViewModel(newItem, Solution);

            newView.ResetModified(true);
            DatabaseSources.Add(newView);
            Items.Add(newView);

            // paste children
            if (savePaste == true)
            {
                Solution.DatabaseSourceList.Add(newItem);
                newView.OnUpdated(this, null);
                Solution.ResetModified(true);
            }
            return(newView);
        }
Пример #4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method applies databasesource updates.</summary>
 ///--------------------------------------------------------------------------------
 public void ProcessEditDatabaseSourcePerformed(DatabaseSourceEventArgs data)
 {
     try
     {
         bool isItemMatch = false;
         if (data != null && data.DatabaseSource != null)
         {
             foreach (DatabaseSourceViewModel item in DatabaseSources)
             {
                 if (item.DatabaseSource.SpecificationSourceID == data.DatabaseSource.SpecificationSourceID)
                 {
                     isItemMatch = true;
                     item.DatabaseSource.TransformDataFromObject(data.DatabaseSource, null, false);
                     item.OnUpdated(item, null);
                     item.ShowInTreeView();
                     break;
                 }
             }
             if (isItemMatch == false)
             {
                 // add new DatabaseSource
                 data.DatabaseSource.Solution = Solution;
                 DatabaseSourceViewModel newItem = new DatabaseSourceViewModel(data.DatabaseSource, Solution);
                 newItem.Updated += new EventHandler(Children_Updated);
                 DatabaseSources.Add(newItem);
                 Solution.DatabaseSourceList.Add(newItem.DatabaseSource);
                 Items.Add(newItem);
                 OnUpdated(this, null);
                 newItem.ShowInTreeView();
             }
         }
     }
     catch (Exception ex)
     {
         ShowIssue(ex.Message + ex.StackTrace);
     }
 }