示例#1
0
        /// <summary>
        /// Reads the application settings from appsettings.json
        /// </summary>
        private void ReadAppConfig()
        {
            DatabaseConfig = new DatabaseConfig
            {
                DatabasePassword   = Configuration["DatabasePassword"],
                DatabaseUser       = Configuration["DatabaseUser"],
                DatabaseServerPort = Convert.ToInt32(Configuration["DatabaseServerPort"]),
                SqlProtocol        = SqlProtocol.Tcp,
                ConnectionTimeOut  = Convert.ToInt32(Configuration["ConnectionTimeOut"]),
                LearnHowFooterUrl  = Configuration["LearnHowFooterUrl"]
            };

            CatalogConfig = new CatalogConfig
            {
                ServicePlan     = Configuration["ServicePlan"],
                CatalogDatabase = Configuration["CatalogDatabase"],
                CatalogServer   = Configuration["CatalogServer"] + ".database.windows.net"
            };

            TenantServerConfig = new TenantServerConfig
            {
                TenantServer    = Configuration["TenantServer"] + ".database.windows.net",
                ResetEventDates = Convert.ToBoolean(Configuration["ResetEventDates"])
            };

            TenantConfig = new TenantConfig
            {
                BlobPath      = Configuration["BlobPath"],
                TenantCulture = Configuration["DefaultRequestCulture"]
            };
        }
示例#2
0
        public InvoicePrint CreateInvoicePrint(int id = 0, int [] InvoiceIds = null)
        {
            var report = new InvoicePrint();

            report.xrPictureBox1.BeforePrint += InvoicePrintPictureBox_BeforePrint;
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
                report.xrLabel2.TextFormatString    = "{0:0.##}";
            }
            if (InvoiceIds == null)
            {
                int[] ids = new int[] { id };
                report.invoiceMasterId.Value = ids;
            }
            else
            {
                report.invoiceMasterId.Value = InvoiceIds;
            }

            report.RequestParameters = false;
            return(report);
        }
示例#3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddHttpContextAccessor(); // Add the IHttpContextAccessor for use in the Tenant Aware middleware

            var tenantConfig = new TenantConfig();

            Configuration.Bind("TenantConfig", tenantConfig);
            services.AddSingleton(tenantConfig); // Add the tenantConfig for use in the Tenant Aware middleware

            services.AddPrise <IProductsRepository>(options => options
                                                    // Plugins will be located at /bin/Debug/netcoreapp3.0/Plugins directory
                                                    // each plugin will have its own directory
                                                    // /OldSQLPlugin
                                                    // /SQLPlugin
                                                    // /TableStoragePlugin
                                                    .WithPluginAssemblyNameProvider <TenantPluginProvider <IProductsRepository> >()
                                                    .WithPluginPathProvider <TenantPluginProvider <IProductsRepository> >()
                                                    .WithDependencyPathProvider <TenantPluginProvider <IProductsRepository> >()

                                                    // Add the configuration for use in the plugins
                                                    // this way, the plugins can read their own config section from the appsettings.json
                                                    .UseHostServices(services, new[] { typeof(IConfiguration) })
                                                    );
        }
示例#4
0
        public DeliveryNotePrint CreateDeliveryNotePrint(int id = 0, int [] OrderprocessId = null)
        {
            //creta and extra report instence
            var report = new DeliveryNotePrint();

            report.xrLabel16.Text = "Delivery Note";
            report.xrLabel17.Text = "Delivery Address:";
            if (OrderprocessId != null)
            {
                report.paramOrderProcessId.Value = OrderprocessId;
            }
            else
            {
                int[] orderprocessID = new int[] { id };
                report.paramOrderProcessId.Value = orderprocessID;
            }
            // requesting the parameter value from end-users.
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }

            report.PoPictureBox.BeforePrint += DnPictureBox_BeforePrint;
            return(report);
        }
        public ActionResult Create([Bind(Include = "TenantConfigId,AlertMinimumProductPrice,EnforceMinimumProductPrice,AlertMinimumPriceMessage,EnforceMinimumPriceMessage,PoReportFooterMsg1,PoReportFooterMsg2,SoReportFooterMsg1,SoReportFooterMsg2,DnReportFooterMsg1,DnReportFooterMsg2,WorksOrderScheduleByMarginHours,WorksOrderScheduleByAmPm,EnableLiveEmails,MiniProfilerEnabled,EnabledRelayEmailServer,EnablePalletingOnPick,WarehouseLogEmailsToDefault,WarehouseScheduleStartTime,WarehouseScheduleEndTime,ErrorLogsForwardEmails,DefaultReplyToAddress,DefaultMailFromText,AutoTransferStockEnabled,EnableStockVarianceAlerts,AuthorisationAdminEmail,DefaultCashAccountID,TenantReceiptPrintHeaderLine1,TenantReceiptPrintHeaderLine2,TenantReceiptPrintHeaderLine3,TenantReceiptPrintHeaderLine4,TenantLogo,PrintLogoForReceipts,SessionTimeoutHours,TenantId,DateCreated,DateUpdated,CreatedBy,UpdatedBy,IsDeleted")] TenantConfig tenantConfig)
        {
            if (ModelState.IsValid)
            {
                if (tenantConfig.TenantConfigId > 0)
                {
                    tenantConfig.TenantId    = CurrentTenantId;
                    tenantConfig.DateUpdated = DateTime.UtcNow;
                    tenantConfig.UpdatedBy   = CurrentUserId;
                    _tenantsServices.UpdateTenantConfig(tenantConfig);
                }
                else
                {
                    tenantConfig.TenantId    = CurrentTenantId;
                    tenantConfig.DateCreated = DateTime.UtcNow;
                    tenantConfig.CreatedBy   = CurrentUserId;
                    _tenantsServices.AddTenantConfig(tenantConfig);
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.DefaultCashAccountID = new SelectList(_accountServices.GetAllValidAccounts(CurrentTenantId).ToList(), "AccountID", "AccountCode", tenantConfig.DefaultCashAccountID);
            ViewBag.TenantId             = new SelectList(_tenantsServices.GetAllTenants(), "TenantId", "TenantName");
            return(View(tenantConfig));
        }
示例#6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var tenantConfig = new TenantConfig();

            Configuration.Bind("TenantConfig", tenantConfig);
            services.AddSingleton(tenantConfig); // Add the tenantConfig for use in the Tenant Aware middleware

            var cla = services.BuildServiceProvider().GetRequiredService <ICommandLineArguments>();

            services.AddHttpClient();
            services.AddHttpContextAccessor(); // Add the IHttpContextAccessor for use in the Tenant Aware middleware

            services.AddPrise <IProductsRepository>(options => options
                                                    // Plugins will be located at /bin/Debug/netcoreapp3.0/Plugins directory
                                                    // each plugin will have its own directory
                                                    // /SQLPlugin
                                                    // /TableStoragePlugin
                                                    // /CosmosDbPlugin
                                                    .WithDefaultOptions(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"))
                                                    .WithPluginAssemblyNameProvider <TenantPluginAssemblyNameProvider <IProductsRepository> >()
                                                    .WithPluginPathProvider <TenantPluginPathProvider <IProductsRepository> >()

                                                    // Switches between network loader and local disk loader
                                                    .LocalOrNetwork <IProductsRepository>(cla.UseNetwork)

                                                    .WithDependencyPathProvider <TenantPluginDependencyPathProvider <IProductsRepository> >()
                                                    .UseHostServices(services, new[] { typeof(IConfiguration) })

                                                    .WithSelector <HttpClientPluginSelector <IProductsRepository> >()
                                                    .WithHostFrameworkProvider <AppHostFrameworkProvider>()
                                                    );
        }
示例#7
0
        public ActionResult LoginSSO(string email = "", string username = "", string oapass = "")
        {
            Session.Clear();
            try
            {
                if (string.IsNullOrWhiteSpace(oapass))
                {
                    return(RedirectToAction("Index", "Login"));
                }
                if (string.IsNullOrWhiteSpace(email) && string.IsNullOrWhiteSpace(username))
                {
                    return(RedirectToAction("Index", "Login"));
                }
                var user = new SysUser();
                if (!string.IsNullOrWhiteSpace(email))
                {
                    user = _userManager.GetUserByEmail(email);
                }
                else if (!string.IsNullOrWhiteSpace(username))
                {
                    user = _userManager.GetUserByName(username);
                }
                if (user == null || user.UserId == 0)
                {
                    return(RedirectToAction("Index", "Login"));
                }
                //if (user.Password != oapass.GetMd5(2))
                //    return RedirectToAction("Login", "Home");
                if (!user.Password.Trim().Equals(oapass.Trim(), StringComparison.CurrentCultureIgnoreCase))
                {
                    return(RedirectToAction("Index", "Login"));
                }
                CurrentUser = user;

                //初始化角色
                //MyRoles = _roleManager.GetRolesForUser(user.UserId).ToArray();

                //部署时,根据域名获取当前租户
                var tenantService = new TenantManager();
                CurrentTenant = tenantService.GetTenantById(user.TenantId);

                IEnumerable <int> permissionIds = SystemCache.Instance.UserPermissions(user.UserId,
                                                                                       new RoleManager().GetUserPermissionIds);

                if (!permissionIds.Any())
                {
                    this.SessionExt()["errmsg"] = webUILang.UserHaveNotRight;
                    return(RedirectToAction("Index", "Login"));
                }

                SiteConfig = new TenantConfig(user.TenantId);
                SampleLoginLog.AddLoginLog(user);
                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                this.SessionExt()["errmsg"] = ex.Message;
                return(RedirectToAction("Index", "Login"));
            }
        }
        public async Task <IActionResult> Assets(string tenantName = null)
        {
            _tenantId = GetTenantId(tenantName);

            var assets = new List <bGridAsset>();

            _tenantConfig = await ReadConfig(_roomsConfig);

            if (_tenantConfig.KnownAssets == null || _tenantConfig.KnownAssets.Count == 0)
            {
                return(View(assets));
            }

            await GetbGridAssets();

            var knowAssets = _tenantConfig.KnownAssets;
            var assetsList = _bGridAssets.Where(a => knowAssets.Count(k => k.Id == a.id) > 0);


            foreach (var asset in assetsList)
            {
                asset.assetType = knowAssets.Where(k => k.Id == asset.id).First().Type;
                asset.assetName = knowAssets.Where(k => k.Id == asset.id).First().Name;
                assets.Add(asset);
            }
            return(View(assets));
        }
示例#9
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddHttpContextAccessor(); // Add the IHttpContextAccessor for use in the TenantAssemblySelector

            var tenantConfig = new TenantConfig();

            Configuration.Bind("TenantConfig", tenantConfig);
            services.AddSingleton(tenantConfig); // Add the tenantConfig for use in the TenantAssemblySelector

            services.AddPrise <IProductsRepository>(options => options
                                                    .WithDefaultOptions(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins"))
                                                    .ScanForAssemblies(composer =>
                                                                       composer.UseDiscovery())
                                                    // UseDiscovery() comes from the Prise.AssemblyScanning.Discovery package and
                                                    //  it will scan the Plugins directory recursively for implementations of IProductsRepository.

                                                    // Add the configuration for use in the plugins
                                                    // this way, the plugins can read their own config section from the appsettings.json
                                                    .UseHostServices(services, new[] { typeof(IConfiguration) })

                                                    // The TenantAssemblySelector will select which assembly plugin to load.
                                                    .WithAssemblySelector <TenantAssemblySelector <IProductsRepository> >()
                                                    );
        }
示例#10
0
        public ClientService(OAuthContext context,
                             IConfiguration configuration,
                             IOptions <TenantConfig> tenantConfig,
                             IWebHostEnvironment hostingEnvironment,
                             IPasswordHasher <User> passwordHasher,
                             ProxyService proxyService,
                             IDistributedCacheService distributedCache)
        {
            _context = context;

            _clients = context.Clients;

            _clientConfiguration = context.ClientConfigurations;

            _user = context.Users;

            _userClient = context.UserClients;

            _passwordHasher = passwordHasher;

            _configuration = configuration;

            _tenantConfig = tenantConfig.Value;

            _hostingEnvironment = hostingEnvironment;

            _proxyService = proxyService;

            _distributedCache = distributedCache;
        }
示例#11
0
        public TenantDataContext CreateContext(TenantConfig tenant)
        {
            var optionsBuilder = new DbContextOptionsBuilder <TenantDataContext>();

            optionsBuilder.UseMySql(tenant.ConnectionString());

            return(new TenantDataContext(optionsBuilder.Options));
        }
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     WebApiConfig.Register(GlobalConfiguration.Configuration);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     TenantConfig.RegisterPlumbing(HttpContext.Current);
 }
示例#13
0
        public async Task <User> Authenticate(string email, string password, TenantConfig tenant)
        {
            PasswordHasher <User> hasher = new PasswordHasher <User>(
                new OptionsWrapper <PasswordHasherOptions>(
                    new PasswordHasherOptions()
            {
                CompatibilityMode = PasswordHasherCompatibilityMode.IdentityV2
            })
                );

            Console.WriteLine($"Authenticating {email}");

            var user = await _multiTenantContext.Users.Include(x => x.Employments).ThenInclude(x => x.TenantConfig)
                       .FirstOrDefaultAsync(x => x.Email == email);

            if (user == null)
            {
                Console.WriteLine("Cant find user");
                return(null);
            }

            if (tenant.Name != _appSettings.BaseHost)
            {
                if (await _multiTenantContext.Employments.FirstOrDefaultAsync(x =>
                                                                              x.TenantId == tenant.Id && x.UserId == user.Id) == null)
                {
                    Console.WriteLine("User isn't employed by the tenant");
                    return(null);
                }
            }


            if (hasher.VerifyHashedPassword(user, user.Password, password) == PasswordVerificationResult.Failed)
            {
                Console.WriteLine("Password incorrect");
                return(null);
            }

            var tokenHandler    = new JwtSecurityTokenHandler();
            var key             = Encoding.ASCII.GetBytes(_appSettings.Secret);
            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject = new ClaimsIdentity(new Claim[]
                {
                    new Claim(ClaimTypes.Name, user.Id.ToString())
                }),
                Expires            = DateTime.UtcNow.AddDays(7),
                SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key),
                                                            SecurityAlgorithms.HmacSha256Signature)
            };
            var token = tokenHandler.CreateToken(tokenDescriptor);

            user.Token    = tokenHandler.WriteToken(token);
            user.Password = null;

            return(user);
        }
示例#14
0
        public void ShouldInitializeWhenTenantConfigCreationParametersAreValid()
        {
            string productsDataSource = "a", suppliersDataSource = "b", supplierProductBarcodesDataSource = "c";
            var    tenantConfig =
                new TenantConfig(productsDataSource, suppliersDataSource, supplierProductBarcodesDataSource);

            Assert.AreEqual(tenantConfig.ProductsDataSource, productsDataSource);
            Assert.AreEqual(tenantConfig.SuppliersDataSource, suppliersDataSource);
            Assert.AreEqual(tenantConfig.SupplierProductBarcodesDataSource, supplierProductBarcodesDataSource);
        }
        // GET: TenantConfigs/Details/5
        public ActionResult Details(int?id)
        {
            TenantConfig tenantConfig = _tenantsServices.GetTenantConfigById(CurrentTenantId);

            if (tenantConfig == null)
            {
                return(HttpNotFound());
            }
            return(View(tenantConfig));
        }
示例#16
0
 public async Task <IList <UserViewModel> > GetAllUsersAsync(TenantConfig tenant)
 {
     return(await _multiTenantContext.Employments.Where(x => x.TenantId == tenant.Id).Select(x =>
                                                                                             new UserViewModel()
     {
         Avatar = x.User.Avatar,
         Id = x.User.Id,
         Email = x.User.Email,
         DisplayName = x.User.DisplayName
     }).ToListAsync());
 }
示例#17
0
 private List <Room> GetRooms(string type)
 {
     _tenantConfig = ReadConfig(_roomsConfig).Result;
     if (_tenantConfig.Rooms != null)
     {
         return(_tenantConfig.Rooms.Where(r => r.RoomType == type).OrderBy(r => r.Name).ToList <Room>());
     }
     else
     {
         return(new List <Room>());
     }
 }
示例#18
0
        /// <summary>
        /// 租户配置
        /// </summary>
        /// <param name="tenantId"></param>
        /// <returns></returns>
        public TenantConfig TenantConf(int tenantId)
        {
            var cacheKey = "tenantconfig:tenantId_" + tenantId;
            var config   = CacheHelper.CacheService.Get <TenantConfig>(cacheKey);

            if (config == null)
            {
                config = new TenantConfig(tenantId);
                CacheHelper.CacheService.Set(cacheKey, config, CachingExpirationType.Stable);
            }
            return(config);
        }
示例#19
0
        public async Task <ActionResult <bool> > Update(TenantConfig tenantConfig)
        {
            var tenant = (await _tenantService.GetTenantFromHostAsync());

            if (tenant != null)
            {
                Console.WriteLine($"updating tenant {tenant.Id} : {tenant.Name}");
                return(await _tenantService.UpdateTenantAsync(tenant, tenantConfig));
            }

            return(BadRequest("Tenant doesn't exist"));
        }
示例#20
0
        public async Task <IActionResult> Rooms(string tenantName = null)
        {
            _tenantId     = GetTenantId(tenantName);
            _tenantConfig = ReadConfig(_roomsConfig).Result;

            var rooms = GetRooms("meet");

            ViewBag.Message        = "";
            ViewBag.Tenant         = tenantName;
            ViewBag.ImageContainer = _tenantConfig.ImageContainer;
            return(View(rooms));
        }
示例#21
0
        public WorksOrderPrint CreateWorksOrderPrint(int id = 0)
        {
            var          report = new WorksOrderPrint();
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.paramOrderId.Value = id;
            report.RequestParameters  = false;
            return(report);
        }
示例#22
0
        public void ShouldInitializeWhenTenantCreationParametersAreValid()
        {
            var id           = "a";
            var name         = "b";
            var tenantConfig = new TenantConfig("p", "s", "ps");
            var tenant       = new Tenant(id, name, tenantConfig);

            Assert.AreEqual(tenant.Id, id);
            Assert.AreEqual(tenant.Name, name);
            Assert.AreEqual(tenant.Config.ProductsDataSource, tenantConfig.ProductsDataSource);
            Assert.AreEqual(tenant.Config.SuppliersDataSource, tenantConfig.SuppliersDataSource);
            Assert.AreEqual(tenant.Config.SupplierProductBarcodesDataSource,
                            tenantConfig.SupplierProductBarcodesDataSource);
        }
示例#23
0
        public TransferOrderPrint CreateTransferOrderPrint(int id = 0)
        {
            var          report = new TransferOrderPrint();
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.paramOrderId.Value        = id;
            report.RequestParameters         = false;
            report.ToPictureBox.BeforePrint += ToPictureBox_BeforePrint;
            return(report);
        }
示例#24
0
        public async Task <JsonResult> GetRoomStatusOnDate(string roomId, string dateTime, string type, string tenantName)
        {
            _tenantId     = GetTenantId(tenantName);
            _tenantConfig = await ReadConfig(_roomsConfig);

            var checkDateTime = DateTime.Parse(dateTime);
            var timediff      = DateTime.Now - checkDateTime;

            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time");

            checkDateTime = TimeZoneInfo.ConvertTimeToUtc(checkDateTime, tz);

            var room  = new Room(24);
            var rooms = GetRooms(type).Where <Room>(r => r.Id == roomId);

            if (rooms.Count() > 0)
            {
                room = rooms.First();
            }
            else
            {
                room.Id         = roomId;
                room.Name       = roomId.Split('@')[0];
                room.HasMailBox = true;
            };


            if (Math.Abs(timediff.TotalMinutes) > 30)
            {
                room = await GetRoomData(room, checkDateTime, _tenantId);
            }
            else
            {
                if (!_cache.TryGetValue(_tenantId + "_" + roomId, out Room cachedRoom))
                {
                    room = await GetRoomData(room, checkDateTime, _tenantId);

                    // Save data in cache.
                    var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromSeconds(_roomsConfig.Value.CacheTime));
                    _cache.Set(_tenantId + "_" + roomId, room, cacheEntryOptions);
                }
                else
                {
                    room = cachedRoom;
                }
            }

            return(Json(room));
        }
示例#25
0
        public PalleteDispatchesReport CreatePalleteReport(int id = 0)
        {
            //creta and extra report instence
            var          report = new PalleteDispatchesReport();
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.dispatchId.Value = id;
            // requesting the parameter value from end-users.
            report.RequestParameters = false;
            return(report);
        }
示例#26
0
        public POCollectionNotePrint CreatePurchaseOrderPrints(int id = 0)
        {
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            var report = new POCollectionNotePrint();

            report.paramOrderId.Value = id;
            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.RequestParameters         = false;
            report.PoPictureBox.BeforePrint += PoPictureBox_BeforePrint;
            return(report);
        }
示例#27
0
        public GoodsReceiveNotePrint CreateGoodsReceiveNotePrint(Guid id)
        {
            //creta and extra report instence
            var          report = new GoodsReceiveNotePrint();
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.paramGoodsReceiveId.Value = id;
            // requesting the parameter value from end-users.
            report.RequestParameters         = false;
            report.PoPictureBox.BeforePrint += GrnPictureBox_BeforePrint;
            return(report);
        }
示例#28
0
        public void PopulateTenantConfigsTest()
        {
            var venueModel = new VenueModel
            {
                CountryCode = "USA",
                VenueName   = "TestVenue"
            };

            var databaseConfig = new DatabaseConfig
            {
                DatabasePassword = "******",
                DatabaseUser     = "******"
            };

            var tenantConfig = new TenantConfig
            {
                BlobPath = "testPath"
            };

            var venueTypeModel = new VenueTypeModel
            {
                EventTypeShortNamePlural = "shortName",
                VenueType = "pop",
                Language  = "en-us"
            };

            var tenantModel = new TenantModel
            {
                TenantId = 1368421345
            };

            var countries = new List <CountryModel>
            {
                new CountryModel
                {
                    Language    = "en-us",
                    CountryCode = "USA",
                    CountryName = "United States"
                }
            };

            var tenantConfigs = _helper.PopulateTenantConfigs("tenant", "http://events.wtp.bg1.trafficmanager.net/contosoconcerthall", databaseConfig, tenantConfig);

            Assert.IsNotNull(tenantConfigs);
            Assert.AreEqual("$", tenantConfigs.Currency);
            Assert.AreEqual("bg1", tenantConfigs.User);
        }
示例#29
0
        public SalesOrderPrint CreateSalesOrderPrint(int id = 0)
        {
            TenantConfig config = _tenantServices.GetTenantConfigById(CurrentTenantId);

            var report = new SalesOrderPrint();

            report.paramOrderId.Value = id;
            if (!config.ShowDecimalPoint)
            {
                report.lblQuantity.TextFormatString = "{0:0.##}";
            }
            report.RequestParameters         = false;
            report.SoPictureBox.BeforePrint += SoPictureBox_BeforePrint;
            report.FooterMsg1.Text           = config.SoReportFooterMsg1;
            report.FooterMsg2.Text           = config.SoReportFooterMsg2;
            return(report);
        }
示例#30
0
        public async Task <TenantConfig> CreateTenantAsync(CreateTenant createTenant)
        {
            var tenant = new TenantConfig()
            {
                Name        = createTenant.Tenant.Name,
                DbName      = $"warehousedb{createTenant.Tenant.Name}",
                DbServer    = "localhost",
                DbUser      = "******",
                DbPassword  = "******",
                Accent      = createTenant.Tenant.Accent,
                Avatar      = createTenant.Tenant.Avatar,
                Description = createTenant.Tenant.Description
            };

            if ((await _multiTenantContext.TenantConfigs.FirstOrDefaultAsync(x => x.Name == tenant.Name)) != null)
            {
                return(null);
            }

            await _multiTenantContext.TenantConfigs.AddAsync(tenant);

            var employment = new Employment()
            {
                TenantId = tenant.Id,
                UserId   = createTenant.UserId
            };
            await _multiTenantContext.Employments.AddAsync(employment);

            try
            {
                await _multiTenantContext.SaveChangesAsync();

                var optionsBuilder = new DbContextOptionsBuilder <TenantDataContext>();
                optionsBuilder.UseMySql(tenant.ConnectionString());

                var dbContext = new TenantDataContext(optionsBuilder.Options);
                await TenantDataContextSeed.SeedAsync(dbContext, createTenant);

                return(tenant);
            }
            catch
            {
                return(null);
            }
        }