private void OnBeginUpload() { EventHandler <BeginUploadEventArgs> handler = BeginUpload; if (handler != null) { BeginUploadEventArgs args = new BeginUploadEventArgs(); args.ConnectionStrings = ConnectionStrings.Values; args.RestartParameter = RestartParameter; handler(this, args); } }
public void TestTextFileEventHandler() { const String fileName = @"c:\temp\events.log"; BeginUploadEventArgs uploadBeginArgs = new BeginUploadEventArgs(); uploadBeginArgs.ConnectionStrings = new List <String>() { "connectionString1", "connectionString2" }; RestartParameter restartParm = new RestartParameter(); restartParm.TableName = "FUNG"; uploadBeginArgs.RestartParameter = restartParm; IUploadEventHandler uploadEventHandler = new TextFileEventHandler(fileName); uploadEventHandler.HandleUploadBegin(null, uploadBeginArgs); }
private void OnBeginUpload(BeginUploadEventArgs e) { if (BeginUpload != null) BeginUpload(this, e); }
private void AddFiles(string oid, IEnumerable<FileInfo> fileInfos) { List<FileInfo> fileList = new List<FileInfo>(fileInfos); BeginUploadEventArgs beginUploadEventArgs = new BeginUploadEventArgs(fileList); OnBeginUpload(beginUploadEventArgs); if (beginUploadEventArgs.Cancel) return; Queue<FileInfo> files = new Queue<FileInfo>(fileList); if (files.Count > 0) { VisualStateManager.GoToState(this, "Busy", true); FileInfo fileInfo = null; Action<AttachmentResult> add = null; Action<Exception> error = (Action<Exception>)delegate(Exception result) { OnUploadFailed(new UploadFailedEventArgs(result)); // Raise UploadFailed error event add(null); // Upload next file }; add = delegate(AttachmentResult result) { if (result != null && !result.Success) { OnUploadFailed(new UploadFailedEventArgs(new Exception(Properties.Resources.AttachmentEditor_FileUploadFailed))); // Raise UploadFailed error event } if (files.Count > 0) { fileInfo = files.Dequeue(); using (Stream stream = fileInfo.OpenRead()) { this.FeatureLayer.AddAttachment(oid, stream, fileInfo.Name, add, error); }; } else { OnEndUpload(EventArgs.Empty); LoadAttachments(); } }; add(null); } }