Пример #1
0
        public static void SaveLastConfiguration(string ConnectionStringSource, string ConnectionStringDestination)
        {
            Project lastUsedProject = AllProjects.Find(proj => proj.ConnectionStringSource.ToLower() == ConnectionStringSource.ToLower() && proj.ConnectionStringDestination.ToLower() == ConnectionStringDestination.ToLower());

            AllProjects.ForEach(proj => proj.WasLastUsed = false);

            if (lastUsedProject == null)
            {
                lastUsedProject = new Project()
                {
                    ConnectionStringDestination = ConnectionStringDestination,
                    ConnectionStringSource      = ConnectionStringSource,
                    Type        = ProjectType.SQLServer,
                    WasLastUsed = true
                };
                lastUsedProject.Id = Project.AllProjects.Count + 1;
                Add(lastUsedProject);
            }
            else
            {
                lastUsedProject.WasLastUsed                 = true;
                lastUsedProject.ConnectionStringSource      = ConnectionStringSource;
                lastUsedProject.ConnectionStringDestination = ConnectionStringDestination;
                Update(lastUsedProject);
            }

            //Serialize the changes back down to disk
            Serialize();
        }
Пример #2
0
        /// <summary>
        /// Delete an item from the project list
        /// </summary>
        /// <param name="Id"></param>
        public static void Delete(int Id)
        {
            Project toDelete = AllProjects.Find(proj => proj.Id == Id);

            if (toDelete != null)
            {
                AllProjects.Remove(toDelete);
            }

            Serialize();
        }
Пример #3
0
        /// <summary>
        /// Update an existing item in the Project List
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static void Update(Project item)
        {
            Project toUpdate = AllProjects.Find(proj => proj.Id == item.Id);

            toUpdate = new Project()
            {
                ConnectionStringDestination = item.ConnectionStringDestination,
                ConnectionStringSource      = item.ConnectionStringSource,
                Id          = item.Id,
                Name        = item.Name,
                Type        = item.Type,
                WasLastUsed = item.WasLastUsed
            };
        }
Пример #4
0
        /// <summary>
        /// Save an item, decide whether to insert or update.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static void Save(Project item)
        {
            Project projectToSave = AllProjects.Find(proj => proj.Id == item.Id);

            if (projectToSave == null)
            {
                item.Id = Project.AllProjects.Count + 1;
                Add(item);
            }
            else
            {
                Update(projectToSave);
            }

            Serialize();
        }
Пример #5
0
 public static Project GetLastConfiguration()
 {
     //Project item = null;
     return(AllProjects.Find(projects => projects.WasLastUsed));
 }