コード例 #1
0
        public void StoreInformation(Dictionary <string, IEnumerable <object> > information)
        {
            var hashcode = information.GetInformationHashcode();
            var id       = information.GetInformationId();

            var currentInformationFilter =
                Builders <BsonDocument> .Filter.Eq(Id, id) &
                Builders <BsonDocument> .Filter.Eq(IsCurrent, true)
            ;

            var currentInformation         = FindOne(currentInformationFilter);
            var currentInformationHashcode =
                currentInformation == null ?
                null :
                currentInformation.Elements.FirstOrDefault(element => element.Name == Hashcode).Value
            ;

            var isCurrentInformation = currentInformation != null && hashcode == currentInformationHashcode;

            //  Zu übertragende Information hat einen anderen Stand als der aktuelle Stand >> Übertragung in das Data-Warehouse
            if (!isCurrentInformation)
            {
                information = information.Where(entry => !entry.Key.Contains(".")).ToDictionary(
                    entry => entry.Key,
                    entry => entry.Value?.Select(value => value)
                    );

                //  Aktuelle Information mit "nicht aktuell" markieren
                if (currentInformation != null)
                {
                    currentInformation.Set(IsCurrent, false);
                    CollectionInformation.UpdateOneAsync(currentInformationFilter, currentInformation);
                }

                CollectionInformation.InsertOneAsync(new BsonDocument(new Dictionary <string, object> {
                    //  Information ist letzte aktuelle Information
                    { "IsCurrent", true },
                    //  ID des Informationssatz auf der Website
                    { Id, id },
                    //  Hashcode des abzulegenden Informationssatz
                    { Hashcode, hashcode },
                    { "Information", information }
                }));
            }
        }
コード例 #2
0
        public void StoreInformation(Dictionary<string, IEnumerable<object>> information)
        {
            var hashcode = information.GetInformationHashcode();
            var id = information.GetInformationId();

            var currentInformationFilter = 
                Builders<BsonDocument>.Filter.Eq(Id, id) &
                Builders<BsonDocument>.Filter.Eq(IsCurrent, true)
            ;
            var currentInformation = FindOne(currentInformationFilter);
            var currentInformationHashcode = 
                currentInformation == null ? 
                null : 
                currentInformation.Elements.FirstOrDefault(element => element.Name == Hashcode).Value
            ;

            var isCurrentInformation = currentInformation != null && hashcode == currentInformationHashcode;
            //  Zu übertragende Information hat einen anderen Stand als der aktuelle Stand >> Übertragung in das Data-Warehouse
            if(!isCurrentInformation)
            {
                information = information.Where(entry => !entry.Key.Contains(".")).ToDictionary(
                    entry => entry.Key,
                    entry => entry.Value?.Select(value => value)
                );

                //  Aktuelle Information mit "nicht aktuell" markieren
                if (currentInformation != null)
                {
                    currentInformation.Set(IsCurrent, false);
                    CollectionInformation.UpdateOneAsync(currentInformationFilter, currentInformation);
                }
                
                CollectionInformation.InsertOneAsync(new BsonDocument(new Dictionary<string, object>{
                    //  Information ist letzte aktuelle Information
                    { "IsCurrent", true },
                    //  ID des Informationssatz auf der Website
                    { Id, id },
                    //  Hashcode des abzulegenden Informationssatz
                    { Hashcode, hashcode },
                    { "Information", information }
                }));
            }
        }
        public void StoreInformation(Dictionary<string, IEnumerable<object>> information)
        {
            information = information.PrepareInformation();

            var id = information.GetInformationId();
            if(!string.IsNullOrEmpty(id))
            {
                var content = new StringBuilder();

                foreach(var entry in information)
                {
                    content.AppendLine($"{entry.Key} = {string.Join("|", entry.Value)}");
                }

                File.WriteAllText(
                    Path.Combine(Storagefolder, $"{id}.crawl"),
                    content.ToString()
                );
            }
        }
        public void StoreInformation(Dictionary <string, IEnumerable <object> > information)
        {
            information = information.PrepareInformation();

            var id = information.GetInformationId();

            if (!string.IsNullOrEmpty(id))
            {
                var content = new StringBuilder();

                foreach (var entry in information)
                {
                    content.AppendLine($"{entry.Key} = {string.Join("|", entry.Value)}");
                }

                File.WriteAllText(
                    Path.Combine(Storagefolder, $"{id}.crawl"),
                    content.ToString()
                    );
            }
        }