示例#1
0
        public ActionResult Sync(string id)
        {
            var address = addressRepo.GetById(id);
            var mapping = repo.GetByForeignAddress(id);

            try
            {
                bool clearResult = scheduleManager.ClearDPCalendar(mapping.DoctorFacility);
                bool pushResult  = scheduleManager.PushSlots(mapping.DoctorFacility);
                return(Json(new { status = pushResult && clearResult }));
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = ex.Message }));
            }
        }
        public void Execute(IJobExecutionContext context)
        {
            var db     = new HospitalContext();
            var client = new DpApi(AppSettings.ClientId, AppSettings.ClientSecret, (Locale)AppSettings.Locale);

            var scheduleManager = new ScheduleManager(db, client);
            var repo            = new DoctorFacilityRepository(db);

            var mappedDoctors = repo.GetMapped();

            foreach (var item in mappedDoctors)
            {
                bool clearResult = scheduleManager.ClearDPCalendar(item);
                bool pushResult  = scheduleManager.PushSlots(item);

                log.Warn($"Cleaning slot result: {clearResult}");
                log.Warn($"Push slot result: {pushResult}");
            }

            repo.Dispose();
        }