Ejemplo n.º 1
0
        /// <summary>
        /// 外部调用远程提醒
        /// </summary>
        public void OpenRemoteReminder()
        {
            ReminderView view = new ReminderView();

            view.DataContext = new ReminderViewModel("远程提醒");
            view?.Show();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 外部调用备忘提醒
        /// </summary>
        public void OpenMemoReminder()
        {
            ReminderView view = new ReminderView();

            view.DataContext = new ReminderViewModel("备忘提醒");
            view?.Show();
        }
 /// <summary>
 /// 提醒按钮
 /// </summary>
 /// <param name="element"></param>
 private void Remind(ButtonBase element)
 {
     Task.Factory.StartNew(() =>
     {
         //Thread.Sleep(500);
         DispatcherHelper.CheckBeginInvokeOnUI(
             () =>
         {
             ReminderView view = new ReminderView();
             view.DataContext  = new ReminderViewModel.ReminderViewModel();
             view.Show();
         });
     }).ContinueWith(result =>
     {
         if (result.IsFaulted)
         {
         }
     });
 }
Ejemplo n.º 4
0
        public ReminderView GetReminderByType(ReminderEnum type, int?EmployeeId)
        {
            SqlConnection conn = null;
            SqlCommand    cmd  = null;

            try
            {
                conn            = DALHelper.CreateSqlDbConnection();
                cmd             = new SqlCommand("usp_GetCountOfRemindersByType", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@Type", Convert.ToInt32(type));
                if (EmployeeId != null)
                {
                    cmd.Parameters.AddWithValue("@EmployeeId", EmployeeId);
                }

                SqlDataReader rdr    = cmd.ExecuteReader();
                ReminderView  entity = new ReminderView();

                if (rdr.Read())
                {
                    entity.Count = Convert.ToInt32(rdr["Count"]);
                    entity.Url   = Convert.ToString(rdr["Url"]);
                }

                return(entity);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
                cmd.Dispose();
                conn.Dispose();
            }
        }
Ejemplo n.º 5
0
        public async Task <IReminderResponse> SetReminder(ReminderView view)
        {
            //var id = ObjectId.GenerateNewId();
            var registrationEndDate = new DateTime?();
            var title = "";

            if (view.ApplicationId == 1)
            {
                var batch = await _appDbContext.Batches.Where(x => x.Id == view.ActivityID).FirstOrDefaultAsync();

                registrationEndDate = batch.DateRegTo;
                title = await _appDbContext.Programmes.Where(x => x.Id == batch.ProgrammeId).Select(x => x.TitleEn).FirstOrDefaultAsync();
            }
            else if (view.ApplicationId == 2)
            {
                var activity = await _appDbContext.Initiatives.Where(x => x.Id == view.ActivityID).FirstOrDefaultAsync();

                registrationEndDate = activity.RegistrationEndDate;
                title = await _appDbContext.Initiatives.Where(x => x.Id == view.ActivityID).Select(x => x.TitleEn).FirstOrDefaultAsync();
            }
            else if (view.ApplicationId == 3)
            {
                var events = await _appDbContext.EventDays.Where(x => x.EventId == view.ActivityID).FirstOrDefaultAsync();

                registrationEndDate = events.EndTime;
                title = await _appDbContext.Events.Where(x => x.Id == view.ActivityID).Select(x => x.TextEn).FirstOrDefaultAsync();
            }

            var currentDate = DateTime.Now;

            var days = ((registrationEndDate - currentDate) / 3).Value.Days;

            var reminderSendDate = registrationEndDate - TimeSpan.FromDays(days);

            if (days == 0 || reminderSendDate < DateTime.Now)
            {
                reminderSendDate = DateTime.Now;
            }
            try
            {
                var reminder = await _appDbContext.Reminders.Where(x => x.UserID == view.UserID && x.ApplicationId == view.ApplicationId && x.ActivityId == view.ActivityID).FirstOrDefaultAsync();

                if (reminder == null)
                {
                    reminder = new Reminder()
                    {
                        UserID              = view.UserID,
                        ApplicationId       = view.ApplicationId,
                        ActivityId          = view.ActivityID,
                        RegistrationEndDate = registrationEndDate,
                        ReminderSendDate    = reminderSendDate,
                        isReminderSent      = false,
                        Name = title
                    };

                    await _appDbContext.Reminders.AddAsync(reminder);

                    await _appDbContext.SaveChangesAsync();
                }

                var data = _mapper.Map <ReminderViewModel>(reminder);
                return(new ReminderResponse(data));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> SetReminder([FromBody] ReminderView view)
        {
            var result = await _reminderService.SetReminder(view);

            return(Ok(result));
        }