public ActionResult Verify(DownloadEnum download) { var stringKey = Identity.UserID + ParameterManager.ParameterKey; var parameter = SessionHelper.GetSession(stringKey) as SheetVerifyParameter; //var parameter = RedisManager.Get<SheetVerifyParameter>(, RedisManager.Client); if (parameter == null) { return(Content("未获取查询条件!")); } var list = Core.VerifyViewManager.Search(parameter, true); if (list == null) { return(Content("未读取到报销单信息")); } IWorkbook workbook = ExcelManager.WriteVerify(list, download); if (workbook == null) { return(Content("创建表格失败!")); } var ms = new MemoryStream(); workbook.Write(ms); ms.Flush(); byte[] fileContents = ms.ToArray(); return(File(fileContents, ParameterManager.ExcelContentType, string.Format("{0} {1}.xls", download.GetDescription(), DateTime.Now.ToString(ParameterManager.TimeContentType)))); }
public WebPage(string url, string draftFilespec = null, string filespec = null, DownloadEnum download = DownloadEnum.Ignore, LocaliseEnum localise = LocaliseEnum.Ignore) { Url = url; // caller must present as absolute, e.g. by convert(base,relative) DraftFilespec = draftFilespec; Filespec = filespec; Download = download; Localise = localise; }
public static void Downloader(object obj) { FileStream fs = null; Stream stream = null; try { DownloadEnum download = (DownloadEnum)obj; Debug.Log($"开始下载{download.Url}"); if (File.Exists(download.Path)) { File.Delete(download.Path); } string tempFile = download.Path + ".temp"; if (File.Exists(tempFile)) { File.Delete(tempFile); } fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite); HttpWebRequest request = WebRequest.CreateHttp(download.Url); request.Method = "GET"; request.Timeout = 1000; HttpWebResponse response = request.GetResponse() as HttpWebResponse; stream = response.GetResponseStream(); byte[] data = new byte[1024]; int size = stream.Read(data, 0, data.Length); while (size > 0) { fs.Write(data, 0, size); size = stream.Read(data, 0, data.Length); } fs.Close(); stream.Close(); File.Move(tempFile, download.Path); download.callback(); } catch (Exception e) { Debug.LogError(e); } finally { if (fs != null) { fs.Close(); } if (stream != null) { stream.Close(); } } }
public static IWorkbook WriteVerify(List <VerifyView> list, DownloadEnum download) { switch (download) { case DownloadEnum.Transfer_Sheet: return(WriteTransfer(list)); //default: // return null; } return(null); }
private void btnInstall_Click(object sender, RoutedEventArgs e) { if (!this.ValidateData()) { return; } this.SetStatusControl(true); if (!Directory.Exists(this.strUpdateDirectoty)) { Directory.CreateDirectory(this.strUpdateDirectoty); } string str = this.strUpdateDirectoty + "\\PsExec.exe"; if (!System.IO.File.Exists(str)) { this.strLinkDownload = this.strPsExecLink; this.DownloadFile(this.strLinkDownload, str); } switch (this.tabMain.SelectedIndex) { case 0: this.strFileDownloaded = this.tbSetupFile.Text; if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(this.tbSetupFile.Text, string.Empty, false) != 0 && !System.IO.File.Exists(this.tbSetupFile.Text)) { this.eDownload = DownloadEnum.SQL; this.lblRunning.Text = "Download SQL..."; this.isThreadRunning = true; this.DownloadAsync(this.strLinkDownload, this.strFileDownloaded); while (this.isThreadRunning) { DoEvents(); } } if (Microsoft.VisualBasic.CompilerServices.Operators.CompareString(new FileInfo(this.strFileDownloaded).Extension, ".zip", false) == 0) { this.ExtractFile(this.strFileDownloaded); } this.InstallSQL(); if (CommonFunction.CheckServicesStart("MSSQL$" + this.tbInstanceName.Text)) { CommonFunction.ShowInfomation("Cài đặt thành công.\r\nMật khẩu tài khoản sa: 12345678@Abc"); } break; } }
public static IWorkbook WriteSheets(List <Sheet> list, DownloadEnum download) { switch (download) { case DownloadEnum.Sheet: return(WriteAllSheet(list)); case DownloadEnum.Daily_Sheet: return(WriteDaily(list.Where(e => e.Type == SheetType.Daily).ToList())); case DownloadEnum.Errand_Sheet: return(WriteErrand(list.Where(e => e.Type == SheetType.Errand).ToList())); case DownloadEnum.Transfer_Sheet: return(WriteTransfer(list.Where(e => e.Type == SheetType.Transfer).ToList())); case DownloadEnum.Reception_Sheet: return(WriteReception(list.Where(e => e.Type == SheetType.Reception).ToList())); } return(null); }
public IEnumerator Download(Action <string, long, long> addData) { long total = downloadQueue.Select(x => x.Size).ToList().Sum(); addData("下载资源中", 0, total); while (downloadQueue.Count > 0) { var info = downloadQueue.Dequeue(); var download = new DownloadEnum() { Url = httpAddress + info.Name + "@" + info.MD5, Path = Application.streamingAssetsPath + "/" + info.Name, callback = () => { addData(null, info.Size, total); } }; yield return(null); HttpUtil.Downloader(download); } }
public ActionResult Sheet(DownloadEnum download) { var stringkey = string.Format("{0}{1}", Identity.UserID, ParameterManager.ShentuKey); var list = SessionHelper.GetSession(stringkey) as List <Sheet>; //var list = RedisManager.Get<List<Sheet>>(string.Format("{0}{1}", Identity.UserID, ParameterManager.ShentuKey), RedisManager.Client); if (list == null) { return(Content("未读取到报销单信息")); } IWorkbook workbook = ExcelManager.WriteSheets(list, download); if (workbook == null) { return(Content("创建表格失败")); } var ms = new MemoryStream(); workbook.Write(ms); ms.Flush(); byte[] fileContents = ms.ToArray(); return(File(fileContents, ParameterManager.ExcelContentType, string.Format("{0} {1}.xls", download.GetDescription(), DateTime.Now.ToString(ParameterManager.TimeContentType)))); }
/// <summary> /// Initializes a new instance of the <see cref="VideoMetadataInteractionsBuy" /> class. /// </summary> /// <param name="currency">The currency code for the current user's region. (required).</param> /// <param name="displayPrice">Formatted price to display to buy an On Demand video. (required).</param> /// <param name="download">The user's download access to this On Demand video: Option descriptions: * `available` - The video is available for download. * `purchased` - The user has purchased the video. * `restricted` - The user isn't permitted to download the video. * `unavailable` - The video isn't available for download. (required).</param> /// <param name="drm">Whether the video has DRM. (required).</param> /// <param name="link">The URL to buy the On Demand video on Vimeo. (required).</param> /// <param name="price">The numeric value of the price for buying the On Demand video. (required).</param> /// <param name="purchaseTime">The time in ISO 8601 format when the On Demand video was purchased. (required).</param> /// <param name="stream">The user's streaming access to this On Demand video: Option descriptions: * `available` - The video is available for streaming. * `purchased` - The user has purchased the video. * `restricted` - The user isn't permitted to stream the video. * `unavailable` - The video isn't available for streaming (required).</param> /// <param name="uri">The product URI to purchase the On Demand video. (required).</param> public VideoMetadataInteractionsBuy(string currency = default(string), string displayPrice = default(string), DownloadEnum download = default(DownloadEnum), bool drm = default(bool), string link = default(string), decimal?price = default(decimal?), string purchaseTime = default(string), StreamEnum stream = default(StreamEnum), string uri = default(string)) { // to ensure "currency" is required (not null) this.Currency = currency ?? throw new ArgumentNullException("currency is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "displayPrice" is required (not null) this.DisplayPrice = displayPrice ?? throw new ArgumentNullException("displayPrice is a required property for VideoMetadataInteractionsBuy and cannot be null"); this.Download = download; this.Drm = drm; // to ensure "link" is required (not null) this.Link = link ?? throw new ArgumentNullException("link is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "price" is required (not null) this.Price = price ?? throw new ArgumentNullException("price is a required property for VideoMetadataInteractionsBuy and cannot be null"); // to ensure "purchaseTime" is required (not null) this.PurchaseTime = purchaseTime ?? throw new ArgumentNullException("purchaseTime is a required property for VideoMetadataInteractionsBuy and cannot be null"); this.Stream = stream; // to ensure "uri" is required (not null) this.Uri = uri ?? throw new ArgumentNullException("uri is a required property for VideoMetadataInteractionsBuy and cannot be null"); }