Пример #1
0
 private void okButton_Click(object sender, RoutedEventArgs e)
 {
     for (int i = SourceCollection.Count - 1; i >= 0; i--)
     {
         object o = SourceCollection[i];
         if (!SourceCollectionEdited.Contains(o))
         {
             SourceCollection.RemoveAt(i);
         }
     }
     foreach (object o in SourceCollectionEdited)
     {
         if (!SourceCollection.Contains(o))
         {
             SourceCollection.Add(o);
         }
     }
     for (int i = TargetCollection.Count - 1; i >= 0; i--)
     {
         object o = TargetCollection[i];
         if (!TargetCollectionEdited.Contains(o))
         {
             TargetCollection.RemoveAt(i);
         }
     }
     foreach (object o in TargetCollectionEdited)
     {
         if (!TargetCollection.Contains(o))
         {
             TargetCollection.Add(o);
         }
     }
     cancelButton_Click(sender, e);
 }
Пример #2
0
        /// <summary>
        /// Add a new source to the collection and to persistent storage
        /// </summary>
        /// <param name="sourceToAdd"></param>
        /// <returns></returns>
        public static async Task AddSourceAsync(Source sourceToAdd)
        {
            SourceCollection.Add(sourceToAdd);

            // Need to wait for the source to be added to ensure that its ID is available
            await DbAccess.InsertAsync(sourceToAdd);

            // Initialise any source data that may not have been set in the new source
            sourceToAdd.InitialiseAccess();
        }
Пример #3
0
        /// <summary>
        /// Adds an item to the current instance.
        /// </summary>
        /// <param name='item'>
        /// The item to add.
        /// </param>
        public override void Add(TItem item)
        {
            var index = Count;

            if (HandleBeforeAdd(item, index))
            {
                SourceCollection.Add(item);
                HandleAfterAdd(item, index);
                HandleAdditionChange(item);
            }
        }
Пример #4
0
        public void SetCollection()
        {
            string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + "/trainingSaves";

            string[] fileEntries = Directory.GetFiles(path);

            foreach (var file in fileEntries)
            {
                string temp  = file.Remove(0, 82);
                string temp2 = temp.Remove((temp.Length - 4), 4);
                SourceCollection.Add(temp2);
            }
        }
        /// <summary>
        /// Adds an item to the <see cref="ICollection{T}"/>. This implementation
        /// throw <see cref="NotSupportedException"/> if <see cref="TryReverse"/>
        /// returns <see langword="false"/>.
        /// </summary>
        ///
        /// <param name="item">
        /// The object to add to the <see cref="ICollection{T}"/>.
        /// </param>
        /// <exception cref="NotSupportedException">
        /// The <see cref="ICollection{T}"/> is read-only.
        /// </exception>
        public override void Add(TTo item)
        {
            TFrom result;

            if (TryReverse(item, out result))
            {
                SourceCollection.Add(result);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Пример #6
0
        /// <summary>
        /// Imports the source (SOUR tags) from the GEDCOM XML file.
        /// </summary>
        private void ImportSources()
        {
            // Get list of people.
            XmlNodeList list = doc.SelectNodes("/root/SOUR");

            foreach (XmlNode node in list)
            {
                Source source = new Source();

                // Import details about the person.
                source.Id               = GetId(node);
                source.SourceName       = GetValue(node, "TITL");
                source.SourceAuthor     = GetValue(node, "AUTH");
                source.SourcePublisher  = GetValue(node, "PUBL");
                source.SourceNote       = ImportEventNote(node, "NOTE", doc);
                source.SourceRepository = GetValueId(node, "REPO").Replace("@", string.Empty);

                sources.Add(source);
            }
        }
Пример #7
0
        private void Add()
        {
            int y = 0;

            string oldSourceIDs = string.Empty;

            foreach (Source s in source)
            {
                oldSourceIDs += s.Id + "E";
            }

            do
            {
                y++;
            }while (oldSourceIDs.Contains("S" + y.ToString() + "E"));

            string sourceID = "S" + y.ToString();

            Source newSource = new Source(sourceID, "", "", "", "", "");

            source.Add(newSource);
            source.OnContentChanged();
        }
Пример #8
0
 public void AddSource(WonkaRefSource poNewSource)
 {
     SourceCollection.Add(poNewSource);
 }
 /// <summary>
 /// Adds an item to the <see cref="ICollection{T}"/>. This implementation
 /// throw <see cref="InvalidCastException"/> if <paramref name="item"/>
 /// is not a <typeparamref name="TSub"/>.
 /// </summary>
 ///
 /// <param name="item">
 /// The object to add to the <see cref="ICollection{T}"/>.
 /// </param>
 /// <exception cref="NotSupportedException">
 /// The <see cref="ICollection{T}"/> is read-only.
 /// </exception>
 /// <exception cref="InvalidCastException">
 /// When <paramref name="item"/> is not of type <typeparamref name="TSub"/>.
 /// </exception>
 public override void Add(TBase item)
 {
     SourceCollection.Add((TSub)item);
 }
Пример #10
0
 public virtual SourceCollection GetSourceList(SourceColumns orderBy, string orderDirection, int page, int pageSize, out int totalRecords)
 {            
     try
     {
         Database database = DatabaseFactory.CreateDatabase();
         DbCommand dbCommand = database.GetStoredProcCommand("spSourceGetList");
         
         database.AddInParameter(dbCommand, "@OrderBy", DbType.AnsiString, orderBy.ToString());
         database.AddInParameter(dbCommand, "@OrderDirection", DbType.AnsiString, orderDirection.ToString());
         database.AddInParameter(dbCommand, "@Page", DbType.Int32, page);
         database.AddInParameter(dbCommand, "@PageSize", DbType.Int32, pageSize);
         database.AddOutParameter(dbCommand, "@TotalRecords", DbType.Int32, 4);
         
         SourceCollection sourceCollection = new SourceCollection();
         using (IDataReader reader = database.ExecuteReader(dbCommand))
         {
             while (reader.Read())
             {
                 Source source = CreateSourceFromReader(reader);
                 sourceCollection.Add(source);
             }
             reader.Close();
         }
         totalRecords = (int)database.GetParameterValue(dbCommand, "@TotalRecords");
         return sourceCollection;
     }
     catch (Exception ex)
     {
         // log this exception
         log4net.Util.LogLog.Error(ex.Message, ex);
         // wrap it and rethrow
         throw new ApplicationException(SR.DataAccessGetSourceListException, ex);
     }
 }
Пример #11
0
        protected override string BuildPackage()
        {
            var project = new PackageProject();

            var sourceCollection = new SourceCollection <PackageEntry>();

            var itemSource = new ExplicitItemSource
            {
                SkipVersions = false
            };

            sourceCollection.Add(itemSource);

            var list = new List <ID>();

            foreach (var item in Items)
            {
                var i = item;
                if (list.Any(id => id == i.ID))
                {
                    continue;
                }

                list.Add(item.ID);

                var reference = new ItemReference(item.Database.Name, item.Paths.Path, item.ID, LanguageManager.DefaultLanguage, Data.Version.Latest).Reduce();

                itemSource.Entries.Add(reference.ToString());
            }

            var fileSource = new ExplicitFileSource();

            sourceCollection.Add(fileSource);

            foreach (var fileName in Files)
            {
                if (FileUtil.IsFolder(fileName))
                {
                    foreach (var file in Directory.GetFiles(FileUtil.MapPath(fileName), "*", SearchOption.AllDirectories))
                    {
                        var fileInfo = new FileInfo(file);
                        if ((fileInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                        {
                            continue;
                        }

                        if ((fileInfo.Attributes & FileAttributes.System) == FileAttributes.System)
                        {
                            continue;
                        }

                        fileSource.Entries.Add(file);
                    }
                }
                else
                {
                    fileSource.Entries.Add(fileName);
                }
            }

            project.Sources.Add(sourceCollection);

            project.Name = "Sitecore Package";
            project.Metadata.PackageName = PackageName;
            project.Metadata.Author      = Author;
            project.Metadata.Version     = Version;
            project.Metadata.Publisher   = Publisher;
            project.Metadata.License     = License;
            project.Metadata.Comment     = Comment;
            project.Metadata.Readme      = Readme;
            project.Metadata.PostStep    = PostStep;

            var context          = new SimpleProcessingContext();
            var intermediateFile = GetIntermediateFileName(FileName);

            try
            {
                using (var writer = new PackageWriter(PathUtils.MapPath(intermediateFile)))
                {
                    writer.Initialize(context);
                    PackageGenerator.GeneratePackage(project, writer);
                }

                Commit(intermediateFile, FileName);
            }
            catch
            {
                Cleanup(intermediateFile);
                throw;
            }

            return(FileName);
        }
Пример #12
0
 public int Add(object value)
 {
     return(SourceCollection.Add(value) + 1);
 }
Пример #13
0
        public void GeneratePackage()
        {
            var getReaderProcessor = ReaderTypeProcessor.GetTypeProcessor(this.FileType);

            var items = getReaderProcessor.ReadFile(this.FilePath);

            var packageProject = new PackageProject
            {
                Metadata =
                {
                    PackageName = this.PackageName,
                    Author      = this.Author,
                    Version     = this.Version,
                    Publisher   = this.Publisher
                }
            };

            var packageFileSource = new ExplicitFileSource
            {
                Name = "Custom File Source"
            };

            var packageItemSource = new ExplicitItemSource
            {
                Name = "Custom Item Source"
            };

            var sourceCollection = new SourceCollection <PackageEntry>();

            sourceCollection.Add(packageItemSource);

            foreach (var item in items)
            {
                if (item.ObjectType.ToLower().Equals("item"))
                {
                    var itemUri = Factory.GetDatabase(Settings.GetSetting("SourceDatabase")).Items.GetItem(item.ObjectPath);

                    if (itemUri != null)
                    {
                        if (item.IncludeSubItem.ToLower().Equals("true"))
                        {
                            sourceCollection.Add(new ItemSource()
                            {
                                SkipVersions = true,
                                Database     = itemUri.Uri.DatabaseName,
                                Root         = itemUri.Uri.ItemID.ToString()
                            });
                        }
                        else
                        {
                            packageItemSource.Entries.Add(new ItemReference(itemUri.Uri, false).ToString());
                        }
                    }
                }
                else if (item.ObjectType.ToLower().Equals("file"))
                {
                    var pathMapped = MainUtil.MapPath(item.ObjectPath);

                    packageFileSource.Entries.Add(pathMapped);
                }
            }

            if (packageFileSource.Entries.Count > 0)
            {
                packageProject.Sources.Add(packageFileSource);
            }

            if (packageItemSource.Entries.Count > 0 || sourceCollection.Sources.Count > 0)
            {
                packageProject.Sources.Add(sourceCollection);
            }

            packageProject.SaveProject = true;

            var packageGeneratorFolder = Settings.GetSetting("PackageGeneratorFolder");

            using (var writer = new PackageWriter(MainUtil.MapPath(string.Format("{0}/{1}/{2}.zip", Settings.PackagePath, packageGeneratorFolder, this.PackageName))))
            {
                Context.SetActiveSite("shell");

                writer.Initialize(Installer.CreateInstallationContext());

                PackageGenerator.GeneratePackage(packageProject, writer);

                Context.SetActiveSite("website");
            }
        }