public static Result GetCurrentPackId(SortResult sortResult) { try { Pack pack; using (var db = new Data.AppContext()) { pack = db.Packs.Where(o => o.SortResult == sortResult).OrderByDescending(o => o.Id).FirstOrDefault(); } if (pack != null && pack.Id > 0) { return(Result.SuccessHasData(pack.Id)); } return(Result.SuccessHasData(0)); } catch (Exception ex) { return(new Result(ex)); } }
public static Result Upload(Battery battery) { Result result; using (var db = new GMCCContext()) { var sql = string.Format("INSERT INTO AutoSorting (CaseNumber, BarCode, CAP, ESR, TestDate, UserID, UserName) VALUES ('{0}', '{1}', {2}, {3}, '{4}', {5}, '{6}')", GetObject.GetById <Pack>(battery.PackId).Code, battery.Code, battery.CAP, battery.ESR, battery.TestTime, Current.User.Id, Current.User.Name); try { if (db.Database.ExecuteSqlCommand(sql) > 0) { result = Result.Success; } else { return(new Result("")); } } catch (Exception ex) { return(new Result(ex)); } } using (var db = new Data.AppContext()) { try { battery = db.Batteries.Where(o => o.Id == battery.Id).FirstOrDefault(); battery.IsUploaded = true; db.SaveChanges(); return(Result.Success); } catch (Exception ex) { return(new Result(ex)); } } }
private void LoadDependencies() { var con = @"Server=.\sqlexpress;Database=PropertiesDb;Trusted_Connection=True;"; var services = new ServiceCollection(); services.AddDbContext <Data.AppContext>(opts => opts.UseSqlServer(con)); services.AddHangfire(x => x.UseSqlServerStorage(con)); services.AddScoped <IPostalCodeRepository, PostalCodeRepository>(); services.AddScoped <IProcessRepository, ProcessRepository>(); services.AddScoped <IJobService, JobService>(); services.AddScoped <ICrawlerService, CrawlerService>(); var serviceProvider = services.BuildServiceProvider(); _jobService = serviceProvider.GetService <IJobService>(); _crawlerService = serviceProvider.GetService <ICrawlerService>(); _processRepository = serviceProvider.GetService <IProcessRepository>(); _postalCodeRepository = serviceProvider.GetService <IPostalCodeRepository>(); _context = serviceProvider.GetService <Data.AppContext>(); }
public Result Create(Tray tray) { try { using (var db = new Data.AppContext()) { if (db.Trays.Count(r => r.Code == tray.Code) > 0) { return(new Result(string.Format("系统中已存在条码为{0}的托盘!", tray.Code))); } db.Trays.Add(new Tray() { Code = tray.Code, Company = tray.Company, CreateTime = DateTime.Now, IsEnabled = true }); db.SaveChanges(); } Arthur.App.Business.Logging.AddOplog(string.Format("新增托盘[{0}]", tray.Code), Arthur.App.Model.OpType.创建); return(Result.Success); } catch (Exception ex) { return(new Result(ex.Message)); } }
public PersonController(Data.AppContext context) { _context = context; }
public PaymentsController(Data.AppContext context) { _context = context; }
public BaseCRUDService(Data.AppContext _db, IMapper m) : base(_db, m) { }
public AuthRepository() { _ctx = new Data.AppContext(); _userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>(_ctx)); }
public VideoCardRepository(AppContext appContext) { _appContext = appContext; }
public ViajanteRepository(Data.AppContext contexto) { _contexto = contexto; }
public RamRepository(AppContext appContext) { _appContext = appContext; }
public MotherBoardRepository(AppContext appContext) { _appContext = appContext; }
public KnjigaController(Data.AppContext db, IFileManager fileManager) { _db = db; _fileManager = fileManager; }
public PowerSuplyRepository(AppContext appContext) { _appContext = appContext; }
public BrandRepository(AppContext appContext) { _appContext = appContext; }
public StorageDriveRepository(AppContext appContext) { _appContext = appContext; }
public MemberRepository(Data.AppContext appContext) { db = appContext; }
public PcCaseRepository(AppContext appContext) { _appContext = appContext; }
public ProcessorRepository(AppContext appContext) { _appContext = appContext; }
public EmpresaRepository(Data.AppContext contexto) { _contexto = contexto; }
public UnitOfWork(string connectionString) { _db = new Data.AppContext(connectionString); }