protected void Page_Load(object sender, EventArgs e) { var df = new DownloadFiles(); int type = 0; try { type = Convert.ToInt32(ddlCategory.SelectedValue); } catch (Exception ex) { Logger.LogException(ex, "Localization.aspx"); } if (!string.IsNullOrEmpty(Request["items"])) { var files = df.GetByTypeId(type).OrderByDescending(p => p.ID).ToList(); rptFile.DataSource = files; } else { var files = df.GetByTypeId(type).OrderByDescending(p => p.ID).Take(5).ToList(); rptFile.DataSource = files; } rptFile.DataBind(); }
public DownloadFilesResponse Get(DownloadFiles filesInfo) { return(new DownloadFilesResponse { Result = _fileExchange.DownloadFilesList(filesInfo.downloads) }); }
public ActionResult About(string fileName) { ViewBag.Message = "Click The Download Button to Download"; var obj = new DownloadFiles(); var filesCollection = obj.GetFiles().Where(f => f.FileName.Contains(fileName)); return(View(filesCollection)); }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_uriSourceUri">The uri that points to the external source of the mod.</param> /// <param name="p_strDefaultSourcePath">The default source path of the mod.</param> /// <param name="p_enmDownloadFiles">The list of files that still need to be downloaded to build the mod.</param> /// <param name="p_tstStatus">The status of the task that is adding the mod.</param> public AddModDescriptor(Uri p_uriSourceUri, string p_strDefaultSourcePath, IEnumerable <Uri> p_enmDownloadFiles, TaskStatus p_tstStatus, List <string> p_lstSourceName) : this() { SourceUri = p_uriSourceUri; DefaultSourcePath = p_strDefaultSourcePath; if (p_enmDownloadFiles != null) { DownloadFiles.AddRange(p_enmDownloadFiles); } SourceName = p_lstSourceName; Status = p_tstStatus; }
/// <summary> /// Update the installed package file details. /// </summary> /// <param name="id"></param> /// <param name="name"></param> /// <param name="version"></param> /// <param name="downloadFiles"></param> public void UpdateInstalledPackageFile(int id, string name, string version, DownloadFiles downloadFiles) { InstalledPackageFiles.Remove(InstalledPackageFiles.First(x => x.Id.Equals(id))); InstalledPackageFiles.Add(new PackageFile { Id = id, Name = name, Version = version, DownloadFiles = downloadFiles }); }
public void NotifyUnmount(string cloudid) { var toremove = UploadFiles.Where(f => f.CloudId == cloudid).ToList(); foreach (var item in toremove) { UploadFiles.Remove(item); } toremove = DownloadFiles.Where(f => f.CloudId == cloudid).ToList(); foreach (var item in toremove) { DownloadFiles.Remove(item); } }
public void OnProviderDownloadStatisticsUpdated(CloudMount mount, StatisticUpdateReason reason, AStatisticFileInfo info) { var cloud = mount.CloudInfo; switch (reason) { case StatisticUpdateReason.DownloadAdded: { var item = new FileItemInfo(cloud.Id, info.Id) { CloudIcon = mount.Instance.CloudServiceIcon, FileName = info.FileName, FullPath = $"{mount.MountLetter}:{info.Path}", ErrorMessage = info.ErrorMessage, Total = info.Total, CloudName = cloud.Name }; DownloadFiles.Remove(item); DownloadFiles.Add(item); } break; case StatisticUpdateReason.DownloadFinished: { DownloadFiles.Remove(new FileItemInfo(cloud.Id, info.Id)); } break; case StatisticUpdateReason.DownloadFailed: { var item = UploadFiles.Single(f => f.Id == info.Id && f.CloudId == cloud.Id); item.ErrorMessage = info.ErrorMessage; DownloadFiles.Remove(item); DownloadFailedFiles.Add(item); if (DownloadFailedFiles.Count > 10) { DownloadFailedFiles.RemoveAt(DownloadFailedFiles.Count - 1); } } break; default: throw new ArgumentOutOfRangeException(); } }
public FileResult GetAllZip(string fileName) { var obj = new DownloadFiles(); var filesCollection = obj.GetFiles().Where(f => f.FileName.Contains(fileName)); using (ZipFile zip = new ZipFile()) { zip.AlternateEncodingUsage = ZipOption.AsNecessary; zip.AddDirectoryByName("Files"); foreach (DownLoadFileInformation file in filesCollection) { zip.AddFile(file.FilePath, "Files"); } string zipName = String.Format("Zip_{0}.zip", DateTime.Now.ToString("yyyy-MMM-dd-HHmmss")); using (MemoryStream memoryStream = new MemoryStream()) { zip.Save(memoryStream); return(File(memoryStream.ToArray(), "application/zip", zipName)); } } }
private void Clear(object obj) { var file = obj as DownloadFile; if (file.DownloadStatus == DownloadStatus.Downloading) { if (MessageBox.Show("ダウンロードを中止してもよろしいですか?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { //do no stuff return; } else { //do yes stuff file.client.CancelAsync(); DownloadFiles.Remove(file); } } else { DownloadFiles.Remove(file); } }
public FileResult Download(string FileID) { int CurrentFileID = Convert.ToInt32(FileID); var obj = new DownloadFiles(); var filesCol = obj.GetFiles(); string CurrentFileName = (filesCol.Where(fls => fls.FileId == CurrentFileID).Select(fls => fls.FilePath)).First(); string contentType = string.Empty; if (CurrentFileName.Contains(".png")) { contentType = "image/png"; } else if (CurrentFileName.Contains(".ico")) { contentType = "image/png"; } else { contentType = "image/*"; } return(File(CurrentFileName, contentType, CurrentFileName)); }
/// <summary> /// Deserializes the object from XML. /// </summary> /// <param name="reader">The xml reader from which to deserialize the object.</param> public void ReadXml(XmlReader reader) { bool booIsEmpty = reader.IsEmptyElement; if (booIsEmpty) { return; } reader.ReadStartElement(); reader.ReadStartElement("sourceUri"); XmlSerializer xsrSerializer = new XmlSerializer(typeof(string)); SourceUri = new Uri((string)xsrSerializer.Deserialize(reader)); reader.ReadEndElement(); reader.ReadStartElement("sourcePath"); xsrSerializer = new XmlSerializer(typeof(string)); SourcePath = (string)xsrSerializer.Deserialize(reader); reader.ReadEndElement(); booIsEmpty = reader.IsEmptyElement; try { reader.ReadStartElement("sourceName"); if (!booIsEmpty) { while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "string") { xsrSerializer = new XmlSerializer(typeof(string)); SourceName.Add((string)xsrSerializer.Deserialize(reader)); } reader.ReadEndElement(); } } catch { } finally { if (SourceName.Count == 0) { SourceName.Add("Default"); } } reader.ReadStartElement("defaultSourcePath"); xsrSerializer = new XmlSerializer(typeof(string)); DefaultSourcePath = (string)xsrSerializer.Deserialize(reader); reader.ReadEndElement(); try { reader.ReadStartElement("status"); xsrSerializer = new XmlSerializer(typeof(TaskStatus)); Status = (TaskStatus)xsrSerializer.Deserialize(reader); reader.ReadEndElement(); } catch { Status = TaskStatus.Paused; } booIsEmpty = reader.IsEmptyElement; reader.ReadStartElement("downloadFiles"); if (!booIsEmpty) { while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "file") { DownloadFiles.Add(new Uri(reader["path"])); booIsEmpty = reader.IsEmptyElement; reader.ReadStartElement("file"); if (!booIsEmpty) { reader.ReadEndElement(); } } reader.ReadEndElement(); } booIsEmpty = reader.IsEmptyElement; reader.ReadStartElement("downloadedFiles"); if (!booIsEmpty) { while (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "file") { DownloadedFiles.Add(reader["path"]); booIsEmpty = reader.IsEmptyElement; reader.ReadStartElement("file"); if (!booIsEmpty) { reader.ReadEndElement(); } } reader.ReadEndElement(); } reader.ReadEndElement(); }
public FileDownloadController() { obj = new DownloadFiles(); }
public EmployeeController() { obj = new DownloadFiles(); }
public HomeController() { obj = new DownloadFiles(); }
public AdminController() { obj = new DownloadFiles(); }
protected void ObjectDataSourceItemsList_OnDeleting(object sender, ObjectDataSourceMethodEventArgs e) { string path = WebConfigurationManager.AppSettings["DownloadFilesPath"]; DownloadFile d = e.InputParameters[0] as DownloadFile; DownloadFiles ds = new DownloadFiles(); DownloadFile f = d != null? ds.GetById(d.ID) : d ; if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(f.FileName) && f != null && d != null) { string rootpath = Path.Combine(path, f.FileName); if (File.Exists(rootpath)) { File.Delete(rootpath); } rootpath = Path.Combine(path, d.ID + ".jpg"); if (File.Exists(rootpath)) { File.Delete(rootpath); } } }
public FileProcessController() { obj = new DownloadFiles(); }
/// <summary> /// Updates the installed game mods. /// </summary> /// <param name="categoryId"></param> /// <param name="modId"></param> /// <param name="region"></param> /// <param name="noOfFiles"></param> /// <param name="dateInstalled"></param> /// <param name="downloadFiles"></param> public void UpdateInstalledGameMod(string categoryId, int modId, string region, int noOfFiles, DateTime dateInstalled, DownloadFiles downloadFiles) { RemoveInstalledGameMod(categoryId); InstalledGameMods.Add(new InstalledMod { CategoryId = categoryId, ModId = modId, Region = region, Files = noOfFiles, DateInstalled = dateInstalled, DownloadFiles = downloadFiles }); }
protected void GridViewItemsList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Download") { int id = int.Parse(e.CommandArgument.ToString()); DownloadUserForms duf = new DownloadUserForms(); List<DownloadUserForm> list = duf.GetByFileID(id); DownloadFiles df = new DownloadFiles(); var file = df.GetById(id); ReportOptions ro = new ReportOptions(); ro.Columns = "Email,FirstName,LastName"; ro.HeaderText = "Email,Имя,Фамилия"; ro.FileName = string.Format("csvreport_{0}_file.csv",file.FileName); new CsvHelper().WriteToCSV(list, ro); } }
public static void Server_FileCompleted(Packet p, Session s) { byte result = p.ReadByte(); // File downloaded var file = DownloadFiles[0]; System.Diagnostics.Debug.WriteLine($"Server_FileCompleted: {file.ID} - Result:{result}"); // Close the file m_FileStream.Close(); m_FileStream.Dispose(); // Process the file if (file.ImportToPk2) { // Get the Pk2 to open int pk2FileNameLength = file.Path.IndexOf("\\"); string pk2FileName = file.Path.Remove(pk2FileNameLength); // Open the Pk2 and insert the file if (Pk2Writer.Open(pk2FileName, LauncherSettings.CLIENT_BLOWFISH_KEY)) { if (Pk2Writer.ImportFile(file.Path.Substring(pk2FileNameLength + 1) + "\\" + file.Name, "Temp\\" + file.ID)) { System.Diagnostics.Debug.WriteLine($"File {file.Name} imported into the Pk2"); } // Close the Pk2 Pk2Writer.Close(); } // Delete the file File.Delete("Temp\\" + file.ID); } else { // Create an empty file to decompress (zlib) using (FileStream outFileStream = File.Create("Temp\\" + file.Name)) { using (FileStream inFileStream = new FileStream("Temp\\" + file.ID, FileMode.Open, FileAccess.Read)) { // Read past unknown bytes (4) and zlib header bytes (2) inFileStream.Seek(6, SeekOrigin.Begin); using (DeflateStream zlib = new DeflateStream(inFileStream, CompressionMode.Decompress)) { zlib.CopyTo(outFileStream); } } // Delete decompressed file File.Delete("Temp\\" + file.ID); } // Check file path if (file.Path != string.Empty) { // Create directory if doesn't exists if (!Directory.Exists(file.Path)) { Directory.CreateDirectory(file.Path); } // Fix path for easy file moving file.Path += "\\"; } // Check if it's the Launcher to process it at the end var launcherFilename = Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); if (file.Path == string.Empty && file.Name.Equals(launcherFilename, StringComparison.InvariantCultureIgnoreCase)) { ForceMovingFile("Temp\\" + file.Name, "Temp\\_" + file.Name); } else { // Move or replace from Temp to the folder required ForceMovingFile("Temp\\" + file.Name, file.Path + file.Name); } } // Remove the file and delete it from Temp DownloadFiles.RemoveAt(0); // Continue protocol if (DownloadFiles.Count > 0) { RequestFileDownload(s); } else { System.Diagnostics.Debug.WriteLine($"Download finished!"); // Update SV.T on media.pk2 UpdateSilkroadVersion(); // Update done! LauncherViewModel.Instance.IsUpdating = false; // Dispose pk2 writer Pk2Writer.Deinitialize(); // Replace the Launcher if exists if (File.Exists("Temp\\_" + Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName))) { // Replace launcher required StartReplacer(); } else { // Update launcher version LauncherViewModel.Instance.Version = DownloadVersion; LauncherViewModel.Instance.CanStartGame = true; // Stop connection s.Stop(); } } }
private void Save() { if (DetailsViewEditItem.CurrentMode == DetailsViewMode.Insert) { Logger.LogInfo("DetailsViewEditItem.CurrentMode == DetailsViewMode.Insert", "DownloadFiles"); try { //DetailsViewEditItem.InsertItem(false); DownloadFile downloadFile = new DownloadFile(); var fu = DetailsViewEditItem.FindControl("fuFile") as FileUpload; if (fu != null && fu.HasFile) { downloadFile.FileName = fu.PostedFile.FileName; downloadFile.MimeType = fu.PostedFile.ContentType; string path = WebConfigurationManager.AppSettings["DownloadFilesPath"]; string filePath = Path.Combine(path, downloadFile.FileName); Logger.LogInfo("FileUpload exists", "DownloadFiles"); fu.PostedFile.SaveAs(filePath); Logger.LogInfo("File was saved " + filePath, "DownloadFiles"); } var txtName = DetailsViewEditItem.FindControl("txtName") as TextBox; if (txtName != null) { Logger.LogInfo("txtName exists ", "DownloadFiles"); downloadFile.Name = txtName.Text; } var txtDescription = DetailsViewEditItem.FindControl("txtDescription") as TextBox; if (txtDescription != null) { downloadFile.Description = txtDescription.Text; } var ddl = DetailsViewEditItem.FindControl("ddlCategory") as DropDownList; if (ddl != null) { downloadFile.TypeId = Convert.ToInt32(ddl.SelectedValue); } DownloadFiles m = new DownloadFiles(); Logger.LogInfo("Saving DownloadFiles ", "DownloadFiles"); m.Add(downloadFile); Logger.LogInfo("Saved DownloadFiles ", "DownloadFiles"); ID = downloadFile.ID; uploadImage(); // DetailsViewEditItem.ChangeMode(DetailsViewMode.Edit); } catch (Exception ex) { Logger.LogException(ex, "DownloadFiles"); ShowError(ex); } } else if (DetailsViewEditItem.CurrentMode == DetailsViewMode.Edit) { Logger.LogInfo("DetailsViewEditItem.CurrentMode == DetailsViewMode.Edit", "DownloadFiles"); DetailsViewEditItem.UpdateItem(false); } }
public async Task <IActionResult> DownloadFile() { DownloadFiles file = await _logic.DownLoadFileOfCourse(Request.Query.Keys.FirstOrDefault()); return(File(file.mem, file.myme, file.path)); }