public ActionResult DisplayReport(SendReport model) { // вытащили отчет var jxml = DB.reportxml.Where(x => x.JobName == model.jobName).Select(x => x.JobName).SingleOrDefault(); if (jxml == null) { logger.Error($"XML отчета {model.jobName} не найден"); ErrorMessage("Отчет не найден"); return(RedirectToAction("Index", "Report")); } var jext = GetJobExtend(model.jobName); if (jext == null) { logger.Error($"Дополнительные параметры отчета {model.jobName} не найдены"); ErrorMessage("Отчет не найден"); return(RedirectToAction("Index", "Report")); } // вытащили заголовок отчета ViewBag.Title = jext.CustomName; // добавили список адресов для выбора ViewData["MailToList"] = h.GetMailList(); foreach (var error in model.Validate()) { ModelState.AddModelError(error.PropertyName, error.Message); } // если модель невалидна - возвращаем пользователю if (!ModelState.IsValid) { return(View(model)); } var file = helper.GetExcel(jext); Mails.ManualPostReportMessage(jext, file.FullName, model.MailTo); SuccessMessage("Отчет отправлен на указанные email"); return(View(model)); }
public ActionResult DisplayReport(string jobName) { // вытащили отчет var jxml = DB.reportxml.Where(x => x.JobName == jobName).Select(x => x.JobName).SingleOrDefault(); if (jxml == null) { logger.Error($"Отчет {jobName} не найден"); ErrorMessage("Отчет не найден"); return(RedirectToAction("Index", "Report")); } var jext = GetJobExtend(jobName); if (jext == null) { logger.Error($"Дополнительные параметры отчета {jobName} не найдены"); ErrorMessage("Отчет не найден"); return(RedirectToAction("Index", "Report")); } ViewBag.Title = jext.CustomName; // добавили список адресов для выбора ViewData["MailToList"] = h.GetMailList(); // по умолчанию выделен email пользователя var model = new SendReport(); model.MailTo = new List <string>() { CurrentUser.Login }; model.jobName = jobName; return(View(model)); }
public UIDialogResult(ExecutionFlow execution, SendReport report) { this.Execution = execution; this.Report = report; }
internal UIDialogResult(ExecutionFlow execution, SendReport report) { this.Execution = execution; this.Report = report; }
public MainPageViewModel() { this.SelectedProviderChanged = new Command((nothing) => { if (PLEASEWORK == "Create New Task") { Visibility = true; } else { Visibility = false; EntryContent = ""; } }); //INSIDE THIS FUNCTION BELOW YOU NEED TO GIVE ME THE LIST OF TASK NAMES FOR THIS SPECIFIC TEAM //FROM THE DATABASE. YOU NEED TO REPLACE THE : new ObservableCollection<string>. GetTaskNamesFromDB(); Visibility = false; //END OF SHIT SHOW this.CurrentYearText = Convert.ToString(DateTime.Today.Year); this.CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(DateTime.Today.Month); CalendarDays = new List <Day>(); SavedReports = new List <Day>(); // create 42 objects for the CalendarDays collection for (int i = 0; i < 42; i++) { CalendarDays.Add(new Day()); //var Cell = new Day(); } CalendarFunc(); this.RightArrowClick = new Command((nothing) => { BeforeSwitchingMonth(); SelectedDate = SelectedDate.AddMonths(1); CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(SelectedDate.Month); CalendarFunc(); if (SelectedDate.Month == 1) { CurrentYearText = Convert.ToString(Convert.ToInt32(SelectedDate.Year)); } AfterSwitchingMonth(); }); this.LeftArrowClick = new Command((nothing) => { BeforeSwitchingMonth(); SelectedDate = SelectedDate.AddMonths(-1); CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(SelectedDate.Month); CalendarFunc(); if (SelectedDate.Month == 12) { CurrentYearText = Convert.ToString(Convert.ToInt32(SelectedDate.Year)); } AfterSwitchingMonth(); }); this.SendReportButton = new Command(async(nothing) => { if ((string.IsNullOrWhiteSpace(PLEASEWORK) && Visibility == false) || (string.IsNullOrWhiteSpace(EntryContent) && Visibility == true)) { await App.Current.MainPage.DisplayAlert("Attention!", "Please enter a task name or select a task from the ones provided", "Ok"); return; } if (string.IsNullOrWhiteSpace(Description)) { bool answer = await App.Current.MainPage.DisplayAlert("Attention!", "Task Description field is empty, submit the report anyway?", "Yes", "No"); if (answer == false) { return; } Description = "No Description provided by the user"; } //Load = true; //foreach (var calendarDay in CalendarDays.Where(c => !string.IsNullOrEmpty(c.Entry))) //{ // var resultstest = SavedReports.Where(d => d.Date == calendarDay.Date).ToList(); // if(resultstest.Count>0) // { // resultstest.First().Entry = calendarDay.Entry; // } // else // { // NewObject = new Day(); // NewObject.Date = calendarDay.Date; // NewObject.Entry = calendarDay.Entry; // SavedReports.Add(NewObject); // } // calendarDay.Entry = null; //} equivalent to the below first linq query bool valuechanged = false; //used for the problem if (SavedReports.Count == 0) //used for the problem { NewObject = new Day(); SavedReports.Add(NewObject); valuechanged = true; } var results = from a in CalendarDays //pre-save step from b in SavedReports where !string.IsNullOrEmpty(a.Entry) select new { itemA = a, itemB = b }; foreach (var result in results.ToList()) { if (result.itemB.Date == result.itemA.Date) //check if saved reports has a record of this cell { result.itemB.Entry = result.itemA.Entry; result.itemA.Entry = null; result.itemB.Exist = true; } } foreach (var result in results.ToList()) { if (result.itemA.Entry != null) //if no pre-existing object of this cell exists, create one { NewObject = new Day { Date = result.itemA.Date, Entry = result.itemA.Entry, Exist = true }; result.itemA.Entry = null; SavedReports.Add(NewObject); } } if (valuechanged == true) { SavedReports.RemoveAt(0); } // UNTIL HERE foreach (Day item in SavedReports.ToList()) { if (string.IsNullOrEmpty(item.Entry) && !item.Exist) //check if there is an unnecesary saved report to remove { SavedReports.Remove(item); } else if (!string.IsNullOrEmpty(item.Entry)) //save/make official entries from current and other pages already saved in //savedreports that are currently not official yet { item.Hours += double.Parse(item.Entry, CultureInfo.CurrentCulture); item.Entry = null; } } List <Day_For_Sending> temp = new List <Day_For_Sending>(); foreach (Day item in SavedReports.ToList()) { temp.Add(new Day_For_Sending(item.Date, (int)item.Hours)); } json = JsonConvert.SerializeObject(temp); //Saving by serizalizing first //DONT NEED THIS ANYMORE...OLD CODE FOR SAVING //if (Device.RuntimePlatform == Device.Windows) //checking what device is in use to use appropriate method // await SavefileWin(json); //else // DependencyService.Get<ISaveAndLoad>().SaveText("CalendarFile.txt", json); //************************** HERE ****************************** // the object FullReport below contains all the necessary, connect your thingy string TaskName = Visibility == true ? EntryContent : PLEASEWORK; var FullReport = new SendReport(TeamInterfacePageUser8.Team_Id, TaskName, Description, json); string r = await Api_Connector.Connect(String.Format(URL, TeamInterfacePageUser8.Team_Id, TaskName, Description, DateTime.Now.ToString(), json)); if (r.Equals("1")) { await App.Current.MainPage.DisplayAlert("Notification!", "Report Sent Sucessfully!", "Continue"); await App.Current.MainPage.Navigation.PopAsync(); } else { await App.Current.MainPage.DisplayAlert("Error!", r + "!!!", "OK"); } // CalendarFunc(); we dont need this anymore i think }); this.ResetButton = new Command((nothing) => { //for (int i = SavedReports.Count - 1; i >= 0; i--) //remove saved reports // SavedReports.RemoveAt(i); //THIS IS EQUIVALENT TO THE LINE CLEAR BELOW // SavedReports.Clear(); for (int i = 0; i < 42; i++) //reset calendar page { CalendarDays[i].Entry = null; } //try //THIS DELETES THE FILE AND FOLDER //{ // if (Device.RuntimePlatform == Device.Windows) // await DeleteFileWin(); // else // DependencyService.Get<ISaveAndLoad>().DeleteFile("CalendarFile.txt"); //} //catch { } //saving automatically after reseting the data in the app //json = JsonConvert.SerializeObject(SavedReports); //if (Device.RuntimePlatform == Device.Windows) // await SavefileWin(json); //else // DependencyService.Get<ISaveAndLoad>().SaveText("CalendarFile.txt", json); CalendarFunc(); }); }