/// <summary> /// 添加日程信息 /// </summary> /// <param name="user"></param> private void AddSchedule(User user) { Schedule schedule = GiveSchedule(user); int i = ScheduleManager.AddSchedule(schedule); if (i != 0) { if (this.lbUserName.Items.Count > 0) { foreach (ListItem li in lbUserName.Items) { PreContract preContract = new PreContract(); preContract.Schedule.ScheduleId = i; preContract.UserId = li.Value; int count = PreContractManager.AddPreContract(preContract); if (count == 0) { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true); break; } } Response.Redirect("PersonSchedule.aspx"); } else { Response.Redirect("PersonSchedule.aspx"); } } else { ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true); } }
public void GenerateScheduleTest() { IScheduleManager scheduleManager = new ScheduleManager(_scheduleAccessor, _shiftTimeAccessor); List <BaseScheduleLine> lines = new List <BaseScheduleLine> { new BaseScheduleLine { BaseScheduleID = 1000000, DepartmentID = "Management", ShiftTimeID = 100002, ERoleID = "Manager", Count = 1 } }; DateTime date = DateTime.Now; ScheduleVM scheduleVM = scheduleManager.GenerateSchedule(date, lines); int result = scheduleVM.ScheduleLines.Count; int target = 10; Assert.AreEqual(target, result); }
public SetupTimeBangla() { InitializeComponent(); _scheduleManager = new ScheduleManager(); BindUi(); }
protected void buildingDropDownList_SelectedIndexChanged(object sender, EventArgs e) { try { List <Room> rooms = new List <Room>(); aScheduleManager = new ScheduleManager(); rooms = aScheduleManager.GetAllRooms(Convert.ToInt16(buildingDropDownList.Text)); roomDropDownList.DataSource = rooms; roomDropDownList.DataBind(); } catch (SqlException sqlException) { msgLabel.ForeColor = Color.Red; msgLabel.Text = "Database error.See details error: " + sqlException.Message; } catch (Exception exception) { msgLabel.ForeColor = Color.Red; string errorMessage = "Unknow error occured."; errorMessage += exception.Message; if (exception.InnerException != null) { errorMessage += exception.InnerException.Message; } msgLabel.Text = errorMessage; } }
public void TestAddScheduleHours() { IScheduleManager scheduleManager = new ScheduleManager(_scheduleAccessor, _shiftTimeAccessor); scheduleManager.AddScheduledHours(1000000); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile("Images/png/[email protected]")); this.TitleImage.Image = UIImage.FromFile("images/png/divisions/[email protected]"); this.HomeBtn.SetBackgroundImage(UIImage.FromFile("images/png/[email protected]"), UIControlState.Normal); //this.chartWeightTB.Background = UIImage.FromFile("images/png/[email protected]"); this.chartWeightAddBtn.SetBackgroundImage(UIImage.FromFile("images/png/[email protected]"), UIControlState.Normal); this.chartWeightTB.Placeholder = "Мой вес сегодня"; RectangleF rct = this.View.ViewWithTag(3).Frame; chview = new ChartView(sch_list, rct); View.AddSubview(chview); this.chartWeightAddBtn.TouchUpInside += (sender, e) => { int weight = System.Convert.ToInt32(this.chartWeightTB.Text, 10); phase_dict[DateTime.Today].m_weight = weight; ScheduleManager.SaveScheduleRecord(phase_dict[DateTime.Today]); this.chartWeightTB.ResignFirstResponder(); sch_list = ScheduleManager.GetScheduleRecords(); chview.RemoveFromSuperview(); chview = new ChartView(sch_list, this.View.ViewWithTag(3).Frame); View.AddSubview(chview); }; this.HomeBtn.TouchUpInside += (sender, e) => { this.NavigationController.PopToRootViewController(true); }; }
public SendResult Send(JMessage msg) { using (var article = SiteManager.Get <ArticleManager>()) { string author = AppManager.Instance.UserManager.GetById(msg.SenderId.ToString()).Name; foreach (int id in msg.SendToIds.Union(msg.CopyToIds)) { var ca = article.CreateByCatalog(ScheduleEvent.Root.Id); ca.Article.Options = ScheduleEvent.OptionNotice; ca.SetExt(ScheduleEvent.Root.AlertBefore, 5); ca.SetExt(ScheduleEvent.Root.StartTime, DateTime.Now); ca.SetExt(ScheduleEvent.Root.AllDay, true); ca.SetExt(ScheduleEvent.Root.ProcessUrl, msg.Url); ca.Article.Title = msg.Title; ca.Article.Text = msg.Content; ca.Article.EditorId = id; ca.Article.Author = author; ca.Article.CreateTime = DateTime.Now; ScheduleManager.AdjustAlertTime(ca); article.Save(ca); } SendResult result = new SendResult { MessageId = msg.Id, SentTime = DateTime.Now, PlanSendTime = msg.PlanSendTime, }; return(result); } }
void CheckForScheduleUpdates() { try { if (!ScheduleManager.LastUpdatedUtc.HasValue) { //new Task(ScheduleManager.LoadAllSchedules).Start(); Task.Run(() => ScheduleManager.LoadAllSchedules()); } else { var lastServerUpdate = ChatServices.LastScheduleUpdate(); var hasServerUpdates = lastServerUpdate.HasValue && lastServerUpdate.Value > ScheduleManager.LastUpdatedUtc.Value; var newDateToProcess = ScheduleManager.LastUpdatedUtc.Value.AddHours(ScheduleManager.ScheduleDateTimeOffset).Date < DateTime.UtcNow.AddHours(ScheduleManager.ScheduleDateTimeOffset).Date; if (hasServerUpdates || newDateToProcess) { //new Task(ScheduleManager.LoadAllSchedules).Start(); Task.Run(() => ScheduleManager.LoadAllSchedules()); } else { if (ScheduleManager.ProfilesToReload.Any()) { Task.Run(() => ScheduleManager.UpdateChangedScheduleAvailability()); } } } } catch (Exception) { } }
private BusinessObjects() { ScheduleManager = new ScheduleManager(); HelpManager = new HelpManager(); OutputManager = new OutputManager(); ThemeManager = new ThemeManager(); }
public void ExpandSchedule(DateTime minStartDate, DateTime maxEndDate) { var mgr = new ScheduleManager(); TimeSlots.Clear(); TimeSlots.AddRange(mgr.ExpandSchedule(Schedule, minStartDate, maxEndDate)); }
private void NextAct() { IScheduleable scheduleable = ScheduleManager.Get(); if (scheduleable == null) { TickAll(); AddAll(); return; } System.Console.WriteLine("{0}", (scheduleable as Actor).GetParent().NAME); if ((scheduleable as Actor).GetParent() == Player) { IsPlayerTurn = true; } else { var ai = (scheduleable as Actor).GetComponent <ConsoleScreenGameHelper.Core.Entity.Components.AI>(ComponentType.AI); ai.Act(); (scheduleable as Actor).GetParent().Update(); if ((scheduleable as Actor).Stats.Energy >= 7) { ScheduleManager.Add((scheduleable as Actor)); } else if ((scheduleable as Actor).Stats.Energy > 0) { ScheduleManager.Add((scheduleable as Actor), 5); } else { ScheduleManager.Add((scheduleable as Actor), 7); } NextAct(); } }
private void btnDC_Click(object sender, EventArgs e) { int n = 0; Random rd = new Random(); string OrderId = ""; OrderId += DateTime.Now.Year.ToString(); OrderId += DateTime.Now.Month.ToString(); OrderId += DateTime.Now.Day.ToString(); for (int i = 0; i < 6; i++) { OrderId += rd.Next(0, 10).ToString(); } n = OrderManager.InsertOrder(OrderId, Convert.ToInt32(lbTableId.Text)); ScheduleManager.DeleteSchedule(); TableManager.UpdateTypebyTableId(5, lbTableId.Text); TableManager.UpdateTableNowInfo(lbTableId.Text, OrderId, DateTime.Now, 0, null, false); if (n > 0) { // FoodPlayer.Ctlcontrols.stop(); FrmFoodMain drm = new FrmFoodMain(); FrmFoodInfo ffi = new FrmFoodInfo(); drm.lbTable.Text = lbTableId.Text; drm.lbOrderId.Text = OrderId; this.Hide(); drm.Show(); } else { Transmit.FrmFoodMain.Tipsk("打开失败请重试!"); } }
private void SchedulerCallback(object sender) { try { if (ConfigGlobal_Arsenal.SchedulerActive) { var declaringType = MethodBase.GetCurrentMethod().DeclaringType; if (declaringType != null) { var assembly = declaringType.Assembly.GetName().Name; ScheduleManager.Execute(assembly); } } } catch (Exception ex) { ILog log = new AppLog(); log.Warn(ex, new LogInfo { MethodInstance = MethodBase.GetCurrentMethod(), ThreadInstance = Thread.CurrentThread }); } }
private void ItemsGet() { // Read sample item info from XML document into a DataSet try { // Populate the repeater control with the Items DataSet ScheduleManager obj = new ScheduleManager(); PagedDataSource objPds = new PagedDataSource(); objPds.DataSource = obj.GetSchedules(); objPds.AllowPaging = true; objPds.PageSize = 5; objPds.CurrentPageIndex = CurrentPage; lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of " + objPds.PageCount.ToString(); // Disable Prev or Next buttons if necessary commandPrevious.Enabled = !objPds.IsFirstPage; commandNext.Enabled = !objPds.IsLastPage; Repeater1.DataSource = objPds; Repeater1.DataBind(); } catch (ScheduleManagerException ex) { lblMessage.Text = ex.Message; } }
static void Main(string[] args) { //var xmlManager = new XmlManager(); //xmlManager.LoadGroups("../../XML_files/groups.xml"); //xmlManager.LoadSchedule("../../XML_files/schedule.xml"); //xmlManager.LoadDirectory("../../XML_files"); //var l = Teacher.Get(); //foreach (var item in l) //{ // Console.WriteLine(item); //} //LogManager.LogException(new Exception("be carefull")); //BL.AbsenceForTeacher.Add(new AbsencesForTeacherDTO() //{ // FromDate = _CastDTO.DateToDTO(DateTime.Now), // ToDate = _CastDTO.DateToDTO(DateTime.Now), // TeacherId = 179, // Type = 4, // TeacherStandIn = 180 //}); //var z = BL.Class.ClassByLayer.Keys; //var x = BL.Class.ClassByLayer; var s = new ScheduleManager(); var l1 = s.GetScheduleByClass(9, 2); //Console.WriteLine(l1.Count()); var l2 = s.GetScheduleByTeacher(1093); //Console.ReadLine(); }
public ActionResult Index() { //Indexte kullanacağım ViewModeli oluşturuyorum IndexViewModel indexViewModel = new IndexViewModel(); //kisiler tablosunu çekip kisiliste değişkenine atıyorum Repository <User> kisiler = new Repository <User>(); List <User> kisiliste = kisiler.List(); //haftalık çalışma sürelerini ScheduleManager'de hesaplayıp listeye atıyorum. ScheduleManager sm = new ScheduleManager(); List <int> listsure = new List <int>(); listsure = sm.haftalikCalismaSuresi(); //Şu an işte olanları buluyor CurrentManager cm = new CurrentManager(); List <User> currenthere = new List <User>(); foreach (var item in kisiliste) { if (cm.IsHere(item.Id)) { currenthere.Add(item); } } indexViewModel.mevcutkullanici = kisiler.Find(x => x.Id == CurrentSession.User.Id); indexViewModel.kisilist = kisiliste; indexViewModel.kisisure = listsure; indexViewModel.currenthere = currenthere; return(View(indexViewModel)); }
public ScheduleViewModel() { _scheduleManager = new ScheduleManager(); _scheduleManager.UpdateScheduleIfNeeded(); using (ClinicModelContainer container = new ClinicModelContainer()) { _schedules = new ObservableCollection <DistrictSchedule>( container.DistrictSchedules); foreach (var sch in _schedules) { sch.Doctor = sch.Doctor; sch.Surgery = sch.Surgery; sch.Doctor.SiteDoctors = sch.Doctor.SiteDoctors; sch.Doctor.SiteDoctors.First().Site = sch.Doctor.SiteDoctors.First().Site; } Sites = container.Sites.ToList(); } _currentMonthNumber = DateTime.Now.Month; UpdateCurrentDays(_currentMonthNumber); _selectedDay = CurrentDays.ToList() .Find(d => int.Parse(d.DayNumber) == DateTime.Now.Day); _selectedSite = Sites[0]; _selectedDayIndex = CurrentDays.IndexOf(SelectedDay); SelectNewSchedules(_selectedSite.Number, _currentMonthNumber, int.Parse(_selectedDay.DayNumber)); }
private void FrmSchedule_Load(object sender, EventArgs e) { Transmit.FrmSchedule = this; flpSchedule.Controls.Clear(); List <Schedule> sds = ScheduleManager.selectSchedule(); #region 加载订单 if (sds.Count == 0) { FrmImage2 fi2 = new FrmImage2(); plSchedule.Controls.Clear(); plSchedule.Controls.Add(fi2); } else { lbFTime.Text = sds[0].FTime.Substring(0, 5); lbFNumber.Text = sds[0].FNumber.ToString(); lbOrderId.Text = sds[0].OrderId; lbFName.Text = sds[0].FName; pbxFImage.Image = Image.FromFile(Application.StartupPath + @"\Images\食物\" + sds[0].FName + ".jpg"); for (int i = 0; i < sds.Count; i++) { flpSchedules fs = new flpSchedules(); fs.lbFName.Text = sds[i].FName; fs.lbOrderId.Text = sds[i].OrderId; flpSchedule.Controls.Add(fs); } } #endregion }
public void ShouldCreateTheScheduleItemsSpecified() { //arrange var mySchedule = new Schedule() { ScheduleItems = new List <ScheduleItem>() { new ScheduleItem() { StartDateTime = new DateTime(2019, 5, 17, 15, 0, 0), EndDateTime = new DateTime(2019, 5, 17, 16, 0, 0) } } }; //act var sut = new ScheduleManager(); var results = sut.ExpandSchedule(mySchedule, new DateTime(2019, 1, 1), new DateTime(2019, 12, 31)); //assert Assert.Single(results); Assert.Equal(15, results.First().StartDateTime.Hour); }
public static void Main(string[] args) { var serviceCollection = new ServiceCollection(); var serviceProvider = serviceCollection.BuildServiceProvider(); var logger = serviceProvider.GetService <ILogger <Program> >(); var scheduler = new ScheduleManager(new RunnerConfiguration(maxRunnerInstances: 3, tasksDividerPerRunner: 2), logger); var r = new Random(); for (int i = 0; i < 100; i++) { var time = r.Next(10, 20); var name = $"Test {i.ToString()}"; var task = new ScheduledTask(name, () => { Console.WriteLine($"{DateTime.UtcNow}\t\t{name} >> Running each {time}sec"); }, TimeSpan.FromSeconds(time).TotalMilliseconds, true); scheduler.TryScheduleTask(task); } while (true) { Console.WriteLine($"{DateTime.UtcNow} | Sleeping"); Thread.Sleep(1000); } }
public void Ao_Obter_14_Meses_A_Partir_Do_Menos_3_Deve_Retornar_De_Janeiro_A__Dezembro() { ScheduleManager sc = new ScheduleManager(); var meses = sc.GetMonthTranslated(14, -3); Assert.IsTrue(meses.Count == 12); }
public override void ViewDidLoad() { base.ViewDidLoad(); this.OkayBtn.Clicked += (sender, e) => { DismissViewController(true, null); // get & parse params this.YourWeightTF.ResignFirstResponder(); string your_w = this.YourWeightTF.Text; string desire_w = this.DesireWeightTF.Text; m_my_weight = System.Convert.ToInt32(your_w, 10); int goal_diff = m_my_weight - System.Convert.ToInt32(desire_w, 10); int a_days = System.Convert.ToInt32(this.AtackTF.Text, 10); // clear prev schedule ScheduleManager.DeleteAllScheduleRecords(); // calculate and save schedule(attack& cruise for now) List <ScheduleRecord> recs_list = ScheduleMaker.makeAttackCruise(goal_diff, a_days, DateTime.Now.Date); foreach (var sch in recs_list) { sch.m_weight = m_my_weight; ScheduleManager.SaveScheduleRecord(sch); } PrefsRecord pref = PrefsManager.GetPrefsRecordValue("isDietStarted"); pref.PrefValue = "1"; // diet have started PrefsManager.UpdatePrefsRecord(pref); }; }
public ActionResult Edit(Base_Article a, int caId = 0) { Base_CatalogArticle ca; if (caId > 0) { ca = _schedule.Article.GetById(caId); if (ca.Article.State == ScheduleEvent.OptionReadOnly) { return(JsonTips("error", SStr.CantChangeReadonlySchedule)); } } else { a.State = ArticleState.Published; ca = new Base_CatalogArticle { CatalogId = ScheduleEvent.Root.Id, }; } ca.Article = a; ca.Article.EditorId = CurrentUserId.ToInt(); ScheduleManager.AdjustAlertTime(ca); _schedule.Article.Save(ca); // Manager.Save(evt); return(JsonTips("success", JStr.SuccessSaved, ca.Article.Title)); }
public void Update() { if (Player == null) { GetPlayer(); } DidPlayerAct = false; if (IsPlayerTurn) { Player.Update(); if (DidPlayerAct == true) { if (Player.GetComponent <Statistic>(ComponentType.Stats).Energy >= 7) { ScheduleManager.Add(Player.GetComponent <Actor>(ComponentType.Actor)); } else if (Player.GetComponent <Statistic>(ComponentType.Stats).Energy > 0) { ScheduleManager.Add(Player.GetComponent <Actor>(ComponentType.Actor), 5); } else { ScheduleManager.Add(Player.GetComponent <Actor>(ComponentType.Actor), 7); } IsPlayerTurn = false; TickAll(); } } else { NextAct(); TickAll(); } }
//NOTE: Use Save() when calling directly, it will generate correct salt. //NOTE: Add and Update should be used only by Replication on the remote side, so that they don't regenerate salt again !!! public static void Update(string pSalt, PartnerDto pPartner) { using (Rbr_Db _db = new Rbr_Db()) { using (Transaction _tx = new Transaction(_db, pSalt, pPartner)) { PartnerDto _originalPartner = PartnerManager.Get(_db, pPartner.PartnerId); ContactInfoManager.Update(_db, pPartner.ContactInfo); //TODO: NEW DAL - handle Person deletion... if (pPartner.Employees != null) { foreach (PersonDto _employee in pPartner.Employees) { _employee.PartnerId = pPartner.PartnerId; PersonManager.Save(_db, pSalt, _employee); } } if (pPartner.BillingSchedule != null) { ScheduleManager.Save(_db, pPartner.BillingSchedule); } else if (_originalPartner.BillingSchedule != null) { ScheduleManager.Delete(_db, _originalPartner.BillingSchedule.ScheduleId); } PartnerManager.Update(_db, pPartner); _tx.Commit(); } } }
// GET: Mentor public MentorController(UserManager user, MentorManager mentor, ScheduleManager schedule, MenteeManager mentee) { _user = user; _schedule = schedule; _mentor = mentor; _mentee = mentee; }
public async Task <ActionResult> Schedule(HttpPostedFileBase inputFile) { // Invalid file if (!IsValidFile(inputFile, out string errorMessage)) { ViewBag.Message = errorMessage; return(View("Index")); } var lineParser = new InputLineParser(); var inputDataParser = new ConferenceInputDataParser(lineParser); var talks = await inputDataParser.LoadTalks(inputFile); if (talks.Count == 0) { ViewBag.Message = "No valid registered talks found in the input file."; } var tracks = inputDataParser.GetTracks(talks); var recursiveScheduler = new NonRecursiveScheduler(); var scheduleManager = new ScheduleManager(recursiveScheduler); scheduleManager.Schedule(talks, tracks); var output = new ScheduledResult { Tracks = tracks }; OutputSet.Items.Add(output); return(RedirectToAction("ScheduleDetails", new { id = output.Id })); }
protected virtual void UpdateScheduleRunInfo(ScheduledItem scheduledItem, Activity activity) { if (scheduledItem != null) { int count = 3; do { try { if (scheduledItem.FrequencyType == ScheduledFrequencyType.OnceThenDelete) { ScheduleManager.Delete(scheduledItem.Id); } else { scheduledItem.LastExecutedOn = DateTime.Now; scheduledItem.LastExecuteActivityId = activity.Id; scheduledItem.NextRunOn = ScheduledItem.CalcNextRunTime(scheduledItem.NextRunOn, scheduledItem.FrequencyType, scheduledItem.Frequency, true, scheduledItem.StartOn, scheduledItem.EndOn, scheduledItem.IsActive); scheduledItem = ScheduleManager.Update(scheduledItem, false); } count = 0; } catch (Exception e) { LOG.Error("Error in UpdateScheduleRunInfo().", e); } }while (--count > 0); } }
public void Ao_Obter_Os_Dias_De_Fevereiro_Deve_Retornar_Menos_De_Trinta() { ScheduleManager sc = new ScheduleManager(); List <DayToShow> days = sc.GetDaysTranslated(DateTime.Now.Year, 2); int ulfimoDia = days[days.Count - 1].Day; Assert.IsTrue(ulfimoDia < 30); }
public ActionResult DeleteConfirmed(int id) { ScheduleManager scheduleManager = db.ScheduleManagers.Find(id); db.ScheduleManagers.Remove(scheduleManager); db.SaveChanges(); return(RedirectToAction("Index")); }
static void Main(string[] args) { var triggerFactory = new TriggerFactory(); var iterationFactory = new TimeIterationFactory(); var task1 = new SchedulerTask(triggerFactory.OnceRun(), () => consoleTask("Once task")); var task2 = new SchedulerTask(triggerFactory.Interval(iterationFactory.Interval(new TimeSpan(0, 0, 2))), () => consoleTask("Interval task, every 2 second")); var scheduler = new ScheduleManager(100, task1, task2); scheduler.Start(); Thread.Sleep(10000); scheduler.Stop(); }
/// <summary> /// Initializes a new instance of the <see cref="ServiceHelper"/> class. /// </summary> public ServiceHelper() : base() { m_logStatusUpdates = DefaultLogStatusUpdates; m_monitorServiceHealth = DefaultMonitorServiceHealth; m_requestHistoryLimit = DefaultRequestHistoryLimit; m_queryableSettingsCategories = DefaultQueryableSettingsCategories; m_persistSettings = DefaultPersistSettings; m_settingsCategory = DefaultSettingsCategory; m_processes = new List<ServiceProcess>(); m_remoteClients = new List<ClientInfo>(); m_clientRequestHistory = new List<ClientRequest.Info>(); m_serviceComponents = new List<ISupportLifecycle>(); m_clientRequestHandlers = new List<ClientRequestHandler>(); m_componentEnabledStates = new Dictionary<ISupportLifecycle, bool>(); m_telnetPassword = "******"; // Components m_statusLog = new LogFile(); m_statusLog.LogException += m_statusLog_LogException; m_statusLog.FileName = "StatusLog.txt"; m_statusLog.SettingsCategory = "StatusLog"; m_processScheduler = new ScheduleManager(); m_processScheduler.ScheduleDue += m_scheduler_ScheduleDue; m_processScheduler.SettingsCategory = "ProcessScheduler"; m_errorLogger = new ErrorLogger(); m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.SettingsCategory = "ErrorLogger"; m_errorLogger.ErrorLog.SettingsCategory = "ErrorLog"; }
/// <summary> /// Initializes a new instance of the <see cref="ServiceHelper"/> class. /// </summary> public ServiceHelper() : base() { m_telnetSessionPassword = "******"; m_logStatusUpdates = DefaultLogStatusUpdates; m_maxStatusUpdatesLength = DefaultMaxStatusUpdatesLength; m_maxStatusUpdatesFrequency = DefaultMaxStatusUpdatesFrequency; m_monitorServiceHealth = DefaultMonitorServiceHealth; m_requestHistoryLimit = DefaultRequestHistoryLimit; m_supportTelnetSessions = DefaultSupportTelnetSessions; m_secureRemoteInteractions = DefaultSecureRemoteInteractions; m_persistSettings = DefaultPersistSettings; m_settingsCategory = DefaultSettingsCategory; m_processes = new List<ServiceProcess>(); m_remoteClients = new List<ClientInfo>(); m_clientRequestHistory = new List<ClientRequestInfo>(); m_serviceComponents = new List<object>(); m_clientRequestHandlers = new List<ClientRequestHandler>(); m_componentEnabledStates = new Dictionary<ISupportLifecycle, bool>(); // Components m_statusUpdateQueue = ProcessQueue<StatusUpdate>.CreateSynchronousQueue(ProcessStatusUpdates); m_statusUpdateQueue.Name = "StatusUpdateQueue"; m_statusUpdateQueue.ProcessException += StatusUpdateQueue_ProcessException; m_statusLog = new LogFile(); m_statusLog.FileName = "StatusLog.txt"; m_statusLog.SettingsCategory = "StatusLog"; m_statusLog.LogException += StatusLog_LogException; m_processScheduler = new ScheduleManager(); m_processScheduler.SettingsCategory = "ProcessScheduler"; m_processScheduler.ScheduleDue += Scheduler_ScheduleDue; m_errorLogger = new ErrorLogger(); m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.SettingsCategory = "ErrorLogger"; m_errorLogger.ErrorLog.SettingsCategory = "ErrorLog"; m_errorLogger.LoggingException += ErrorLogger_LoggingException; }
/// <summary> /// Releases the unmanaged resources used by an instance of the <see cref="ServiceHelper" /> class and optionally releases the managed resources. /// </summary> /// <param name="disposing"><strong>true</strong> to release both managed and unmanaged resources; <strong>false</strong> to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { SaveSettings(); if (m_statusLog != null) { m_statusLog.LogException -= m_statusLog_LogException; m_statusLog.Dispose(); } m_statusLog = null; if (m_scheduler != null) { m_scheduler.ScheduleDue -= m_scheduler_ScheduleDue; m_scheduler.Dispose(); } m_scheduler = null; if (m_errorLogger != null) { m_errorLogger.Dispose(); } m_errorLogger = null; if (m_performanceMonitor != null) { m_performanceMonitor.Dispose(); } m_performanceMonitor = null; if (m_remoteCommandProcess != null) { m_remoteCommandProcess.ErrorDataReceived -= m_remoteCommandProcess_ErrorDataReceived; m_remoteCommandProcess.OutputDataReceived -= m_remoteCommandProcess_OutputDataReceived; if (!m_remoteCommandProcess.HasExited) m_remoteCommandProcess.Kill(); m_remoteCommandProcess.Dispose(); } m_remoteCommandProcess = null; // Service processes are created and owned by remoting server, so we dispose them if (m_processes != null) { foreach (ServiceProcess process in m_processes) { process.Dispose(); } m_processes.Clear(); } m_processes = null; // Detach any remoting server events, we don't own this component so we don't dispose it RemotingServer = null; } } finally { base.Dispose(disposing); // Call base class Dispose(). m_disposed = true; // Prevent duplicate dispose. } } }
public ServiceHelper() { m_logStatusUpdates = DefaultLogStatusUpdates; m_monitorServiceHealth = DefaultMonitorServiceHealth; m_requestHistoryLimit = DefaultRequestHistoryLimit; m_queryableSettingsCategories = DefaultQueryableSettingsCategories; m_persistSettings = DefaultPersistSettings; m_settingsCategory = DefaultSettingsCategoryName; m_processes = new List<ServiceProcess>(); m_connectedClients = new List<ClientInfo>(); m_clientRequestHistory = new List<ClientRequestInfo>(); m_serviceComponents = new List<IServiceComponent>(); m_clientRequestHandlers = new List<ClientRequestHandlerInfo>(); m_pursip = "s3cur3"; // Components m_statusLog = new LogFile(); m_statusLog.LogException += m_statusLog_LogException; m_statusLog.FileName = "StatusLog.txt"; m_statusLog.PersistSettings = true; m_statusLog.SettingsCategory = "StatusLog"; m_scheduler = new ScheduleManager(); m_scheduler.ScheduleDue += m_scheduler_ScheduleDue; m_scheduler.PersistSettings = true; m_scheduler.SettingsCategory = "Scheduler"; m_errorLogger = new ErrorLogger(); m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.PersistSettings = true; m_errorLogger.SettingsCategory = "ErrorLogger"; }
/// <summary> /// Initializes a new instance of the <see cref="ServiceHelper"/> class. /// </summary> public ServiceHelper() { m_telnetSessionPassword = "******"; m_logStatusUpdates = DefaultLogStatusUpdates; m_maxStatusUpdatesLength = DefaultMaxStatusUpdatesLength; m_maxStatusUpdatesFrequency = DefaultMaxStatusUpdatesFrequency; m_monitorServiceHealth = DefaultMonitorServiceHealth; m_healthMonitorInterval = DefaultHealthMonitorInterval; m_requestHistoryLimit = DefaultRequestHistoryLimit; m_supportFileManagementCommands = DefaultSupportFileManagementCommands; m_supportTelnetSessions = DefaultSupportTelnetSessions; m_supportSystemCommands = DefaultSupportSystemCommands; m_secureRemoteInteractions = DefaultSecureRemoteInteractions; m_serializationFormat = DefaultSerializationFormat; m_persistSettings = DefaultPersistSettings; m_settingsCategory = DefaultSettingsCategory; m_processes = new List<ServiceProcess>(); m_remoteClients = new List<ClientInfo>(); m_clientRequestHistory = new List<ClientRequestInfo>(); m_serviceComponents = new List<object>(); m_clientRequestHandlers = new List<ClientRequestHandler>(); m_componentEnabledStates = new Dictionary<ISupportLifecycle, bool>(); m_clientStatusUpdateLookup = new Dictionary<Guid, ClientStatusUpdateConfiguration>(); m_threadScheduler = new LogicalThreadScheduler(); m_threadScheduler.UnhandledException += LogicalThread_ProcessException; m_statusUpdateThread = m_threadScheduler.CreateThread(2); m_statusUpdateQueue = new List<StatusUpdate>(); // Components m_statusLog = new LogFile(); m_statusLog.FileName = "StatusLog.txt"; m_statusLog.SettingsCategory = "StatusLog"; m_statusLog.LogException += StatusLog_LogException; m_processScheduler = new ScheduleManager(); m_processScheduler.SettingsCategory = "ProcessScheduler"; m_processScheduler.ScheduleDue += Scheduler_ScheduleDue; m_errorLogger = new ErrorLogger(); m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.SettingsCategory = "ErrorLogger"; m_errorLogger.ErrorLog.SettingsCategory = "ErrorLog"; m_errorLogger.LoggingException += ErrorLogger_LoggingException; }
public static void MigrateSurveyCustomer() { PortalDbContext portalDbContext = new PortalDbContext(); PortalDbRepository<Access> accesPortalDbRepository = new PortalDbRepository<Access>(portalDbContext); PortalDbRepository<SurveyCustomer> surveyCustomerRepository = new PortalDbRepository<SurveyCustomer>(portalDbContext); PortalDbRepository<SurveyQuestion> surveyQuestionRepository = new PortalDbRepository<SurveyQuestion>(portalDbContext); PortalDbRepository<SurveysGeneralAnswer> surveysGeneralAnswerRepository = new PortalDbRepository<SurveysGeneralAnswer>(portalDbContext); PortalDbRepository<SurveysPossibleAnswer> surveyPossibleAnswerRepository = new PortalDbRepository<SurveysPossibleAnswer>(portalDbContext); Manager portalDbManager = new Manager(accesPortalDbRepository); /////////////===================>>>>>>>>>>>>>>>>>>> SurveyCustomerDbManager SurveyCustomerDbManager = new SurveyCustomerDbManager(surveyCustomerRepository, portalDbManager); SurveyQuestionManager SurveyQuestionManager = new SurveyQuestionManager(surveyQuestionRepository, portalDbManager); SurveyGeneralAnswerManager SurveyGeneralAnswerManager = new SurveyGeneralAnswerManager(surveysGeneralAnswerRepository, portalDbManager); SurveyPossibleAnswerManager SurveyPossibleAnswerManager = new SurveyPossibleAnswerManager(surveyPossibleAnswerRepository, portalDbManager); ////////////////////////////////////////////////// CosmeticExpressDbContext cosmeticExpressDbContext = new CosmeticExpressDbContext(); CosmeticExpressDbRepository<Access> accesCosmeticExpressDbRepository = new CosmeticExpressDbRepository<Access>(cosmeticExpressDbContext); CosmeticExpressDbRepository<User> userRepository = new CosmeticExpressDbRepository<User>(cosmeticExpressDbContext); CosmeticExpressDbRepository<Schedule> scheduleRepository = new CosmeticExpressDbRepository<Schedule>(cosmeticExpressDbContext); CosmeticExpressDbRepository<Office> officeRepository = new CosmeticExpressDbRepository<Office>(cosmeticExpressDbContext); CosmeticExpressDbRepository<VWCompleteSurgery> VWCompleteSurgeryRepository = new CosmeticExpressDbRepository<VWCompleteSurgery>(cosmeticExpressDbContext); CosmeticExpressDbRepository<Entity.CosmeticExpress.Patient> CosmeticExpressPatientRepository = new CosmeticExpressDbRepository<Entity.CosmeticExpress.Patient>(cosmeticExpressDbContext); Manager cosmeticExpressDbManager = new Manager(accesCosmeticExpressDbRepository); UserManager userManager = new UserManager(userRepository, cosmeticExpressDbManager); ScheduleManager scheduleManager = new ScheduleManager(scheduleRepository, cosmeticExpressDbManager); OfficeManager officeManager = new OfficeManager(officeRepository, cosmeticExpressDbManager); VWCompleteSurgeryManager vwCompleteSurgeryManager = new VWCompleteSurgeryManager(VWCompleteSurgeryRepository, cosmeticExpressDbManager); CosmeticExpressPatientManager CosmeticExpressPatientManager = new CosmeticExpressPatientManager(CosmeticExpressPatientRepository, cosmeticExpressDbManager); ////////////////////////////////////////////////// ApplicationDbContext applicationDbContext = new ApplicationDbContext(); ApplicationDbRepository<Access> accesApplicationDbRepository = new ApplicationDbRepository<Access>(applicationDbContext); ApplicationDbRepository<Review> reviewRepository = new ApplicationDbRepository<Review>(applicationDbContext); ApplicationDbRepository<Doctor> doctorRepository = new ApplicationDbRepository<Doctor>(applicationDbContext); ApplicationDbRepository<Lead> leadRepository = new ApplicationDbRepository<Lead>(applicationDbContext); ApplicationDbRepository<Expert> expertRepository = new ApplicationDbRepository<Expert>(applicationDbContext); ApplicationDbRepository<Center> centerRepository = new ApplicationDbRepository<Center>(applicationDbContext); ApplicationDbRepository<Entity.ReviewManagerEntities.Patient> ApplicationPatientRepository = new ApplicationDbRepository<Entity.ReviewManagerEntities.Patient>(applicationDbContext); Manager applicationDbManager = new Manager(accesApplicationDbRepository); ReviewManager reviewManager = new ReviewManager(reviewRepository, applicationDbManager); ///////////////////=============================>>>>>>>>>>>>>>> DoctorManager doctorManager = new DoctorManager(doctorRepository, applicationDbManager); LeadManager leadManager = new LeadManager(leadRepository, applicationDbManager); ExpertManager expertManager = new ExpertManager(expertRepository, applicationDbManager); CenterManager centerManager = new CenterManager(centerRepository, applicationDbManager); ApplicationPatientManager ApplicationPatientManager = new ApplicationPatientManager(ApplicationPatientRepository, cosmeticExpressDbManager); var SurveyQuestionCollection = SurveyQuestionManager.Get().ToArray(); var SurveyCustomerCollection = SurveyCustomerDbManager.Get().ToArray(); var SurveyPossibleAnswerCollection = SurveyPossibleAnswerManager.Get().ToArray(); var SurveyGeneralAnswerCollection = SurveyGeneralAnswerManager.Get().ToArray(); ICollection<VWCompleteSurgery> vwCompleteSurgeriesCollection = vwCompleteSurgeryManager.Get().ToArray(); var doctors = doctorManager.Get().Select(d => new{ d.Id, d.FullName, d.Reviews.Count }).ToArray(); var sources = reviewManager.Get().GroupBy(r => r.Source).ToArray().Select(group => new {Source = group.Key, Count = group.Count()}); ICollection<Review> ReviewCollection = new List<Review>(); foreach (var sgAnswer in SurveyGeneralAnswerCollection) { if (!reviewManager.Get().Any(review => review.ExternalId == sgAnswer.Id && review.Source == "Portal") && sgAnswer.SurveyTemplateId == 2) { //Schedule Schedule = scheduleManager.Get(sched => //sched.PatientID == sgAnswer.SurveyCustomer.ExternalId //&& sched.ServiceID == 5 //&& sched.dtStart.AddMonths(3) >= sgAnswer.SurveyDate).FirstOrDefault(); VWCompleteSurgery surgery = vwCompleteSurgeriesCollection.Where(surg => surg.PatientID == sgAnswer.SurveyCustomer.ExternalId && surg.dtStart.AddMonths(3) >= sgAnswer.SurveyDate).FirstOrDefault(); if (surgery != null) { Review review = new Review(); review.Source = "Portal"; review.ExternalId = sgAnswer.Id; review.Rating = 0; review.CreatedOn = surgery.dtStart; //FROM CEXPRESS/Patient/Patient Entity.CosmeticExpress.Patient CosmeticExpressPatient = CosmeticExpressPatientManager.Get(patient => patient.PatientID == surgery.PatientID).FirstOrDefault(); var existingApplicationPatient = ApplicationPatientManager.Get(patient => patient.ExternalId == CosmeticExpressPatient.PatientID && patient.Source == "CosmeticExpress").FirstOrDefault(); if (existingApplicationPatient != null) { review.PatientId = existingApplicationPatient.Id; } else { Entity.ReviewManagerEntities.Patient Patient = new Entity.ReviewManagerEntities.Patient() { ExternalId = CosmeticExpressPatient.PatientID, FirstName = CosmeticExpressPatient.FirstName, LastName = CosmeticExpressPatient.LastName, MiddleName = CosmeticExpressPatient.MiddleName, DOB = CosmeticExpressPatient.DOB, Email = CosmeticExpressPatient.Email, Source = "CosmeticExpress" }; review.Patient = Patient; } //FROM CEXPRESS/USER TO APP/DOCTOR User User = userManager.Get(user => user.UserID == surgery.ProviderUserID).FirstOrDefault(); var existingDoctorinDb = doctorManager.Get(doc => doc.ExternalId == User.UserID && doc.Source == "CosmeticExpress").FirstOrDefault(); var reviewInCollectionWithSameDoctor = ReviewCollection.FirstOrDefault(rev => rev.Doctor != null && rev.Doctor.ExternalId == User.UserID && rev.Doctor.Source == "CosmeticExpress"); if (existingDoctorinDb != null) { review.DoctorId = existingDoctorinDb.Id; } else { if (reviewInCollectionWithSameDoctor != null) { review.Doctor = reviewInCollectionWithSameDoctor.Doctor; } } if (review.Doctor == null && review.DoctorId == null) { { Doctor Doctor = new Doctor() { FullName = User.FullName, Source = "CosmeticExpress", ExternalId = User.UserID }; review.Doctor = Doctor; } } //FROM CEXPRESS/OFFICE TO APP/CENTER Office Office = officeManager.Get(office => office.OfficeId == surgery.OfficeID).FirstOrDefault(); var existingCenterinDb = centerManager.Get(center => center.ExternalId == surgery.OfficeID).FirstOrDefault(); var centerInCollectionWithSameDoctor = ReviewCollection.FirstOrDefault(rev => rev.Center != null && rev.Center.ExternalId == Office.OfficeId && rev.Center.Source == "CosmeticExpress"); if (existingCenterinDb != null) { review.CenterId = existingCenterinDb.Id; } else { if (centerInCollectionWithSameDoctor != null) { review.Center = centerInCollectionWithSameDoctor.Center; } } if (review.Center == null && review.CenterId == null) { Center Center = new Center() { Name = Office.OfficeName, Source = "CosmeticExpress", ExternalId = Office.OfficeId }; review.Center = Center; } //Recorriendo cada pregunta dentro del survey para calcular el rating foreach (var answer in sgAnswer.SurveysAnswers) { if (SurveyQuestionCollection.FirstOrDefault(q => q.Id == answer.SurveyQuestionId).QuestionType == "edit") { review.Text = answer.Answer != null ? answer.Answer.ToString() : "Empty"; } else { var anwersItem = SurveyPossibleAnswerCollection.FirstOrDefault(spa => spa.Id == answer.SurveysPossibleAnswerId); review.Rating += anwersItem != null ? anwersItem.Weight : 0; } } //anadiento el review a la coleccion ReviewCollection.Add(review); } } } //from ReviewCollection to reviewManager foreach (var review in ReviewCollection) { reviewManager.Add(review); } reviewManager.SaveChanges(); }
/// <summary> /// Initializes schedule manager. /// </summary> private void _InitializeScheduleManager() { if (App.Current.Project != null) { _currentScheduleManager = App.Current.Project.Schedules; _SubscribeToActiveSchedulePropertyChanged(); } }