public PrintResult PrintLocalReport(LocalReportPrintingParameter printingParam) { PrintResult pr = new PrintResult(); try { //foreach (var datasource in datasources) //{ // printingParam.Datasources.Add(datasource.Key, datasource.Value); //} printingParam.PrinterName = ThirdStoreConfig.Instance.ThirdStorePrinterName; _localReportPrinting.SetReportPrintingParameters(printingParam); pr = _localReportPrinting.PrintReport(); } catch (Exception ex) { LogManager.Instance.Error(ex.InnerException.Message + ex.InnerException.StackTrace); pr.Success = false; pr.Message = ex.ToString(); } return(pr); }
private void btnPrintBarcodes_Click(object sender, EventArgs e) { bok = true; log.Info("Print barcode"); //#if DEBUG // ReadExpectedBarcodes(); // btnNext.Enabled = true; // return; //#endif try { PrintResult res = Global.Instance.server.PrintBarcodes(neededBarcodes); bok = (bool)res.bok; btnNext.Enabled = bok; if (!bok) { string errMsg = res.errDescription; log.Error(errMsg); SetInfo(errMsg, Color.Red); return; } Global.Instance.expectedBarcodes = res.barcodes.ToList(); } catch (Exception ex) { log.Error(ex.Message); SetInfo(ex.Message, Color.Red); } }
public void PrintActionResultNeedsToCreateAValidJpeg() { //Arrange var memoryStream = new MemoryStream(); var httpContext = new FakeHttpContext(outputStream: memoryStream); var httpController = new Mock <Controller>(); var controllerContext = httpController .Object .SetFakeControllerContext(httpContext.Object, routeValues: new Dictionary <string, string> { { "action", "testaction" }, { "controller", "testcontroller" } }); var mockActionResult = PrintResult.PrintToJpeg(); mockActionResult.RetrieveHtml = (viewName, masterName, model, context) => "<html><head></head><body>Test Content</body></html>"; //Act mockActionResult.ExecuteResult(controllerContext); //Assert var actualBytes = memoryStream.ToArray(); for (var i = 0; i < actualBytes.Length; i++) { Assert.AreEqual(Resources.JpegBrowser[i], actualBytes[i]); } }
public void PrintActionResultNeedsToCreateAValidPdf() { //Arrange var httpContext = new FakeHttpContext(); var httpController = new Mock <Controller>(); var controllerContext = httpController .Object .SetFakeControllerContext(httpContext.Object, routeValues: new Dictionary <string, string> { { "action", "testaction" }, { "controller", "testcontroller" } }); var mockActionResult = PrintResult.PrintToPdf(); mockActionResult.RetrieveHtml = (viewName, masterName, model, context) => "<html><head></head><body>Test Content</body></html>"; //Act mockActionResult.ExecuteResult(controllerContext); //Assert httpContext.Response .Verify(@base => @base.BinaryWrite(It.Is <byte[]>( actualBytes => PdfReader.TestPdfFile(actualBytes) == 14))); }
public void Do_build_documents_only_once() { var result = new PrintResult("тест", Enumerable.Range(0, 1).Select(r => new DefaultDocument(new FlowDocument()))); var paginator1 = result.Paginator; var paginator2 = result.Paginator; Assert.IsTrue(ReferenceEquals(paginator1.Source, paginator2.Source)); }
public static void SaveAndOpen(PrintResult result) { var file = "output.xps"; var paginator = result.Paginator; paginator.SaveToXps(file); Process.Start(file); }
public ActionResult PrintJpg(DashboardRequest request) { var model = new DashboardPrintModel { Summary = CreateSummary(request), Request = request }; return(PrintResult.PrintToJpeg("Print", model)); }
public static void MergePdf(PrintResult printResult, Action <string> updateStatus = null) { var workbookNameNoExt = Path.GetFileNameWithoutExtension(printResult.WorkbookPath); var folderPath = printResult.OutputFolderPath; var mergedFilePath = folderPath + "\\" + workbookNameNoExt + ".pdf"; updateStatus?.Invoke("マージ中... " + mergedFilePath); MergePdf(printResult.PrintedPdfPaths, mergedFilePath, updateStatus); updateStatus?.Invoke("マージ中... 完成"); }
public PrintPreviewViewModel(PrintResult result) : this() { if (result == null) { return; } this.result = result; var paginator = result.Paginator; Orientation = PrintResult.GetPageOrientation(paginator); Document = PrintHelper.ToFixedDocument(paginator); }
protected IEnumerable <IResult> Preview(string name, BaseDocument doc) { var docSettings = doc.Settings; if (docSettings != null) { yield return(new DialogResult(new SimpleSettings(docSettings))); } var printResult = new PrintResult(name, doc); var model = new PrintPreviewViewModel(printResult); yield return(new DialogResult(model, fullScreen: true)); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Poisson poisson = new Poisson(); rs.Clear(); mean = 2000; stdev = Math.Sqrt(2000); poisson.Lambda = 2000; for (int i = 0; i < numSamples; ++i) { rs.Push(poisson.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("Poisson Discrete", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Exponential exponential = new Exponential(); rs.Clear(); mean = 2; stdev = 2; for (int i = 0; i < numSamples; ++i) { exponential.StandardDeviation = 2; //exponential.Mean = mean; rs.Push(exponential.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("exponential", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Triangular tri = new Triangular(); rs.Clear(); var a = tri.LowerBound; var b = tri.UpperBound; var c = tri.Mode; mean = (a + b + c) / 3; stdev = Math.Sqrt((a * a + b * b + c * c - a * b - a * c - b * c) / 18); for (int i = 0; i < numSamples; ++i) { rs.Push(tri.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("Triangular", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Gamma gamma = new Gamma(); rs.Clear(); mean = 2; stdev = 5; for (int i = 0; i < numSamples; ++i) { gamma.Mean = mean; gamma.StandardDeviation = stdev; rs.Push(gamma.Sample(defaultrs)); //yy } PrintResult.CompareMeanAndVariance("gamma", mean, stdev * stdev, rs.Mean(), rs.Variance()); // TODO: result not consistent need to fix the bug }
public void TestMeanAndVariacneConsistency_Std() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Normal normal = new Normal(); rs.Clear(); mean = 2; stdev = 5; for (int i = 0; i < numSamples; ++i) { normal.Mean = mean; normal.StandardDeviation = stdev; rs.Push(normal.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("normal", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Uniform uniform = new Uniform(); rs.Clear(); var a = uniform.UpperBound; var b = uniform.LowerBound; mean = (a + b) / 2; stdev = Math.Sqrt((b - a) * (b - a) / 12); for (int i = 0; i < numSamples; ++i) { rs.Push(uniform.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("uniform", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
private byte[] PrintOperHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; JsonObject info; bool found = operationInput.TryGetJsonObject("printParameters", out info); if (!found || info == null) { throw new ArgumentNullException("printParameters"); } ExportMapInfo printInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <ExportMapInfo>(info.ToJson()); JsonObject result = new JsonObject(); ExportMap export = new ExportMap(); string outmsg = string.Empty; bool isPrinted = export.Export(printInfo, out outmsg); PrintResult pr = new PrintResult(); if (isPrinted) { pr.IsPrinted = isPrinted; pr.FileName = outmsg; pr.OutMsg = "制图成功!"; } else { pr.IsPrinted = isPrinted; pr.FileName = "未找到!"; pr.OutMsg = outmsg; } result.AddObject("result", pr); return(Encoding.UTF8.GetBytes(result.ToJson())); }
public void TestMeanAndVariacneConsistency() { List <int> numList = new List <int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Uniform <int> uniform = new Uniform <int>(); uniform.Candidates = numList; rs.Clear(); mean = 50; stdev = 0; for (int i = 0; i < numSamples; ++i) { rs.Push(uniform.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("uniform categorical", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Uniform uniform = new Uniform(); rs.Clear(); var a = Convert.ToDouble(uniform.UpperBound); var b = Convert.ToDouble(uniform.LowerBound); mean = (a + b) / 2; stdev = Math.Sqrt(0.25); for (int i = 0; i < numSamples; ++i) { rs.Push(uniform.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("uniform", mean, stdev * stdev, rs.Mean(), rs.Variance()); Assert.IsTrue(Math.Abs(mean - rs.Mean()) < 0.1); Assert.IsTrue(Math.Abs(stdev * stdev - rs.Variance()) < 0.1); }
public void TestMeanAndVariacneConsistency_MuSigma() { const int numSamples = 100000; double mean, stdev; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); LogNormal logNormal = new LogNormal(); rs.Clear(); mean = 2; stdev = 5; var muTemp = Math.Log(mean) - 0.5 * Math.Log(1 + stdev * stdev / mean / mean); var sigmaTemp = Math.Sqrt(Math.Log(1 + stdev * stdev / mean / mean)); for (int i = 0; i < numSamples; ++i) { logNormal.Mu = muTemp; logNormal.Sigma = sigmaTemp; rs.Push(logNormal.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("logNormal", mean, stdev * stdev, rs.Mean(), rs.Variance()); }
public void TestMeanAndVariacneConsistency_Mean() { const int numSamples = 100000; double mean, variance; RunningStat rs = new RunningStat(); Random defaultrs = new Random(); Beta beta = new Beta(); rs.Clear(); //double a = 2, b = 70; //mean = a / (a + b); //variance = mean * (1 - mean) / (a + b + 1); mean = 0.1; variance = 0.1 * 0.1; for (int i = 0; i < numSamples; ++i) { beta.Mean = mean; beta.StandardDeviation = Math.Sqrt(variance); rs.Push(beta.Sample(defaultrs)); } PrintResult.CompareMeanAndVariance("Beta", mean, variance, rs.Mean(), rs.Variance()); }
/// <summary> /// 打印 /// </summary> /// <param name="text"></param> /// <param name="timeOut"></param> public static PrintResult Send(string text, PrintConfigData printConfigData, int timeOut = 10) { //用户id string partner = printConfigData.Partner; //"21108"; //apikey API 密钥 string apikey = printConfigData.ApiKey; //"2f12779e593499b981beb7fe9644bb934b9dada7"; //机器码 终端编号 string machine_code = printConfigData.MachineCode; //"4004547827"; //终端密钥 string machine_key = printConfigData.MachineKey; //"6a7r3enumfbu"; //接口地址 string url = "http://open.10ss.net:8888"; //时间戳 string time = ""; //签名 string sign = ""; #region 开始生成时间戳 time = GetTimeSpan(); #endregion #region 参数列表 Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("machine_code", machine_code); parameters.Add("partner", partner); parameters.Add("time", time); #endregion //对apikey+(machine_code+partner+time)+mkey 进行签名加密 sign = getSign(parameters, apikey, machine_key); PrintData data = new PrintData(); data.Put("partner", partner); //用户id data.Put("machine_code", machine_code); //机器码 终端编号 data.Put("time", time); //时间戳 data.Put("sign", sign); //签名 data.Put("content", text); //产生随机的商户订单号 string response = HttpService.Post(url, data.ToUrl(), timeOut); JsonData jsonData = JsonMapper.ToObject(response); //服务器返回状态 var state = jsonData["state"].ToString(); var result = new PrintResult { Success = false, Message = "系统繁忙,稍后再试" }; if (state == "1") { result.Success = true; result.Message = "打印成功"; } else if (state == "2") { result.Message = "打印失败,提交时间超时"; } else if (state == "3") { result.Message = "打印失败,参数有误"; } else if (state == "4") { result.Message = "打印失败,sign加密验证失败"; } return(result); //Logger.Error("服务器错误:", actionExecutedContext.Exception); //state:"1","id":"1234" 数据提交成功,1234代表单号,打印完成上报时用、详情请查看:打印完成自动上报接口文档 //state:"2" 提交时间超时。验证你所提交的时间戳超过3分钟后拒绝接受 //state:"3" 参数有误 //state:"4" sign加密验证失败 }
public void OnSuccess(PrintResult result) { log.Info($"OnSuccess: {result}"); }
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { //取消 this.Result = PrintResult.Cancelled; }
public ActionResult PrintJpg(int?id = null) { var model = CreateOverViewReportModel(id); return(PrintResult.PrintToJpeg("Print", model)); }
public static Func <int, Action <int> > PrintAddResult(int x) => y => result => PrintResult(x)("+")(y)(result);
private static PrintResult PrintToPaper( Application excel, string printer, CancellationToken cancelToken,//Cancel token string filePath, IEnumerable <WorksheetInfo> sheetInfos, PrintSettings printSettings ) { var result = new PrintResult(); var exportFolderPath = ""; var pdfNamePrefix = ""; //Print to separate folders if (!printSettings.ExportToSingleFolder) { //Create a folder with the same name as the excel var fileName = Path.GetFileNameWithoutExtension(filePath); var folderPath = Path.GetDirectoryName(filePath); exportFolderPath = folderPath + "\\" + fileName; Directory.CreateDirectory(exportFolderPath); } //Print to a single folder else { //User single folder path as the export path exportFolderPath = printSettings.SingleFolderPath; if (printSettings.AttachWorkbookNameBeforeWorksheet) { var excelName = Path.GetFileNameWithoutExtension(filePath); pdfNamePrefix = excelName + "_"; } } result.OutputFolderPath = exportFolderPath; result.WorkbookPath = filePath; //Try to export worksheet as pdf try { //Open workbook var wb = excel.Workbooks.Open(Filename: filePath, ReadOnly: true); //A dictionary to save worksheet data from workbook var worksheetDict = new Dictionary <string, Worksheet>(); foreach (Worksheet ws in wb.Worksheets) { worksheetDict.Add(ws.Name, ws); } foreach (var worksheetInfo in sheetInfos.Where(x => x.IsWorksheetChecked)) { //Check if checked worksheet's name is contained in this workbook if (!worksheetDict.ContainsKey(worksheetInfo.SheetName)) { continue; } //Get worksheet var ws = worksheetDict[worksheetInfo.SheetName]; //Get start and end information uint fromPage = 1; uint toPage = (uint)ws.PageSetup.Pages.Count; if (worksheetInfo.StartPage > 0) { fromPage = worksheetInfo.StartPage; } if (worksheetInfo.EndPage > 0) { toPage = worksheetInfo.EndPage; } //Print to pdf if (!printSettings.PrintToPaper) { var pdfFilePath = exportFolderPath + "\\" + pdfNamePrefix + ws.Name + ".pdf"; ws.PrintOut( From: fromPage, To: toPage, ActivePrinter: printer, PrToFileName: pdfFilePath ); result.PrintedPdfPaths.Add(pdfFilePath); } //Print to paper else { ws.PrintOut( From: fromPage, To: toPage, ActivePrinter: printer ); } if (cancelToken.IsCancellationRequested) { break; } } //foreach (Worksheet ws in wb.Worksheets) //{ // if (sheetInfos.Any(x => x.SheetName == ws.Name && x.IsSheetChecked)) // { // var target = sheetInfos.First(x => x.SheetName == ws.Name && x.IsSheetChecked); // uint fromPage = 1; // uint toPage = (uint)ws.PageSetup.Pages.Count; // if (target.StartPage > 0) // fromPage = target.StartPage; // if (target.EndPage > 0) // toPage = target.EndPage; // //Print to pdf // if (!printSettings.PrintToPaper) // { // var pdfFilePath = exportFolderPath + "\\" + pdfNamePrefix + ws.Name + ".pdf"; // ws.PrintOut( // From: fromPage, // To: toPage, // ActivePrinter: printer, // PrToFileName: pdfFilePath // ); // result.PrintedPdfPaths.Add(pdfFilePath); // } // //Print to paper // else // ws.PrintOut( // From: fromPage, // To: toPage, // ActivePrinter: printer // ); // } // if (cancelToken.IsCancellationRequested) // break; //} //Close workbook wb.Close(SaveChanges: false); } catch { } return(result); }
//public ActionResult Index(string levelString, string session, string arm, string DateFrom, string DateTo, string ApprovedString, string searchString, string SexString, string LevelString, string StudentIDString, int? page // , string paidschoolfess, string term, bool? printQuery) //{ public ActionResult Index(string levelString, string session, string arm, string DateFrom, string DateTo, string ApprovedString, string searchString, string SexString, string LevelString, string StudentIDString, int?page , string paidschoolfess, string term) { bool?thePrintQuery = null; // thePrintQuery = printQuery; if (User.IsInRole("Parent")) { List <TermRegistration> studentList = new List <TermRegistration>(); int theParentUserName = Convert.ToInt32(User.Identity.Name); Parent theParent = work.ParentRepository.Get(a => a.UserID == theParentUserName).First(); List <PrimarySchoolStudent> theStudents = work.PrimarySchoolStudentRepository.Get(a => a.ParentID == theParent.ParentID).ToList(); int counter = 0; foreach (PrimarySchoolStudent s in theStudents) { if (counter == 0) { theParent.StudentIDOne = Convert.ToString(s.UserID); } if (counter == 1) { theParent.StudentIDTwo = Convert.ToString(s.UserID); } if (counter == 2) { theParent.StudentIDThree = Convert.ToString(s.UserID); } if (counter == 3) { theParent.StudentIDFour = Convert.ToString(s.UserID); } if (counter == 4) { theParent.StudentIDFive = Convert.ToString(s.UserID); } counter = counter + 1; } if (!(string.IsNullOrEmpty(theParent.StudentIDOne))) { int theStudentID = Convert.ToInt32(theParent.StudentIDOne); //List<TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID && a.Term == term && a.Session == session).ToList(); List <TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID).ToList(); if (theList.Count > 0) { studentList.Add(theList[0]); } } if (!(string.IsNullOrEmpty(theParent.StudentIDTwo))) { int theStudentID = Convert.ToInt32(theParent.StudentIDTwo); List <TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID).ToList(); if (theList.Count > 0) { studentList.Add(theList[0]); } } if (!(string.IsNullOrEmpty(theParent.StudentIDThree))) { int theStudentID = Convert.ToInt32(theParent.StudentIDThree); List <TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID).ToList(); if (theList.Count > 0) { studentList.Add(theList[0]); } } if (!(string.IsNullOrEmpty(theParent.StudentIDFour))) { int theStudentID = Convert.ToInt32(theParent.StudentIDFour); List <TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID).ToList(); if (theList.Count > 0) { studentList.Add(theList[0]); } } if (!(string.IsNullOrEmpty(theParent.StudentIDFive))) { int theStudentID = Convert.ToInt32(theParent.StudentIDFive); List <TermRegistration> theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID).ToList(); if (theList.Count > 0) { studentList.Add(theList[0]); } } List <SelectListItem> theItem = new List <SelectListItem>(); theItem.Add(new SelectListItem() { Text = "None", Value = "" }); foreach (var level in studentList) { theItem.Add(new SelectListItem() { Text = level.StudentID.ToString(), Value = level.StudentID.ToString() }); } ViewData["studentIds"] = theItem; // students = studentList; } if (term == "First") { ViewBag.Term = "1"; } if (term == "Second") { ViewBag.Term = "2"; } if (term == "Third") { ViewBag.Term = "3"; } decimal totalAmount = 0; if (Request.HttpMethod == "GET") { // searchString = currentFilter; } else { page = 1; } ViewBag.CurrentFilter = searchString; var students = from s in work.TermRegistrationRepository.Get(a => a.Term == term) select s; // var students = from s in work.TermRegistrationRepository.Get() // select s; if (!String.IsNullOrEmpty(term)) { // students = from s in work.TermRegistrationRepository.Get() // select s; students = students.Where(s => s.Term.Equals(term)); } if (!String.IsNullOrEmpty(session)) { students = students.Where(s => s.Session.Equals(session)); } if (!String.IsNullOrEmpty(LevelString)) { students = students.Where(s => s.Level == LevelString); } if (!String.IsNullOrEmpty(StudentIDString)) { int theID = Convert.ToInt32(StudentIDString); students = students.Where(s => s.StudentID == theID); } int pageSize = 50; int pageNumber = (page ?? 1); if (!String.IsNullOrEmpty(paidschoolfess)) { if (paidschoolfess == "Owing") { var payments = from s in work.SchoolFeePaymentRepository.Get() select s; if (!String.IsNullOrEmpty(term)) { payments = payments.Where(s => s.Term.Equals(term)); } if (!String.IsNullOrEmpty(session)) { payments = payments.Where(s => s.Session.Equals(session)); } if (!String.IsNullOrEmpty(LevelString)) { payments = payments.Where(s => s.Level == LevelString); } if (!String.IsNullOrEmpty(StudentIDString)) { int theID = Convert.ToInt32(StudentIDString); payments = payments.Where(s => s.StudentID == theID); } // payments = payments.Where(a => a.Owing > 0).OrderBy(a => a.StudentID);//.OrderBy(a => a.DatePaid); TermRegistration theStudentWhoRegistered = new TermRegistration(); List <TermRegistration> theOwingStudents = new List <TermRegistration>(); List <SchoolFeePayment> theRegisteredSchoolFeePyament = new List <SchoolFeePayment>(); SchoolFeePayment thePayment = new SchoolFeePayment(); TermRegistration tR = new TermRegistration(); SchoolFeePayment sF = new SchoolFeePayment(); List <TermRegistration> theRegisteredStudents = new List <TermRegistration>(); theRegisteredStudents = students.ToList(); foreach (TermRegistration t in theRegisteredStudents) { List <SchoolFeePayment> thisGuyPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == t.StudentID && a.Term == term).OrderByDescending(a => a.DatePaid).ToList(); if (thisGuyPayment.Count() > 0) { SchoolFeePayment theCurrentPayment = thisGuyPayment[0]; if (theCurrentPayment.Owing > 0) { totalAmount += theCurrentPayment.Owing; theOwingStudents.Add(new TermRegistration { DateRegistered = t.DateRegistered, Owing = t.Owing, TermRegistrationID = t.TermRegistrationID, Register = t.Register, Sex = t.Sex, LastName = t.LastName, FirstName = t.FirstName, SchoolFeesKind = theCurrentPayment.TheSchoolFeesType, Cost = theCurrentPayment.Cost, Level = theCurrentPayment.Level, Session = theCurrentPayment.Session, Term = theCurrentPayment.Term, StudentID = theCurrentPayment.StudentID, }); } } } students = theOwingStudents; } else { if (Convert.ToBoolean(paidschoolfess) == true) { List <SchoolFeePayment> listOfPayments = work.SchoolFeePaymentRepository.Get().Where(a => a.Owing <= 0).OrderBy(a => a.DatePaid).ToList(); List <TermRegistration> theRegisteredStuentWhoHavePaid = new List <TermRegistration>(); foreach (TermRegistration r in students) { foreach (SchoolFeePayment l in listOfPayments) { if (r.StudentID == l.StudentID) { totalAmount += l.Cost; theRegisteredStuentWhoHavePaid.Add(r); break; } } // if(s.StudentID ==)theRegisteredStuentWhoHavePaid } students = theRegisteredStuentWhoHavePaid; } else { List <TermRegistration> theNeverPaidStuddentStudents = new List <TermRegistration>(); List <TermRegistration> theRegisteredStudents = new List <TermRegistration>(); theRegisteredStudents = students.ToList(); theRegisteredStudents = students.ToList(); foreach (TermRegistration t in theRegisteredStudents) { List <SchoolFeePayment> thisGuyPayment = new List <SchoolFeePayment>(); // List<SchoolFeePayment> thisGuyPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == t.StudentID && a.Term == term).OrderByDescending(a => a.DatePaid).ToList(); if (string.IsNullOrEmpty(session)) { thisGuyPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == t.StudentID && a.Term == term).OrderByDescending(a => a.DatePaid).ToList(); } if (!(string.IsNullOrEmpty(session))) { thisGuyPayment = work.SchoolFeePaymentRepository.Get(a => a.StudentID == t.StudentID && a.Session == session && a.Term == term).OrderByDescending(a => a.DatePaid).ToList(); } if (thisGuyPayment.Count() == 0) { totalAmount += t.Cost; theNeverPaidStuddentStudents.Add(new TermRegistration { LastName = t.LastName, FirstName = t.FirstName, SchoolFeesKind = t.SchoolFeesKind, Cost = t.Cost, Level = t.Level, Session = t.Session, Term = t.Term, StudentID = t.StudentID }); } } students = theNeverPaidStuddentStudents; } } } if (User.IsInRole("Parent")) { //ViewBag.Term = "1"; int theParentUserName = Convert.ToInt32(User.Identity.Name); Parent theParent = work.ParentRepository.Get(a => a.UserID == theParentUserName).First(); List <TermRegistration> studentList = new List <TermRegistration>(); int theStudentID = 0; if (!(string.IsNullOrEmpty(StudentIDString))) { theStudentID = Convert.ToInt32(StudentIDString); } List <TermRegistration> theList = new List <TermRegistration>(); theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID && a.Term == term && a.Session == session && a.Level == LevelString).ToList(); students = theList; } if (User.IsInRole("Student")) { // ViewBag.Term = "1"; int theStudentUserName = Convert.ToInt32(User.Identity.Name); List <PrimarySchoolStudent> theStudent = new List <PrimarySchoolStudent>(); List <TermRegistration> theList = new List <TermRegistration>(); theStudent = work.PrimarySchoolStudentRepository.Get(a => a.UserID == theStudentUserName).ToList(); // List<TermRegistration> studentList = new List<TermRegistration>(); if ((theStudent.Count > 0)) { int theStudentID = Convert.ToInt32(theStudent[0].UserID); theList = work.TermRegistrationRepository.Get(a => a.StudentID == theStudentID && a.Level == LevelString && a.Term == term && a.Session == session).ToList(); //if (theList.Count > 0) //{ // theList.Add(theList[0]); // } } students = theList; } if (thePrintQuery != null && students.Count() > 0) { thePrintQuery = null; StringWriter oStringWriter1 = new StringWriter(); Document itextDoc = new Document(PageSize.LETTER); itextDoc.Open(); Response.ContentType = "application/pdf"; PrintResult print = new PrintResult(); // Set up the document and the MS to write it to and create the PDF writer instance MemoryStream ms = new MemoryStream(); //Document document = new Document(PageSize.A3.Rotate()); Document document = new Document(PageSize.A4); PdfWriter writer = PdfWriter.GetInstance(document, ms); // Open the PDF document document.Open(); Document thedoc = new SchoolFeesPrinting().FeesPrinting(students.ToList(), ref oStringWriter1, ref document); iTextSharp.text.pdf.draw.VerticalPositionMark seperator = new iTextSharp.text.pdf.draw.LineSeparator(); seperator.Offset = -6f; document.Close(); // Hat tip to David for his code on stackoverflow for this bit // http://stackoverflow.com/questions/779430/asp-net-mvc-how-to-get-view-to-generate-pdf byte[] file = ms.ToArray(); MemoryStream output = new MemoryStream(); output.Write(file, 0, file.Length); output.Position = 0; HttpContext.Response.AddHeader("content-disposition", "attachment; filename=SchoolFees.pdf"); return(new FileStreamResult(output, "application/pdf")); //new FileStreamResult(output, "application/pdf"); // return View(new FileStreamResult(output, "application/pdf")); } ViewBag.TotalAmount = totalAmount; ViewBag.Count = students.Count(); return(View(students.ToPagedList(pageNumber, pageSize))); // } // else // { // return View("Index3", students.ToPagedList(pageNumber, pageSize)); // } }
public static int Main(string[] args) { var trace = false; string output_filename = null; var show_help = false; var use_precompiled = true; var options = new OptionSet { { "o=|output", "Write output to file instead of standard output.", v => output_filename = v }, { "t|trace-parsing", "Produce a trace of the parse process.", v => trace = v != null }, { "p|no-precomp", "do not use precompiled libraries", v => use_precompiled = v == null }, { "h|help", "show this message and exit", v => show_help = v != null } }; List <string> files; try { files = options.Parse(args); } catch (OptionException e) { Console.Error.Write(AppDomain.CurrentDomain.FriendlyName + ": "); Console.Error.WriteLine(e.Message); Console.Error.WriteLine("Try “" + AppDomain.CurrentDomain.FriendlyName + " --help” for more information."); return(1); } if (show_help) { Console.WriteLine("Usage: " + AppDomain.CurrentDomain.FriendlyName + " input.o_0"); Console.WriteLine("Run a Flabbergast file and display the “value” attribute."); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return(1); } if (files.Count != 1) { Console.Error.WriteLine("Exactly one Flabbergast script must be given."); return(1); } var assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Print"), AssemblyBuilderAccess.Run); CompilationUnit.MakeDebuggable(assembly_builder); var module_builder = assembly_builder.DefineDynamicModule("PrintModule", true); var unit = new CompilationUnit(module_builder, true); var collector = new ConsoleCollector(); var task_master = new ConsoleTaskMaster(); var resource_finder = new ResourcePathFinder(); resource_finder.PrependPath(Path.Combine(Path.GetDirectoryName(Path.GetFullPath(files[0])), "lib")); resource_finder.AddDefault(); task_master.AddUriHandler(new CurrentInformation(false)); task_master.AddUriHandler(BuiltInLibraries.INSTANCE); task_master.AddUriHandler(SettingsHandler.INSTANCE); var db_handler = new DbUriHandler(); db_handler.Finder = resource_finder; task_master.AddUriHandler(db_handler); task_master.AddUriHandler(EnvironmentUriHandler.INSTANCE); task_master.AddUriHandler(HttpHandler.INSTANCE); task_master.AddUriHandler(FtpHandler.INSTANCE); task_master.AddUriHandler(FileHandler.INSTANCE); var resource_handler = new ResourceHandler(); resource_handler.Finder = resource_finder; task_master.AddUriHandler(resource_handler); if (use_precompiled) { var precomp = new LoadPrecompiledLibraries(); precomp.Finder = resource_finder; task_master.AddUriHandler(precomp); } var dyncomp = new DynamicallyCompiledLibraries(collector); dyncomp.Finder = resource_finder; task_master.AddUriHandler(dyncomp); var parser = Parser.Open(files[0]); parser.Trace = trace; var run_type = parser.ParseFile(collector, unit, "Printer"); if (run_type != null) { var computation = (Computation)Activator.CreateInstance(run_type, task_master); var filewriter = new PrintResult(task_master, computation, output_filename); filewriter.Slot(); task_master.Run(); task_master.ReportCircularEvaluation(); return(filewriter.Success ? 0 : 1); } return(1); }
private void друкToolStripMenuItem_Click(object sender, EventArgs e) { PrintResult frm = new PrintResult(); frm.Show(); }