//读取库存报告模板并另存报告,返回完整储存路径 public void GenerateFBAInventoryReport(FBAInventoryInfo info) { _ws = _wb.Worksheets[1]; _ws.Cells[4, 2] = info.Customer; _ws.Cells[4, 4] = info.CloseDate.ToString("yyyy-MM-dd"); _ws.Cells[6, 2] = info.CurrentPlts; _ws.Cells[6, 4] = info.TotalResidualQuantity; _ws.Cells[6, 6] = info.CurrentLooseCtns; _ws.Cells[6, 8] = info.TotalResidualQuantity - info.CurrentLooseCtns; var startRow = 9; foreach (var i in info.FBAResidualInventories) { _ws.Cells[startRow, 1] = i.Container; _ws.Cells[startRow, 2] = i.Type; _ws.Cells[startRow, 3] = i.ShipmentId; _ws.Cells[startRow, 4] = i.AmzRefId; _ws.Cells[startRow, 5] = i.WarehouseCode; _ws.Cells[startRow, 6] = Math.Round(i.GrossWeightPerCtn, 2); _ws.Cells[startRow, 7] = Math.Round(i.CBMPerCtn, 2); _ws.Cells[startRow, 8] = i.OriginalQuantity; _ws.Cells[startRow, 9] = Math.Round((double)i.ResidualQuantity, 2); _ws.Cells[startRow, 10] = i.Location; startRow += 1; } var fullPath = @"D:\InventoryReport\FBA-" + info.Customer + "-InventoryReport-" + DateTime.Now.ToString("yyyyMMddhhmmssffff") + ".xls"; _wb.SaveAs(fullPath, Type.Missing, "", "", Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, 1, false, Type.Missing, Type.Missing, Type.Missing); _excel.Quit(); //使用主线程调用委托,等于用主线程调用Quick()方法,以达到阻塞线程的目的 var handler = new QuitHandler(_excel.Quit); handler.Invoke(); var response = HttpContext.Current.Response; var downloadFile = new FileInfo(fullPath); response.ClearHeaders(); response.Buffer = false; response.ContentType = "application/octet-stream"; response.AppendHeader("Content-Disposition", "attachment; filename=" + info.Customer + " Inventory Report - " + HttpUtility.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls", System.Text.Encoding.UTF8)); response.Clear(); response.AppendHeader("Content-Length", downloadFile.Length.ToString()); response.WriteFile(downloadFile.FullName); response.Flush(); response.Close(); response.End(); var killer = new ExcelKiller(); killer.Dispose(); }
public void TestHistory() { AddChatUsers("test-a", "a", "b", "c"); AddChatUsers("test-b", "b", "c"); AddChatUsers("test-c", "a", "c"); var quitHandler = new QuitHandler(); var msg = new MsgEventArgs { Command = "QUIT", Data = new[] { "test" }, Meta = "a!b@c" }; Caller.quit = new Action <QuitAction>(res => { }); Caller.action = new Action <Action>(res => { }); var action = quitHandler.Msg(Talker, Caller, msg) as QuitAction; Assert.IsNotNull(action); CollectionAssert.AreEqual(new[] { "test-a", "test-c" }, action.ChatNames.ToArray()); }
public void TestQuitRemoveName() { AddChatUsers("test-a", "a", "b", "c"); AddChatUsers("test-b", "b", "c"); AddChatUsers("test-c", "a", "c"); var quitHandler = new QuitHandler(); var msg = new MsgEventArgs { Command = "QUIT", Data = new[] { "test" }, Meta = "a!b@c" }; Caller.quit = new Action <QuitAction>(res => { }); quitHandler.Msg(Talker, Caller, msg); CollectionAssert.AreEqual(new[] { "b", "c" }, Talker.Chats["test-a"].Users.Select(u => u.IrcUser.Nick).ToArray()); CollectionAssert.AreEqual(new[] { "b", "c" }, Talker.Chats["test-b"].Users.Select(u => u.IrcUser.Nick).ToArray()); CollectionAssert.AreEqual(new[] { "c" }, Talker.Chats["test-c"].Users.Select(u => u.IrcUser.Nick).ToArray()); }
public void TestQuit() { var quitHandler = new QuitHandler(); var msg = new MsgEventArgs { Command = "QUIT", Data = new[] { "test" }, Meta = "a!b@c" }; var visited = false; Caller.quit = new Action <QuitAction>(res => { Assert.AreEqual("test", res.Message); var user = res.User; Assert.AreEqual("a", user.Nick); Assert.AreEqual("b", user.Name); Assert.AreEqual("c", user.Host); visited = true; }); quitHandler.Msg(Talker, Caller, msg); Assert.IsTrue(visited); }
public void TestOnlyTriggerOnQuit() { var quitHandler = new QuitHandler(); Assert.AreEqual("QUIT", quitHandler.ForCommand()); }
//读取库存报告模板并另存报告,且直接下载 public void GenerateFBAInventoryReport(FBAInventoryInfo info) { _ws = _wb.Worksheets[1]; _ws.Cells[4, 2] = info.Customer; _ws.Cells[4, 4] = info.CloseDate.ToString("yyyy-MM-dd"); _ws.Cells[4, 6] = info.CurrentTotalCtns - info.CurrentLooseCtns; _ws.Cells[4, 8] = info.CurrentLooseCtns; _ws.Cells[6, 2] = info.CurrentTotalPlts; _ws.Cells[6, 4] = info.TotalPickingPlts; _ws.Cells[6, 6] = info.CurrentTotalCtns; _ws.Cells[6, 8] = info.TotalPickingCtns; var startRow = 9; foreach (var i in info.FBACtnInventories) { _ws.Cells[startRow, 1] = i.Container; _ws.Cells[startRow, 2] = i.SubCustomer; _ws.Cells[startRow, 3] = i.Type; _ws.Cells[startRow, 4] = i.ShipmentId; _ws.Cells[startRow, 5] = i.AmzRefId; _ws.Cells[startRow, 6] = i.WarehouseCode; _ws.Cells[startRow, 7] = Math.Round(i.GrossWeightPerCtn, 2); _ws.Cells[startRow, 8] = Math.Round(i.CBMPerCtn, 2); _ws.Cells[startRow, 9] = i.OriginalQuantity; _ws.Cells[startRow, 10] = i.PickingCtns; _ws.Cells[startRow, 11] = Math.Round((double)i.ResidualQuantity, 2); _ws.Cells[startRow, 12] = Math.Round((double)i.HoldQuantity, 2); _ws.Cells[startRow, 13] = i.Location; startRow += 1; } _ws.get_Range("A1:M" + startRow, Type.Missing).HorizontalAlignment = XlVAlign.xlVAlignCenter; _ws.get_Range("A1:M" + startRow, Type.Missing).VerticalAlignment = XlVAlign.xlVAlignCenter; _ws.get_Range("A1:M" + startRow, Type.Missing).Borders.LineStyle = 1; _ws = _wb.Worksheets[2]; _ws.Cells[4, 2] = info.Customer; _ws.Cells[4, 4] = info.CloseDate.ToString("yyyy-MM-dd"); _ws.Cells[4, 6] = info.CurrentTotalCtns - info.CurrentLooseCtns; _ws.Cells[4, 8] = info.CurrentLooseCtns; _ws.Cells[6, 2] = info.CurrentTotalPlts; _ws.Cells[6, 4] = info.TotalPickingPlts; _ws.Cells[6, 6] = info.CurrentTotalCtns; _ws.Cells[6, 8] = info.TotalPickingCtns; startRow = 9; foreach (var g in info.FBAPalletGroupInventories) { var ctnIndex = startRow; _ws.Cells[startRow, 1] = g.PltId; _ws.Cells[startRow, 2] = g.Container; _ws.Cells[startRow, 3] = g.SubCustomer; _ws.Cells[startRow, 4] = g.ActualPlts; _ws.Cells[startRow, 5] = g.PickingPlts; _ws.Cells[startRow, 6] = g.AvailablePlts; _ws.Cells[startRow, 7] = g.Location; foreach (var c in g.InPalletCtnInventories) { _ws.Cells[ctnIndex, 8] = c.Id; _ws.Cells[ctnIndex, 9] = c.ShipmentId; _ws.Cells[ctnIndex, 10] = c.AmzRefId; _ws.Cells[ctnIndex, 11] = c.WarehouseCode; _ws.Cells[ctnIndex, 12] = c.GrossWeightPerCtn; _ws.Cells[ctnIndex, 13] = c.CBMPerCtn; _ws.Cells[ctnIndex, 14] = c.OriginalQuantity; _ws.Cells[ctnIndex, 15] = c.PickingCtns; _ws.Cells[ctnIndex, 16] = c.ResidualQuantity; _ws.Cells[ctnIndex, 17] = c.HoldQuantity; ctnIndex += 1; } //如果一托盘里面有很多SKU,则合并托盘单元格 if (g.InPalletCtnInventories.Count > 1) { var rangeId = _ws.get_Range("A" + startRow, "A" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeId.Merge(rangeId.MergeCells); var rangeContainer = _ws.get_Range("B" + startRow, "B" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeContainer.Merge(rangeContainer.MergeCells); var rangeSunCustomer = _ws.get_Range("C" + startRow, "C" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeSunCustomer.Merge(rangeSunCustomer.MergeCells); var rangeOrgPlt = _ws.get_Range("D" + startRow, "D" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeOrgPlt.Merge(rangeOrgPlt.MergeCells); var rangePlt = _ws.get_Range("E" + startRow, "E" + (startRow + g.InPalletCtnInventories.Count - 1)); rangePlt.Merge(rangePlt.MergeCells); var rangeStockPlt = _ws.get_Range("F" + startRow, "F" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeStockPlt.Merge(rangeStockPlt.MergeCells); var rangeLocation = _ws.get_Range("G" + startRow, "G" + (startRow + g.InPalletCtnInventories.Count - 1)); rangeLocation.Merge(rangeLocation.MergeCells); } startRow += g.InPalletCtnInventories.Count; } _ws.get_Range("A1:O" + startRow, Type.Missing).HorizontalAlignment = XlVAlign.xlVAlignCenter; _ws.get_Range("A1:O" + startRow, Type.Missing).VerticalAlignment = XlVAlign.xlVAlignCenter; _ws.get_Range("A1:O" + startRow, Type.Missing).Borders.LineStyle = 1; var fullPath = @"D:\InventoryReport\FBA-" + info.Customer + "-InventoryReport-" + DateTime.Now.ToString("yyyyMMddhhmmssffff") + ".xls"; _wb.SaveAs(fullPath, Type.Missing, "", "", Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, 1, false, Type.Missing, Type.Missing, Type.Missing); _excel.Quit(); //使用主线程调用委托,等于用主线程调用Quick()方法,以达到阻塞线程的目的 var handler = new QuitHandler(_excel.Quit); handler.Invoke(); var response = HttpContext.Current.Response; var downloadFile = new FileInfo(fullPath); response.ClearHeaders(); response.Buffer = false; response.ContentType = "application/octet-stream"; response.AppendHeader("Access-Control-Allow-Origin", "*"); response.AppendHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE"); response.AppendHeader("Access-Control-Allow-Headers", "Content-Type"); response.AppendHeader("Content-Disposition", "attachment; filename=" + info.Customer + "-Inventory Report-" + HttpUtility.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls", System.Text.Encoding.UTF8)); response.Clear(); response.AppendHeader("Content-Length", downloadFile.Length.ToString()); response.WriteFile(downloadFile.FullName); response.Flush(); response.Close(); response.End(); var killer = new ExcelKiller(); killer.Dispose(); }
public void SetUp() { theSession = MockRepository.GenerateStub <ISmtpSession>(); theHandler = new QuitHandler(); theToken = new SmtpToken(); }