Beispiel #1
0
        public void ResetUnSchedulePhysicians()
        {
            try
            {
                // create log
                _logger.AddLogEntry(_service3Name, "INPROGRESS", _service3Name + " Started", "");

                using (var objService = new PhysicianService())
                {
                    var now        = DateTime.Now.ToEST();
                    var physicians = objService.GetUnSchedulePhysiciansForService()
                                     .ToList();
                    physicians.ForEach(p =>
                    {
                        p.status_key                = PhysicianStatus.NotAvailable.ToInt();
                        p.status_change_date        = now;
                        p.status_change_cas_key     = null;
                        p.status_change_date_forAll = now;

                        using (var objLogService = new PhysicianStatusLogService())
                        {
                            objLogService.Create(new Model.physician_status_log
                            {
                                psl_user_key     = p.Id,
                                psl_created_by   = "unscheduled physicians service",
                                psl_created_date = DateTime.Now.ToEST(),
                                psl_phs_key      = PhysicianStatus.NotAvailable.ToInt(),
                                psl_start_date   = DateTime.Now.ToEST(),
                                psl_status_name  = PhysicianStatus.NotAvailable.ToString()
                            });
                        }
                    });

                    if (physicians.Count() > 0)
                    {
                        objService.SaveChanges();
                        var    physicianUserIds = physicians.Select(m => m.Id).ToList();
                        string url      = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey;
                        string postData = Newtonsoft.Json.JsonConvert.SerializeObject(physicianUserIds);
                        scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json);
                    }

                    var Nhphysicians = objService.GetNHUnSchedulePhysiciansForService()
                                       .ToList();
                    Nhphysicians.ForEach(p =>
                    {
                        p.status_key                = PhysicianStatus.NotAvailable.ToInt();
                        p.status_change_date        = now;
                        p.status_change_cas_key     = null;
                        p.status_change_date_forAll = now;

                        using (var objLogService = new PhysicianStatusLogService())
                        {
                            objLogService.Create(new Model.physician_status_log
                            {
                                psl_user_key     = p.Id,
                                psl_created_by   = "unscheduled physicians service",
                                psl_created_date = DateTime.Now.ToEST(),
                                psl_phs_key      = PhysicianStatus.NotAvailable.ToInt(),
                                psl_start_date   = DateTime.Now.ToEST(),
                                psl_status_name  = PhysicianStatus.NotAvailable.ToString()
                            });
                        }
                    });

                    if (Nhphysicians.Count() > 0)
                    {
                        objService.SaveChanges();
                        var    physicianUserIds = Nhphysicians.Select(m => m.Id).ToList();
                        string url      = scrapper.baseUrl + "/RPCHandler/RefreshPhysicianStatus?SignalRAuthKey=" + Settings.SignalRAuthKey;
                        string postData = Newtonsoft.Json.JsonConvert.SerializeObject(physicianUserIds);
                        scrapper.GetData(url, "POST", postData, ref Cookies, ContentTypes.Json);
                    }
                }
            }
            catch (Exception exception)
            {
                _logger.AddLogEntry(_service3Name, "ERROR", exception, "");
            }
            finally
            {
                _logger.AddLogEntry(_service3Name, "COMPLETED", "", "");
            }
        }