protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { string sheetName = SheetName.Get(context); string cellName_Begin = CellName_Begin.Get(context); string cellName_End = CellName_End.Get(context); int cellRow_Begin = CellRow_Begin.Get(context); int cellColumn_Begin = CellColumn_Begin.Get(context); int cellRow_End = CellRow_End.Get(context); int cellColumn_End = CellColumn_End.Get(context); Excel::_Worksheet sheet; if (sheetName != null) { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } else { sheet = excelApp.ActiveSheet; } Excel::Range range1, range2; range1 = cellName_Begin == null ? sheet.Cells[cellRow_Begin, cellColumn_Begin] : sheet.Range[cellName_Begin]; range2 = cellName_End == null ? sheet.Cells[cellRow_End, cellColumn_End] : sheet.Range[cellName_End]; Excel::Range range = sheet.Range[range1, range2]; if (!ShiftCells) { range.Clear(); } else { if (ShiftType == ShiftTypes.ShiftUp) { range.Delete(Excel.XlDeleteShiftDirection.xlShiftUp); } else if (ShiftType == ShiftTypes.ShiftLeft) { range.Delete(Excel.XlDeleteShiftDirection.xlShiftToLeft); } } System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); System.Runtime.InteropServices.Marshal.ReleaseComObject(range); sheet = null; range = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL删除区域执行过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag]; Application wordApp = property.GetValue(context.DataContext) as Application; try { if (_Copy) { wordApp.Selection.Copy(); } if (_Paste) { wordApp.Selection.Paste(); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message); CommonVariable.realaseProcessExit(wordApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataRow dataRow = DataRow.Get(context); DataColumn dataColumn = DataColumn.Get(context); Int32 columnIndex = ColumnIndex.Get(context); string columnName = ColumnName.Get(context); object value = null; try { if (dataColumn != null) { value = dataRow[dataColumn]; } else if (columnName != null && columnName != "") { value = dataRow[columnName]; } else { value = dataRow[columnIndex]; } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取行数据失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { //先走本地Browser逻辑 其次走流程 if (currBrowser.Get(context) == null) { PropertyDescriptor property = context.DataContext.GetProperties()[OpenBrowser.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[AttachBrowser.OpenBrowsersPropertyTag]; } if (property == null) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "活动流程传递的浏览器变量为空,请检查!"); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); } Browser getBrowser = property.GetValue(context.DataContext) as Browser; if (getBrowser.getICFBrowser() != null) { getBrowser.getICFBrowser().Close(); } } else { Browser thisBrowser = currBrowser.Get(context); if (thisBrowser.getICFBrowser() != null) { thisBrowser.getICFBrowser().Close(); } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { Int32 sheetIndex = SheetIndex.Get(context); string oldSheetName = OldSheetName.Get(context); string sheetName = SheetName.Get(context); Excel::Sheets sheets = excelApp.ActiveWorkbook.Sheets; if (oldSheetName != "" && oldSheetName != null) { sheets.Item[oldSheetName].Name = sheetName; } else { sheets.Item[sheetIndex].Name = sheetName; } System.Runtime.InteropServices.Marshal.ReleaseComObject(sheets); sheets = null; GC.Collect(); } catch (Exception e) { new CommonVariable().realaseProcessExit(excelApp); SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL重命名工作表执行过程出错", e.Message); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { try { m_Delegate = new runDelegate(Run); UiElement element = null; var selStr = Selector.Get(context); element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } else { PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope]; element = property.GetValue(context.DataContext) as UiElement; } AutomationElement autoEle = element.NativeObject as AutomationElement; while (true) { if (WaitNotActivity && WaitNotVisible) { //不可见 不活动 逻辑 } else if (WaitNotActivity) { //不活动逻辑 } else if (WaitNotVisible) { //不可见逻辑 } else { if (!autoEle.IsEnabled) { break; } } Thread.Sleep(500); } return(m_Delegate.BeginInvoke(callback, state)); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "等待元素消失出错", e.Message); if (ContinueOnError.Get(context)) { return(m_Delegate.BeginInvoke(callback, state)); } else { throw e; } } }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag]; Application wordApp = property.GetValue(context.DataContext) as Application; try { Int32 operateCount = OperateCount.Get(context); if (_NewLine) { for (int i = 0; i < operateCount; i++) { wordApp.Selection.TypeParagraph(); } } if (_PageBreak) { for (int i = 0; i < operateCount; i++) { wordApp.Selection.InsertBreak(); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message); CommonVariable.realaseProcessExit(wordApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { m_Delegate = new runDelegate(Run); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet; if (sheetName == null) { sheet = excelApp.ActiveSheet; } else { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } object data = new object(); Excel.Range xCopyFromRange = null; Int32 rowColNum = RowColNum.Get(context); if (CurrReadType == ReadType.读取行) { data = sheet.Rows[rowColNum].Value; xCopyFromRange = sheet.Rows[rowColNum] as Excel.Range; xCopyFromRange.Copy(); } else { data = sheet.Columns[rowColNum].Value; xCopyFromRange = sheet.Columns[rowColNum] as Excel.Range; xCopyFromRange.Copy(); } //Collection<object> _data = new Collection<object>(); //foreach (object cell in ((object[,])data)) //{ // if (cell != null) // { // _data.Add(cell); // } // else // break; //} RolColData.Set(context, data); System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL行列读取执行过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { string sheetName = SheetName.Get(context); string cellName_Begin = CellName_Begin.Get(context); int cellRow_Begin = CellRow_Begin.Get(context); int cellColumn_Begin = CellColumn_Begin.Get(context); System.Data.DataTable dt = DataTable.Get(context); Excel::_Worksheet sheet; if (sheetName != null) { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } else { sheet = excelApp.ActiveSheet; } Excel::Range range = cellName_Begin == null ? sheet.Cells[cellRow_Begin, cellColumn_Begin] : sheet.Range[cellName_Begin]; int iRowBegin = range.Row; int iColBegin = range.Column; int i = 0; if (isTitle) { for (int j = 0; j <= dt.Columns.Count - 1; j++) { sheet.Cells[iRowBegin + i, j + iColBegin] = dt.Columns[j].ColumnName; } i++; } for (int a = 0; a <= dt.Rows.Count - 1; a++) { for (int j = 0; j <= dt.Columns.Count - 1; j++) { sheet.Cells[iRowBegin + i + a, j + iColBegin] = dt.Rows[a][j]; } } System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL写入区域执行过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Browser browser = new Browser(); PropertyDescriptor property = context.DataContext.GetProperties()[OpenBrowser.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[AttachBrowser.OpenBrowsersPropertyTag]; } if (property == null) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "活动流程传递的浏览器变量为空,请检查!"); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); } Browser getBrowser = property.GetValue(context.DataContext) as Browser; String winHandleBefore = getBrowser.getICFBrowser().CurrentWindowHandle; if (getBrowser.getICFBrowser() != null) { //ReadOnlyCollection<string> chromeHandles = getBrowser.getCFBrowser().WindowHandles; //string chromeHandle = chromeHandles[chromeHandles.Count - 1]; //ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"packages\Selenium.Chrome.WebDriver.76.0.0\driver"); //ChromeDriver chromeDriver = getBrowser.getCFBrowser() as ChromeDriver; //chromeDriver.SwitchTo().Window(chromeHandle); //ReadOnlyDesiredCapabilities sss; //browser.SetCFBrowser(chromeDriver); //getBrowser.getCFBrowser().SwitchTo().Window(chromeHandle); //getBrowser.getCFBrowser().Navigate().GoToUrl("http://www.baidu.com"); } else if (getBrowser.getIEBrowser() != null) { var allShellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.InternetExplorer ieBrowser in allShellWindows) { if (!CommonVariable.BrowsersList.Contains(ieBrowser)) { browser.SetIEBrowser(ieBrowser); } } } ArrayList list = new ArrayList(); var ShellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.InternetExplorer isBrowser in ShellWindows) { list.Add(isBrowser); } CommonVariable.BrowsersList = list; newBrowser.Set(context, browser); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataTable dataTable = new DataTable(); BuildDataTable.ReadDataTableFromXML(this.TableInfo, dataTable); this.DataTable.Set(context, dataTable); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { string url = NevaUrl.Get(context); Browser thisBrowser = currBrowser.Get(context); //先走 其次走流程 if (thisBrowser == null) { PropertyDescriptor property = context.DataContext.GetProperties()[OpenBrowser.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[AttachBrowser.OpenBrowsersPropertyTag]; } if (property == null) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "活动流程传递的浏览器变量为空,请检查!"); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); } Browser getBrowser = property.GetValue(context.DataContext) as Browser; if (getBrowser.getICFBrowser() != null) { getBrowser.getICFBrowser().Navigate().GoToUrl(url); } //else if (getBrowser.getIEBrowser() != null) //{ // getBrowser.getIEBrowser().Navigate(url); //} ////确保页面是否已加载完成 //while (getBrowser.getIEBrowser().ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) //{ // Thread.Sleep(500); //} } else { if (thisBrowser.getICFBrowser() != null) { thisBrowser.getICFBrowser().Navigate().GoToUrl(url); } //else if (thisBrowser.getIEBrowser() != null) //{ // thisBrowser.getIEBrowser().Navigate(url); //} ////确保页面是否已加载完成 //while (thisBrowser.getIEBrowser().ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) //{ // Thread.Sleep(500); //} } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataTable table = this.DataTable1.Get(context); DataTable table2 = this.DataTable2.Get(context); DataTable table3 = this.JoinTables(table, table2, context); this.DataTable.Set(context, table3); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { try { m_Delegate = new runDelegate(Run); string filterText = FilterText.Get(context); TreeScope treeScope; if (Scope == ScopeOption.Children) { treeScope = TreeScope.Children; } else if (Scope == ScopeOption.Descendants) { treeScope = TreeScope.Descendants; } else { treeScope = TreeScope.Subtree; } UiElement element = null; var selStr = Selector.Get(context); element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } else { PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope]; element = property.GetValue(context.DataContext) as UiElement; } List <UiElement> uiList = new List <UiElement>(); uiList = element.FindAllByFilter(treeScope, TrueCondition.Default, filterText); UiList.Set(context, uiList); return(m_Delegate.BeginInvoke(callback, state)); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取子节点元素失败", e.Message); if (ContinueOnError.Get(context)) { return(m_Delegate.BeginInvoke(callback, state)); } else { throw e; } } }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag]; Application wordApp = property.GetValue(context.DataContext) as Application; try { float fontSize = FontSize.Get(context); Int32 leftMargin = LeftMargin.Get(context); Int32 rightMargin = RightMargin.Get(context); Int32 topMargin = TopMargin.Get(context); Int32 bottomMargin = BottomMargin.Get(context); Selection sel = wordApp.Selection; Font font = sel.Font; /*字体设置*/ font.Size = fontSize; if (Font != 0) { font.Name = ConvertFont(Font.ToString()); } font.ColorIndex = (WdColorIndex)_FontColor; font.Shadow = Convert.ToInt32(_Shadow); font.Bold = Convert.ToInt32(_FontBold); font.Italic = Convert.ToInt32(_FontItalic); if (_FontUnderLine) { font.Underline = WdUnderline.wdUnderlineSingle; } /*段落对齐设置*/ ParagraphFormat paraFmt; paraFmt = sel.ParagraphFormat; paraFmt.Alignment = (WdParagraphAlignment)_Align; sel.ParagraphFormat = paraFmt; /*页面设置*/ PageSetup pgSet = wordApp.ActiveDocument.PageSetup; pgSet.LeftMargin = leftMargin; pgSet.RightMargin = rightMargin; pgSet.TopMargin = topMargin; pgSet.BottomMargin = bottomMargin; } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message); CommonVariable.realaseProcessExit(wordApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { m_Delegate = new runDelegate(Run); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet; if (sheetName == null) { sheet = excelApp.ActiveSheet; } else { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } int rowCounts = 0, colCounts = 0; //有效行列数 不包含中间的空行 if (isValid) { rowCounts = sheet.UsedRange.Rows.Count; colCounts = sheet.UsedRange.Columns.Count; } //空行/列截止 else if (isActive) { rowCounts = sheet.UsedRange.CurrentRegion.Rows.Count; colCounts = sheet.UsedRange.CurrentRegion.Columns.Count; } else if (isSingleLine) { rowCounts = sheet.get_Range("A65535").get_End(Excel.XlDirection.xlUp).Row; colCounts = sheet.get_Range("IV1").get_End(Excel.XlDirection.xlToLeft).Column; } RowCounts.Set(context, rowCounts); ColCounts.Set(context, colCounts); System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL获取行列总数过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); IntPtr _handle = handle.Get(context); if (currWindow == null) { currWindow = new Window(); currWindow.setWindowHwnd((int)_handle); } try { var selStr = Selector.Get(context); UiElement element = UiElement.FromSelector(selStr); if (currWindow != null) { Win32Api.SendMessage((IntPtr)currWindow.getWindowHwnd(), Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } else if (element != null) { Win32Api.SendMessage(element.WindowHandle, Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } else { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { Window getBrowser = property.GetValue(context.DataContext) as Window; Win32Api.SendMessage((IntPtr)getBrowser.getWindowHwnd(), Win32Api.WM_CLOSE, IntPtr.Zero, IntPtr.Zero); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "关闭窗口错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { //string cellName_Begin = CellName_Begin.Get(context); //string cellName_End = CellName_End.Get(context); //int cellRow_Begin = CellRow_Begin.Get(context); //int cellColumn_Begin = CellColumn_Begin.Get(context); //int cellRow_End = CellRow_End.Get(context); //int cellColumn_End = CellColumn_End.Get(context); //string sheetName = SheetName.Get(context); //Excel::_Worksheet sheet; //if (sheetName == null) // sheet = excelApp.ActiveSheet; //else // sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; //Excel::Range range1, range2; //range1 = cellName_Begin == null ? sheet.Cells[cellRow_Begin, cellColumn_Begin] : sheet.Range[cellName_Begin]; //range2 = cellName_End == null ? sheet.Cells[cellRow_End, cellColumn_End] : sheet.Range[cellName_End]; Excel::_Worksheet sheet; Excel::Range range1, range2; RangeFunction.GetRange(excelApp, context, SheetName, CellName_Begin, CellName_End, CellRow_Begin, CellColumn_Begin, CellRow_End, CellColumn_End, out sheet, out range1, out range2); if (cellMergeOrUnMerge == CellMergeOrUnMerge.合并单元格) { sheet.Range[range1, range2].Merge(); } else { sheet.Range[range1, range2].UnMerge(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL合并单元格过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); try { if (currWindow == null) { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { currWindow = property.GetValue(context.DataContext) as Window; } } Win32Api.Rect rect = new Win32Api.Rect(); Win32Api.GetWindowRect((IntPtr)currWindow.getWindowHwnd(), out rect); int oldWidth = rect.Right - rect.Left; int oldHeight = rect.Bottom - rect.Top; int oldPosX = rect.Left; int oldPosY = rect.Top; int newPosX = PosX.Get(context); int newPosY = PosY.Get(context); int newWidth = Width.Get(context); int newHeight = Height.Get(context); int defPosX = newPosX == 0 ? oldPosX : newPosX; int defPosY = newPosY == 0 ? oldPosY : newPosY; int defWidth = newWidth == 0 ? oldWidth : newWidth; int defHeight = newHeight == 0 ? oldHeight : newHeight; Win32Api.MoveWindow(currWindow.getWindowHwnd(), defPosX, defPosY, defWidth, defHeight, true); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "关闭窗口错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataTable dataTable = this.DataTable.Get(context); if (dataTable == null) { throw new ArgumentException(""); } DataTable dataTable2 = dataTable; DataTable dataTable3 = this.FilterRows(dataTable2, context); this.OutDataTable.Set(context, this.Select(dataTable3, context)); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataTable dataTable = DataTable.Get(context); try { dataTable.Clear(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "清空数据表失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
//异步流程执行开始函数 protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Browser thisBrowser = currBrowser.Get(context); try { //先走本活动配置逻辑 其次走流程 if (thisBrowser == null) { //根据OpenBrowser标志获取其抽象化属性 PropertyDescriptor property = context.DataContext.GetProperties()[OpenBrowser.OpenBrowsersPropertyTag]; if (property == null) { //根据AttachBrowser标志获取其抽象化属性 property = context.DataContext.GetProperties()[AttachBrowser.OpenBrowsersPropertyTag]; } if (property == null) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "活动流程传递的浏览器变量为空,请检查!"); m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); } //抽象化属性转换为可用Browser属性 Browser getBrowser = property.GetValue(context.DataContext) as Browser; IWebDriver driver = getBrowser.getICFBrowser(); TabSwitchFunc(context, driver); } else { if (thisBrowser.getICFBrowser() != null) { IWebDriver driver = thisBrowser.getICFBrowser() as ChromeDriver; TabSwitchFunc(context, driver); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "标签页切换失败", e); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { try { m_Delegate = new runDelegate(Run); var selStr = Selector.Get(context); UiElement element = null; element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } else { PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope]; element = property.GetValue(context.DataContext) as UiElement; } if (WaitActive) { //等待元素活动逻辑 } if (WaitVisible) { //等待元素可见逻辑 } if (element != null) { FoundElement.Set(context, element); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取子节点元素失败", e.Message); if (ContinueOnError.Get(context)) { return(m_Delegate.BeginInvoke(callback, state)); } else { throw e; } } return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { Int32 cellColumn = CellColumn.Get(context); Int32 cellRow = CellRow.Get(context); string cellName = CellName.Get(context); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet; if (sheetName == null) { sheet = excelApp.ActiveSheet; } else { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } object cellContent = null; if (cellName == null) { cellContent = sheet.Cells[cellRow, cellColumn].Value2; } else { cellContent = sheet.Range[cellName].Value2; } CellContent.Set(context, cellContent); System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL获取单元格内容出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { string sheetName = SheetName.Get(context); excelApp.Worksheets.Add(); excelApp.ActiveSheet.Name = sheetName; } catch (Exception e) { new CommonVariable().realaseProcessExit(excelApp); SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL增加新工作表执行过程出错", e.Message); } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { PropertyDescriptor property = context.DataContext.GetProperties()[ExcelCreate.GetExcelAppTag]; Excel::Application excelApp = property.GetValue(context.DataContext) as Excel::Application; try { m_Delegate = new runDelegate(Run); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet; if (sheetName == null) { sheet = excelApp.ActiveSheet; } else { sheet = excelApp.ActiveWorkbook.Sheets[sheetName]; } object data = new object(); Int32 rowColNum = RowColNum.Get(context); if (CurrInsertType == InsertType.制行) { sheet.Rows[rowColNum].Value = RolColData.Get(context); } else { sheet.Columns[rowColNum].Value = RolColData.Get(context); } System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet); sheet = null; GC.Collect(); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL行列复制执行过程出错", e.Message); new CommonVariable().realaseProcessExit(excelApp); } return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Type type = typeof(T); DataTable dataTable = DataTable.Get(context); DataColumn column = Column.Get(context); string columnName = ColumnName.Get(context); object defaultValue = DefaultValue.Get(context); try { if (column != null) { dataTable.Columns.Add(column); } else { DataColumn newColumn = new DataColumn(columnName); newColumn.DataType = type; if (defaultValue != null) { newColumn.DefaultValue = defaultValue; } if (MaxLength >= 0) { newColumn.MaxLength = MaxLength; } newColumn.AllowDBNull = AllowNull; newColumn.Unique = Unique; newColumn.AutoIncrement = AutoIncrement; dataTable.Columns.Add(newColumn); } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "增加数据库列失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { try { m_Delegate = new runDelegate(Run); var selStr = Selector.Get(context); UiElement element = null; UiElement parentEle = null; element = Common.GetValueOrDefault(context, this.Element, null); if (element == null && selStr != null) { element = UiElement.FromSelector(selStr); } else { PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope]; element = property.GetValue(context.DataContext) as UiElement; } parentEle = element; for (int i = 0; i < UpLevels; i++) { parentEle = parentEle.AutomationElementParent; } AncestorElement.Set(context, parentEle); return(m_Delegate.BeginInvoke(callback, state)); } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取父节点元素失败", e.Message); if (ContinueOnError.Get(context)) { return(m_Delegate.BeginInvoke(callback, state)); } else { throw e; } } }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { DataTable dataTable = DataTable.Get(context); DataRow dataRow = DataRow.Get(context); object[] objs = ArrayRow.Get(context); try { if (dataRow != null) { dataTable.Rows.Add(dataRow); } else { object[] newObjs = null; if (objs.Length > dataTable.Columns.Count) { List <object> list = new List <object>(); for (int i = 0; i < dataTable.Columns.Count; i++) { list.Add(objs[i]); } newObjs = list.ToArray(); dataTable.Rows.Add(newObjs); } else { dataTable.Rows.Add(objs); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "增加数据库行失败", e.Message); throw e; } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state) { Window currWindow = ActiveWindow.Get(context); try { if (currWindow != null) { Win32Api.SendMessage((IntPtr)currWindow.getWindowHwnd(), Win32Api.WM_SYSCOMMAND, (IntPtr)Win32Api.SC_MINIMIZE, IntPtr.Zero); } else { PropertyDescriptor property = context.DataContext.GetProperties()[WindowActive.OpenBrowsersPropertyTag]; if (property == null) { property = context.DataContext.GetProperties()[WindowAttach.OpenBrowsersPropertyTag]; } if (property != null) { Window getBrowser = property.GetValue(context.DataContext) as Window; Win32Api.SendMessage((IntPtr)getBrowser.getWindowHwnd(), Win32Api.WM_SYSCOMMAND, (IntPtr)Win32Api.SC_MINIMIZE, IntPtr.Zero); } } } catch (Exception e) { SharedObject.Instance.Output(SharedObject.enOutputType.Error, "窗口最小化错误产生", e.Message); if (ContinueOnError.Get(context)) { } else { throw; } } m_Delegate = new runDelegate(Run); return(m_Delegate.BeginInvoke(callback, state)); }
public AsyncDemo(string name) { m_Name = name; m_Delegate = new runDelegate(Run); }