예제 #1
0
        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));
            }
        }
예제 #2
0
        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>();
        }
예제 #4
0
 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));
     }
 }
예제 #5
0
 public PersonController(Data.AppContext context)
 {
     _context = context;
 }
예제 #6
0
 public PaymentsController(Data.AppContext context)
 {
     _context = context;
 }
예제 #7
0
 public BaseCRUDService(Data.AppContext _db, IMapper m) : base(_db, m)
 {
 }
예제 #8
0
 public AuthRepository()
 {
     _ctx         = new Data.AppContext();
     _userManager = new UserManager <IdentityUser>(new UserStore <IdentityUser>(_ctx));
 }
예제 #9
0
 public VideoCardRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #10
0
 public ViajanteRepository(Data.AppContext contexto)
 {
     _contexto = contexto;
 }
예제 #11
0
 public RamRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #12
0
 public MotherBoardRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #13
0
 public KnjigaController(Data.AppContext db, IFileManager fileManager)
 {
     _db          = db;
     _fileManager = fileManager;
 }
예제 #14
0
 public PowerSuplyRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #15
0
 public BrandRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #16
0
 public StorageDriveRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #17
0
 public MemberRepository(Data.AppContext appContext)
 {
     db = appContext;
 }
예제 #18
0
 public PcCaseRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #19
0
 public ProcessorRepository(AppContext appContext)
 {
     _appContext = appContext;
 }
예제 #20
0
 public EmpresaRepository(Data.AppContext contexto)
 {
     _contexto = contexto;
 }
예제 #21
0
 public UnitOfWork(string connectionString)
 {
     _db = new Data.AppContext(connectionString);
 }