/// <summary> /// SolveRequest is sent by Computational Client /// </summary> /// <param name="messagePackage"></param> private void handleSolveRequestMessage(MessagePackage messagePackage) { SolveRequestMessage message = (SolveRequestMessage)messagePackage.Message; InformBackup(message); // if the cluster can solve this problem if (clientTracker.CanSolveProblem(message.ProblemType)) { Task task = new Task((int)systemTracker.GetNextTaskID(), message.ProblemType, message.Data); taskTracker.AddTask(task); if (Server.primaryMode) { NoOperationMessage responseNoOp = new NoOperationMessage(clientTracker.BackupServers); SolveRequestResponseMessage response = new SolveRequestResponseMessage((ulong)task.ID); List <Message> messages = new List <Message>(); messages.Add(responseNoOp); messages.Add(response); server.Send(messagePackage.Socket, messages); SmartConsole.PrintLine("Sent a SolveRequestResponse Message", SmartConsole.DebugLevel.Basic); } } else { //TODO RESPONSE MESSAGE Console.Write(" >> TM ERROR\n"); } }
private void Save() { Task task = new Task() { APS = APSHours.Checked, Date = Date.Value.ToLongDateString(), ElapsedTime = ElapsedTime.Value.ToString("HH:mm:ss") + ".00", StartTime = StartTime.Value.ToLongTimeString(), EndTime = EndTime.Value.ToLongTimeString(), IssueNumber = IssueNumber.Text, TimeUsed = TimeUsed.Value.ToString(), TaskID = Setting.Value.Log_CurrentTaskID++ }; Setting.Save(); bool isToday = false; if (task.Date == DateTime.Today.ToShortDateString()) { isToday = true; } if (isToday) { TaskTracker.AddTask(task); } else { var path = Program.DataPath + "\\TaskData\\" + task.Date.Replace('/', '-') + ".json"; Day day; if (!File.Exists(path)) { day = new Day() { Date = task.Date, DayID = Setting.Value.Log_CurrentDayID++, EndTime = task.EndTime, LongDate = DateTime.Parse(task.Date).ToLongDateString(), StartTime = task.StartTime, Tasks = new List <Task>(), TotalTime = task.ElapsedTime, TotalTimeOnTasks = task.ElapsedTime, TotalUsedTime = task.TimeUsed }; day.Tasks.Add(task); } else { day = Serializer <Day> .LoadFromJSONFile(path); day.Tasks.Add(task); day.TotalTimeOnTasks = TaskTracker.RecursionElapsedTime(day, 0); day.TotalUsedTime = TaskTracker.GetTotalTimeUsed(day); } TaskTracker.ExportDay(day); } }
public void OptionPageActivity() { var tt = new TaskTracker(); var urlField = _activity.FindViewById <EditText>(Resource.Id.ApiUnr); var vibraSwitch = _activity.FindViewById <Switch>(Resource.Id.VibraSwitch); var saveOptions = _activity.FindViewById <Button>(Resource.Id.SaveOptions); UpdateDisplay(urlField, vibraSwitch); saveOptions.Click += (sender, e) => { tt.AddTask(() => { Settings.UrlAdress = urlField.Text; Settings.VibrationState = vibraSwitch.Checked; _data.SavePreferences(); }); _activity.OnBackPressed(); }; }
public void MainViewActivity() { string toolBarLabel = $"\t \t \t \t \t \t Welcome {_params.AppName} v {_params.AppVersion}"; var img = _activity.GetDrawable(Resource.Drawable.mute_off); var toolBarPrewView = BitmapFactory.DecodeResource(_activity.Resources, Resource.Drawable.blank_title); #region Get the UI controls from the loaded layout: var powerButton = _activity.FindViewById <Button>(Resource.Id.PowerButton); var homeButton = _activity.FindViewById <Button>(Resource.Id.HomeButton); var backButton = _activity.FindViewById <Button>(Resource.Id.BackButton); var previousButton = _activity.FindViewById <Button>(Resource.Id.previousButton); var rewindButton = _activity.FindViewById <Button>(Resource.Id.rewindButton); var playpauseButton = _activity.FindViewById <Button>(Resource.Id.playpauseButton); var forwardButton = _activity.FindViewById <Button>(Resource.Id.forwardButton); var nextButton = _activity.FindViewById <Button>(Resource.Id.nextButton); var upButton = _activity.FindViewById <Button>(Resource.Id.upButton); var leftButton = _activity.FindViewById <Button>(Resource.Id.leftButton); var okButton = _activity.FindViewById <Button>(Resource.Id.okButton); var rightButton = _activity.FindViewById <Button>(Resource.Id.rightButton); var downButton = _activity.FindViewById <Button>(Resource.Id.downButton); var volumUpButton = _activity.FindViewById <Button>(Resource.Id.VolumUpButton); var volumDownButton = _activity.FindViewById <Button>(Resource.Id.VolumDownButton); var muteButton = _activity.FindViewById <ImageButton>(Resource.Id.muteButton); muteButton.SetImageDrawable(img); // Replace ToolBar var toolbar = _activity.FindViewById <Toolbar>(Resource.Id.toolbar); var tolbarImg = _activity.FindViewById <ImageView>(Resource.Id.toolbarImg); var tolbarTxt = _activity.FindViewById <TextView>(Resource.Id.toolbarText); #endregion _activity.SetActionBar(toolbar); _activity.ActionBar.Title = String.Empty; tolbarImg.SetImageBitmap(toolBarPrewView); tolbarTxt.Text = toolBarLabel; tolbarTxt.Selected = true; var tt = new TaskTracker(); tt.TaskCompleted += async(sender, e) => { await UpdateTitle(tolbarImg, toolBarLabel, toolBarPrewView, tolbarTxt); }; #region Buttons command muteButton.Click += (sender, e) => tt.AddTask(() => Action(new VolumMute(_jsonService))); previousButton.Click += (sender, e) => tt.AddTask(() => Action(new GoToPrevious(_jsonService))); rewindButton.Click += (sender, e) => tt.AddTask(() => Action(new SetSpeedDecrement(_jsonService))); playpauseButton.Click += (sender, e) => tt.AddTask(() => { Action(new PlayPause(_jsonService)); }); forwardButton.Click += (sender, e) => tt.AddTask(() => { Action(new SetSpeedIncrement(_jsonService)); }); nextButton.Click += (sender, e) => tt.AddTask(() => { Action(new GoToNext(_jsonService)); }); powerButton.Click += (sender, e) => tt.AddTask(() => { Action(new Power(_jsonService)); }); upButton.Click += (sender, e) => tt.AddTask(() => { Action(new Up(_jsonService)); }); leftButton.Click += (sender, e) => tt.AddTask(() => { Action(new Left(_jsonService)); }); okButton.Click += (sender, e) => tt.AddTask(() => { Action(new Select(_jsonService)); }); rightButton.Click += (sender, e) => tt.AddTask(() => { Action(new Right(_jsonService)); }); downButton.Click += (sender, e) => tt.AddTask(() => { Action(new Down(_jsonService)); }); homeButton.Click += (sender, e) => tt.AddTask(() => { Action(new Home(_jsonService)); }); backButton.Click += (sender, e) => tt.AddTask(() => { Action(new Back(_jsonService)); }); volumUpButton.Click += (sender, e) => tt.AddTask(() => { Action(new VolumUp(_jsonService)); }); volumDownButton.Click += (sender, e) => tt.AddTask(() => { Action(new VolumDown(_jsonService)); }); #endregion }