public CarTypesController(VendorDbContext context) { //لایسنس Stimulsoft //StiLicense.LoadFromString("6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHn0s4gy0Fr5YoUZ9V00Y0igCSFQzwEqYBh/N77k4f0fWXTHW5rqeBNLkaurJDenJ9o97TyqHs9HfvINK18Uwzsc/bG01Rq+x3H3Rf+g7AY92gvWmp7VA2Uxa30Q97f61siWz2dE5kdBVcCnSFzC6awE74JzDcJMj8OuxplqB1CYcpoPcOjKy1PiATlC3UsBaLEXsok1xxtRMQ283r282tkh8XQitsxtTczAJBxijuJNfziYhci2jResWXK51ygOOEbVAxmpflujkJ8oEVHkOA/CjX6bGx05pNZ6oSIu9H8deF94MyqIwcdeirCe60GbIQByQtLimfxbIZnO35X3fs/94av0ODfELqrQEpLrpU6FNeHttvlMc5UVrT4K+8lPbqR8Hq0PFWmFrbVIYSi7tAVFMMe2D1C59NWyLu3AkrD3No7YhLVh7LV0Tttr/8FrcZ8xirBPcMZCIGrRIesrHxOsZH2V8t/t0GXCnLLAWX+TNvdNXkB8cF2y9ZXf1enI064yE5dwMs2fQ0yOUG/xornE"); _context = context; //StiLicense.LoadFromFile("wwwroot/Reports/license.key"); }
public ProductsController(IWebHostEnvironment enviroment, VendorDbContext context, UserManager <ApplicationUser> usermanager) { _enviroment = enviroment; _context = context; _usermanager = usermanager; }
public async Task DownloadOuiCsv() { var dbPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "testDb.db"); var vlm = new VendorListMaintenance(dbPath, "http://localhost/ieee/mac.csv"); await vlm.UpdateVendors(); using (var dataContext = new VendorDbContext(dbPath)) { var google = dataContext.Vendors.First(x => x.Assignment == "001A11"); Assert.AreEqual(google.OrganizationName, "Google, Inc."); Assert.AreEqual(google.OrganizationAddress, "1600 Amphitheater Parkway Mountain View CA US 94043 "); } }
/// <summary> /// 機器登録 /// </summary> /// <param name="packet">受信ARPパケット</param> private void DeviceRegister(Packet packet) { // イーサネットタイプがARP以外は破棄 if (packet.Ethernet.EtherType != EthernetType.Arp) { return; } var arp = packet.Ethernet.Arp; lock (this.lockObj) { // 送信元MACアドレスが登録済みの場合は破棄 if (this.Devices.Any(x => x.MacAddress.SequenceEqual(arp.SenderHardwareAddress.ToArray()))) { return; } this.Devices.Add(new Device() { IPAddress = new CalculatableIPAddress(arp.SenderProtocolAddress.ToArray()), MacAddress = arp.SenderHardwareAddress.ToArray() }); // 時間のかかるベンダ検索、ホスト名逆引き処理をTask化 this.taskList.Add( Task.Run(() => { using (var dataContext = new VendorDbContext(this._vendorDbPath)) { foreach (var device in this.Devices) { var vendorId = string.Join("", device.MacAddress.Take(3).Select(m => $"{m:X2}")); device.Vendor = dataContext.Vendors.FirstOrDefault(x => x.Assignment == vendorId); try { #pragma warning disable CS0618 // 型またはメンバーが古い形式です // Dns.GetHostEntryは正引き出来ないと失敗となるためDns.GetHostByAddressを使用する。 device.HostName = (Dns.GetHostByAddress(device.IPAddress)).HostName; #pragma warning restore CS0618 // 型またはメンバーが古い形式です } catch (SocketException) { } } } }) ); // 完了済みの削除 this.taskList.RemoveAll(task => task.Status == TaskStatus.RanToCompletion || task.Status == TaskStatus.Canceled || task.Status == TaskStatus.Faulted); } }
/// <summary> /// ベンダリストアップデート /// </summary> /// <returns></returns> public async Task UpdateVendors() { //完全に判定するならばMA-L,MA-M,MA-Sをそれぞれ更新する必要がある //MA-SをMA-Mにも登録 //MA-MをMA-Lにも登録する? this.IsBusy = true; var hc = new HttpClient(); var res = await hc.GetAsync(this._macAddressUrl, HttpCompletionOption.ResponseHeadersRead); //全体のファイルサイズ var fullsize = (long)res.Content.Headers.ContentLength; using (var httpStream = await res.Content.ReadAsStreamAsync()) using (var sr = new StreamReader(httpStream)) using (var csvReader = new CsvReader(sr)) using (var dataContext = new VendorDbContext(this._vendorDbPath)) { using (var transaction = dataContext.Database.BeginTransaction()) { // ベンダIDが被ってるものがある。詳細は不明なため、2件目以降はスキップする。 // 登録済みのベンダIDを退避しておく。 var insertedAssignments = new List <string>(); // 現在データ全件DELETE await dataContext.Database.ExecuteSqlCommandAsync("DELETE FROM Vendors;"); csvReader.Configuration.HasHeaderRecord = true; csvReader.Configuration.RegisterClassMap <VendorMapper>(); await Task.Run(() => { foreach (var vendor in csvReader.GetRecords <Vendor>()) { if (insertedAssignments.All(x => x != vendor.Assignment)) { dataContext.Vendors.Add(vendor); insertedAssignments.Add(vendor.Assignment); } this.ProgressRate = (int)(((double)csvReader.Context.CharPosition / fullsize) * 100); } }); await dataContext.SaveChangesAsync(); transaction.Commit(); } this.IsBusy = false; } }
protected override void OnStartup(StartupEventArgs e) { DispatcherHelper.UIDispatcher = this.Dispatcher; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); var vendorDbPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "VendorList.db"); var macAddressUrl = "https://standards.ieee.org/develop/regauth/oui/oui.csv"; using (var dataContext = new VendorDbContext(vendorDbPath)) { dataContext.Database.EnsureCreated(); } this.MainWindow = new MainWindow() { DataContext = new MainWindowViewModel(vendorDbPath, macAddressUrl) }; this.MainWindow.ShowDialog(); }
public static async void Setup(this VendorDbContext context, UserManager <User> userManager, RoleManager <Role> roleManager, long id) { var user = await userManager.FindByIdAsync(id.ToString()); var adminRole = await roleManager.FindByNameAsync("Admin"); if (adminRole == null) { adminRole = new Role("Admin"); await roleManager.AddClaimAsync(adminRole, new Claim(ClaimTypes.Role, "projects.view")); await roleManager.AddClaimAsync(adminRole, new Claim(ClaimTypes.Role, "projects.create")); await roleManager.AddClaimAsync(adminRole, new Claim(ClaimTypes.Role, "projects.update")); } if (!await userManager.IsInRoleAsync(user, adminRole.Name)) { await userManager.AddToRoleAsync(user, adminRole.Name); } var accountManagerRole = await roleManager.FindByNameAsync("Account Manager"); if (accountManagerRole == null) { accountManagerRole = new Role("Account Manager"); await roleManager.CreateAsync(accountManagerRole); await roleManager.AddClaimAsync(accountManagerRole, new Claim(ClaimTypes.Role, "account.manage")); } if (!await userManager.IsInRoleAsync(user, accountManagerRole.Name)) { await userManager.AddToRoleAsync(user, accountManagerRole.Name); } }
public CorroborantTypesController(VendorDbContext context) { _context = context; }
public ProductTypesController(VendorDbContext context) { _context = context; }
public OwnershipTypesController(VendorDbContext context) { _context = context; }
public CorroborantsController(VendorDbContext context, IWebHostEnvironment enviroment) { _context = context; _enviroment = enviroment; }
public DashboardRepository(VendorDbContext context) { _context = context; }
public LicenseTypesController(VendorDbContext context) { _context = context; }
public static void EnsureSeedData(this VendorDbContext context) { if (context.IsMigrationsApplied()) { if (!context.Users.Any()) { context.Users.Add( new User { UserName = "******", Email = "-", LockoutEnabled = false, Image = null, RegisterDate = DateTime.Now, Update = DateTime.Now }); context.SaveChanges(); } if (!context.Languages.Any()) { context.Languages.AddRange( new Language { Name = "Русский", Alias = "ru-RU", IsDefault = true, Update = DateTime.Now, UserUpDateId = 1 }, new Language { Name = "English", Alias = "en-US", IsDefault = false, Update = DateTime.Now, UserUpDateId = 1 }); context.SaveChanges(); } if (!context.Products.Any()) { context.Products.AddRange( new Product { // Name = "DetailOne", // Description = "The first detail", // Update = DateTime.Now, UserUpdateId = 1 }, new Product { // Name = "DetailTwo", // Description = "The second detail", // Update = DateTime.Now, UserUpdateId = 1 }); context.SaveChanges(); } } }
public CalendarManagementController(VendorDbContext db) { this.db = db; }
public BranchTypesController(VendorDbContext context) { _context = context; }
public CustomerTypesController(VendorDbContext context) { _context = context; }
public CompanyTypesController(VendorDbContext context) { _context = context; }
public ManufacturingGroupsController(VendorDbContext context) { _context = context; }
public BaseController(VendorDbContext context) { Context = context; }
public ApplicationController(VendorDbContext context) : base(context) { }
public Authentication(Settings settings, VendorDbContext context) { _settings = settings; _context = context; }
public CompaniesController(VendorDbContext context, IWebHostEnvironment environment) { _enviroment = environment; _context = context; }
public ProductionRatesController(VendorDbContext context) { _context = context; }
public HomeController(ILogger <HomeController> logger, VendorDbContext context) { _logger = logger; _context = context; }
public BranchInfrastructureTypesController(VendorDbContext context) { _context = context; }