public ProgressVM GetMacros(DateTime date, int userId) { ProgressVM vm = new ProgressVM(); try { using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); string sql = "SELECT SUM(carbs) as TotalCarbs, SUM(Proteins) as TotalProteins, SUM(Fats) as TotalFats, SUM(KCal) as TotalCalories from Food join Nutrition_Log as NL on NL.food_id = Food.ID where NL.user_id= @userId and Cast(NL.meal_date as date)= @date"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@userId", userId); cmd.Parameters.AddWithValue("@date", date); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { vm.Carbs = reader.IsDBNull(reader.GetOrdinal("TotalCarbs")) ? 0 : Convert.ToDouble(reader["TotalCarbs"]); vm.Protein = reader.IsDBNull(reader.GetOrdinal("TotalProteins")) ? 0 : Convert.ToDouble(reader["TotalProteins"]); vm.Fats = reader.IsDBNull(reader.GetOrdinal("TotalFats")) ? 0 : Convert.ToDouble(reader["TotalFats"]); vm.Calories = reader.IsDBNull(reader.GetOrdinal("TotalCalories")) ? 0 : Convert.ToDouble(reader["TotalCalories"]); } } } catch (SqlException) { throw; } return(vm); }
void Save(ModuleVM[] files) { var list = new Tuple <DnModule, string> [files.Length]; if (files.Length == 1) { var vm = files[0]; var filename = new PickSaveFilename().GetFilename(GetModuleFilename(vm.Module), GetDefaultExtension(GetModuleFilename(vm.Module), vm.IsExe, vm.Module.CorModule.IsManifestModule), PickFilenameConstants.DotNetAssemblyOrModuleFilter); if (string.IsNullOrEmpty(filename)) { return; } list[0] = Tuple.Create(vm.Module, filename); } else { var dir = new PickDirectory().GetDirectory(null); if (!Directory.Exists(dir)) { return; } for (int i = 0; i < files.Length; i++) { var file = files[i]; var filename = DebugOutputUtils.GetFilename(file.Module.Name); var lf = filename.ToUpperInvariant(); if (lf.EndsWith(".EXE") || lf.EndsWith(".DLL") || lf.EndsWith(".NETMODULE")) { } else if (file.Module.CorModule.IsManifestModule) { filename += file.IsExe ? ".exe" : ".dll"; } else { filename += ".netmodule"; } list[i] = Tuple.Create(file.Module, Path.Combine(dir, filename)); } } var data = new ProgressVM(Dispatcher.CurrentDispatcher, new PEFilesSaver(list)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = appWindow.MainWindow; win.Title = list.Length == 1 ? dnSpy_Debugger_Resources.ModuleSaveModuleTitle : dnSpy_Debugger_Resources.ModuleSaveModulesTitle; var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } messageBoxManager.Show(string.Format(dnSpy_Debugger_Resources.ErrorOccurredX, data.ErrorMessage)); }
public static void Save(IResourceNode[] nodes, bool useSubDirs, ResourceDataType resourceDataType) { if (nodes == null) { return; } var files = GetFiles(GetResourceData(nodes, resourceDataType), useSubDirs).ToArray(); if (files.Length == 0) { return; } var data = new ProgressVM(MainWindow.Instance.Dispatcher, new ResourceSaver(files)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = MainWindow.Instance; win.Title = files.Length == 1 ? "Save Resource" : "Save Resources"; var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } MainWindow.Instance.ShowMessageBox(string.Format("An error occurred:\n\n{0}", data.ErrorMessage)); }
public IActionResult MacroBreakdown() { User user = authProvider.GetCurrentUser(); ProgressVM vm = progressDAL.GetMacros(DateTime.Today.Date, user.Id); return(View(vm)); }
/// <summary> /// Sends current userId to other pages - profile info, progress and charts /// </summary> /// <param name="val"></param> public void SendUserId(int userId) { //user id to profile info ProfileInfoVM.SetUserValues(userId); //user id to progress page ProgressVM.SetUserValues(userId); //user id to charts page ChartsVM.SetUserValues(userId); }
public ProgressVM GetProgressVM(string memberId) { ProgressVM model = new ProgressVM { DoneQuestions = Progress .Where(p => p.MemberId == memberId) .Count(), TotalAmountOfQuestion = Question.Count(), }; return(model); }
private async void UploadData(object obj) { ProgressVM.ShowLoading(); ProgressVM.ReportProgress(new ProgressState { ProgressTasksDone = 0, ProgressDescriptionText = Resources.PeopleUploadValidateDomainMessage }); await ValidateDomainsAsync(InputRows); if (ProgressVM.IsProgressCancelled) { return; } var inputRowsGroupedByContracts = InputRows.GroupBy(_ => new { _.IdentityNumber, _.ManagerId }, v => v); ProgressVM.ReportProgress(new ProgressState { ProgressTasksDone = 0, ProgressDescriptionText = Resources.PeopleUploadGenerateStructureTreeMessage }); var tree = inputRowsGroupedByContracts.GenerateTree(c => c.Key.IdentityNumber, c => c.Key.ManagerId ?? string.Empty, string.Empty); await RequestDefaultPassword(InputRows); if (ProgressVM.IsProgressCancelled) { return; } var descendantList = tree.Descendants(_ => _.Children).ToList(); var contactsCount = descendantList.SelectMany(_ => _.Item).Count(); var uploadedContracts = 0; foreach (var account in descendantList) { if (ProgressVM.IsProgressCancelled) { break; } foreach (var contract in account.Item) { var externalAccount = await FillAccount(contract); var accountResult = await UploadAccount(externalAccount); ProgressVM.ReportProgress(new ProgressState { ProgressTasksDone = ++uploadedContracts, ProgressTasksTotal = contactsCount, ProgressDescriptionText = string.Format(Resources.PeopleUploadReportUploadStatusMessage, contract.Name, contract.Surname, contract.IdentityNumber) }); } } ProgressVM.ReportProgress(new ProgressState { ProgressTasksDone = uploadedContracts, ProgressTasksTotal = contactsCount, ProgressDescriptionText = string.Format(Resources.PeopleUploadFinishUploadMessage, Environment.NewLine, uploadedContracts) }); }
async public Task ExecuteFuncAsyncWithProgress() { var localProgress = new ProgressVM(); int i = 0; await vCommandAsync.ExecuteActionAsync(localProgress, (progress, onprogress) => { for (; i < 10; i++) { progress.Progress = i; onprogress(); } }); Assert.AreEqual(10, i); Assert.AreEqual(9, localProgress.Progress); }
async public Task ExecuteFuncAsyncWithProgressInt() { var localProgress = new ProgressVM(); int i = 0; var res = await vCommandAsync <int> .ExecuteFuncAsync(localProgress, (progress, onprogress) => { for (; i < 10; i++) { progress.Progress = i; onprogress(); } return(i); }); Assert.AreEqual(10, i); Assert.AreEqual(9, localProgress.Progress); }
internal static void Execute2(DnHexBox dnHexBox, Window ownerWindow) { Debug.Assert(ownerWindow != null); var doc = dnHexBox.Document; if (doc == null) { return; } var sel = dnHexBox.Selection; if (sel == null) { return; } var dialog = new WF.SaveFileDialog() { Filter = PickFilenameConstants.AnyFilenameFilter, RestoreDirectory = true, ValidateNames = true, }; if (dialog.ShowDialog() != WF.DialogResult.OK) { return; } var data = new ProgressVM(Dispatcher.CurrentDispatcher, new HexDocumentDataSaver(doc, sel.Value.StartOffset, sel.Value.EndOffset, dialog.FileName)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; win.Title = string.Format(dnSpy_Shared_Resources.HexEditorSaveSelection_Title, sel.Value.StartOffset, sel.Value.EndOffset); var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } App.MsgBox.Instance.Show(string.Format(dnSpy_Shared_Resources.AnErrorOccurred, data.ErrorMessage)); }
internal static void Execute2(DnHexBox dnHexBox) { var doc = dnHexBox.Document; if (doc == null) { return; } var sel = dnHexBox.Selection; if (sel == null) { return; } var dialog = new WF.SaveFileDialog() { Filter = PickFilenameConstants.AnyFilenameFilter, RestoreDirectory = true, ValidateNames = true, }; if (dialog.ShowDialog() != WF.DialogResult.OK) { return; } var data = new ProgressVM(MainWindow.Instance.Dispatcher, new HexDocumentDataSaver(doc, sel.Value.StartOffset, sel.Value.EndOffset, dialog.FileName)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = MainWindow.Instance; win.Title = string.Format("Save Selection 0x{0:X}-0x{1:X}", sel.Value.StartOffset, sel.Value.EndOffset); var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } MainWindow.Instance.ShowMessageBox(string.Format("An error occurred:\n\n{0}", data.ErrorMessage)); }
async public Task AsyncCommandIntWithProgress() { var localProgress = new ProgressVM(); int i = 0; var command = vCommandAsync <int> .Create(localProgress, (token, progress, onprogress) => { for (; i < 10; i++) { progress.Progress = i; onprogress(); } return(i); }, (o) => { return(true); }); await command.ExecuteAsync(null); Assert.AreEqual(10, i); Assert.AreEqual(9, localProgress.Progress); }
public override void SaveSelection() { if (HexView.Selection.IsEmpty) { return; } var dialog = new WF.SaveFileDialog() { Filter = PickFilenameConstants.AnyFilenameFilter, RestoreDirectory = true, ValidateNames = true, }; if (dialog.ShowDialog() != WF.DialogResult.OK) { return; } var selectionSpan = HexView.Selection.StreamSelectionSpan; var data = new ProgressVM(CurrentDispatcher, new HexBufferDataSaver(HexView.Buffer, selectionSpan, dialog.FileName)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = OwnerWindow; var info = SelectionToUserValue(selectionSpan.Start, selectionSpan.End); win.Title = string.Format(dnSpy_Resources.HexEditorSaveSelection_Title, info.Anchor.ToUInt64(), info.Active.ToUInt64()); var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } messageBoxService.Show(string.Format(dnSpy_Resources.AnErrorOccurred, data.ErrorMessage)); }
/// <summary> /// Saves the nodes /// </summary> /// <param name="nodes">Nodes</param> /// <param name="useSubDirs">true to create sub directories, false to dump everything in the same folder</param> /// <param name="resourceDataType">Type of data to save</param> /// <param name="ownerWindow">Owner window</param> public static void Save(IResourceDataProvider[] nodes, bool useSubDirs, ResourceDataType resourceDataType, Window ownerWindow = null) { if (nodes == null) { return; } Tuple <ResourceData, string>[] files; try { files = GetFiles(GetResourceData(nodes, resourceDataType), useSubDirs).ToArray(); } catch (Exception ex) { MsgBox.Instance.Show(ex); return; } if (files.Length == 0) { return; } var data = new ProgressVM(Dispatcher.CurrentDispatcher, new ResourceSaver(files)); var win = new ProgressDlg(); win.DataContext = data; win.Owner = ownerWindow ?? Application.Current.MainWindow; win.Title = files.Length == 1 ? dnSpy_Contracts_DnSpy_Resources.SaveResource : dnSpy_Contracts_DnSpy_Resources.SaveResources; var res = win.ShowDialog(); if (res != true) { return; } if (!data.WasError) { return; } MsgBox.Instance.Show(string.Format(dnSpy_Contracts_DnSpy_Resources.AnErrorOccurred, data.ErrorMessage)); }
public void AddRecord() { ProgressVM.AddRecord(); UpdateChart(); }
public IActionResult GetProgress() { ProgressVM model = context.GetProgressVM(userManager.GetUserId(User)); return(Json(model)); }
public void EditRecord() { ProgressVM.EditData(); UpdateChart(); }
public void UpdateRecord() { ProgressVM.UpdateRecord(); UpdateDashboard(); UpdateChart(); }
private void OnProgressGeneratorAttaching(ProgressVM context, IBinder <IContextWrapper <ProgressVM> > binder) { binder.AttachChild(context, _progressV); }