protected override void Execute(NativeActivityContext context) { try { string fromfolderpath = FromFolderPath.Get(context); if (Directory.Exists(fromfolderpath)) { string tofolderpath = ToFolderPath.Get(context); string destinationfolder = Path.GetFileName(fromfolderpath); tofolderpath = tofolderpath + "\\" + destinationfolder; Directory.Move(fromfolderpath, tofolderpath); } else if (!Directory.Exists(fromfolderpath)) { Log.Logger.LogData("Folder does not exist in path - " + fromfolderpath + " in activity Folder_Move", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_Move", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string workbookFullName = WorkbookFullName.Get(context); string workbookName = string.Empty; ExcelHelper.Shared.GetApp().DisplayAlerts = false; // bool needToOpen = NeedToOpen.Get(context); if (File.Exists(workbookFullName)) { workbookName = Path.GetFileName(workbookFullName); } else { Log.Logger.LogData("Workbook file do not exist, Error in activity CellValue_Copy", LogLevel.Error); context.Abort(); } if (NeedToOpen == true) { ExcelHelper.Shared.GetApp().Workbooks.Open(workbookFullName); } string worksheetName = WorksheetName.Get(context); string cell = Cell.Get(context); ExcelHelper.Shared.GetRange(workbookName, worksheetName, cell).Copy(); } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity CellValue_Copy", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string folderPath = FolderPath.Get(context); if (Directory.Exists(folderPath)) { Directory.Delete(folderPath, true); } else { Log.Logger.LogData("Folder does not exist in path - " + folderPath + " in activity Folder_Delete", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_Delete", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string SourcePath = FolderPath.Get(context); string DestinationPath = CopyPath.Get(context); string DestFolder = Path.GetFileName(SourcePath); DestinationPath = DestinationPath + "\\" + DestFolder; if (Directory.Exists(SourcePath)) { if (isOverride == true && Directory.Exists(DestinationPath)) { Directory.Delete(DestinationPath, true); } else if (isOverride == false && Directory.Exists(DestinationPath)) { throw new Exception("File with the same name already exist - " + DestinationPath); } if (!Directory.Exists(DestinationPath)) { Directory.CreateDirectory(DestinationPath); } //Now Create all of the directories foreach (string dirPath in Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories)) { Directory.CreateDirectory(dirPath.Replace(SourcePath, DestinationPath)); } //Copy all the files & Replaces any files with the same name foreach (string newPath in Directory.GetFiles(SourcePath, "*.*", SearchOption.AllDirectories)) { File.Copy(newPath, newPath.Replace(SourcePath, DestinationPath), true); } } else if (!Directory.Exists(SourcePath)) { Log.Logger.LogData("Folder does not exist in path - " + SourcePath + " in activity Folder_Copy", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_Copy", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string workbookFullName = FilePath.Get(context); int count = 0; // ExcelHelper.Shared.GetApp().DisplayAlerts = false; // var count = ExcelHelper.Shared.GetWorkbookByName(workbookName, true).Worksheets.Count; if (!workbookFullName.Contains(".")) { workbookFullName = workbookFullName + ".xlsx"; } if (!File.Exists(workbookFullName)) { Logger.Log.Logger.LogData("File do not exists :" + workbookFullName + " in activity Excel_Worksheet_Count", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } else { ExcelHelper.Shared.Close_OpenedFile(workbookFullName); string worksheetName = string.Empty; string workbookName = Path.GetFileName(workbookFullName); dynamic workBookObject = ExcelHelper.Shared.GetApp().Workbooks.Open(workbookFullName); dynamic worksheets = workBookObject.Worksheets; count = worksheets.count(); if (NeedToClose == true) { workBookObject.Close(); } if (false == NeedToClose) { workBookObject.Close(); ExcelHelper.Shared.GetApp().Workbooks.Open(workbookFullName); } if (ExcelHelper.Shared.GetApp().Workbooks.Count == 0) { ExcelHelper.Shared.Dispose(); } } Count.Set(context, count); } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Excel_Worksheet_Count", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { object misValue = System.Reflection.Missing.Value; string workbookFullName = WorkbookFullName.Get(context); string workbookName = string.Empty; //bool needToSave = NeedToSave.Get(context); //bool needToClose = NeedToClose.Get(context); ExcelHelper.Shared.GetApp().DisplayAlerts = false; if (File.Exists(workbookFullName)) { workbookName = Path.GetFileName(workbookFullName); } else { Log.Logger.LogData("Workbook file do not exist, Error in activity CellValue_Paste", LogLevel.Error); context.Abort(); } string worksheetName = WorksheetName.Get(context); string cell = Cell.Get(context); ExcelHelper.Shared.GetRange(workbookName, worksheetName, cell).PasteSpecial(PasteType); //if (PasteValuesOnly) //{ // ExcelHelper.Shared.GetRange(WorkbookName, WorksheetName, Cell).PasteSpecial(XlPasteType.xlPasteValuesAndNumberFormats); //} //else //{ // ExcelHelper.Shared.GetRange(WorkbookName, WorksheetName, Cell).PasteSpecial(); //} if (NeedToSave == true) { ExcelHelper.Shared.GetWorkbookByName(workbookName, true).Save(); } if (NeedToClose == true) { ExcelHelper.Shared.GetWorkbookByName(workbookName, true).Close(); } if (ExcelHelper.Shared.GetApp().Workbooks.Count == 0) { ExcelHelper.Shared.Dispose(); } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Execute", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string workbookFullName = FilePath.Get(context); string worksheetName = WorksheetName.Get(context); if (!workbookFullName.Contains(".")) { workbookFullName = workbookFullName + ".xlsx"; } if (!File.Exists(workbookFullName)) { Log.Logger.LogData("Excel file does not exist:\"" + workbookFullName + "\" in activity Excel_Worksheet_Exists", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } else { ExcelHelper.Shared.Close_OpenedFile(workbookFullName); string workbookName = Path.GetFileName(workbookFullName); dynamic workBookObject = ExcelHelper.Shared.GetApp().Workbooks.Open(workbookFullName); dynamic worksheets = workBookObject.Worksheets; bool value = ExcelHelper.Shared.GetWorksheetByName(workbookName, worksheetName, false) != null; Exists.Set(context, value); if (true == NeedToClose) { workBookObject.Close(); } if (false == NeedToClose) { workBookObject.Close(); ExcelHelper.Shared.GetApp().Workbooks.Open(workbookFullName); } if (ExcelHelper.Shared.GetApp().Workbooks.Count == 0) { ExcelHelper.Shared.Dispose(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Excel_Worksheet_Exists", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string[] files = null; string folderpath = FolderPath.Get(context); //@"C:\Work" string filter = FilterOnFileExtension.Get(context); if ((string.IsNullOrEmpty(folderpath)) || (folderpath.Trim().Length == 0)) { Log.Logger.LogData("Please enter folder path in activity Folder_FileList", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } else if (!Directory.Exists(folderpath)) { Log.Logger.LogData("Folder does not exist in path - " + folderpath + " in activity Folder_FileList", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } else if (Directory.Exists(folderpath)) { if ((string.IsNullOrEmpty(filter)) || (filter.Trim().Length == 0)) { filter = "*"; } if (AllSubDirectories) { files = Directory.GetFiles(folderpath, filter, SearchOption.AllDirectories); } else { files = Directory.GetFiles(folderpath, filter, SearchOption.TopDirectoryOnly); } ResultFileStringArray.Set(context, files); } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_FileList", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { //throw new NotImplementedException(); try { string path = FolderPath.Get(context); string newname = NewFolderName.Get(context); //string oldname = FolderName.Get(context); //int len = oldname.Length; // string filepath = Path.GetDirectoryName(path); if (Directory.Exists(path)) { // string newpath = path.Remove(path.Length - len, len); string dirpath = Path.GetDirectoryName(path); string newpath = dirpath + "\\" + newname; if (isOverride == true) { if (Directory.Exists(newpath) && !(path.Equals(newpath))) { Directory.Delete(newpath, true); } } Directory.Move(path, newpath); } else { Log.Logger.LogData("Folder does not exist in path - " + path + " in activity Folder_Rename", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_Rename", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string fromfilepath = FilePath.Get(context); string tofilepath = ToFilePath.Get(context); if (File.Exists(tofilepath)) { if (true == IsOverride) { File.Delete(tofilepath); File.Copy(fromfilepath, tofilepath); } else { Log.Logger.LogData("The file " + tofilepath + " is already exists in activity File_Copy", LogLevel.Error); } } else { File.Copy(fromfilepath, tofilepath); } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity File_Copy", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { dt.DataTable db = new System.Data.DataTable(); System.Data.DataTable dtable = null; try { string strcolumnName = string.Empty; strcolumnName = ColumnName.Get(context); dtable = DataTableObject.Get(context); DataColumn colString = new DataColumn(strcolumnName); if (string.IsNullOrEmpty(ColumnType)) { ColumnType = "System.String"; } colString.DataType = System.Type.GetType(ColumnType); dtable.Columns.Add(colString); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity DataTableAddColumn", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { //ThreadInvoker.Instance.RunByUiThread(() => //{ string ScreenPath = ImagePath.Get(context); if ((ScreenPath != null) && (ScreenPath != string.Empty)) { if (File.Exists(ScreenPath)) { string sValue = SetText.Get(context); GetSetClick getSetClick = new GetSetClick(); ImageRecognition imgRecognition = new ImageRecognition(); getSetClick = GetSetClick.Set; bool result = imgRecognition.GetSetClickImage(ScreenPath, getSetClick, sValue, 10000, accuracy); Result.Set(context, result); } } //}); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndSetText", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string filepath = FilePath.Get(context); string text = Text.Get(context); if (true == NewFile) { writeText(filepath, text); } else { if (File.Exists(filepath)) { writeText(filepath, text); } else { Log.Logger.LogData("The file " + filepath + " does not exist in activity File_WriteText", LogLevel.Error); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity File_WriteText", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string workbookFullName = FilePath.Get(context); if (!workbookFullName.Contains(".")) { workbookFullName = workbookFullName + ".xlsx"; } ExcelHelper.Shared.GetApp().DisplayAlerts = false; var wb = ExcelHelper.Shared.GetApp().Workbooks.Add(); ExcelHelper.Shared.GetApp().DisplayAlerts = false; ExcelHelper.Shared.GetApp().ActiveWorkbook.SaveAs(workbookFullName); Workbook.Set(context, wb); } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Workbook_Count", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { int start = this.Start.Get(context); int stop = this.Stop.Get(context); int step = this.Step.Get(context); // Raise exception when step is 0 as this causes infinite loop. if (step == 0) { throw new InvalidOperationException("Setting step = 0 causes an infinite loop."); } // If you're running this sample in debug mode in Visual Studio, it may breakpoint // near here because the sample intentionally passes in invalid input to demonstrate // this check. // Only run when there is an action activity set in the body, so that at each step // an action is taken. There will be no execution with invalid range and step values. if (this.Body != null && this.Body.Handler != null && Condition(start, stop, step)) { this.loopVariable.Set(context, start); context.ScheduleActivity(this.invokeBody, this.AddStep); } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity RangeEnumeration", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { dtable = DataTableObject.Get(context); string lstResult = string.Empty; rowcount = 0; // activitycount = Activities.Count - 1; activitycount = 0; DataRow dataRow = dtable.Rows[rowcount]; CurrentDataRow.Set(context, dataRow); lstResult = Convert.ToString(dataRow[ColumnNumber]); ListResult.Set(context, lstResult); var itemInner = Activities[activitycount]; context.ScheduleActivity(itemInner, onCompleted); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity DataTableForEach", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { // we are using static method because by default the regular expression engine caches the 15 most recently used static regular expressions if (this.Replacement.Get(context) != null) { res = Regex.Replace(this.Input.Get(context), this.Pattern.Get(context), this.Replacement.Get(context), this.RegexOption); } else { res = Regex.Replace(this.Input.Get(context), this.Pattern.Get(context), this.MatchEvaluator, this.RegexOption); } Result.Set(context, res); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Regex_Replace", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { ExcelHelper.Shared.GetApp().DisplayAlerts = false; var count = ExcelHelper.Shared.GetApp().Workbooks.Count; ExcelHelper.Shared.GetApp().Workbooks.Close(); //for (var i = 0; i < count; i++) //{ // ExcelHelper.Shared.GetApp().Workbooks.Item(i).Close(); //} if (ExcelHelper.Shared.GetApp().Workbooks.Count == 0) { ExcelHelper.Shared.Dispose(); } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Excel_Workbook_CloseAll", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { Xcoo = XCooridinate.Get(context); Ycoo = YCooridinate.Get(context); Xpos = X_Start.Get(context); Ypos = Y_Start.Get(context); try { switch (Find_Method) { //case FindMethod.CaptureImage: // string sImagePath = ImagePath.Get(context); // bool result = false; // if (File.Exists(sImagePath)) // { // GetSetClick getSetClick = new GetSetClick(); // ImageRecognition imgRecognition = new ImageRecognition(); // getSetClick = GetSetClick.Hover; // result = imgRecognition.DragDropImage(sImagePath, getSetClick, Xcoo, Ycoo, 10000, Accuracy); // Result.Set(context, result); // } // break; case FindMethod.CaptureXY: int endX = Xcoo; int endY = Ycoo; //endX = endX - Xpos; //endY = endY - Ypos; SetCursorPos(Xpos, Ypos); Thread.Sleep(1000); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); Thread.Sleep(1000); // mouse_event(MOUSEEVENTF_MOVE, endX, endY, 0, 0); SetCursorPos(Xpos + Xcoo, Ypos + Ycoo); Thread.Sleep(1000); mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); break; } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndClick", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected virtual void ContinueAtMatchValue( NativeActivityContext context, ActivityInstance completedInstance, DynamicValue result) { if (completedInstance.State == ActivityInstanceState.Faulted) { context.Abort(new Exception(Properties.Resources.FailMatchValue)); } int caseIndex = context.GetValue <int>(this.CaseIndex); DynamicValue expressionValue = context.GetValue <DynamicValue>(this.Expression); if (DoValuesMatch(expressionValue, result)) { MatchCase matchCase = this.Cases[caseIndex]; this.OnCaseMatched(context, completedInstance, result, matchCase.Case); } else { caseIndex++; if (caseIndex >= this.Cases.Count) { if (null != this.Default) { this.OnCaseMatched(context, completedInstance, result, this.Default); } return; } context.SetValue <int>(this.CaseIndex, caseIndex); MatchCase nextMatchCase = this.Cases[caseIndex]; context.ScheduleActivity(nextMatchCase.Expression, onMatchValueComplete); } }
protected override void PostExecute(NativeActivityContext context, UnhandledExceptionAction unhandledExceptionAction) { Exception propagatedException = PropagatedException.Get(context); ReceiveRequestSendResponseScopeExecutionProperty executionProperty = context.GetReceiveRequestSendResponseScopeExecutionProperty(); // Due to this activity will handle the fault, the Finally activity in the TryCatch will be executed also, // we have to prevent canceling the operation and the stored previous response in the extension. executionProperty.Faulted = true; switch (unhandledExceptionAction) { default: case UnhandledExceptionAction.Abort: // This will implicitly also call OnUnhandledException. context.Abort(propagatedException); break; case UnhandledExceptionAction.Cancel: // Don't wait for completion, that is critical only for the persistence to happen before the taskCompletionSource of the request is completed. context.ScheduleActivity(cancelWorkflow); break; case UnhandledExceptionAction.Terminate: // Don't wait for completion, that is critical only for the persistence to happen before the taskCompletionSource of the request is completed. context.ScheduleAction(terminateWorkflow, propagatedException); break; } }
protected override void Execute(NativeActivityContext context) { try { string sImagePath = ImagePath.Get(context); bool result = false; if (File.Exists(sImagePath)) { GetSetClick getSetClick = new GetSetClick(); ImageRecognition imgRecognition = new ImageRecognition(); getSetClick = GetSetClick.Click; result = imgRecognition.GetSetClickImage(sImagePath, getSetClick, "", 10000, Accuracy); Result.Set(context, result); } //}); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Image_FindAndClick", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { string sendKeyValue = string.Empty; try { sendKeyValue = SendKeyValue.Get(context); if (string.IsNullOrEmpty(sendKeyValue)) { Logger.Log.Logger.LogData("SendKey value is null or empty", Logger.LogLevel.Error); } else { //ThreadInvoker.Instance.RunByUiThread(() => //{ SendKeys.SendWait(sendKeyValue); //}); Logger.Log.Logger.LogData("SendKey value sent", Logger.LogLevel.Info); } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity SendKey", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string strAppId = ApplicationId.Get(context); string strSafe = Safe.Get(context); string strObjectName = ObjectName.Get(context); PSDKPasswordRequest passRequest = new PSDKPasswordRequest(); PSDKPassword psdkpassword; passRequest.AppID = strAppId; // "RESTExamples"; passRequest.Safe = strSafe; // "T-APP-CYBR-RESTAPI"; passRequest.Object = strObjectName; //"Database-MicrosoftSQLServer-JG-sql01.joe-garcia.local-Svc_BambooHR"; // Set required properties to be returned other than password passRequest.RequiredProperties.Add("PolicyId"); passRequest.RequiredProperties.Add("UserName"); passRequest.RequiredProperties.Add("Address"); // Sending the request to get the password psdkpassword = PasswordSDK.GetPassword(passRequest); string username = psdkpassword.UserName; string textPwd = psdkpassword.Content; if (!string.IsNullOrEmpty(username)) { UserName.Set(context, username); } else { Logger.Log.Logger.LogData("User name is null or empty in activity FetchSecurePassword", Logger.LogLevel.Info); } if (!string.IsNullOrEmpty(textPwd)) { SecureString strpwd = ToSecureString(textPwd); if (strpwd != null) { Password.Set(context, strpwd); } } else { Logger.Log.Logger.LogData("Password is null or empty in activity FetchSecurePassword", Logger.LogLevel.Info); } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity FetchSecurePassword", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string folderName = FolderName.Get(context); string folderPath = FolderPath.Get(context); string rawPath = folderPath; if (Directory.Exists(folderPath)) { folderPath = folderPath + "\\" + folderName; if (Directory.Exists(folderPath)) { Log.Logger.LogData("Folder already exists in path - " + folderPath + " in activity Folder_Create", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } else { Directory.CreateDirectory(folderPath); } } else { Log.Logger.LogData("Path does not exist - " + rawPath + " in activity Folder_Create", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_Create", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string msg = null; if (this.Message.Get(context) != null) { msg = this.Message.Get(context).ToString(); } switch (CsrId) { case LogLevel.Debug: Logger.Log.Logger.LogData(msg, Logger.LogLevel.Debug); break; case LogLevel.Info: Logger.Log.Logger.LogData(msg, Logger.LogLevel.Info); break; case LogLevel.Warning: Logger.Log.Logger.LogData(msg, Logger.LogLevel.Warning); break; case LogLevel.Error: Logger.Log.Logger.LogData(msg, Logger.LogLevel.Error); break; case LogLevel.Fatal: Logger.Log.Logger.LogData(msg, Logger.LogLevel.Fatal); break; default: //MessageBox.Show("Default"); //MessageBox.Show(Message.ToString()); break; } } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Log", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { string workbookName = FilePath.Get(context); try { if (!workbookName.Contains(".")) { workbookName = workbookName + ".xlsx"; } if (File.Exists(workbookName)) { workbookName = Path.GetFileName(workbookName); ExcelHelper.Shared.GetWorkbookByName(workbookName, true).Close(); } if (ExcelHelper.Shared.GetApp().Workbooks.Count == 0) { ExcelHelper.Shared.Dispose(); } } catch (Exception ex) { if (ex.HResult == -2146233088) { Log.Logger.LogData("Excel file \"" + workbookName + "\" is not opened to close in activity Workbook_Close", LogLevel.Info); } else { Log.Logger.LogData(ex.Message + " in activity Workbook_Close", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string folderpath = FolderPath.Get(context); if (Directory.Exists(folderpath)) { var folderInfo = new FileInfo(folderpath); var dirInfo = new DirectoryInfo(folderpath); FolderName.Set(context, folderInfo.Name); // FolderCount.Set(context, folderInfo.Extension); // FileCount.Set(context, folderInfo.Length); FolderCount.Set(context, dirInfo.GetDirectories().Length); FileCount.Set(context, dirInfo.GetFiles().Length); CreationTime.Set(context, folderInfo.CreationTime); LastAccessTime.Set(context, folderInfo.LastAccessTime); LastWriteTime.Set(context, folderInfo.LastWriteTime); } else if (!Directory.Exists(folderpath)) { Log.Logger.LogData("Folder does not exist in path - " + folderpath + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } } catch (Exception ex) { Log.Logger.LogData(ex.Message + " in activity Folder_GetInformation", LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { string strAppIdToAttach = ApplicationIDToAttach.Get(context); string strTitleOrUrlToAttach = TitleOrUrlToAttach.Get(context); if ((strAppIdToAttach == null) && (strTitleOrUrlToAttach == null)) { Logger.Log.Logger.LogData("''Attach by ApplicationID' or 'Attach by Title/URL' Not Set", LogLevel.Error); context.Abort(); } activitycount = 0; var item = Activities[activitycount]; if (item is ActivityExtended) { ActivityExtended extended = (ActivityExtended)item; extended.ExecuteMe(context, strAppIdToAttach, strTitleOrUrlToAttach); } context.ScheduleActivity(item, onCompleted, onFaulted); // context.ScheduleActivity(item, onCompleted, onFaulted); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity AttachApplication", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
protected override void Execute(NativeActivityContext context) { try { ExecuteAttempt(context); } catch (Exception ex) { Logger.Log.Logger.LogData(ex.Message + " in activity Retry", Logger.LogLevel.Error); if (!ContinueOnError) { context.Abort(); } } }
private void InternalExecute(NativeActivityContext context, ActivityInstance instance) { //this method turn async way to sync. //grab the index of the current Activity var currentActivityIndex = _currentIndex.Get(context); if (currentActivityIndex > 0) { var lastChild = children[currentActivityIndex - 1]; //Get result here, it is sync or async???? RunningResult = RunningResult && ((IPassData)lastChild).GetResult(); if (!RunningResult) { if (ErrorLevel == OnError.AlwaysReturnTrue) RunningResult = true; if (ErrorLevel == OnError.Terminate) { Log.Fatal("Workflow terminated according OnError.Terminate"); context.Abort(); } if (ErrorLevel == OnError.Continue) { //do nothing, just continue } if (ErrorLevel == OnError.JustShowWarning) { Log.Warn("Warning:\n" + lastChild.DisplayName + " Error happened, but we ignore it"); RunningResult = true; } if (ErrorLevel == OnError.StopCurrentScript) { Log.Error("Error:\n" + lastChild.DisplayName + " Error happened, stop current script."); return; } } //set variables value ((AutomationActivity)nextChild).Name to _runningResult AddVariable(lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString()); SetVariableValueByContext(context, lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString()); } if (currentActivityIndex == children.Count) { //if the currentActivityIndex is equal to the count of MySequence's Activities //Suite is complete, then we close the browser here //TODO please reconsider here, this means: suite must be totally independent, it will open & close browser itself. Then if it is called by others, must be very careful!!!!!! var steps = XElement.Parse("<AutoX.Steps OnError=\"" + ErrorLevel + "\" InstanceId=\"" + InstanceId + "\"/>"); var close = XElement.Parse("<Step Action=\"Close\" />"); steps.Add(close); Host.SetCommand(steps); Host.GetResult(); return; } if (_onChildComplete == null) { //on completion of the current child, have the runtime call back on this method _onChildComplete = InternalExecute; } //grab the next Activity in MySequence.Activities and schedule it var nextChild = children[currentActivityIndex]; var childEnabled = false; var child = nextChild as AutomationActivity; if (child != null) { child.SetHost(Host); child.InstanceId = InstanceId; child.SetParentResultId(ResultId); childEnabled = child.Enabled; } //if enabled, run it, don't think to use while, it is a recursive, async cycle here! if (childEnabled) { context.ScheduleActivity(nextChild, _onChildComplete); } //increment the currentIndex _currentIndex.Set(context, ++currentActivityIndex); }
private void InternalExecute(NativeActivityContext context, ActivityInstance instance) { //grab the index of the current Activity var currentActivityIndex = _currentIndex.Get(context); if (currentActivityIndex > 0) { var lastChild = children[currentActivityIndex - 1]; //Get result here, it is sync or async???? RunningResult = RunningResult && ((IPassData)lastChild).GetResult(); if (!RunningResult) { if (ErrorLevel == OnError.AlwaysReturnTrue) RunningResult = true; if (ErrorLevel == OnError.Terminate) { Log.Fatal("Workflow terminated according OnError.Terminate"); context.Abort(); } if (ErrorLevel == OnError.Continue) { //do nothing, just continue } if (ErrorLevel == OnError.JustShowWarning) { Log.Warn("Warning:\n" + lastChild.DisplayName + " Error happened, but we ignore it"); RunningResult = true; } if (ErrorLevel == OnError.StopCurrentScript) { Log.Error("Error:\n" + lastChild.DisplayName + " Error happened, stop current script."); return; } } //set variables value ((AutomationActivity)nextChild).Name to _runningResult AddVariable(lastChild.DisplayName.Replace(" ", "_").Replace(":","_"), RunningResult.ToString()); SetVariableValueByContext(context, lastChild.DisplayName.Replace(" ", "_").Replace(":", "_"), RunningResult.ToString()); } if (currentActivityIndex == children.Count) { //if the currentActivityIndex is equal to the count of MySequence's Activities //MySequence is complete SetFinalResult(); return; } if (_onChildComplete == null) { //on completion of the current child, have the runtime call back on this method _onChildComplete = InternalExecute; } //grab the next Activity in MySequence.Activities and schedule it var nextChild = children[currentActivityIndex]; ((IPassData) nextChild).PassData(InstanceId, UserData); var child = nextChild as AutomationActivity; if (child != null) { child.SetHost(Host); child.SetParentResultId(ResultId); } context.ScheduleActivity(nextChild, _onChildComplete); ////Get result here, it is sync or async???? not important, this is a template, should not calculate the result //_runningResult = _runningResult && ((IPassData)nextChild).GetResult(); //if (!_runningResult) //{ // if (ErrorLevel == OnError.AlwaysReturnTrue) // _runningResult = true; // //if (ErrorLevel == OnError.Terminate) // //{ // // //terminate the instance (send a status to instance) // //} // if (ErrorLevel == OnError.Continue) // { // //do nothing, just continue // } // if (ErrorLevel == OnError.JustShowWarning) // { // //do nothing, log warning // Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it"); // _runningResult = true; // } // if (ErrorLevel == OnError.StopCurrentScript) // { // //log error, then return // } //} //increment the currentIndex _currentIndex.Set(context, ++currentActivityIndex); }
private void InternalExecute(NativeActivityContext context, ActivityInstance instance) { if (_onChildComplete == null) { _onChildComplete = InternalExecute; } Log.Info("in CallTestScreenActivity internalexecute"); var steps = GetSteps(context); Host.SetCommand(steps); var rElement = Host.GetResult(); Log.Info("CallTestScreen Receive result from Host:\n"+rElement); foreach (var stepElement in rElement.Descendants()) { stepElement.SetAttributeValue(Constants.PARENT_ID, ResultId); var ret = stepElement.GetAttributeValue(Constants.RESULT); if (!string.IsNullOrEmpty(ret)) { stepElement.SetAttributeValue("Original", ret); stepElement.SetAttributeValue("Final", ret); RunningResult = ret.Equals(Constants.SUCCESS) && RunningResult; } else RunningResult = false; if (!RunningResult) { if (ErrorLevel == OnError.AlwaysReturnTrue) RunningResult = true; if (ErrorLevel == OnError.Terminate) { Log.Fatal("Workflow terminated according OnError.Terminate"); context.Abort(); } if (ErrorLevel == OnError.Continue) { //do nothing, just continue } if (ErrorLevel == OnError.JustShowWarning) { Log.Warn("Warning:\n" + DisplayName + " Error happened, but we ignore it"); RunningResult = true; } if (ErrorLevel == OnError.StopCurrentScript) { //we cannot stop it here, just pass the result to higher level, until it reach the testscript level, then testscript will stop itself Log.Error("Error:\n" + DisplayName + " Error happened, stop current script."); } } //handle the get value here var action = stepElement.GetAttributeValue("Action"); if (action.Equals("GetValue")) { var data = stepElement.GetAttributeValue("Data"); if (!string.IsNullOrEmpty(data)) { var pos = data.IndexOf("=>", StringComparison.Ordinal); try { //var attr = data.Substring(0, pos); var variable = data.Substring(pos + 2); if (!string.IsNullOrEmpty(variable)) { var value = stepElement.GetAttributeValue(variable); if (!string.IsNullOrEmpty(value)) { } } } catch (Exception ex) { Log.Error(ExceptionHelper.FormatStackTrace("GetValue Failed:", ex)); } } } //result.SetAttributeValue(Constants.UI_OBJECT, UIObject); stepElement.SetAttributeValue(Constants._TYPE, "Result"); DBFactory.GetData().Save(stepElement); } SetFinalResult(); }