Пример #1
0
        /// <summary>
        /// Default Ctor
        /// </summary>
        public Configuration()
        {
            // create codecs list
            this._codecs = new List<string>();
            this._codecs.Add(Codec.Unknown.ToString());
            this._codecs.Add(Codec.DVD.ToString());
            this._codecs.Add(Codec.Divx.ToString());
            this._codecs.Add(Codec.Xvid.ToString());
            this._codecs.Add(Codec.SVCD.ToString());
            this._codecs.Add(Codec.VCD.ToString());
            this._codecs.Add(Codec.MVCD.ToString());
            this._codecs.Add(Codec.MPEG.ToString());
            this._codecs.Add(Codec.WMV.ToString());
            this._codecs.Add(Codec.VHS.ToString());
            this._codecs.Add(Codec.Other.ToString());

            // create qualities list
            this._quality = new List<string>();
            this._quality.Add(Quality.PleaseAnnihilateIt_0.ToString());
            this._quality.Add(Quality.VeryBad_1.ToString());
            this._quality.Add(Quality.Bad_2.ToString());
            this._quality.Add(Quality.TVQuality_3.ToString());
            this._quality.Add(Quality.OK_4.ToString());
            this._quality.Add(Quality.Good_5.ToString());
            this._quality.Add(Quality.VeryGood_6.ToString());
            this._quality.Add(Quality.Perfect_7.ToString());
            this._quality.Add(Quality.DVDQuality_8.ToString());
            this._quality.Add(Quality.CinemaQuality_9.ToString());
            this._quality.Add(Quality.HighDefinition_10.ToString());

            // app path
            string path = Assembly.GetExecutingAssembly().Location;
            path = path.Replace(
                Assembly.GetExecutingAssembly().ManifestModule.Name,
                ""
            );
            this._common_app_path = path;

            // get app data path
            this._common_app_data_path = Environment.GetFolderPath(
                Environment.SpecialFolder.LocalApplicationData
            ) + @"\Toenda\MovieMatic\";
            //this._common_app_data_path = path;

            this._common_app_temp_path = _common_app_data_path + @"Temp\";

            // create if not exist
            DirectoryInfo dir = this._fs.GetDirectory(this._common_app_data_path, true);

            // get config file path
            FileInfo fi = new FileInfo(
                this._common_app_data_path + "MovieMatic.xml"
            );

            this._common_app_data_configfile = fi.FullName;

            // load config
            if(fi.Exists) {
                XmlProvider xml = new XmlProvider(fi.FullName, OpenMode.ForReading);

                if(xml.IsValidXml) {
                    try {
                        this._cn = xml.ReadTag("data", "connectionString");
                    }
                    catch(Exception ex) {
                        string s = ex.Message;
                        this._cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                        this._CreateXmlConfigFile(fi.FullName);
                    }
                }
                else {
                    this._cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                    this._CreateXmlConfigFile(fi.FullName);
                }
            }
            else {
                //this._cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                //this._cn = "[INITIAL]";
                this._cn = "Server=;Database=MovieMatic;Uid=;Pwd=;";

                this._CreateXmlConfigFile(fi.FullName);
            }
        }
Пример #2
0
        /// <summary>
        /// Default Ctor
        /// </summary>
        static Configuration()
        {
            // create codecs list
            _codecs = new List <string>();
            _codecs.Add(Codec.Unknown.ToString());
            _codecs.Add(Codec.DVD.ToString());
            _codecs.Add(Codec.BlueRayDVD.ToString());
            _codecs.Add(Codec.Divx.ToString());
            _codecs.Add(Codec.Xvid.ToString());
            _codecs.Add(Codec.SVCD.ToString());
            _codecs.Add(Codec.VCD.ToString());
            _codecs.Add(Codec.MVCD.ToString());
            _codecs.Add(Codec.MPEG.ToString());
            _codecs.Add(Codec.WMV.ToString());
            _codecs.Add(Codec.VHS.ToString());
            _codecs.Add(Codec.Other.ToString());

            // create qualities list
            _quality = new List <string>();
            _quality.Add(Quality.PleaseAnnihilateIt_0.ToString());
            _quality.Add(Quality.VeryBad_1.ToString());
            _quality.Add(Quality.Bad_2.ToString());
            _quality.Add(Quality.TVQuality_3.ToString());
            _quality.Add(Quality.OK_4.ToString());
            _quality.Add(Quality.Good_5.ToString());
            _quality.Add(Quality.VeryGood_6.ToString());
            _quality.Add(Quality.Perfect_7.ToString());
            _quality.Add(Quality.DVDQuality_8.ToString());
            _quality.Add(Quality.CinemaQuality_9.ToString());
            _quality.Add(Quality.HighDefinition_10.ToString());

            // app path
            string path = Assembly.GetExecutingAssembly().Location;

            path = path.Replace(
                Assembly.GetExecutingAssembly().ManifestModule.Name,
                ""
                );
            _common_app_path = path;

            // get app data path
            _common_app_data_path = Environment.GetFolderPath(
                Environment.SpecialFolder.LocalApplicationData
                ) + @"\Toenda\MovieMatic\";
            //_common_app_data_path = path;

            _common_app_temp_path = _common_app_data_path + @"Temp\";

            // create if not exist
            DirectoryInfo dir = _fs.GetDirectory(_common_app_data_path, true);

            // get config file path
            FileInfo fi = new FileInfo(
                _common_app_data_path + "MovieMatic.xml"
                );

            _common_app_data_configfile = fi.FullName;

            // load config
            if (fi.Exists)
            {
                XmlProvider xml = new XmlProvider(fi.FullName, OpenMode.ForReading);

                if (xml.IsValidXml)
                {
                    try {
                        _cn = xml.ReadTag("data", "connectionString");

                        string tmp = xml.ReadTag("data", "checkForNewVersion");
                        if (!tmp.IsNullOrTrimmedEmpty())
                        {
                            _checkForNewVersion = tmp.IsExpressionTrue();
                        }
                        else
                        {
                            _checkForNewVersion = true;
                        }
                    }
                    catch (Exception ex) {
                        string s = ex.Message;
                        _cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                        _checkForNewVersion = true;
                        _CreateXmlConfigFile(fi.FullName);
                    }
                }
                else
                {
                    _cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                    _checkForNewVersion = true;
                    _CreateXmlConfigFile(fi.FullName);
                }
            }
            else
            {
                //_cn = ConfigurationManager.ConnectionStrings["mmConnection"].ConnectionString;
                //_cn = "[INITIAL]";
                _cn = "Server=;Database=MovieMatic;Uid=;Pwd=;";
                _checkForNewVersion = true;

                _CreateXmlConfigFile(fi.FullName);
            }
        }