public ActionResult Index(int[] projectId, int?taskId, string date, string number, string modifiedDate, string createdDate, int?isArchived, string label, string text, string sortBy, string sortOrder) { var model = new InvoiceIndexModel(); model.Tab = "Invoice"; model.FindCategory = "Invoice"; model.FindText = text; model.Projects = DataHelper.GetProjectList(); model.ProjectId = projectId ?? new int[0]; model.ProjectName = DataHelper.ToString(model.Projects, model.ProjectId, "any project"); model.ProjectDisplayName = DataHelper.Clip(model.ProjectName, 40); model.Date = date ?? string.Empty; model.IsArchived = isArchived ?? 0; model.Filters = MyService.FilterFetchInfoList("Invoice"); model.SortBy = sortBy ?? "InvoiceId"; model.SortOrder = sortOrder ?? "DESC"; model.SortableColumns.Add("InvoiceId", "No."); model.SortableColumns.Add("ProjectName", "Project"); model.SortableColumns.Add("Number", "User"); model.SortableColumns.Add("TaskId", "Task"); var criteria = new InvoiceCriteria() { ProjectId = projectId, TaskId = taskId, Number = number, PreparedDate = new DateRangeCriteria(model.Date), ModifiedDate = new DateRangeCriteria(modifiedDate ?? string.Empty), CreatedDate = new DateRangeCriteria(createdDate ?? string.Empty), IsArchived = DataHelper.ToBoolean(isArchived), Text = text }; var invoices = InvoiceService.InvoiceFetchInfoList(criteria) .AsQueryable(); invoices = invoices.OrderBy(string.Format("{0} {1}", model.SortBy, model.SortOrder)); model.Invoices = invoices; return(RespondTo(format => { format[RequestExtension.Html] = () => this.View(model); format[RequestExtension.Xml] = () => new XmlResult { Data = model.Invoices.ToList(), TableName = "Invoice" }; format[RequestExtension.Json] = () => new JsonResult { Data = model.Invoices, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; })); }
public void Export(int[] projectId, int?taskId, string modifiedDate, string createdDate, int?isArchived, string text, string sortBy, string sortOrder) { var criteria = new InvoiceCriteria() { ProjectId = projectId, TaskId = taskId, ModifiedDate = new DateRangeCriteria(modifiedDate ?? string.Empty), CreatedDate = new DateRangeCriteria(createdDate ?? string.Empty), IsArchived = DataHelper.ToBoolean(isArchived, false), Text = text }; var invoices = InvoiceService.InvoiceFetchInfoList(criteria) .AsQueryable(); invoices = invoices.OrderBy(string.Format("{0} {1}", sortBy ?? "InvoiceId", sortOrder ?? "ASC")); var sw = new StringWriter(); sw.WriteLine( "InvoiceId,Number,TaskId,PreparedDate,ProjectName,Description,Amount,IsArchived,Notes,ModifiedByName,ModifiedDate,CreatedByName,CreatedByDate"); foreach (var invoice in invoices) { var sb = new StringBuilder(); sb.AppendFormat("{0},", invoice.InvoiceId); sb.AppendFormat("\"{0}\",", invoice.Number); sb.AppendFormat("{0},", invoice.TaskId); sb.AppendFormat("{0},", invoice.PreparedDate); sb.AppendFormat("\"{0}\",", invoice.ProjectName); sb.AppendFormat("\"{0}\",", invoice.Description.Replace("\"", "'")); sb.AppendFormat("{0},", invoice.Amount); sb.AppendFormat("{0},", invoice.IsArchived); sb.AppendFormat("\"{0}\",", invoice.Notes); sb.AppendFormat("{0},", invoice.ModifiedByName); sb.AppendFormat("{0},", invoice.ModifiedDate); sb.AppendFormat("{0},", invoice.CreatedByName); sb.AppendFormat("{0}", invoice.CreatedDate); sw.WriteLine(sb.ToString()); } this.Response.AddHeader("Content-Disposition", "attachment; filename=Invoices.csv"); this.Response.ContentType = "application/ms-excel"; this.Response.ContentEncoding = Encoding.GetEncoding("utf-8"); this.Response.Write(sw); this.Response.End(); }
public void HandleEvent(EIMSInvoiceInfoMessage eventMessage) { if (eventMessage.IsPage) { //分页查询返点信息 InvoiceCriteria msg = new InvoiceCriteria(); msg.PM = eventMessage.PMSysNo.ToString(); msg.VendorNumber = eventMessage.VendorSysNo.ToString(); msg.CompanyCode = eventMessage.CompanyCode; msg.ShowLineNumber = eventMessage.PageSize; msg.CurrentPage = eventMessage.PageIndex + 1; msg.ReceiveType = eventMessage.ReceiveType; IEIMSInterfaceService service = WCFAdapter <IEIMSInterfaceService> .GetProxy(); EIMSInvoiceResult result = service.GetEIMSInvoiceListForIPP(msg); eventMessage.ResultList = new List <ReturnPointMsg>(); if (result.EIMSInvoiceList.Count > 0) { result.EIMSInvoiceList.ForEach(a => eventMessage.ResultList.Add(new ReturnPointMsg() { SysNo = a.InvoiceNumber, ReturnPointName = a.InvoiceName, ReturnPoint = a.OriginalAmount, RemnantReturnPoint = a.CurrentAmount }) ); } eventMessage.TotalCount = result.Records; } else { //根据sysno查询返点信息 IEIMSInterfaceService service = WCFAdapter <IEIMSInterfaceService> .GetProxy(); EIMSInvoiceInfo result = service.GetEIMSInvoiceInfo(eventMessage.InvoiceNumber, eventMessage.CompanyCode); eventMessage.Result = new ReturnPointMsg() { SysNo = result.InvoiceNumber, ReturnPointName = result.InvoiceName, ReturnPoint = result.OriginalAmount, RemnantReturnPoint = result.CurrentAmount }; } }
public static InvoiceInfoList InvoiceFetchInfoList(InvoiceCriteria criteria) { return(InvoiceInfoList.FetchInvoiceInfoList(criteria)); }