예제 #1
0
 object IWMSBasicPlugin.GetCustomAdminInterface()
 {
     Debug.WriteLine("IWMSBasicPlugin.GetCustomAdminInterface entered");
     IWMSCacheAdmin CacheAdmin = null;
     try
     {
         CacheAdmin = ( IWMSCacheAdmin ) AdminSettings;
     }
     catch( Exception e )
     {
         Console.WriteLine( "EXCEPTION: " + e.Message + e.StackTrace );
         AdminSettings = null;
     }
     finally
     {
         CacheAdmin = null;
     }
     return( ( object ) AdminSettings );
 }
예제 #2
0
        // creates the config document if it doesn't exist
        // otherwise loads it from disk
        void LoadConfig()
        {
            Debug.WriteLine("CacheProxyPlugin::LoadConfig entered");
            Console.WriteLine( "LoadConfig entered" );

            // get the module path and replace extension with xml
            string Path = Assembly.GetExecutingAssembly().Location;
            string Dir = Path.Substring(0,Path.LastIndexOf('.'));
            ConfigPath = Dir + ".xml";
            DatabasePath = Dir+"database"+".xml";

            try
            {
                Console.WriteLine( "Attempting to load config file {0}", ConfigPath );

                // Load configuration from file

                AdminSettings = new CachePluginAdmin();

                // Choose one or the other means of persistence
                if( ! AdminSettings.LoadSettingsFromXmlFile( ConfigPath ) )
                {
                    Console.WriteLine( "Failed to read XML file.  Reading from server namespace." );
                    AdminSettings.LoadSettingsFromServerNamespace();
                }

                IWMSCacheAdmin cacheAdmin = ( IWMSCacheAdmin ) AdminSettings;
                Console.WriteLine( "AdminSettings loaded: diskquota: " + cacheAdmin.DiskQuota );

                MyChangeEventHandler = new CachePluginAdmin.ModifySettingsEventHandler( PersistSettings );
                AdminSettings.RegisterChangeHandler( MyChangeEventHandler );
            }
            catch(Exception e)
            {
                Console.WriteLine( "ASSERT1: " + e.Message + e.StackTrace );
                //load failed, we will treat this as a new file and save it

            }

            try
            {
                DS = new DataSet("SampleCachePlugin");
                DS.ReadXml(DatabasePath, XmlReadMode.ReadSchema);
            }
            catch(Exception e)
            {
                Console.WriteLine( "ASSERT2: " + e.Message + e.StackTrace );
                CreateCacheTable();
                CreatePlaylistTable();
            }
            File.Delete(DatabasePath);
        }