Example #1
0
        public async void Add <T>(T obj)
        {
            using SkipContext _db = new SkipContext();
            await _db.AddAsync(obj);

            await _db.SaveChangesAsync();
        }
Example #2
0
        public async Task <T> First <T>() where T : class
        {
            using SkipContext _db = new SkipContext();
            T result = _db.DbSet <T>().FirstOrDefault();

            return(await Task.Run(() => result));
        }
Example #3
0
        public async Task <T[]> Where <T>(Func <T, bool> predicate) where T : class
        {
            using SkipContext _db = new SkipContext();
            IEnumerable <T> result = _db.DbSet <T>().Where(predicate);

            return(await Task.Run(() => result.ToArray()));
        }
Example #4
0
        // public async void Change(int Id, SReason obj)
        // {
        //     using SkipContext _db = new SkipContext();
        //     SReason oldObj = _db.DbSet<SReason>().Find(Id);
        //     if(oldObj != null){
        //         if(obj.Skip_Id != 0) oldObj.StudentId = obj.StudentId;
        //         else if(obj.Img != null) oldObj.Img = obj.Img;
        //         else if(obj.Count != 0) oldObj.Count = obj.Count;
        //         else if(obj.Date != null) oldObj.Date = obj.Date;
        //     }
        //     await _db.SaveChangesAsync();
        // }

        public async Task <int> Change <T>(int Id, T obj) where T : class
        {
            using (SkipContext _db = new SkipContext())
            {
                var oldObj = _db.DbSet <T>().Find(Id);
                oldObj = obj;
                return(await _db.SaveChangesAsync());
            }
        }
Example #5
0
 public int GetExceptionCount(SkipContext skipContext)
 {
     return _db.ExecuteQuery(cmd =>
                             {
                                 cmd.CommandText =
                                     "Select Count(*) from BatchStepException where StepName = @StepName and JobName = @JobName";
                                 cmd.Parameters.AddWithValue("@StepName", skipContext.StepName);
                                 cmd.Parameters.AddWithValue("@JobName", _jobName);
                                 return (int) cmd.ExecuteScalar();
                             });
 }
Example #6
0
 public int GetExceptionCount(SkipContext skipContext)
 {
     return(_db.ExecuteQuery(cmd =>
     {
         cmd.CommandText =
             "Select Count(*) from BatchStepException where StepName = @StepName and JobName = @JobName";
         cmd.Parameters.AddWithValue("@StepName", skipContext.StepName);
         cmd.Parameters.AddWithValue("@JobName", _jobName);
         return (int)cmd.ExecuteScalar();
     }));
 }
Example #7
0
        public void SaveExceptionInfo(SkipContext skipContext, int exceptionCount)
        {
            const string insert =
                "Insert into BatchStepException (StepIndex, StepName, JobName, ExceptionMsg, ExceptionDetails) " +
                "Values (@StepIndex, @StepName, @JobName, @ExMsg, @ExDetails)";

            _db.ExecuteQuery(cmd =>
            {
                cmd.CommandText = insert;
                cmd.Parameters.AddWithValue("@StepIndex", skipContext.StepIndex);
                cmd.Parameters.AddWithValue("@StepName", skipContext.StepName);
                cmd.Parameters.AddWithValue("@JobName", _jobName);
                cmd.Parameters.AddWithValue("@ExMsg", skipContext.Exception.Message);
                cmd.Parameters.AddWithValue("@ExDetails", skipContext.Exception.StackTrace);
                return(cmd.ExecuteNonQuery());
            });
        }
Example #8
0
        public SkipContext skip()
        {
            SkipContext _localctx = new SkipContext(Context, State);

            EnterRule(_localctx, 12, RULE_skip);
            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 79; Match(INT);
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                ErrorHandler.ReportError(this, re);
                ErrorHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
Example #9
0
        public async void setSReason(string path, int studentId, string month, int count)
        {
            Student student = await _main.GetById <Student>(studentId);

            Group group = await _main.GetById <Group>(student.GroupId);

            using SkipContext _db = new SkipContext();
            Models.Report value = _db.DbSet <Models.Report>()
                                  .First(e =>
                                         e.EduYear == group.Course &&
                                         e.Month == month &&
                                         e.StudentId == studentId);
            _skip.Add(
                new SReason
            {
                Count   = count,
                Date    = DateTime.Now,
                Img     = path,
                Skip_Id = value.Id
            }
                );
        }
Example #10
0
        public async void setSkip(List <AddSkips> data, string month, int eduYear, int semester, int groupId)
        {
            Student[] students = (await _main.Where <Student>(e => e.GroupId == groupId)).OrderBy(e => e.Surname).ToArray();
            using SkipContext _db = new SkipContext();
            for (int i = 0; i < students.Count(); i++)
            {
                var report = _db.DbSet <Models.Report>()
                             .First(e => e.StudentId == students[i].Id &&
                                    e.EduYear == eduYear &&
                                    e.Semester == semester &&
                                    e.Month == month);

                report.Count += data[i].Count;
                _skip.Add(new SReason
                {
                    Count   = data[i].SReason,
                    Date    = DateTime.Now,
                    Img     = "",
                    Skip_Id = report.Id
                });
                await _db.SaveChangesAsync();
            }
        }
 private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipContext <TSource> context)
 {
     try
     {
         var itemsToSkip = context.Count;
         while (await context.Source.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
         {
             if (itemsToSkip > 0)
             {
                 itemsToSkip--;
             }
             else
             {
                 await yield.ReturnAsync(context.Source.Current).ConfigureAwait(false);
             }
         }
     }
     finally
     {
         if (context.DisposeSource)
         {
             context.Source.Dispose();
         }
     }
 }
 public void SaveExceptionInfo(SkipContext skipContext, int currentCount)
 {
     ++_exceptionCount;
     Console.WriteLine("Skippable exception on line: {0} - {1}", skipContext.StepIndex, skipContext.Exception.Message);
 }
Example #13
0
 public void SaveExceptionInfo(SkipContext skipContext, int currentCount)
 {
     ++_exceptionCount;
     Console.WriteLine("Skippable exception on line: {0} - {1}", skipContext.StepIndex, skipContext.Exception.Message);
 }
Example #14
0
 public async void Remove <T>(T obj)
 {
     using SkipContext _db = new SkipContext();
     _db.Remove(obj);
     await _db.SaveChangesAsync();
 }
 public int GetExceptionCount(SkipContext context)
 {
     return _exceptionCount;
 }
Example #16
0
        public void SaveExceptionInfo(SkipContext skipContext, int exceptionCount)
        {
            const string insert =
                "Insert into BatchStepException (StepIndex, StepName, JobName, ExceptionMsg, ExceptionDetails) " +
                                        "Values (@StepIndex, @StepName, @JobName, @ExMsg, @ExDetails)";

            _db.ExecuteQuery(cmd =>
                             {
                                 cmd.CommandText = insert;
                                 cmd.Parameters.AddWithValue("@StepIndex", skipContext.StepIndex);
                                 cmd.Parameters.AddWithValue("@StepName", skipContext.StepName);
                                 cmd.Parameters.AddWithValue("@JobName", _jobName);
                                 cmd.Parameters.AddWithValue("@ExMsg", skipContext.Exception.Message);
                                 cmd.Parameters.AddWithValue("@ExDetails", skipContext.Exception.StackTrace);
                                 return cmd.ExecuteNonQuery();
                             });
        }
 private static async Task _enumerate(AsyncEnumerator <TSource> .Yield yield, SkipContext <TSource> context)
 {
     using (var enumerator = await context.Source.GetAsyncEnumeratorAsync(yield.CancellationToken).ConfigureAwait(false))
     {
         var itemsToSkip = context.Count;
         while (await enumerator.MoveNextAsync(yield.CancellationToken).ConfigureAwait(false))
         {
             if (itemsToSkip > 0)
             {
                 itemsToSkip--;
             }
             else
             {
                 await yield.ReturnAsync(enumerator.Current).ConfigureAwait(false);
             }
         }
     }
 }
Example #18
0
 public async Task <T[]> Get <T>() where T : class
 {
     using SkipContext _db = new SkipContext();
     return(await Task.Run(() => _db.DbSet <T>().ToArray()));
 }
Example #19
0
 public async Task <T> GetById <T>(int Id) where T : class
 {
     using SkipContext _db = new SkipContext();
     return(await Task.Run(() => _db.DbSet <T>().Find(Id)));
 }
Example #20
0
 public int GetExceptionCount(SkipContext context)
 {
     return(_exceptionCount);
 }