public static void downloadFileUsingAscxDownload(string sFileToDownload, String sTargetFileOrFolder, Callbacks.dMethod_String dCallbackWhenCompleted) { O2Thread.mtaThread( () => { var windowTitle = string.Format("{0} : {1}", "Download File", sFileToDownload); O2Messages.openControlInGUISync(typeof (ascx_DownloadFile), O2DockState.Float, windowTitle); O2Messages.getAscx(windowTitle, guiControl => { if (guiControl != null && guiControl is ascx_DownloadFile) { //var downloadFile = (IControl_DownloadFile)guiControl; //O2Messages.openAscxGui(typeof (ascx_DownloadFile), O2DockState.Float, "Download File"); var adfDownloadFile = (ascx_DownloadFile) guiControl; // Exec.openNewWindowWithControl("DownloadFile"); adfDownloadFile.invokeOnThread( delegate { adfDownloadFile.setDownloadDetails(sFileToDownload,sTargetFileOrFolder); adfDownloadFile.setAutoCloseOnDownload(true); adfDownloadFile.setCallBackWhenCompleted(dCallbackWhenCompleted); adfDownloadFile.downloadFile(); return null; }); } }); }); }
public static void waitForProcessExitAndInvokeCallBankOncompletion(Process pProcess, Callbacks.dMethod_Object dProcessCompletionCallback, bool bNoExecutionTimeLimit) { ThreadStart tsThreadStart = () => waitForProcessExitAndInvokeCallBankOncompletion_Thread(pProcess, dProcessCompletionCallback, bNoExecutionTimeLimit); new Thread(tsThreadStart).Start(); }
public static void downloadFileUsingAscxDownload(String sFileToDownload, Callbacks.dMethod_String downloadDemoFileCallback) { if (String.IsNullOrEmpty(sFileToDownload)) DI.log.error("in downloadFileUsingAscxDownload: No file provided"); else { string sTargetFile = Path.Combine(DI.config.O2TempDir, Path.GetFileName(sFileToDownload)); downloadFileUsingAscxDownload(sFileToDownload, sTargetFile, downloadDemoFileCallback); } }
public static void unzipFileAndInvokeCallback(string assessmentFile, FlowLayoutPanel taskHostControl, Callbacks.dMethod_String callbackToInvokeForEachUnzippedFile) { executeTask(new Task_Unzip(assessmentFile, DI.config.TempFolderInTempDirectory), taskHostControl, resultObject => { if (resultObject is List<string>) foreach (string item in (List<string>)resultObject) callbackToInvokeForEachUnzippedFile(item); }); }
public static bool sendMail(String sHost, String sFrom, String sTo, String sCC, String sSubject, String sMessage, List<String> lsAttachmentFiles, bool bSendSync, Callbacks.dMethod_Bool callback) { try { DI.log.info("Sending email:\n" + "/t/thost:{0}\n" + "/t/tfrom:{1}\n" + "/t/tto:{2}\n" + "/t/tcc:{3}\n" + "/t/tSubject:{4}\n" + "/t/t# attachments:{5}", sHost, sFrom, sTo, sFrom, sCC, sSubject, lsAttachmentFiles.Count); var mmMailMessage = new MailMessage(new MailAddress(sFrom), new MailAddress(sTo)) {From = new MailAddress(sFrom)}; if (sCC != "") mmMailMessage.CC.Add(new MailAddress(sCC)); mmMailMessage.Subject = sSubject; mmMailMessage.Body = sMessage; foreach (String sAttachment in lsAttachmentFiles) { mmMailMessage.Attachments.Add(new Attachment(sAttachment)); } var scSmtpClient = new SmtpClient {Host = sHost}; scSmtpClient.SendCompleted += scSmtpClient_SendCompleted; if (bSendSync) { if (callback != null) eventEmailCompleted += callback; scSmtpClient.SendAsync(mmMailMessage, mmMailMessage.Subject); } else scSmtpClient.Send(mmMailMessage); } catch (Exception ex) { DI.log.error("In sendMail: {0}", ex.Message); callback(false); return false; } return true; }
public void registerSelectedFindingEventCallback(Callbacks.dMethod_Object callback) { eventFindingSelected += callback; }
public void setCallBackWhenCompleted(Callbacks.dMethod_String _callbackWhenCompleted) { dCallbackWhenCompleted = _callbackWhenCompleted; }
private void onAfterTreeViewCheck(TreeNode checkedTreeNode, ref bool _bRecursivelyCheckingAllSubNodes, TreeView targetTreeView, Callbacks.dMethod_ListString onTreeViewCheckClick) { if (false == _bRecursivelyCheckingAllSubNodes) { bRecursivelyCheckingAllSubNodes = true; O2Forms.setCheckBoxStatusForAllTreeNodeChilds_recursive(checkedTreeNode.Nodes, checkedTreeNode.Checked); O2Forms.setCheckBoxStatusForAllParentNodes_recursive(checkedTreeNode, false); var ltnCurrentlySelectedClasses = new List<TreeNode>(); O2Forms.calculateListOfCurrentlySelectedClasses_Recursive(targetTreeView.Nodes,ltnCurrentlySelectedClasses); // clear this variable selectedFilteredSignatures = new List<FilteredSignature>(); if (ltnCurrentlySelectedClasses.Count > 0) { foreach (TreeNode tnTreeNode in ltnCurrentlySelectedClasses) { if (tnTreeNode.Tag != null) switch (tnTreeNode.Tag.GetType().Name) { case "FilteredSignature": var fsFilteredSig = (FilteredSignature) tnTreeNode.Tag; if (false == selectedFilteredSignatures.Contains(fsFilteredSig)) selectedFilteredSignatures.Add(fsFilteredSig); break; case "List`1": //Type tTyp = tnTreeNode.Tag.GetType(); var lfsFilteredSignatures = (List<FilteredSignature>) tnTreeNode.Tag; selectedFilteredSignatures.AddRange(lfsFilteredSignatures); break; default: break; } } } // fire sevent with selected signatures Callbacks.raiseRegistedCallbacks(_onAfterSelect, new object[] {selectedFilteredSignatures}); // create list of signatures and fire event var lsCurrentlySelectedClasses = new List<String>(); foreach (var fsFilteredSignature in selectedFilteredSignatures) if (false == lsCurrentlySelectedClasses.Contains(fsFilteredSignature.sOriginalSignature)) lsCurrentlySelectedClasses.Add(fsFilteredSignature.sOriginalSignature); if (onTreeViewCheckClick != null) onTreeViewCheckClick.Invoke(lsCurrentlySelectedClasses); bRecursivelyCheckingAllSubNodes = false; } }
public static void waitForProcessExitAndInvokeCallBankOncompletion_Thread(Process pProcess, Callbacks.dMethod_Object dProcessCompletionCallback, bool bNoExecutionTimeLimit) { try { if (pProcess != null) { if (bNoExecutionTimeLimit) pProcess.WaitForExit(); else pProcess.WaitForExit(iMaxProcessExecutionTimeOut); } Callbacks.raiseRegistedCallbacks(dProcessCompletionCallback, new object[] {pProcess}); } catch (Exception ex) { DI.log.ex(ex, "In waitForProcessExitAndInvokeCallBankOncompletion:", true); } }