public UploadData resetToCraftedVersion(SerializedVersion serV) { FBVersion newVersion = FBVersion.deserialize(serV.encodedVersion); FBVersion current = this.currentVersion(); return(this.resetInternals(newVersion, current)); }
public bool newTransaction(SerializedVersion newVersion) { this.checkAuthentication(); if (this.transactionEnabled) { throw new FaultException <ServiceErrorMessage>(new ServiceErrorMessage(ServiceErrorMessage.TRANSACTIONALREADYENABLED)); } FBVersion vers = FBVersion.deserialize(newVersion.encodedVersion); FBVersion current = FBVersion.deserialize(this.getCurrentVersion().encodedVersion); if (vers.Equals(current)) { return(false); } this.transactionEnabled = true; this.inSyncVersion = vers; String newDirPath = this.user.rootDirectory.FullName; newDirPath += "\\" + this.inSyncVersion.timestamp.ToString(directoryFormat, CultureInfo.InvariantCulture); this.transactDir = Directory.CreateDirectory(newDirPath); if (this.transactDir == null) { throw new FaultException <ServiceErrorMessage>(new ServiceErrorMessage(ServiceErrorMessage.CREATEVERSIONDIRECTORYFAILED)); } necessaryFiles = new ThreadSafeList <FBFile>(FBVersion.getNecessaryFilesToUpgrade(this.inSyncVersion, this.realFiles.filesAlreadyRepresented())); return(true); }
public UploadData getFile(SerializedVersion serV) { FBVersion ver = FBVersion.deserialize(serV.encodedVersion); PhysicFile found = null; if (ver.fileList.Count != 1) { return(null); } foreach (FBFile file in ver.fileList) { found = findPhysicFile(file); if (found == null) { return(null); } } FileStream fStream = new FileStream(found.getRealFileInfo().FullName, FileMode.Open, FileAccess.Read); String token = Server.GetUniqueKey(20); var secDown = new SecureDownloader(this, token, null, null, fStream); return(new UploadData(UsefullMethods.GetLocalIPAddress(), secDown.port, token)); }
private void buildGraphic() { SerializedVersion[] sversions = null; try { sversions = server.getOldVersions(); } catch { UsefullMethods.setLabelAlert("danger", this.errorBox, "No internet connection!Check it and retry"); return; } this.versions = new FBVersion[sversions.Length]; int i = 0; se.watcher.EnableRaisingEvents = false; versionBox.Items.Clear(); foreach (SerializedVersion v in sversions) { versions[i] = FBVersion.deserialize(v.encodedVersion); System.Windows.Controls.Button button = new System.Windows.Controls.Button(); button.Name = versions[i].timestamp.ToString(TIMESTAMP_FORMAT); button.Content = versions[i].timestamp.ToString("MMM, dd yyyy HH:mm"); button.Click += versionClick; button.MinWidth = 200; button.MinHeight = 22; if (i == sversions.Length - 1) { Color c = (Color)ColorConverter.ConvertFromString("#FF9C1A04"); button.Background = new SolidColorBrush(c); c = (Color)ColorConverter.ConvertFromString("#FFFFFFFF"); button.Foreground = new SolidColorBrush(c); } else { Color c = (Color)ColorConverter.ConvertFromString("#FFFFFFFF"); button.Background = new SolidColorBrush(c); c = (Color)ColorConverter.ConvertFromString("#FF000000"); button.Foreground = new SolidColorBrush(c); } versionBox.Items.Add(button); versionButtons.Add(button); i++; } versionView.Items.Clear(); if (versions.Length > 0) { this.selectedVersion = versions[versions.Length - 1]; versionView.Items.Add(CreateDirectoryNode(this.selectedVersion.root, this.selectedVersion.root.Name)); this.revertVersion.IsEnabled = false; } }
public void GetOldVersionsTest() { doTransaction(); server.commit(); SerializedVersion[] serVers = server.getOldVersions(); Assert.IsTrue(serVers.Length == 1); foreach (SerializedVersion serVer in serVers) { FBVersion ver = FBVersion.deserialize(serVer.encodedVersion); Assert.IsFalse(ver.root.Name.Contains("1970")); } }