public override FindValueResult<FileId, IEnumerable<FileLocation>> FindValue(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> FindValue(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.FindValue(key, callerIdentifier); }
public SearchResult(FileId fileId, IEnumerable<FileLocation> locations, IEnumerable<string> parts, IEnumerable<string> words) { FileId = fileId; Locations = locations; Preview = CreateDocument(words, parts); }
public override void Store(FileId key, IEnumerable<FileLocation> value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Store(key: {0}, value: {1}, callerIdentifier: {2})", key, value.WriteValues(), callerIdentifier); base.Store(key, value, callerIdentifier); }
private static void Main(string[] args) { var stringMetric = new LambdaMetric<string>(string.Compare); var reverseIndexCore = new ReverseIndexCore(new RoutingTable<string>(stringMetric), nodeid => new ReverseIndexServiceClient(new BasicHttpBinding(), new EndpointAddress( nodeid.ServiceUrl))); var reverseIndexContract = new ReverseIndexServiceContract(reverseIndexCore); var reverseIndexHost = new ServiceHost(reverseIndexContract); var fileIdMetric = new LambdaMetric<FileId>((f1, f2) => string.Compare(f1.FileHash, f2.FileHash)); var file2MachineCore = new FileToMachineCore(new RoutingTable<FileId>(fileIdMetric), nodeId => new FileToMachineClient(new BasicHttpBinding(), new EndpointAddress( nodeId.ServiceUrl))); var file2MachineContract = new FileToMachineServiceContract(file2MachineCore); var file2MachineHost = new ServiceHost(file2MachineContract); reverseIndexCore.NodeIdentifier = new NodeIdentifier<string>(reverseIndexHost.BaseAddresses[0].AbsoluteUri + "/ReverseIndex", Cryptography.GetRandomSH1()); file2MachineCore.NodeIdentifier = new NodeIdentifier<FileId>(file2MachineHost.BaseAddresses[0].AbsoluteUri + "/File", new FileId(Cryptography.GetRandomSH1(), "")); // var uniqueFile=new FileId("aloneFile","this file is referenc") for (int i = 1; i < 3; i++) { var file1 = new FileId("a" + i, string.Format("[{0}] -- String containing aaaaas.", i)); var file2 = new FileId("nb" + i, "other string containing BBBBs."); var uniq = new FileId("alone", string.Format("[{0} cadena b{0}]", i)); reverseIndexContract.StoreInto("a" + i, file1); reverseIndexContract.StoreInto("b", file2); reverseIndexContract.StoreInto("b" + i, uniq); file2MachineContract.Store(file1, new[] { new FileLocation("some service address"), new FileLocation("some service addres1s"), }); file2MachineContract.Store(file2, new[] {new FileLocation("some service address")}); file2MachineContract.Store(uniq, new[] {new FileLocation("some service address")}); } reverseIndexHost.Open(); file2MachineHost.Open(); Console.WriteLine("Both services are up and running..."); Console.WriteLine("Press <ENTER> to exit."); Console.ReadLine(); reverseIndexHost.Close(); file2MachineHost.Close(); }
public MessageViewModel(DateTime messageTime, string senderNick, FileId fileId, RoomViewModel roomVm) : this(Room.SpecificMessageId, roomVm, true) { this.fileId = fileId; Sender = new UserViewModel(senderNick, parentRoom); Progress = 0; var localMessageTime = messageTime.ToLocalTime(); Title = Localizer.Instance.Localize(FromKey, localMessageTime.ToString(TimeFormat)); var sizeDim = string.Empty; var size = 0L; using (var client = ClientModel.Get()) { var file = GetFile(client, fileId); if (file.Size < 1024) { sizeDim = Localizer.Instance.Localize(ByteStrKey); size = file.Size; } if (file.Size >= 1024 && file.Size < 1024 * 1024) { sizeDim = Localizer.Instance.Localize(KByteStrKey); size = file.Size / 1024; } if (file.Size >= 1024 * 1024) { sizeDim = Localizer.Instance.Localize(MByteStrKey); size = file.Size / (1024 * 1024); } Text = file.Name + string.Format(SizeFormat, size, sizeDim); } Type = MessageType.File; DownloadFileCommand = new Command(DownloadFile, _ => ClientModel.Api != null); NotifierContext.DownloadProgress += CreateSubscriber<FileDownloadEventArgs>(ClientDownloadProgress); NotifierContext.PostedFileDeleted += CreateSubscriber<FileDownloadEventArgs>(ClientPostedFileDeleted); }
public FileModel(FileId id, ITextBuffer textBuffer, Server server, Dispatcher dispatcher, IVsHierarchy hierarchy, string fullPath) { Hierarchy = hierarchy; FullPath = fullPath; Id = id; Server = server; _textBuffer = textBuffer; var snapshot = textBuffer.CurrentSnapshot; var empty = new CompilerMessage[0]; CompilerMessages = new CompilerMessage[KindCount][] { empty, empty, empty }; CompilerMessagesSnapshots = new ITextSnapshot[KindCount] { snapshot, snapshot, snapshot }; _errorListProviders = new ErrorListProvider[KindCount] { null, null, null}; server.Client.ResponseMap[id] = msg => dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<AsyncServerMessage>(msg2 => Response(msg2)), msg); server.Client.Send(new ClientMessage.FileActivated(id)); textBuffer.Changed += TextBuffer_Changed; }
public Stream GetContent(RootName root, FileId source) { throw new NotImplementedException(); }
public Task <bool> ClearContentAsync(RootName root, FileId target, Func <FileSystemInfoLocator> locatorResolver) { throw new NotImplementedException(); }
protected override string GetFileName(ZiPatchConfig.PlatformId platform) => $"{base.GetFileName(platform)}.index{(FileId == 0 ? string.Empty : FileId.ToString())}";
private FileDescription GetFile(ClientGuard client, FileId fileId) { var room = client.Rooms[parentRoom.Name]; return(room.Files.Find(f => f.Id == fileId)); }
public override bool RemoveInto(string key, FileId value, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return base.RemoveInto(key, value, callerIdentifier); }
public override string ToString() { return(string.Format("{0} {1} {2}#{3}", MessageType, GetVersion(), FileId.ToStringSmall(), ChunkNo)); }
public async Task <Stream> GetContentAsync(RootName root, FileId source) => (await RequireContextAsync(root)).Reader.GetContent(root, source);
/// <summary> /// this class manages the correct download of the file <paramref name = "fileId" /> from /// <paramref name = "locations" />. /// </summary> /// <param name = "fileId"></param> /// <param name = "locations"></param> public DownloadManager(FileId fileId, IEnumerable<FileLocation> locations) { FileId = fileId; Locations = locations; }
protected void btnUpload_Click() { this.WfId = Convert.ToInt32((string)Request.QueryString["wfid"]); this.FileNo = GetFileNo(WfId); if (dllFileType.SelectedItem.ToString() == "Invoice") { if (CheckInput()) { return; } } if (dllFileType.SelectedItem.ToString() == "Other") { if (txtDesc.Text.Trim() == "") { lblmsg.Text = "Description is required for document type of 'Other'"; } this.descRow.Style.Add("display", ""); } if (this.FileUpload.PostedFile.FileName.Trim().Equals("")) { lblmsg.Text = "Please select 'Choose Files' before clicking Upload Files."; lblmsg.Visible = true; return; } int lastPos = FileUpload.PostedFile.FileName.Trim().LastIndexOf(@"."); string suffix = FileUpload.PostedFile.FileName.Trim().Substring(lastPos); if (suffix.ToLower() == ".pdf" || suffix.ToLower() == ".jpg" || suffix.ToLower() == ".jpeg") { lblmsg.Text = ""; } else { lblmsg.Text = "Please upload only PDF or images"; lblmsg.Visible = true; return; } if (lblmsg.Text == "") { HttpFileCollection uploadedFiles = Request.Files; string errorList = ""; DataAccess dba = new DataAccess(); for (int i = 0; i < uploadedFiles.Count; i++) { HttpPostedFile file = uploadedFiles[i]; try { if (file.ContentLength > 0) { if (!file.FileName.Trim().Equals("")) { string descriptor = this.txtDesc.Text; if (descriptor == "") { descriptor = this.dllFileType.SelectedItem.ToString(); } int ftyp = Convert.ToInt32(this.dllFileType.SelectedValue); errorList += this.ProcessFile(ftyp, descriptor, file); } } } catch (Exception Ex) { //Span1.Text += "Error: <br>" + Ex.Message; } } if (errorList == "") { if (uploadedFiles.Count > 1) { string strDBfilePath = dba.dxGetSPString("wfGetFilesRootPath"); string File; string filePath; filePath = strDBfilePath; if (WfId > 0) { filePath += WfId + @"\"; } for (int i = 1; i < uploadedFiles.Count; i++) { HttpPostedFile file = uploadedFiles[i]; string File1 = filePath + SetFileName(file); File = filePath + SetFileName(uploadedFiles[0]); MergeFile(File, File1); int filekeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + SetFileName(file) + "'"); if (filekeyId > 0) { SmartflowLite.UploadDoc doc = new SmartflowLite.UploadDoc(filekeyId); string message = ""; int delCount = doc.DeleteFile(ref message); } } File = filePath + SetFileName(uploadedFiles[0]); System.IO.File.Delete(File.Replace(".pdf", ".jpg")); } HttpPostedFile firstfile = uploadedFiles[0]; string fileonly = firstfile.FileName.Trim().Substring(firstfile.FileName.Trim().LastIndexOf("\\") + 1); int OAid = dba.dxGetIntData("select projmanagerid from claimvalues where wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString()); if (dllFileType.SelectedItem.ToString() == "Inspection Report/Estimate") { createGeneralTask(OAid); } if (dllFileType.SelectedItem.ToString() == "Customer Authorization (Emergency)") { Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999); pr.CreateTasks(WfId, SubProcessId, 22435, userID); int KeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); dba.dxExecuteNonQuery("update wfdet set sindexid=" + KeyId + " where actionid=22436 and wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString()); } if (dllFileType.SelectedItem.ToString().Contains("Scope Document")) { Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999); if (dllFileType.SelectedItem.ToString().Contains("Emergency")) { pr.CreateTasks(WfId, 1, 22395, userID); } else { pr.CreateTasks(WfId, 2, 22395, userID); } } int keyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); if (keyId < 0) { lastPos = fileonly.LastIndexOf(@"."); suffix = fileonly.Substring(lastPos); fileonly = fileonly.Replace(suffix, ".pdf"); keyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); } //this.FileId = keyId; dba.dxExecuteNonQuery("update StrFilesDet set refId=" + this.schId + " where keyId=" + FileId.ToString()); if (dllFileType.SelectedItem.ToString().Contains("Invoice")) { dba.dxExecuteNonQuery("update StrFilesDet set FileId=20, Comments='AP Invoice' where keyId=" + FileId.ToString()); Save(); } string myStringVariable = "File upload and conversion succesfull"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); //Response.Redirect("Claims.aspx"); } else { lblmsg.Text = errorList; } } }
public AstContext(NitraClient client, SolutionId solutionId, ProjectId projectId, FileId fileId, FileVersion fileVersion) { Client = client; SolutionId = solutionId; ProjectId = projectId; FileId = fileId; FileVersion = fileVersion; }
public void Edit(long uid, string no, IClassEditInfo info) { ExceptionHelper.ThrowIfNotId(uid, "uid"); ExceptionHelper.ThrowIfNull(info, "info"); var entity = GetEnabled(no); bool update = false; if (!String.IsNullOrWhiteSpace(info.Name) && entity.name != info.Name.Trim()) { var oldName = entity.name; entity.name = info.Name.Trim(); var entitys = _ClassesRepository.Entities.Where(c => c.no.StartsWith(no) && c.full_name != null).ToArray(); foreach (var item in entitys) { item.full_name = Utility.ReplyFullName(item.full_name, oldName, info.Name); } update = true; } if (!String.IsNullOrWhiteSpace(info.EnName) && entity.name_en != info.EnName.Trim()) { var oldEnName = entity.name_en; entity.name_en = info.EnName.Trim(); var entitys = _ClassesRepository.Entities.Where(c => c.no.StartsWith(no) && c.full_name_en != null).ToArray(); foreach (var item in entitys) { item.full_name_en = Utility.ReplyFullName(item.full_name_en, oldEnName, info.EnName); } update = true; } if (entity.order_by != info.Order) { entity.order_by = info.Order; update = true; } if (!String.IsNullOrWhiteSpace(info.Introduce) && info.Introduce.Trim() != entity.introduce) { entity.introduce = info.Introduce.Trim(); update = true; } if (!String.IsNullOrWhiteSpace(info.IndexImage) && info.IndexImage.Trim() != entity.indexImage) { var sourceId = FileId.FromFileId(info.IndexImage); if (sourceId.IsTempId) { var target = sourceId.ToStorageId(); _FileManager.Copy(sourceId, target); sourceId = target; } entity.indexImage = sourceId.Id; update = true; } if (!String.IsNullOrWhiteSpace(info.ListImage) && info.ListImage.Trim() != entity.listImage) { var sourceId = FileId.FromFileId(info.ListImage); if (sourceId.IsTempId) { var target = sourceId.ToStorageId(); _FileManager.Copy(sourceId, target); sourceId = target; } entity.listImage = sourceId.Id; update = true; } if (update) { _ClassesRepository.SaveChanges(); } }
public override string ToString() { return(string.Format("{0} {1} {2}#{3} {4} |{5}|", MessageType, GetVersion(), FileId.ToStringSmall(), ChunkNo, ReplicationDeg, Body.Length)); }
private static async Task <IIpcResult> AddArtifactsToDropInternalAsync(ConfiguredCommand conf, DropDaemon daemon) { var files = File.GetValues(conf.Config).ToArray(); var fileIds = FileId.GetValues(conf.Config).ToArray(); var hashes = HashOptional.GetValues(conf.Config).ToArray(); var dropPaths = RelativeDropPath.GetValues(conf.Config).ToArray(); if (files.Length != fileIds.Length || files.Length != hashes.Length || files.Length != dropPaths.Length) { return(new IpcResult( IpcResultStatus.GenericError, I($"File counts don't match: #files = {files.Length}, #fileIds = {fileIds.Length}, #hashes = {hashes.Length}, #dropPaths = {dropPaths.Length}"))); } var directoryPaths = Directory.GetValues(conf.Config).ToArray(); var directoryIds = DirectoryId.GetValues(conf.Config).ToArray(); var directoryDropPaths = RelativeDirectoryDropPath.GetValues(conf.Config).ToArray(); var directoryFilters = DirectoryContentFilter.GetValues(conf.Config).ToArray(); if (directoryPaths.Length != directoryIds.Length || directoryPaths.Length != directoryDropPaths.Length || directoryPaths.Length != directoryFilters.Length) { return(new IpcResult( IpcResultStatus.GenericError, I($"Directory counts don't match: #directories = {directoryPaths.Length}, #directoryIds = {directoryIds.Length}, #dropPaths = {directoryDropPaths.Length}, #directoryFilters = {directoryFilters.Length}"))); } (Regex[] initializedFilters, string filterInitError) = InitializeDirectoryFilters(directoryFilters); if (filterInitError != null) { return(new IpcResult(IpcResultStatus.ExecutionError, filterInitError)); } var dropFileItemsKeyedByIsAbsent = Enumerable .Range(0, files.Length) .Select(i => new DropItemForBuildXLFile( daemon.ApiClient, filePath: files[i], fileId: fileIds[i], fileContentInfo: FileContentInfo.Parse(hashes[i]), relativeDropPath: dropPaths[i])).ToLookup(f => WellKnownContentHashUtilities.IsAbsentFileHash(f.Hash)); // If a user specified a particular file to be added to drop, this file must be a part of drop. // The missing files will not get into the drop, so we emit an error. if (dropFileItemsKeyedByIsAbsent[true].Any()) { return(new IpcResult( IpcResultStatus.InvalidInput, I($"The following files are missing, but they are a part of the drop command:{Environment.NewLine}{string.Join(Environment.NewLine, dropFileItemsKeyedByIsAbsent[true])}"))); } (IEnumerable <DropItemForBuildXLFile> dropDirectoryMemberItems, string error) = await CreateDropItemsForDirectoriesAsync( conf, daemon, directoryPaths, directoryIds, directoryDropPaths, initializedFilters); if (error != null) { return(new IpcResult(IpcResultStatus.ExecutionError, error)); } var groupedDirectoriesContent = dropDirectoryMemberItems.ToLookup(f => WellKnownContentHashUtilities.IsAbsentFileHash(f.Hash)); // we allow missing files inside of directories only if those files are output files (e.g., optional or temporary files) if (groupedDirectoriesContent[true].Any(f => !f.IsOutputFile)) { return(new IpcResult( IpcResultStatus.InvalidInput, I($"Uploading missing source file(s) is not supported:{Environment.NewLine}{string.Join(Environment.NewLine, groupedDirectoriesContent[true].Where(f => !f.IsOutputFile))}"))); } // return early if there is nothing to upload if (!dropFileItemsKeyedByIsAbsent[false].Any() && !groupedDirectoriesContent[false].Any()) { return(new IpcResult(IpcResultStatus.Success, string.Empty)); } return(await AddDropItemsAsync(daemon, dropFileItemsKeyedByIsAbsent[false].Concat(groupedDirectoriesContent[false]))); }
public Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) { throw new NotImplementedException(); }
public Task <bool> SetContentAsync(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress, Func <FileSystemInfoLocator> locatorResolver) => Transact(root, (sequenceNr) => new LocalFileContentSet(sequenceNr, target.Value, content.ReadFully()));
[InlineData("1:not-an-int")] // second field not an int public void TestInvalidFileId(string fileIdStr) { XAssert.IsFalse(FileId.TryParse(fileIdStr, out _)); Assert.Throws <ArgumentException>(() => FileId.Parse(fileIdStr)); }
private void FileDeleted(object sender, HierarchyItemEventArgs e) { var path = e.FileName; var ext = Path.GetExtension(path); var id = new FileId(_stringManager.GetId(path)); string action = e.Hierarchy.GetProp<string>(e.ItemId, __VSHPROPID4.VSHPROPID_BuildAction); if (action == "Compile" || action == "Nitra") foreach (var server in _servers) if (server.IsSupportedExtension(ext)) server.FileUnloaded(id); Debug.WriteLine($"tr: FileAdded(FileName='{path}' id={id})"); }
internal void FileAdded(ProjectId projectId, string path, FileId id, FileVersion version) { Client.Send(new ClientMessage.FileLoaded(projectId, path, id, version)); }
public SearchResult(FileId fileId, IEnumerable<FileLocation> locations, IEnumerable<string> parts) : this(fileId, locations, parts, Enumerable.Empty<string>()) { }
public Task <bool> ClearContentAsync(RootName root, FileId target, Func <FileSystemInfoLocator> locatorResolver) => Transact(root, (sequenceNr) => new LocalFileContentCleared(sequenceNr, target.Value));
public override void StoreInto(string key, FileId value, NodeIdentifier<string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
internal void ViewDeactivated(IWpfTextView wpfTextView, FileId id) { var fileModel = wpfTextView.TextBuffer.Properties.GetProperty<FileModel>(Constants.FileModelKey); fileModel.Remove(wpfTextView); }
public override void StoreInto(string key, FileId value, NodeIdentifier <string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
public override bool RemoveInto(string key, FileId value, NodeIdentifier <string> callerIdentifier = null) { Console.WriteLine("ReverseIndex -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return(base.RemoveInto(key, value, callerIdentifier)); }
/// <nodoc/> public override string ToString() { return(FileId.ToString(m_file)); }
public bool IsFileDownloading(FileId fileId) { return(_downloadingFiles.ContainsKey(fileId)); }
public override FindNodeResult<FileId> FindNode(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> FindNode(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.FindNode(key, callerIdentifier); }
public void ClearContent(RootName root, FileId target) { throw new NotImplementedException(); }
public static OperationGraph Deserialize(System.IO.BinaryReader reader) { // Read the File Header with version var headerBuffer = reader.ReadBytes(4); if (headerBuffer[0] != 'B' || headerBuffer[1] != 'O' || headerBuffer[2] != 'G' || headerBuffer[3] != '\0') { throw new InvalidOperationException("Invalid operation graph file header"); } var fileVersion = reader.ReadUInt32(); if (fileVersion != FileVersion) { throw new InvalidOperationException("Operation graph file version does not match expected"); } // Read the set of files headerBuffer = reader.ReadBytes(4); if (headerBuffer[0] != 'F' || headerBuffer[1] != 'I' || headerBuffer[2] != 'S' || headerBuffer[3] != '\0') { throw new InvalidOperationException("Invalid operation graph files header"); } var fileCount = reader.ReadUInt32(); var files = new List <(FileId FileId, Path Path)>(); for (var i = 0; i < fileCount; i++) { // Read the command working directory var fileId = new FileId(reader.ReadUInt32()); var file = new Path(ReadString(reader)); files.Add((fileId, file)); } // Read the set of operations headerBuffer = reader.ReadBytes(4); if (headerBuffer[0] != 'R' || headerBuffer[1] != 'O' || headerBuffer[2] != 'P' || headerBuffer[3] != '\0') { throw new InvalidOperationException("Invalid operation graph root operations header"); } // Read the root operation ids var rootOperationIds = ReadOperationIdList(reader); // Read the set of operations headerBuffer = reader.ReadBytes(4); if (headerBuffer[0] != 'O' || headerBuffer[1] != 'P' || headerBuffer[2] != 'S' || headerBuffer[3] != '\0') { throw new InvalidOperationException("Invalid operation graph operations header"); } var operationCount = reader.ReadUInt32(); var operations = new List <OperationInfo>(); for (var i = 0; i < operationCount; i++) { operations.Add(ReadOperationInfo(reader)); } if (reader.BaseStream.Position != reader.BaseStream.Length) { var remaining = reader.BaseStream.Length - reader.BaseStream.Position; throw new InvalidOperationException($"Operation graph file corrupted - Did not read the entire file {remaining}"); } return(new OperationGraph( files, rootOperationIds, operations)); }
public void SetContent(RootName root, FileId target, Stream content, IProgress <ProgressValue> progress) { throw new NotImplementedException(); }
public override bool Remove(FileId key, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> Remove(key: {0}, callerIdentifier: {1})", key, callerIdentifier); return base.Remove(key, callerIdentifier); }
public Task <Stream> GetContentAsync(RootName root, FileId source) { throw new NotImplementedException(); }
public override bool RemoveInto(FileId key, FileLocation value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> RemoveInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); return base.RemoveInto(key, value, callerIdentifier); }
public override int GetHashCode() { var hashCode = Created.GetHashCode() ^ LastModified.GetHashCode() ^ Size.GetHashCode() ^ IsFavorite.GetHashCode() ^ CommentsCount.GetHashCode() ^ CommentsUnread.GetHashCode() ^ ShareTypes.GetHashCode() ^ HasPreview.GetHashCode(); if (ContentType != null) { hashCode ^= ContentType.GetHashCode(); } if (Name != null) { hashCode ^= Name.GetHashCode(); } if (Path != null) { hashCode ^= Path.GetHashCode(); } if (CommentsHref != null) { hashCode ^= CommentsHref.GetHashCode(); } // Is null on directories if (ETag != null) { hashCode ^= ETag.GetHashCode(); } if (!string.IsNullOrEmpty(Id)) { hashCode ^= Id.GetHashCode(); } if (!string.IsNullOrEmpty(FileId)) { hashCode ^= FileId.GetHashCode(); } if (!string.IsNullOrEmpty(OwnderId)) { hashCode ^= OwnderId.GetHashCode(); } if (!string.IsNullOrEmpty(OwnerDisplayName)) { hashCode ^= OwnerDisplayName.GetHashCode(); } if (!string.IsNullOrEmpty(Checksums)) { hashCode ^= Checksums.GetHashCode(); } return(hashCode); }
internal void ViewActivated(IWpfTextView wpfTextView, FileId id, IVsHierarchy hierarchy, string fullPath) { var textBuffer = wpfTextView.TextBuffer; TryAddServerProperty(textBuffer); FileModel fileModel = VsUtils.GetOrCreateFileModel(wpfTextView, id, this, hierarchy, fullPath); TextViewModel textViewModel = VsUtils.GetOrCreateTextViewModel(wpfTextView, fileModel); fileModel.ViewActivated(textViewModel); }
public void DownloadMany() { const int fileCount = 5; var fileIds = new FileId[fileCount]; var fileStreams = new ByteArrayStream[fileCount]; var client = new Client(KTestHost, TestPort); client.Connect(); // Upload files var rand = new Random(); for (var i = 0; i < fileCount; i++) { fileIds[i] = GenerateFileId(); fileStreams[i] = new ByteArrayStream(rand.Next(64 * 1024, 128 * 1024)); client.BeginTransaction(fileIds[i]); client.Upload(FileType.Asset, fileStreams[i]); client.EndTransaction(); } Thread.Sleep(50); // Download var receivedCount = 0; Exception err = null; var mre = new ManualResetEvent(false); client.DownloadFinished += (sender, args) => { try { Assert.AreEqual(args.Result, DownloadResult.Success); Assert.AreEqual(args.DownloadItem.Id, fileIds[receivedCount]); var downloadItem = (TestDownloadItem)args.DownloadItem; Assert.IsTrue(Util.ByteArraysAreEqual(fileStreams[receivedCount].BackingBuffer, downloadItem.Bytes)); receivedCount++; Assert.AreEqual(fileCount - receivedCount, args.DownloadQueueLength); } catch (Exception e) { err = e; } finally { if (err != null || receivedCount == fileCount) { mre.Set(); } } }; for (var i = 0; i < fileCount; i++) { client.QueueDownload(new TestDownloadItem(fileIds[i], FileType.Asset)); } Assert.AreEqual(fileCount, client.DownloadQueueLength); Assert.IsTrue(mre.WaitOne(2000)); if (err != null) { throw err; } Assert.AreEqual(fileCount, receivedCount); }
internal void CaretPositionChanged(FileId fileId, int pos, FileVersion version) { Client.Send(new ClientMessage.SetCaretPos(fileId, version, pos)); }
public void AddFileMessage(DateTime messageTime, string senderNick, FileId fileId) { AddMessage(new MessageViewModel(messageTime, senderNick, fileId, this)); }
internal void FileUnloaded(FileId id) { Client.Send(new ClientMessage.FileUnloaded(id)); }
public RemovePersonsFileCommand(string requesterUserAuthId, TreeId treeId, FileId fileId, PersonId personId) : base(requesterUserAuthId, treeId) { FileId = fileId; PersonId = personId; }
internal void ViewDeactivated(IWpfTextView wpfTextView, FileId id) { FileModel fileModel; if (wpfTextView.TextBuffer.Properties.TryGetProperty<FileModel>(Constants.FileModelKey, out fileModel)) fileModel.Remove(wpfTextView); }
public override void StoreInto(FileId key, FileLocation value, NodeIdentifier<FileId> callerIdentifier = null) { Console.WriteLine("File2Machine -> StoreInto(key: {0}, value: {1}, callerIdentifier: {2})", key, value, callerIdentifier); base.StoreInto(key, value, callerIdentifier); }
private FileDescription GetFile(ClientGuard client, FileId fileId) { var room = client.Chat.GetRoom(parentRoom.Name); return(room.TryGetFile(fileId)); }
public override int GetHashCode() { return(FileId.GetHashCode()); }
private FileDescription GetFile(ClientGuard client, FileId fileId) { var room = client.Rooms[parentRoom.Name]; return room.Files.Find(f => f.Id == fileId); }
protected void Page_Load(object sender, EventArgs e) { try { JH_Auth_QY QYMODEL = new JH_Auth_QYB().GetALLEntities().FirstOrDefault(); if (szhlcode != "") { if (!string.IsNullOrEmpty(FileId))//如果FileID不为空 { string filename = ""; int fileId = int.Parse(FileId.Split(',')[0]); FT_File file = new FT_FileB().GetEntity(d => d.ID == fileId); if (type == "file") //默认下载文件 { List <string> extends = new List <string>() { "jpg", "png", "gif", "jpeg" }; if (extends.Contains(file.FileExtendName.ToLower())) { string width = Request["width"] ?? ""; string height = Request["height"] ?? ""; Response.AddHeader("Content-Disposition", "attachment;filename=" + file.Name); Response.ContentType = "application/octet-stream"; filename = QYMODEL.FileServerUrl + "/" + QYMODEL.QYCode + "/document/" + file.zyid; if (width + height != "") { filename = QYMODEL.FileServerUrl + "/" + QYMODEL.QYCode + "/document/image/" + file.zyid + (width + height != "" ? ("/" + width + "/" + height) : ""); } Response.Redirect(filename); } else { Response.AddHeader("Content-Disposition", "attachment;filename=" + Name); Response.ContentType = "application/octet-stream"; filename = QYMODEL.FileServerUrl + "/" + QYMODEL.QYCode + "/document/" + file.zyid; Response.Redirect(filename); } } else //返回代表类型的图片 { Response.AddHeader("Content-Disposition", "attachment;filename=" + Name); Response.ContentType = "application/octet-stream"; filename = "/ViewV5/images/qywd/" + file.FileExtendName + ".png"; Response.Redirect(filename); } } else { if (type == "folder" && MD5 != "")//下载压缩文件 { Response.AddHeader("Content-Disposition", "attachment;filename=" + Name); Response.ContentType = "application/octet-stream"; string filename = QYMODEL.FileServerUrl + "/zipfile/" + MD5; Response.Redirect(filename); } if (type == "video" && MD5 != "") { string url = QYMODEL.FileServerUrl + "/" + QYMODEL.QYCode + "/document/" + MD5; Byte[] bytes = new WebClient().DownloadData(url); Response.OutputStream.Write(bytes, 0, bytes.Length); } if (type == "TX" && !string.IsNullOrEmpty(userName)) //获取用户头像 { var userinfo = new JH_Auth_UserB().GetEntity(p => p.UserName == userName); //抓取当前用户信息 //JH_Auth_User userinfo = UserInfo.User; if (userinfo != null) { string filename = ""; if (userinfo.UserLogoId != null) { FT_File file = new FT_FileB().GetEntity(d => d.ID == userinfo.UserLogoId); List <string> extends = new List <string>() { "jpg", "png", "gif", "jpeg" }; if (!extends.Contains(file.FileExtendName.ToLower()))//文件不是图片的不返回地址,此方法只用于图片查看 { return; } filename = QYMODEL.FileServerUrl + "/" + QYMODEL.QYCode + "/document/" + file.zyid; Response.AddHeader("Content-Disposition", "attachment;filename=" + file.Name); Response.ContentType = "application/octet-stream"; } else if (!string.IsNullOrEmpty(userinfo.txurl)) { Response.AddHeader("Content-Disposition", "attachment;filename=" + Name); Response.ContentType = "application/octet-stream"; filename = userinfo.txurl; } else { Response.AddHeader("Content-Disposition", "attachment;filename=" + Name); Response.ContentType = "application/octet-stream"; filename = "/ViewV5/images/tx.png"; } Response.Redirect(filename); return; } } } } } catch (Exception ex) { } // Response.ContentType = "application/x-zip-compressed"; }
private void FileAdded(object sender, HierarchyItemEventArgs e) { var path = e.FileName; var ext = Path.GetExtension(path); var id = new FileId(_stringManager.GetId(path)); string action = e.Hierarchy.GetProp<string>(e.ItemId, __VSHPROPID4.VSHPROPID_BuildAction); if (action == "Compile" || action == "Nitra") { object obj; var hr2 = e.Hierarchy.GetProperty(e.ItemId, (int)__VSHPROPID.VSHPROPID_ExtObject, out obj); var projectItem = obj as EnvDTE.ProjectItem; if (ErrorHelper.Succeeded(hr2) && projectItem != null) { var projectPath = projectItem.ContainingProject.FullName; var projectId = new ProjectId(_stringManager.GetId(projectPath)); foreach (var server in _servers) if (server.IsSupportedExtension(ext)) server.FileAdded(projectId, path, id, new FileVersion()); Debug.WriteLine($"tr: FileAdded(BuildAction='{action}', FileName='{path}' projectId={projectId})"); return; } } Debug.WriteLine($"tr: FileAdded(BuildAction='{action}', FileName='{path}')"); }
private void OnDocumentWindowOnScreenChanged(object sender, DocumentWindowOnScreenChangedEventArgs e) { var fullPath = e.Info.FullPath; var ext = Path.GetExtension(fullPath); var id = new FileId(_stringManager.GetId(fullPath)); var windowFrame = e.Info.WindowFrame; var vsTextView = VsShellUtilities.GetTextView(windowFrame); var wpfTextView = vsTextView.ToIWpfTextView(); if (wpfTextView == null) return; var dispatcher = wpfTextView.VisualElement.Dispatcher; var hierarchy = windowFrame.GetHierarchyFromVsWindowFrame(); if (e.OnScreen) { foreach (var server in _servers) if (server.IsSupportedExtension(ext)) server.ViewActivated(wpfTextView, id, hierarchy, fullPath); } else { foreach (var server in _servers) if (server.IsSupportedExtension(ext)) server.ViewDeactivated(wpfTextView, id); } }
internal void ViewActivated(IWpfTextView wpfTextView, FileId id, IVsHierarchy hierarchy, string fullPath) { var textBuffer = wpfTextView.TextBuffer; if (!textBuffer.Properties.ContainsProperty(Constants.ServerKey)) textBuffer.Properties.AddProperty(Constants.ServerKey, this); FileModel fileModel = VsUtils.GetOrCreateFileModel(wpfTextView, id, this, hierarchy, fullPath); TextViewModel textViewModel = VsUtils.GetOrCreateTextViewModel(wpfTextView, fileModel); fileModel.ViewActivated(textViewModel); }