public WSProfile[] AddProfiles(WSProfile[] profiles) { WSProfile[] createdProfiles = new WSProfile[profiles.Length]; for (int i = 0; i < profiles.Length; i++) { var wsProfile = profiles[i]; createdProfiles[i] = Client.CreateProfile(wsProfile); } Client.Commit(); return(createdProfiles); }
protected void Page_Load(object sender, EventArgs e) { // Create safe error messages. string generalErrorMsg = "A problem has occurred on this web site. Please try again. " + "If this error continues, please contact support."; string httpErrorMsg = "An HTTP error occurred. Page Not found. Please try again."; string unhandledErrorMsg = "The error was unhandled by application code."; // Display safe error message. FriendlyErrorMsg.Text = generalErrorMsg; // Determine where error was handled. string errorHandler = Request.QueryString["handler"]; if (errorHandler == null) { errorHandler = "Error Page"; } // Get the last error from the server. Exception ex = Server.GetLastError(); // Get the error number passed as a querystring value. string errorMsg = Request.QueryString["msg"]; if (errorMsg == "404") { ex = new HttpException(404, httpErrorMsg, ex); FriendlyErrorMsg.Text = ex.Message; } // If the exception no longer exists, create a generic exception. if (ex == null) { ex = new Exception(unhandledErrorMsg); } // Show error details to only you (developer). LOCAL ACCESS ONLY. if (Request.IsLocal) { // Detailed Error Message. ErrorDetailedMsg.Text = ex.Message; // Show where the error was handled. // ErrorHandler.Text = errorHandler; // Show local access details. DetailedErrorPanel.Visible = true; if (ex.InnerException != null) { InnerMessage.Text = ex.GetType().ToString() + "::" + ex.InnerException.Message; InnerTrace.Text = ex.InnerException.StackTrace; } else { InnerMessage.Text = ex.GetType().ToString(); if (ex.StackTrace != null) { InnerTrace.Text = ex.StackTrace.ToString().TrimStart(); } } } // Log the exception. //ExceptionUtility.LogException(ex, errorHandler); WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], "ErrorPage", ApplicationType.WebApplication); filter.LogError(ex); // Clear the error from the server. Server.ClearError(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { var candId = Session["CandId"].ToString(); var batchId = Session["BatchId"].ToString(); var tenant = SessionHelper.GetTenantID(Session); using (QuizBookDbEntities1 _db = new QuizBookDbEntities1()) { if (string.IsNullOrEmpty(tenant)) { ErecruitHelper.SetErrorData(new NullReferenceException("There must be a valid Organisation"), Session); Response.Redirect("ErrorPage.aspx", false); } else { if (string.IsNullOrEmpty(candId)) { ErecruitHelper.SetErrorData(new NullReferenceException("There must be a valid candidate"), Session); Response.Redirect("ErrorPage.aspx", false); } else { if (string.IsNullOrEmpty(batchId)) { ErecruitHelper.SetErrorData(new NullReferenceException("There must be a valid Batch"), Session); Response.Redirect("ErrorPage.aspx", false); } else { var cid = long.Parse(candId); var bid = long.Parse(batchId); var tid = long.Parse(tenant); var repM = _db.TestResultReports.FirstOrDefault(s => s.candId == cid && s.batchId == bid && s.tenantId == tid); var repSum = _db.TestReportSummaries.FirstOrDefault(x => x.ReportId == repM.Id); var repAns = _db.TestReportAnswers.Where(x => x.ReportId == repM.Id).ToList(); logoCt.Src = GetUrl("book.png"); //var result = _db.IndividualTestResult_sp(bid, cid, tid).ToList(); //var cand = result.FirstOrDefault(); candidateId.Text = repM.candidateId.ToUpper(); candidateName.Text = repM.candidateName.ToUpper(); batchName.Text = repM.batchName.ToUpper(); tenantName.Text = repM.tenantName.ToUpper(); tstDate.Text = repM.tstDate; var forList = repAns.Select(x => new { sn = x.sn, question = x.question, Mark = x.Mark, Score = x.Score, chosenAnswer = x.chosenAnswer, correctAnswer = x.correctAnswer, Status = x.correct == "Correct" ? "<span style='color:#008000;'>Right</span>":x.correct == "Partial"? "<span style='color:#ffb400;'>Partial</span>": " <span style='color:#f00;'>Wrong</span>", }).ToList(); //var forList = result.Select((s, i) => new //{ // sn = (i + 1).ToString(), // Question = s.QuestionDetails, // Answer = string.IsNullOrEmpty(s.ChosenAnswerDetails) ? "Unanswered" : s.ChosenAnswerDetails, // CorrectAnswer = s.CorrectAnswer, // Status = s.Correct.HasValue ? s.Correct.Value ? "<b style='color:green;'>Right</b>" : "<b style='color:red;'>Wrong</b>" : "<b style='color:red;'>Wrong</b>" //}).ToList(); ResultList.DataSource = forList; ResultList.DataBind(); var summary = new ResultModel { Correct = repSum.Correct.Value, Partial = repSum.Partial.Value, Wrong = repSum.Wrong.Value, Unanswered = repSum.Unanswered.Value, CorrectPercent = repSum.CorrectPercent.Value, PartialPercent = repSum.PartialPercent.Value, WrongPercent = repSum.WrongPercent.Value, UnansweredPercent = repSum.UnansweredPercent.Value, CorrectCount = repSum.CorrectCount.Value, PartialCount = repSum.PartialCount.Value, WrongCount = repSum.WrongCount.Value, UnansweredCount = repSum.UnansweredCount.Value, questionCount = repSum.questionCount.HasValue ? repSum.questionCount.Value:0, questionTotalMark = repSum.questionTotalMark.HasValue? repSum.questionTotalMark.Value:0, testDate = repSum.testDate.Value }; var totalQustionMark = forList.Sum(x => x.Mark); Correct.Text = repM.Correct.ToString(); Wrong.Text = repM.Wrong.ToString(); Partial.Text = repM.Partial.ToString(); Unanswered.Text = repM.Unanswered.ToString(); percentage.Text = repM.percentage.ToString(); result_correct.Text = summary.Correct.ToString(); result_partial.Text = summary.Partial.ToString(); result_wrong.Text = summary.Wrong.ToString(); result_unanswered.Text = summary.Unanswered.ToString(); sumation_result.Text = (summary.Correct + summary.Partial).ToString() + " out of " + totalQustionMark; } } } } } catch (Exception ex) { WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], Path.GetFileName(Request.Url.AbsolutePath) + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name, ApplicationType.WebApplication); filter.LogError(ex); //ErecruitHelper.SetErrorData(ex, Session); //Response.Redirect("ErrorPage.aspx", false); } } }
protected void pdfBtn_Click(object sender, EventArgs e) { try { var lbl = string.Format("IndividualTestReport_{0}_{1}", candidateId.Text, batchName.Text); //Response.Clear(); //Response.ContentType = "application/pdf"; //Response.AddHeader("content-disposition", "attachment;filename="+lbl+".pdf"); //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.Buffer = true; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); Panel1.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); //GlobalConfig gc = new GlobalConfig(); //gc.SetPaperSize(PaperKind.A4); //gc.SetPaperOrientation(true); //byte[] pdfBuf = new SynchronizedPechkin(gc).Convert(sr.ReadToEnd()); //MemoryStream ms = new MemoryStream(pdfBuf); //ms.WriteTo(Response.OutputStream); //Response.End(); string pdf_page_size = "A4"; PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true); string pdf_orientation = "Landscape"; PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), pdf_orientation, true); //int webPageWidth = 1024; //try //{ // webPageWidth = Convert.ToInt32(TxtWidth.Text); //} //catch { } //int webPageHeight = 0; //try //{ // webPageHeight = Convert.ToInt32(TxtHeight.Text); //} //catch { } // instantiate a html to pdf converter object HtmlToPdf converter = new HtmlToPdf(); // set css media type converter.Options.CssMediaType = (HtmlToPdfCssMediaType)Enum.Parse(typeof(HtmlToPdfCssMediaType), "Screen", true); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; //converter.Options.WebPageWidth = webPageWidth; //converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(sr.ReadToEnd()); // save pdf document doc.Save(Response, false, lbl + ".pdf"); // close pdf document doc.Close(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], Path.GetFileName(Request.Url.AbsolutePath) + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name, ApplicationType.WebApplication); filter.LogError(ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { var tenant = SessionHelper.GetTenantID(Session); using (QuizBookDbEntities1 _db = new QuizBookDbEntities1()) { if (string.IsNullOrEmpty(tenant)) { ErecruitHelper.SetErrorData(new NullReferenceException("There must be a valid Organisation"), Session); Response.Redirect("ErrorPage.aspx", false); } else { var selectedBatch = Session["GrpList"] == null?0: long.Parse(Session["GrpList"].ToString()); DateTime?fromDate = DateTime.Now; if ((bool)Session["From"]) { fromDate = null; } else { fromDate = (DateTime)Session["dateFrom"]; } DateTime?toDate = DateTime.Now; if ((bool)Session["To"]) { toDate = null; } else { toDate = (DateTime)Session["dateTo"]; } //var toDate = (bool)Session["To"] ? null : (DateTime)Session["dateTo"]; //logoCtrl.ImageUrl = HostingEnvironment.MapPath("~/Images/book.png"); //logoCtrl.ImageUrl = GetUrl("book.png"); logoCt.Src = GetUrl("book.png"); //Session["imageURL"] = GetUrl("Images/book.png"); var details = new ERecruitReportFactory().BatchReport(selectedBatch, fromDate, toDate, long.Parse(tenant)).ToList(); var oneInstance = details.FirstOrDefault(); var count = details.Count(); candCount.Text = count.ToString(); batchName.Text = oneInstance == null? "":oneInstance.BatchName; ppassed.Text = count > 0?((details.Count(x => x.Passed == 1) / count) * 100) + " %":"0 %"; pfailed.Text = count > 0 ? ((details.Count(x => x.Failed == 1) / count) * 100) + " %" : "0 %"; ResultList.DataSource = details; ResultList.DataBind(); } } } catch (Exception ex) { WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], Path.GetFileName(Request.Url.AbsolutePath) + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name, ApplicationType.WebApplication); filter.LogError(ex); //ErecruitHelper.SetErrorData(ex, Session); //Response.Redirect("ErrorPage.aspx", false); } } }
protected void pdfBtn_Click(object sender, EventArgs e) { try { // Response.Clear(); //Response.ContentType = "application/pdf"; //Response.AddHeader("content-disposition", "attachment;filename=BatchReport.pdf"); //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.Buffer = true; StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); bresult.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); //Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f); //HTMLWorker htmlparser = new HTMLWorker(pdfDoc); //PdfWriter.GetInstance(pdfDoc, Response.OutputStream); //pdfDoc.Open(); //htmlparser.Parse(sr); //pdfDoc.Close(); //GlobalConfig gc = new GlobalConfig(); //gc.SetPaperSize(PaperKind.A4); //gc.SetPaperOrientation(true); //byte[] pdfBuf = new SynchronizedPechkin(gc).Convert(sr.ReadToEnd()); //MemoryStream ms = new MemoryStream(pdfBuf); ////Response.Write(pdfDoc); //ms.WriteTo(Response.OutputStream); //Response.End(); // read parameters from the webpage //string htmlString = TxtHtmlCode.Text; //string baseUrl = TxtBaseUrl.Text; string pdf_page_size = "A4"; PdfPageSize pageSize = (PdfPageSize)Enum.Parse(typeof(PdfPageSize), pdf_page_size, true); string pdf_orientation = "Landscape"; PdfPageOrientation pdfOrientation = (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation), pdf_orientation, true); //int webPageWidth = 1024; //try //{ // webPageWidth = Convert.ToInt32(TxtWidth.Text); //} //catch { } //int webPageHeight = 0; //try //{ // webPageHeight = Convert.ToInt32(TxtHeight.Text); //} //catch { } // instantiate a html to pdf converter object HtmlToPdf converter = new HtmlToPdf(); // set converter options converter.Options.PdfPageSize = pageSize; converter.Options.PdfPageOrientation = pdfOrientation; //converter.Options.WebPageWidth = webPageWidth; //converter.Options.WebPageHeight = webPageHeight; // create a new pdf document converting an url SelectPdf.PdfDocument doc = converter.ConvertHtmlString(sr.ReadToEnd()); // save pdf document doc.Save(Response, false, "BatchReport.pdf"); // close pdf document doc.Close(); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.SuppressContent = true; HttpContext.Current.ApplicationInstance.CompleteRequest(); } catch (Exception ex) { WSProfile filter = new WSProfile(System.Reflection.Assembly.GetExecutingAssembly().FullName.Split(',')[0], Path.GetFileName(Request.Url.AbsolutePath) + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name, ApplicationType.WebApplication); filter.LogError(ex); } }