public void DownloadAsync(string securityToken, string transactionId, string dataflow, string directoryPath) { this.SetMustUnderstand(); this.RaiseRequestorEvent("Starting Download"); NodeDocument[] documents = new NodeDocument[0]; this.requestor.BeginDownload(securityToken, transactionId, dataflow, documents, new AsyncCallback(this.DownloadAsyncCallback), directoryPath); this.RaiseRequestorEvent("Begin Download Executted"); }
public string Notify(string securityToken, string nodeAddress, string dataflow, string name, string type, string message) { this.RaiseRequestorEvent("Parsing Documents"); NodeDocument[] documents = new NodeDocument[] { new NodeDocument() }; documents[0].name = name; documents[0].content = Util.ToBytes(message); documents[0].type = type; return(this.Notify(securityToken, nodeAddress, dataflow, documents)); }
public static void WritePackageVersion(string aVersion) { XElement vNode = NodeDocument?.FindElement(_VERSION); if (vNode == null) { return; } vNode.SetElementValue(_VERSION, aVersion); //NodeDocument.Save(); }
private NodeDocument[] ParseDocuments(string[] filePaths) { NodeDocument[] documentArray = new NodeDocument[filePaths.Length]; for (int i = 0; i < filePaths.Length; i++) { documentArray[i] = new NodeDocument(); documentArray[i].name = Util.GetFileName(filePaths[i]); documentArray[i].content = Util.GetBytes(filePaths[i]); documentArray[i].type = Util.GetFileExtentsion(filePaths[i]); } return(documentArray); }
private void DownloadAsyncCallback(IAsyncResult result) { this.RaiseRequestorEvent("DownloadAsyncCallback Invoked"); if (!result.IsCompleted) { throw new ApplicationException("DownloadAsyncCallback invoked but the processed has not yet completed."); } NodeDownloadEventArgs args = new NodeDownloadEventArgs(); string asyncState = (string)result.AsyncState; if (!Directory.Exists(asyncState)) { args.IsSuccess = false; args.ErrorMessage = "The target directory does not exist: " + asyncState; } else { try { this.RaiseRequestorEvent("Parsing Results"); NodeDocument[] documents = new NodeDocument[0]; this.requestor.EndDownload(result, out documents); this.LoadDocumentsFromContext(ref documents); foreach (NodeDocument document in documents) { string fileName = Path.Combine(asyncState, document.name); Util.WriteFile(fileName, document.content); args.Add(fileName); } args.IsSuccess = true; this.RaiseRequestorEvent("Results Parsed"); } catch (Exception innerException) { args.ErrorMessage = innerException.Message; while (innerException.InnerException != null) { innerException = innerException.InnerException; args.ErrorMessage = args.ErrorMessage + innerException.Message; } } if (this.AsyncDownloadCompletedEvent != null) { this.AsyncDownloadCompletedEvent(this, args); } } }
public string[] Download(string securityToken, string transactionId, string dataflow, string directoryPath, bool overwriteExistingFiles) { NodeDocument[] documents = new NodeDocument[0]; this.Download(securityToken, transactionId, dataflow, ref documents); ArrayList list = new ArrayList(); this.RaiseRequestorEvent("Saving Docments"); foreach (NodeDocument document in documents) { string fileName = Path.Combine(directoryPath, document.name); if (File.Exists(fileName) && !overwriteExistingFiles) { fileName = Path.Combine(directoryPath, Guid.NewGuid().ToString()); } File.WriteAllBytes(fileName, document.content); list.Add(fileName); } this.RaiseRequestorEvent("Document Saved"); return((string[])list.ToArray(typeof(string))); }