Example #1
0
        public static void Start()
        {
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Converters = new List<JsonConverter> { new JsonImageConverter() }
            };

            ////if (!System.Diagnostics.Debugger.IsAttached)
            ////{
            ////    Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
            ////    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            ////}

            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("ru");
            Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ru");
            Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = ".";
            Thread.CurrentThread.CurrentUICulture.NumberFormat.CurrencyDecimalSeparator = ".";
            Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = ".";
            Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator = ".";

            Random = new Random();

            UserID = Guid.Parse("10000001-28E0-4E14-B18C-E8185351E5C7");
            Mef = new Mef();

            var mefCatalog = new AggregateCatalog();
            mefCatalog.Catalogs.Add(new AssemblyCatalog(typeof(App).Assembly));

            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"bin\buhtacore.dll"))
                throw new Exception("AppDomain.CurrentDomain.BaseDirectory работает неправильно.");

            mefCatalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory+"bin", "company.dll"));

            //Debug.Print("AppDomain.CurrentDomain.BaseDirectory", AppDomain.CurrentDomain.BaseDirectory);

            ////mefCatalog.Catalogs.Add(new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory, "nopCommerce.dll"));

            CompositionContainer mefContainer = new CompositionContainer(mefCatalog);
            mefContainer.ComposeParts(Mef);

            //Schema = new Schema("ps-web", null, "BuhtaSchema", "sa1", "sonyk");    // работа
            Schema = new Schema(@"5.19.239.191", 52538, "BuhtaSchema", "sa1", "sonyk");    // работа

            var sqlDatabases = Schema.GetObjects<SchemaDatabase>();

            if (sqlDatabases.Count == 0)
                throw new Exception("Нет баз данных SQL в схеме '" + Schema.SchemaSqlDatabase + "'");
            else
                Schema.SqlDB = sqlDatabases[0];

            SchemaBaseRole.LoadRoles();

            SchemaVirtualTable.LoadVirtualTables();

            //Schema = new Schema("5.19.239.191", 64123, "Buhta", "kostia", "sonyk");  // дома
        }