public void Handle(UpdateFile update) { this.BeginOnUIThread(() => { var panel = List.ItemsPanelRoot as ItemsStackPanel; if (panel == null) { return; } if (panel.FirstCacheIndex < 0) { return; } //for (int i = panel.FirstCacheIndex; i <= panel.LastCacheIndex; i++) for (int i = 0; i < ViewModel.Items.Count; i++) { var chat = ViewModel.Items[i]; if (chat.UpdateFile(update.File)) { var container = List.ContainerFromItem(chat) as ListViewItem; if (container == null) { return; } var content = container.ContentTemplateRoot as Grid; var photo = content.Children[0] as ProfilePicture; photo.Source = PlaceholderHelper.GetChat(null, chat, 36); } } }); }
public UpdateFileDto(UpdateFile updateFile) { _directory = updateFile.DestinationFolder; _file = updateFile.Name; _operation = DecodeUpdateOperation(updateFile.UpdateOperation); _updateType = DecodeUpdateType(updateFile.UpdateType); }
public wsusUpdate(UpdateFile src) { this.fileHashFromWSUS = src.Hash; this.downloadURI = src.OriginUri.ToString(); this.sizeBytes = src.TotalBytes; this.filename = getTemporaryFilename(); }
public void Rename_File() { var rnd = new Random(); var data = new byte[100]; rnd.NextBytes(data); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Upload a file var upload = _filesApi.CreateFile(fileName, _testFolder, data.Length, data); //Create new unique file name var newFileName = Guid.NewGuid().ToString(); //Create UpdateFile DTO var update = new UpdateFile(_testFolder, newFileName); //Rename file var renamedFile = _filesApi.UpdateFileMetadata(upload.Id, update); Assert.AreEqual(upload.Id, renamedFile.Id); Assert.AreEqual(newFileName, renamedFile.Name); }
public void DoNotCreatePartialOutputFileIfExceptionDuringProcessWhenIndicated() { Assert.Throws <ArgumentException>(() => UpdateFile.Update(@"TestUpdateFiles\TestSubstitution5.xml", @"TestUpdateFiles\TestConfig1.xml")); var fileName = @"TestUpdateFiles\TestConfig1.xml_partial"; Assert.False(File.Exists(fileName)); }
private static void ProcessUpdate() { Console.WriteLine("Fetching update info..."); UpdateFile update = new UpdateFile(); update.ReadXmlFromInterweb("http://www.xobanimot.com/snakebite/update/update.xml"); var SBVersion = GetSBVersion(); var UpdaterVersion = GetUpdaterVersion(); if (update.Updater.Version.AsVersion() > UpdaterVersion) { Console.WriteLine(String.Format("Updating SBUpdater to version {0}...", update.Updater.Version.AsString())); // Process updating the updater DownloadAndUpdateUpdater(update.Updater.URL); } else { Console.WriteLine("SBUpdater is up to date."); } if (update.SnakeBite.Version.AsVersion() > SBVersion) { Console.WriteLine(String.Format("Updating SnakeBite to version {0}...", update.SnakeBite.Version.AsString())); // Process updating SnakeBite DownloadAndUpdateSnakeBite(update.SnakeBite.URL); } else { Console.WriteLine("SnakeBite is up to date."); } Process.Start("SnakeBite.exe"); }
public void Create_Rename_Download_Delete_File() { var fileName = Guid.NewGuid().ToString(); var rnd = new Random(); var data = new byte[50]; rnd.NextBytes(data); var create = _filesApi.CreateFile(fileName, "/SDK_Test_Folder", 50, data); Assert.That(create.Name, Is.EqualTo(fileName)); Assert.That(create.Path, Is.EqualTo("/SDK_Test_Folder")); var newName = Guid.NewGuid().ToString(); var updateFile = new UpdateFile("/SDK_Test_Folder", newName); var update = _filesApi.UpdateFileMetadata(create.Id, updateFile); Assert.That(update.Name, Is.EqualTo(newName)); Assert.That(update.Path, Is.EqualTo("/SDK_Test_Folder")); Assert.That(update.Id, Is.EqualTo(create.Id)); var download = _filesApi.DownloadFile(update.Id); var endData = new byte[50]; download.Read(endData); Assert.That(endData, Is.EqualTo(data)); _filesApi.DeleteFile(update.Id); Assert.Throws <ApiException>(() => _filesApi.GetFile(create.Id)); }
public void Handle(UpdateFile update) { BeginOnUIThread(() => { Delegate?.UpdateFile(update.File); }); }
public UpdateAppFileInfo(string filename) { var updateFile = UpdateFile.Open(filename); archiveEntries = updateFile.Select(e => new UpdateEntryViewModel(this, filename, e)) .ToList(); }
public void OnUpdateFile(DeploymentFile file) { UpdateFile?.Invoke(new UpdateEventArgs { File = file, }); }
public void Move_File() { var rnd = new Random(); var data = new byte[100]; rnd.NextBytes(data); //Create a unique file name var fileName = Guid.NewGuid().ToString(); //Create a unique folder name var folderName = Guid.NewGuid().ToString(); //Upload a file var upload = _filesApi.CreateFile(fileName, _testFolder, data.Length, data); //Create a folder var createFolder = new CreateFolder(_testFolder, folderName); var folder = _foldersApi.CreateFolder(createFolder); //Create UpdateFile DTO var update = new UpdateFile(_testFolder + "/" + folder.Name, fileName); //Move a file var movedFile = _filesApi.UpdateFileMetadata(upload.Id, update); Assert.AreEqual(upload.Id, movedFile.Id); Assert.AreEqual(_testFolder + "/" + folder.Name, movedFile.Path); }
public async void Handle(UpdateFile update) { var file = update.File; if (_mapping.TryGetValue(file.Id, out List <EmojiSet> sets)) { foreach (var set in sets) { set.UpdateFile(file); } var emojiSet = sets.FirstOrDefault(); if (emojiSet == null) { return; } if (file.Local.IsFileExisting()) { var folder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("emoji", CreationCollisionOption.OpenIfExists); await TryCopyPartLocally(folder, file.Local.Path, emojiSet.Id, emojiSet.Version, file.Id == emojiSet.Document.Id); var current = _settings.Appearance.EmojiSet; if (file.Id == emojiSet.Document.Id && current.Id == emojiSet.Id && current.Version <= emojiSet.Version) { await UpdateAsync(); } } } }
/** * Add file. * Add a single file. * @param version current version number * @param file informations about file to update * @see CopyFileToLocal() * @see ReportMessage() * @return update status */ public UpdateStatus AddFile(string version, UpdateFile file) { // Get file from remote location. string localPath = base.CopyFileToLocal(version, file); if (localPath == "0") { return(UpdateStatus.FAILED); } // Copy file to installed version. if (!File.Exists(localPath)) { return(UpdateStatus.FAILED); } try { string finalPath = new StringBuilder() .Append(SettingsManager.Instance.BasePath) .Append(Path.DirectorySeparatorChar) .Append(file.DestinationFolder) .Append(Path.DirectorySeparatorChar) .Append(file.Name) .ToString(); if (!Directory.Exists(Path.GetDirectoryName(finalPath))) { Directory.CreateDirectory(Path.GetDirectoryName(finalPath)); } File.Copy(localPath, finalPath, true); } catch (Exception ex) { ReportMessage(ex.Message); return(UpdateStatus.FAILED); } // Delete from download directory. File.Delete(localPath); return(UpdateStatus.OK); }
/// <summary> /// Downloads a single file belonging to an update package. Supports resuming a partial download /// </summary> /// <param name="destinationFilePath">Download destination file.</param> /// <param name="updateFile">The update file to download.</param> /// <param name="cancellationToken">Cancellation token</param> public void DownloadToFile( string destinationFilePath, UpdateFile updateFile, CancellationToken cancellationToken) { if (!File.Exists(destinationFilePath)) { // Destination file does not exist; create it and then download it using (var fileStream = File.Create(destinationFilePath)) { DownloadToStream(fileStream, updateFile, 0, cancellationToken); } } else { // Destination file exists; if only partially downloaded, seek to the end and resume download // from where we left off using (var fileStream = File.Open(destinationFilePath, FileMode.Open, FileAccess.Write)) { if (fileStream.Length != (long)updateFile.Size) { fileStream.Seek(0, SeekOrigin.End); DownloadToStream(fileStream, updateFile, fileStream.Length, cancellationToken); } } } }
public async Task UpdateFile(UpdateFile file) { //var dbFile = await _fileRepository.GetFilesAsync(file.FileId); //dbFolder.Name = folder.Name; //dbFolder.Date = DateTime.Now; //await _folderRepository.UpdateFolder(dbFolder); }
static bool LoadLastUpdateFile() { _updateFiles = new UpdateFile(); if (File.Exists(_updateFileName)) { try { string[] content = File.ReadAllLines(_updateFileName); if (content != null) { for (int i = 0; i < content.Length - 1; i++) { if (!string.IsNullOrEmpty(content[i])) { string [] kvp = content[i].Split(','); if (kvp == null || kvp.Length < 2) { Debug.LogError("Can not parse last update file with content " + content[i]); return(false); } _updateFiles.files[kvp[0]] = kvp[1]; } } _updateFiles.resVersion = float.Parse(content[content.Length - 1]); } } catch (Exception ex) { throw new Exception("Load UpdateFile Error:" + ex.Message); return(false); } } return(true); }
public void UpdateAllWhenError_SingleError_ThrowsArgumentException() { var content = XDocument.Load(@"TestUpdateFiles\TestConfig1.xml"); Assert.Throws <ArgumentException>(() => UpdateFile.UpdateFiles(@"TestUpdateFiles\TestSubstitution32.xml", new Lazy <TagDictionary>(), false)); content.Save(@"TestUpdateFiles\TestConfig1.xml"); }
public void DoNotRemoveAttributesUnlessSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("quack", newConfig.XPathSelectElement("/root/value").Attribute("duckAttr").Value); }
public void SubstituteInNameSpacedFile() { var newConfig = XDocument.Parse(UpdateFile.Update(@"TestUpdateFiles\TestSubstitution3.xml", @"TestUpdateFiles\TestConfig2.xml")); var nms = new XmlNamespaceManager(new NameTable()); nms.AddNamespace("c", "http://madeup.com"); Assert.AreEqual("newvalue", newConfig.XPathSelectElement("/c:root/c:value", nms).Value); }
private void deleteFile_Click(object sender, RoutedEventArgs e) { var corpus = (Corpus)listCorpora.SelectedItem; var file = (ICorpora)listFiles.SelectedItem; corpusManager.RemoveFile(corpus, file); UpdateFile?.Invoke(); }
public void RemoveChildrenIfEmptyReplacementSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution8.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("", newConfig.XPathSelectElement("/root/value").Value); }
public void CondensedChangeAttributeStructure() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution28.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Attribute("myAttr").Value); }
public void CreatePartialOutputFileIfExceptionDuringProcessWhenIndicated() { Assert.Throws <NDjangoWrapper.NDjangoWrapperException>(() => UpdateFile.Update(@"TestUpdateFiles\TestSubstitution5.xml", @"TestUpdateFiles\TestConfig1.xml", outputFailureContext: true)); var fileName = @"TestUpdateFiles\TestConfig1.xml_partial"; Assert.IsTrue(File.Exists(fileName)); }
public void RemoveAttributesIfSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution8.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.IsNull(newConfig.XPathSelectElement("/root/value").Attribute("duckAttr")); }
public void ChangeValueOfAttributeWithFixedSub() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("after", newConfig.XPathSelectElement("/root/value").Attribute("myAttr").Value); }
public void JsonTest_WithFilePath() { dynamic newJson = JObject.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution37.xml", @"TestUpdateFiles\TestJson01.json" )); Assert.AreEqual("C:\\Temp", (string)newJson.Data); }
public void DoNotChangeChildrenUnlessNewValueSpecified() { var newConfig = XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution7.xml", @"TestUpdateFiles\TestConfig3.xml" )); Assert.AreEqual("oldValue", newConfig.XPathSelectElement("/root/value").Value); }
public void AddAttributeWhenAlreadyExists_ThrowsApplicationException() { var content = XDocument.Load(@"TestUpdateFiles\TestConfig1.xml"); Assert.Throws <ApplicationException>(() => UpdateFile.UpdateFiles(@"TestUpdateFiles\TestSubstitution34.xml", new Lazy <TagDictionary>(), false)); content.Save(@"TestUpdateFiles\TestConfig1.xml"); }
public void TestSubTime() { var time1 = new DateTime(2001, 1, 1, 12, 10, 0); var time2 = new DateTime(2001, 1, 1, 12, 15, 0); var file1 = new UpdateFile {LastWriteTime = time1}; var file2 = new UpdateFile {LastWriteTime = time2}; Assert.IsTrue(file1 < file2); Console.WriteLine(time1.Subtract(time2).TotalSeconds); }
/// <summary> /// Gets a read only stream for an update content file /// </summary> /// <param name="updateFile">The update file to open</param> /// <returns>Read only stream for the requested update content file</returns> public Stream Get(UpdateFile updateFile) { if (!Contains(updateFile)) { throw new Exception("The requested file is not downloaded"); } return(File.OpenRead(GetUpdateFilePath(updateFile))); }
public void InvalidSubstitutionXmlShouldThrow() { Assert.Throws <XmlSchemaValidationException>(() => XDocument.Parse(UpdateFile.Update( @"TestUpdateFiles\TestSubstitution20.xml", @"TestUpdateFiles\TestConfig2.xml", new Dictionary <string, object> { { "tagged", "after" }, { "Environment", "LOC" } } ))); }
/// <summary>Gets the size of the file.</summary> /// <param name="file">The <c>UpdateFile</c> to get the file size for.</param> /// <param name="fileLocation">The location for the file.</param> static void GetFileSize(ref UpdateFile file, string fileLocation = null) { file.FileSize = Utilities.GetFileSize( Utilities.ExpandInstallLocation( fileLocation ?? file.Destination, Core.AppInfo.Directory, Core.AppInfo.Platform, Core.AppInfo.ValueName)); }
private static void GenerateUpdateXml() { UpdateFile update = new UpdateFile(); update.SnakeBite.OldVersion = 800; update.SnakeBite.Version.Version = "0.8.0.0"; update.SnakeBite.URL = "http://www.xobanimot.com/snakebite/update/update.zip"; update.Updater.OldVersion = 2; update.Updater.Version.Version = "0.0.0.2"; update.Updater.URL = "http://www.xobanimot.com/snakebite/update/updater.zip"; update.WriteXml("test.xml"); }
public HttpResponseMessage Put(int agreementId, int fileId, [FromBody] AgreementFileApiModel model) { // PUT will only update the file's custom name and visibility properties model.AgreementId = agreementId; model.Id = fileId; var command = new UpdateFile(User); Mapper.Map(model, command); _updateHandler.Handle(command); var response = Request.CreateResponse(HttpStatusCode.OK, "Agreement file was successfully updated."); return response; }
/// <summary> /// Gets the Update Data from File /// </summary> /// <param name="file">The Update File</param> public static Update FromFile(string file) { if (string.IsNullOrEmpty(file)) return null; var update = new Update(); good morni (XmlReader reader = XmlReader.Create(file)) { while (reader.Read()) if (reader.IsStartElement()) switch (reader.Name) { case "Info": update.Name = reader["Name"]; update.ID = Convert.ToInt32(reader["ID"]); update.ChangeLog = reader["Changelog"]; break; case "UpdateFile": var upfile = new UpdateFile(Convert.ToDouble(reader["VersionID"])); upfile.FileID = Convert.ToInt32(reader["ID"]); upfile.Name = reader["Name"]; upfile.URL = reader["URL"]; upfile.OutPath = reader["Out"]; upfile.Add = Convert.ToBoolean(reader["Add"]); update.ListedUpdateFiles.Add(upfile); break; } } return update; }
private void formLauncher_Load(object sender, EventArgs e) { textInfo = cultureInfo.TextInfo; // Check for updates Debug.LogLine("[Update] Checking for updates"); UpdateFile updater = new UpdateFile(); bool updateSuccess = updater.ReadXmlFromInterweb("http://www.xobanimot.com/snakebite/update/update.xml"); if (updateSuccess) { if (updater.SnakeBite.Version.AsVersion() > ModManager.GetSBVersion()) { Debug.LogLine(String.Format("Update found! Version {0} is available", updater.SnakeBite.Version.AsVersion())); labelUpdate.Text = String.Format("SnakeBite version {0} now available!", updater.SnakeBite.Version.AsString()); labelUpdate.Show(); } else { Debug.LogLine("No update found"); } } // Retrieve and display version info var MGSVersionInfo = FileVersionInfo.GetVersionInfo(Properties.Settings.Default.InstallPath + "\\mgsvtpp.exe"); string SBVersion = Application.ProductVersion; string MGSVersion = MGSVersionInfo.ProductVersion; // Update version text string VersionText = String.Format("MGSV {0} / SB {1}", MGSVersion, SBVersion); labelVersion.Text = VersionText; UpdateVersionLabel(); UpdateModToggle(); SetupTheme(); // Fade in form Opacity = 0; int duration = 100;//in milliseconds int steps = 30; Timer timer = new Timer(); timer.Interval = duration / steps; int currentStep = 0; timer.Tick += (arg1, arg2) => { Opacity = ((double)currentStep) / steps; currentStep++; if (Opacity == 1) { timer.Stop(); timer.Dispose(); } }; timer.Start(); }
/// <summary>Calculates the hash.</summary> /// <param name="file">The <c>UpdateFile</c> to update the hash for.</param> /// <param name="fileLocation">The alternate location of the file.</param> void CalculateHash(ref UpdateFile file, string fileLocation = null) { this.hashesGenerating++; file.Hash = Utilities.GetHash( Utilities.ExpandInstallLocation( fileLocation ?? file.Destination, Core.AppInfo.Directory, Core.AppInfo.Platform, Core.AppInfo.ValueName)); }
/// <summary>Adds a file to the list.</summary> /// <param name="fullName">The full path to the file.</param> /// <param name="pathToFiles">The full directory path of the files being added.</param> /// <param name="impersonateAppDirectory"><c>True</c> to use use %INSTALLDIR% instead of real location of the file.</param> void AddFile(string fullName, string pathToFiles, bool impersonateAppDirectory) { string installDirectory = Utilities.IsRegistryKey(Core.AppInfo.Directory) ? Utilities.GetRegistryValue( Core.AppInfo.Directory, Core.AppInfo.ValueName, Core.AppInfo.Platform) : Core.AppInfo.Directory; installDirectory = impersonateAppDirectory ? pathToFiles : Utilities.ConvertPath(installDirectory, true, Core.AppInfo.Platform); string installUrl = fullName.Replace(installDirectory, @"%INSTALLDIR%\", true); installUrl = installUrl.Replace(@"\\", @"\"); string downloadUrl = fullName.Replace(installDirectory, @"%DOWNLOADURL%/", true); if (downloadUrl == fullName) { downloadUrl = @"%DOWNLOADURL%/" + Path.GetFileName(fullName); } else { downloadUrl = downloadUrl.Replace(@"\\", @"/"); downloadUrl = downloadUrl.Replace(@"\", @"/"); downloadUrl = downloadUrl.Replace(@"//", @"/"); } var file = new UpdateFile { Action = FileAction.Update, Destination = installUrl, Hash = Properties.Resources.CalculatingHash, Source = downloadUrl }; this.Dispatcher.BeginInvoke(new Action(() => Core.UpdateInfo.Files.Add(file))); this.CalculateHash(ref file, fullName); GetFileSize(ref file, fullName); }