Пример #1
0
        private void TryLoadIgnore(string fileName, bool silent)
        {
            try
            {
                _ignore = DVDProfilerSerializer <Ignore.IgnoreConfiguration> .Deserialize(fileName);
            }
            catch
            {
                if (!silent)
                {
                    MessageBox.Show("The ignore file cannot be read.", "Read error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                _ignore = null;
            }

            if (_ignore != null)
            {
                IgnoreFileTextBox.Text = fileName;

                UpdateIgnoreLabel();
            }
            else
            {
                IgnoreFileTextBox.Text = string.Empty;

                IgnoresLoadedLabel.Text = string.Empty;
            }
        }
        public static void Initialize(TestContext _)
        {
            var fileName = "Test2.xml";

            var collection = DVDProfilerSerializer <Collection> .Deserialize(fileName);

            _graph = GraphBuilder.Build(collection.DVDList);
        }
Пример #3
0
        private void TryLoadCollection(string fileName)
        {
            _collection = DVDProfilerSerializer <Collection> .Deserialize(fileName);

            CollectionFileTextBox.Text = fileName;

            var profileCount = _collection.DVDList?.Length ?? 0;

            ProfilesLoadedLabel.Text = $"{profileCount:#,0} profiles loaded.";
        }
Пример #4
0
        public void Load(IDVDProfilerAPI api)
        {
            Api = api;

            if (Directory.Exists(_applicationPath) == false)
            {
                Directory.CreateDirectory(_applicationPath);
            }

            if (File.Exists(_settingsFile))
            {
                try
                {
                    _settings = DVDProfilerSerializer <Settings> .Deserialize(_settingsFile);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format(MessageBoxTexts.FileCantBeRead, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            this.CreateSettings();

            if (_settings.DefaultValues.ReceiveFromCastCrewEdit)
            {
                this.LoadReceiver();
            }

            if (Directory.Exists(_applicationPath) == false)
            {
                Directory.CreateDirectory(_applicationPath);
            }

            Api.RegisterForEvent(PluginConstants.EVENTID_FormCreated);

            _copyCastMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Copy Cast", CopyCastMenuId);

            _copyCrewMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Copy Crew", CopyCrewMenuId);

            _pasteMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Paste Cast / Crew", PasteMenuId);

            _receiverSettingMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"Tools", "Enable Cast/Crew Edit 2 Receiver", ReceiverSettingMenuId);

            api.SetRegisteredMenuItemChecked(_receiverSettingMenuToken, _settings.DefaultValues.ReceiveFromCastCrewEdit);

            var pluginVersion = this.PluginVersion.ToString();

            if (_settings.CurrentVersion != pluginVersion)
            {
                this.OpenReadme();

                _settings.CurrentVersion = pluginVersion;
            }
        }
Пример #5
0
 private static void TryGetSettings()
 {
     try
     {
         _Settings = DVDProfilerSerializer <Settings> .Deserialize(_SettingsFile);
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format(MessageBoxTexts.FileCantBeRead, _SettingsFile, ex.Message), MessageBoxTexts.WarningHeader, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Пример #6
0
        internal static Collection TryGetCollection(String file)
        {
            try
            {
                Collection collection = DVDProfilerSerializer <Collection> .Deserialize(file);

                return(collection);
            }
            catch
            {
                return(null);
            }
        }
        private static v2_2.CheckConfiguration LoadFrom_v1_x(string fileName)
        {
            var config_v1_1 = DVDProfilerSerializer <v1_1.CheckConfiguration> .Deserialize(fileName);

            var config_v2_0 = config_v1_1.Upgrade();

            var tempFile = Path.GetTempFileName();

            Save(config_v2_0, tempFile);

            var config_v2_2 = DVDProfilerSerializer <v2_2.CheckConfiguration> .Deserialize(tempFile);

            return(config_v2_2);
        }
        public static void Initialize(TestContext _)
        {
            const string SampleXml = "sample.xml";

            if (File.Exists(SampleXml))
            {
                File.Delete(SampleXml);
            }

            System.IO.Compression.ZipFile.ExtractToDirectory(@"..\..\..\..\sample_xml.zip", ".");

            var collection = DVDProfilerSerializer <Collection> .Deserialize(SampleXml);

            _graph = GraphBuilder.Build(collection.DVDList);
        }
Пример #9
0
        public void Load(IDVDProfilerAPI api)
        {
            _serviceProvider.Api = api;

            if (IOServices.Folder.Exists(_applicationPath) == false)
            {
                IOServices.Folder.CreateFolder(_applicationPath);
            }

            if (IOServices.File.Exists(_settingsFile))
            {
                try
                {
                    _settings = DVDProfilerSerializer <Settings> .Deserialize(_settingsFile);
                }
                catch (Exception ex)
                {
                    UIServices.ShowMessageBox(string.Format(MessageBoxTexts.FileCantBeRead, _settingsFile, ex.Message), MessageBoxTexts.ErrorHeader, Buttons.OK, Icon.Error);
                }
            }

            if (_settings == null)
            {
                _settings = new Settings();
            }

            if (_settings.DefaultValues == null)
            {
                _settings.DefaultValues = new DefaultValues();
            }

            _serviceProvider.DefaultValues = _settings.DefaultValues;

            Api.RegisterForEvent(PluginConstants.EVENTID_FormCreated);

            _addMenuToken = Api.RegisterMenuItem(PluginConstants.FORMID_Main, PluginConstants.MENUID_Form, @"DVD", "Add by DVD Disc ID", AddMenuId);
        }
        private static v2_2.CheckConfiguration LoadFrom_v2_2(string fileName)
        {
            var config = DVDProfilerSerializer <v2_2.CheckConfiguration> .Deserialize(fileName);

            return(config);
        }
Пример #11
0
        internal ExceptionXml Process(string collectionFile, string mdfTargetFile)
        {
            ExceptionXml exceptionXml = null;

            DbContextTransaction transaction = null;

            try
            {
                CopyDatabaseFiles(mdfTargetFile);

                var collection = DVDProfilerSerializer <Profiler.Collection> .Deserialize(collectionFile);

                var profiles = collection.DVDList;

                //Phase 2: Fill Hashtables
                var cache = new CollectionCache(profiles);

                //                       "metadata=res://*/CollectionModel.csdl|res://*/CollectionModel.ssdl|res://*/CollectionModel.msl;provider=System.Data.SqlClient;provider connection string='data source=(LocalDB)\MSSQLLocalDB;attachdbfilename=|DataDirectory|\Collection.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework'"
                var connectionString = $@"metadata=res://*/CollectionModel.csdl|res://*/CollectionModel.ssdl|res://*/CollectionModel.msl;provider=System.Data.SqlClient;provider connection string='data source=(LocalDB)\MSSQLLocalDB;attachdbfilename={mdfTargetFile};integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;';";

                using (_context = new CollectionEntities(connectionString))
                {
                    //_context.Database.Log = Console.WriteLine;

                    _context.Configuration.AutoDetectChangesEnabled = false;

                    using (transaction = _context.Database.BeginTransaction())
                    {
                        CheckDbVersion();

                        //Phase 3: Fill Basic Data Into Database
                        var baseData = InsertBaseData(cache);

                        //Phase 4: Fill DVDs into Database
                        InsertData(profiles, baseData);

                        transaction.Commit();
                    }
                }

                Feedback?.Invoke(this, new EventArgs <string>($"{(profiles?.Length ?? 0):#,##0} profiles transformed."));
            }
            catch (Exception exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch
                {
                }

                try
                {
                    if (File.Exists(mdfTargetFile))
                    {
                        File.Delete(mdfTargetFile);
                    }
                }
                catch
                {
                }

                var ex = exception;

                while (ex != null)
                {
                    Feedback?.Invoke(this, new EventArgs <string>($"Error: {ex.Message} "));

                    ex = ex.InnerException;
                }

                exceptionXml = new ExceptionXml(exception);
            }

            return(exceptionXml);
        }