Esempio n. 1
0
        private void CreateLibrary(params MemoryLibraryItem[] libraries)
        {
            if (libraries == null || libraries.Length == 0)
            {
                return;
            }

            foreach (var item in libraries)
            {
                if (item == null)
                {
                    continue;
                }

                var serverLibs = Sign.Controller.Connection.ServerLibraries;
                if (serverLibs.Count == 0)
                {
                    _files.Add(new UfeFileGenerator {
                        Sign = _sign, Library = item
                    });
                }
                else
                {
                    foreach (var serverItem in Sign.Controller.Connection.ServerLibraries)
                    {
                        UfeFileGenerator pair = null;

                        if (item.Id == serverItem.Id &&
                            CompareDateTime(DateTime.Parse(serverItem.ModifyTime), item.ModifyTime))
                        {
                            pair = new UfeFileGenerator {
                                Sign = _sign, Library = item
                            };
                            pair.IsUpdate = true;

                            if ((serverItem.UploadMode & UploadMode.Scheduler) == UploadMode.Scheduler)
                            {
                                pair.UploadMode = UploadMode.All;
                            }
                            else
                            {
                                pair.UploadMode = UploadMode.Live;
                            }
                        }
                        else
                        {
                            pair = new UfeFileGenerator {
                                Sign = _sign, Library = item, UploadMode = UploadMode.Live,
                            };
                        }

                        if (pair != null)
                        {
                            _files.Add(pair);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void CreateLibrary <T>(params T[] libraries) where T : MemoryLibraryItem
        {
            if (libraries != null && libraries.Length > 0)
            {
                ExistType type;

                //Parallel.ForEach<T>(libraries, item =>
                foreach (var item in libraries)
                {
                    if (item != null)
                    {
                        UfeFileGenerator pair = null;
                        type = IsExistInServerLibraries(item);
                        if (type == ExistType.No && !IsExistInLibraries(item, _files))
                        {
                            pair = new UfeFileGenerator {
                                Sign = _sign, Library = item
                            }
                        }
                        ;
                        else if (type == ExistType.NeededUpdate && !IsExistInLibraries(item, _needUpdatedItems))
                        {
                            pair = new UfeFileGenerator {
                                Sign = _sign, Library = item
                            };
                            pair.IsUpdate = true;
                            //_needUpdatedItems.Add(pair);
                        }

                        if (pair != null)
                        {
                            _files.Add(pair);
                        }
                    }
                }
                //});
            }
        }
Esempio n. 3
0
        public ParseResult Parse()
        {
            var messages        = Item.Messages;
            var timeSliceGroups = Item.TimeSliceGroups;
            var playlists       = Item.Playlists;

            Check.Require(messages != null, "messages != null");
            Check.Require(messages.Count > 0, "messages.Count > 0");

            List <MemoryLibraryItem> items = new List <MemoryLibraryItem>();

            items.AddRange(messages.ToArray());

            if (timeSliceGroups != null && timeSliceGroups.Count > 0)
            {
                items.AddRange(timeSliceGroups.ToArray());
            }

            if (playlists != null && playlists.Count > 0)
            {
                items.AddRange(playlists.ToArray());
            }


            ExistType        type;
            UfeFileGenerator pair = null;

            ParseResult             result            = new ParseResult();
            List <UfeFileGenerator> _files            = result.Generators;
            List <UfeFileGenerator> _needUpdatedItems = result.NeedUpdatedGenerators;

            foreach (var item in items)
            {
                if (item != null)
                {
                    type = IsExistInServerLibraries(item, Sign);

                    if (type == ExistType.No && !IsExistInLibraries(item, _files))
                    {
                        pair = new UfeFileGenerator {
                            Sign = Sign, Library = item
                        }
                    }
                    ;

                    else if (type == ExistType.NeededUpdate && !IsExistInLibraries(item, _needUpdatedItems))
                    {
                        pair = new UfeFileGenerator {
                            Sign = Sign, Library = item
                        };
                        _needUpdatedItems.Add(pair);
                    }

                    if (pair != null)
                    {
                        _files.Add(pair);
                    }
                }
            }

            Check.Require(_files.Count > 0, "_files.Count > 0");
            return(result);
        }