/// <summary> /// Saves the answer. /// </summary> private async void SaveAnswer() { var date = DateTime.Now; var response = new CheckListResponse { CategoryId = RecordResponse.CategoryId, Question = RecordResponse.QuestionName, Answer = Answer, CorrAction = SelectedCorrectiveAction != string.Empty ? SelectedCorrectiveAction : HACCPUtil.GetResourceString("None"), QuestionType = RecordResponse.QuestionType.ToString(), UserName = HaccpAppSettings.SharedInstance.UserName, DeviceId = HaccpAppSettings.SharedInstance.DeviceId, SiteId = HaccpAppSettings.SharedInstance.SiteSettings.SiteId, IsNa = 0, Hour = date.Hour.ToString(), Day = date.Day.ToString(), Minute = date.Minute.ToString(), Month = date.Month.ToString(), Sec = date.Second.ToString(), Year = date.Year.ToString(), Tzid = HaccpAppSettings.SharedInstance.SiteSettings.TimeZoneId, Min = RecordResponse.Min, Max = RecordResponse.Max, QuestionId = RecordResponse.QuestionId, Catname = RecordResponse.CategoryName, ChecklistId = HaccpAppSettings.SharedInstance.SiteSettings.CheckListId }; Debug.WriteLine("++++++++++++++++++++++++++++++"); Debug.WriteLine("***Category Name= {0}***", response.Catname); Debug.WriteLine("++++++++++++++++++++++++++++++"); dataStore.SaveCheckListResponse(response); RecordResponse.RecordStatus = 1; dataStore.UpdateQuestionRecordStatus(RecordResponse); MessagingCenter.Send(RecordResponse, HaccpConstant.QuestionMessage); dataStore.UpdateCategoryRecordStatus(RecordResponse.CategoryId); MessagingCenter.Send(new CategoryStatus { CategoryId = RecordResponse.CategoryId }, HaccpConstant.CategoryMessage); IsBusy = false; SaveCommand.ChangeCanExecute(); await Page.PopPage(); if (HaccpAppSettings.SharedInstance.DeviceSettings.AutoAdvance) { MessagingCenter.Send(new AutoAdvanceCheckListMessage { CurrentId = RecordResponse.QuestionId }, HaccpConstant.AutoadvancechecklistMessage); } }
/// <summary> /// Saves the check list response. /// </summary> public void SaveCheckListResponse(CheckListResponse checklistResponse) { lock (Locker) { // var response = database.Table<CheckListResponse> ().FirstOrDefault (x => x.QuestionID == checklistResponse.QuestionID); // if (response != null) { // checklistResponse.RecordNo = response.RecordNo; // database.Update (checklistResponse); // } else Database.Insert(checklistResponse); } }
/// <summary> /// Builds the upload check list record service method URL. /// </summary> /// <returns>The upload check list record service method URL.</returns> /// <param name="checklistResponse">Checklist response.</param> /// <param name="batchId"></param> private static StringBuilder BuildUploadCheckListRecordServiceMethodUrl(CheckListResponse checklistResponse, string batchId) { var checkListUploadUrl = new StringBuilder(); var questionType = GetString(checklistResponse.QuestionType) == ((short)QuestionType.YesOrNo).ToString() ? "y" : "n"; var answer = checklistResponse.Answer; if (checklistResponse.QuestionType == ((short)QuestionType.NumericAnswer).ToString()) { answer = ((string.IsNullOrEmpty(checklistResponse.Answer) ? 0 : ConvertToDouble(checklistResponse.Answer)) * 10) .ToString(); } checkListUploadUrl.AppendFormat( /*"{record:\"{0}\", catname:\"{1}\", question:\"{2}\", month:\"{3}\", day:\"{4}\", year:\"{5}\", hour:\"{6}\", minute:\"{7}\", " + * "sec:\"{8}\", username:\"{9}\", questionType:\"{10}\", min:\"{11}\", max:\"{12}\", corraction:\"{13}\", answer:\"{14}\", " + * "device:\"{15}\", batch:\"{16}\", siteId:\"{17}\", checklistid:\"{18}\", isna:\"{19}\", tzID:\"{20}\"}",*/ "/HACCPManagerService/UploadChecklists?record={0}&catname={1}&question={2}&month={3}&day={4}&year={5}&hour={6}&minute={7}&" + "sec={8}&username={9}&questionType={10}&min={11}&max={12}&corraction={13}&answer={14}&" + "device={15}&batch={16}&siteId={17}&checklistid={18}&isna={19}&tzID={20}", GetString(checklistResponse.RecordNo), GetString(checklistResponse.Catname), GetString(checklistResponse.Question), GetString(checklistResponse.Month), GetString(checklistResponse.Day), GetString(checklistResponse.Year), GetString(checklistResponse.Hour), GetString(checklistResponse.Minute), GetString(checklistResponse.Sec), GetString(checklistResponse.UserName), questionType, questionType == "y" ? "" : GetString(checklistResponse.Min), questionType == "y" ? "" : GetString(checklistResponse.Max), GetString(checklistResponse.CorrAction), GetString(answer), GetString(checklistResponse.DeviceId), batchId, GetString(checklistResponse.SiteId), GetString(checklistResponse.ChecklistId), GetString(checklistResponse.IsNa), GetString(checklistResponse.Tzid)); return(checkListUploadUrl); }
/// <summary> /// Executes the NA command. /// </summary> /// <returns>The NA command.</returns> protected override async Task ExecuteNACommand() { if (IsBusy) { return; } var result = await Page.ShowConfirmAlert(string.Empty, HACCPUtil.GetResourceString("SavedNAastheAnswerfortheQuestion")); if (result) { try { IsBusy = true; NACommand.ChangeCanExecute(); var response = new CheckListResponse(); var date = DateTime.Now; response.CategoryId = RecordResponse.CategoryId; response.Question = RecordResponse.QuestionName; response.QuestionType = RecordResponse.QuestionType.ToString(); response.UserName = HaccpAppSettings.SharedInstance.UserName; response.DeviceId = HaccpAppSettings.SharedInstance.DeviceId; response.SiteId = HaccpAppSettings.SharedInstance.SiteSettings.SiteId; response.IsNa = 1; response.Hour = date.Hour.ToString(); response.Day = date.Day.ToString(); response.Minute = date.Minute.ToString(); response.Month = date.Month.ToString(); response.Sec = date.Second.ToString(); response.Year = date.Year.ToString(); response.Tzid = HaccpAppSettings.SharedInstance.SiteSettings.TimeZoneId; response.Answer = "0"; response.Min = RecordResponse.Min; response.Max = RecordResponse.Max; response.QuestionId = RecordResponse.QuestionId; response.Catname = RecordResponse.CategoryName; response.ChecklistId = HaccpAppSettings.SharedInstance.SiteSettings.CheckListId; response.CorrAction = string.Empty; dataStore.SaveCheckListResponse(response); RecordResponse.RecordStatus = 1; dataStore.UpdateQuestionRecordStatus(RecordResponse); MessagingCenter.Send(RecordResponse, HaccpConstant.QuestionMessage); dataStore.UpdateCategoryRecordStatus(RecordResponse.CategoryId); MessagingCenter.Send(new CategoryStatus { CategoryId = RecordResponse.CategoryId }, HaccpConstant.CategoryMessage); IsBusy = false; NACommand.ChangeCanExecute(); } catch (Exception ex) { Debug.WriteLine("Ooops! Something went wrong. Exception: {0}", ex); } finally { IsBusy = false; NACommand.ChangeCanExecute(); Page.PopPage(); if (HaccpAppSettings.SharedInstance.DeviceSettings.AutoAdvance) { MessagingCenter.Send(new AutoAdvanceCheckListMessage { CurrentId = RecordResponse.QuestionId }, HaccpConstant.AutoadvancechecklistMessage); } } } }