protected override void Execute(NativeActivityContext context) { var viewService = IoC.Instance.Resolve <IViewService>(); var fontSize = FontSize.Get(context); var result = viewService.ShowDialog(Title.Get(context), Message.Get(context), Buttons, Image, DefaultResult, fontSize); DialogResult.Set(context, result == MessageBoxResult.OK || result == MessageBoxResult.Yes); }
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)); }
private DialogSourceViewModel GetMainModel(NativeActivityContext context, ValueDataField property, bool canMovePrev = true) { var model = new DialogSourceViewModel { PanelCaption = PanelCaption.Get(context), FontSize = FontSize.Get(context), IsMenuVisible = false, }; // добавим параметр property.SetFocus = true; model.Fields.Add(property); var footerMenuItem = new ValueDataField { Name = "footerMenu", FieldType = typeof(IFooterMenu), Visible = true, IsEnabled = true }; footerMenuItem.FieldName = footerMenuItem.Name; footerMenuItem.SourceName = footerMenuItem.Name; model.Fields.Add(footerMenuItem); var footerMenu = new List <ValueDataField>(); if (canMovePrev) { var prevBtn = new ValueDataField { Name = "F2", Caption = "Назад", FieldType = typeof(Button) }; prevBtn.FieldName = prevBtn.Name; prevBtn.SourceName = prevBtn.Name; prevBtn.Value = prevBtn.Name; footerMenu.Add(prevBtn); } var nextBtn = new ValueDataField { Name = "F1", Caption = "Далее", FieldType = typeof(Button) }; nextBtn.FieldName = nextBtn.Name; nextBtn.SourceName = nextBtn.Name; nextBtn.Value = nextBtn.Name; footerMenu.Add(nextBtn); footerMenuItem.Set(ValueDataFieldConstants.FooterMenu, footerMenu.ToArray()); model.UpdateSource(); return(model); }
private async Task <bool> ExecuteWithTimeout(AsyncCodeActivityContext context, CancellationToken cancellationToken = default) { var text = Text.Get(context); var fontsize = FontSize.Get(context); var fontname = FontName.Get(context); var outputfilepath = OutputFilePath.Get(context); return(await Task.FromResult(new WallpaperGenerater().GenerateWallPaperFromSolidColor(BackGroundColor, TextColor, text, fontsize, fontname, outputfilepath))); }
private DialogSourceViewModel CreateDialogModel(ActivityContext context, ValueDataField property) { var model = new DialogSourceViewModel { PanelCaption = "Введите значение", FontSize = FontSize.Get(context), IsMenuVisible = false, }; // добавим параметр property.SetFocus = true; model.Fields.Add(property); var footerMenu = new List <ValueDataField>(); var footerMenuItem = new ValueDataField { Name = "Menu0", Caption = "Назад", Value = "Escape" }; footerMenuItem.Set(ValueDataFieldConstants.Row, 0); footerMenuItem.Set(ValueDataFieldConstants.Column, 0); footerMenu.Add(footerMenuItem); footerMenuItem = new ValueDataField { Name = "Menu1", Caption = "Далее", Value = "Enter" }; footerMenuItem.Set(ValueDataFieldConstants.Row, 0); footerMenuItem.Set(ValueDataFieldConstants.Column, 1); footerMenu.Add(footerMenuItem); var footerMenufield = new ValueDataField { Name = ValueDataFieldConstants.FooterMenu, Caption = ValueDataFieldConstants.FooterMenu, FieldType = typeof(FooterMenu), IsEnabled = true }; footerMenufield.Set(ValueDataFieldConstants.FooterMenu, footerMenu.ToArray()); model.Fields.Add(footerMenufield); model.UpdateSource(); return(model); }
private DialogSourceViewModel GetMainModel(NativeActivityContext context, ValueDataField property) { var model = new DialogSourceViewModel { PanelCaption = "Введите значение", FontSize = FontSize.Get(context), IsMenuVisible = false, }; // добавим параметр property.SetFocus = true; model.Fields.Add(property); var footerMenuItem = new ValueDataField { Name = "footerMenu", FieldType = typeof(IFooterMenu), Visible = true, IsEnabled = true }; footerMenuItem.FieldName = footerMenuItem.Name; footerMenuItem.SourceName = footerMenuItem.Name; model.Fields.Add(footerMenuItem); var nextBtn = new ValueDataField { Name = "F1", Caption = "Далее", FieldType = typeof(Button), }; nextBtn.FieldName = nextBtn.Name; nextBtn.SourceName = nextBtn.Name; nextBtn.Value = nextBtn.Name; nextBtn.Set(ValueDataFieldConstants.Row, 0); nextBtn.Set(ValueDataFieldConstants.Column, 1); footerMenuItem.Set(ValueDataFieldConstants.FooterMenu, new[] { nextBtn }); model.UpdateSource(); return(model); }
protected override void Execute(NativeActivityContext context) { //var test = WorkflowInspectionServices.GetActivities(this); var result = new DialogModel { Header = Header.Get(context), Description = Description.Get(context), FontSize = FontSize.Get(context) }; foreach (var field in Fields) { field.FieldName = field.Name; field.SourceName = field.Name; } ActivityHelpers.SetWorkFlowPropertyValue(context, Fields); result.Fields.AddRange(Fields); context.SetValue(Result, result); Layout.Set(context, LayoutValue); }
protected override void Execute(CodeActivityContext context) { this.ImgReview = InputImage.Get(context); this.StrText = InputText.Get(context); this.ListStrCandidate = CandidateStringList.Get(context); this.IntFrameWidth = FrameWidth.Get(context); this.IntImageFrameHeight = ImageFrameHeight.Get(context); this.IntTextFrameHeight = TextFrameHeight.Get(context); this.IntFontSize = FontSize.Get(context); this.IsDisableEnterKeySubmit = DisableEnterKeySubmit.Get(context); this.IsUnRead = false; this.IsModify = false; FormMain fm = new FormMain(this); fm.ShowDialog(); IsModified.Set(context, this.IsModify); IsUnreadable.Set(context, this.IsUnRead); ReviewedText.Set(context, this.StrText); }
protected override void Execute(NativeActivityContext context) { var placeCode = PlaceCode.Get(context); _fontSize = FontSize.Get(context); try { if (string.IsNullOrEmpty(placeCode)) { throw new NullReferenceException("Не указан код места"); } using (var mgr = IoC.Instance.Resolve <IBaseManager <Place2Blocking> >()) { var blocking = mgr.GetFiltered(string.Format("{0}='{1}'", SourceNameHelper.Instance.GetPropertySourceName(typeof(Place2Blocking), Place2Blocking.Place2BlockingPlaceCodePropertyName), placeCode)).ToArray(); if (blocking.Length > 0) { Place2Blocking[] actualBlocks; switch (Operation) { case PlaceOperationEnum.IN: actualBlocks = blocking.Where( i => Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN.ToString()) || Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN_IN.ToString())) .ToArray(); break; case PlaceOperationEnum.OUT: actualBlocks = blocking.Where( i => Equals(i.Place2BlockingBlockingCode, PlaceBlockingEnum.PLACE_BAN.ToString())) .ToArray(); break; default: actualBlocks = blocking; break; } if (actualBlocks.Length == 0) { Result.Set(context, false); } else { Result.Set(context, true); if (ShowDialog) { var placeName = actualBlocks[0].GetProperty(Place2Blocking.VPLACENAMEPropertyName); var message = new StringBuilder(); message.AppendFormat("Место '{0}' заблокировано!", placeName); foreach (var b in actualBlocks) { message.AppendFormat("{0}{1}: {2}", System.Environment.NewLine, b.GetProperty(Place2Blocking.VBLOCKINGNAMEPropertyName), b.Place2BlockingDesc); } ShowWarningMessage("Предупреждение", message.ToString()); } } } else { Result.Set(context, false); } } } catch (Exception ex) { if (ShowDialog) { ShowErrorMessage(ex); } Result.Set(context, false); } }
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); double rowHeight = RowHeight.Get(context); double colWidth = ColWidth.Get(context); Int32 fontSize = FontSize.Get(context); string sheetName = SheetName.Get(context); Excel::_Worksheet sheet = null; 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::Range range = sheet.Range[range1, range2]; /*对齐设置*/ if ((int)_AlignStyle != 0) { range.HorizontalAlignment = (AlignEnum)_AlignStyle; } /*字体*/ range.Font.Bold = isBold; range.Font.Italic = isItalic; range.Font.Underline = isUnderLine; if (Font != 0) { range.Font.Name = ConvertFont(Font.ToString()); } range.Font.Size = fontSize; if ((int)_FontColor != 0) { range.Font.ColorIndex = (int)_FontColor; } /*填充色*/ if ((int)_CellColor != 0) { range.Interior.ColorIndex = (int)_CellColor; } /*行列宽度*/ range.RowHeight = rowHeight; range.ColumnWidth = colWidth; /*边框*/ if ((int)_BorderStyle != 0) { switch ((int)_BorderType) { case 0: { range.Borders.LineStyle = (int)_BorderStyle; break; } case 1: { range.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = (int)_BorderStyle; break; } case 2: { range.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = (int)_BorderStyle; break; } case 3: { range.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = (int)_BorderStyle; break; } case 4: { range.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = (int)_BorderStyle; break; } default: break; } } 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 void Execute(NativeActivityContext context) { // получим все параметры var teCode = TeCode.Get(context); // переведем код ТЕ в верхний регистр if (!string.IsNullOrEmpty(teCode)) { teCode = teCode.ToUpper(); } var placeCode = PlaceCode.Get(context); var isPack = IsPack.Get(context); var length = Length.Get(context); var width = Width.Get(context); var height = Height.Get(context); var tareWeight = TareWeight.Get(context); var weight = Weight.Get(context); var mandants = Mandants.Get(context); var teTypeCode = TeTypeCode.Get(context); var autoTeType = AutoTeType.Get(context); var extFilter = Filter.Get(context); _fontSize = FontSize.Get(context); var suspendNotifyCollectionChanged = SuspendNotifyCollectionChanged.Get(context); var teManager = IoC.Instance.Resolve <IBaseManager <TE> >(); try { if (suspendNotifyCollectionChanged) { teManager.SuspendNotifications(); } // если поле тип ТЕ пустое и не стоит признак пытаться определить тип ТЕ автоматически if (string.IsNullOrEmpty(teTypeCode) && !autoTeType) { throw new OperationException("Не указан тип ТЕ"); } // если поле тип ТЕ заполнено и установлен признак получения автоматически if (!string.IsNullOrEmpty(teTypeCode) && autoTeType) { throw new OperationException("Неверные настройки получения типа ТЕ"); } var uw = BeginTransactionActivity.GetUnitOfWork(context); if (uw != null) { throw new OperationException("Действие в транзакции запрещено"); } // проверим существование ТЕ if (!string.IsNullOrEmpty(teCode)) { var bpManager = IoC.Instance.Resolve <IBPProcessManager>(); var existTe = bpManager.CheckInstanceEntity("TE", teCode); if (existTe == 1) { var existTeObj = teManager.Get(teCode); if (existTeObj == null) { throw new OperationException("Нет прав на ТЕ с кодом {0}", teCode); } ExceptionResult.Set(context, null); TeCode.Set(context, teCode); OutTe.Set(context, existTeObj); Exist.Set(context, true); Result.Set(context, true); return; } } // фильтр на тип ТЕ var filter = string.Empty; // фильтр по мандантам if (!string.IsNullOrEmpty(mandants)) { filter = string.Format( "tetypecode in (select tt2m.tetypecode_r from wmstetype2mandant tt2m where tt2m.partnerid_r in ({0}))", mandants); } // фильтр по упаковкам if (isPack) { filter = string.Format( "{0}tetypecode in (select CUSTOMPARAMVAL.cpvkey from wmscustomparamvalue CUSTOMPARAMVAL where CUSTOMPARAMVAL.CPV2ENTITY = 'TETYPE' and CUSTOMPARAMVAL.CUSTOMPARAMCODE_R = 'TETypeIsPackingL2' and CUSTOMPARAMVAL.CPVVALUE is not null and CUSTOMPARAMVAL.CPVVALUE != '0')", string.IsNullOrEmpty(filter) ? string.Empty : filter + " and "); } // дополнительный фильтр по типам ТЕ if (!string.IsNullOrEmpty(extFilter)) { filter = string.Format( "{0}{1}", string.IsNullOrEmpty(filter) ? string.Empty : filter + " and ", extFilter); } // если надо определить тип ТЕ автоматически if (autoTeType) { teTypeCode = BPH.DetermineTeTypeCodeByTeCode(teCode, filter); } var teTypeObj = GetTeType(teTypeCode, filter); // если не выбрали тип ТЕ if (teTypeObj == null) { ExceptionResult.Set(context, null); TeCode.Set(context, teCode); OutTe.Set(context, null); Exist.Set(context, false); Result.Set(context, false); return; } var teObj = new TE(); teObj.SetKey(teCode); teObj.SetProperty(TE.TETypeCodePropertyName, teTypeObj.GetKey()); teObj.SetProperty(TE.CreatePlacePropertyName, placeCode); teObj.SetProperty(TE.CurrentPlacePropertyName, placeCode); teObj.SetProperty(TE.StatusCodePropertyName, TEStates.TE_FREE.ToString()); teObj.SetProperty(TE.TEPackStatusPropertyName, isPack ? TEPackStatus.TE_PKG_CREATED.ToString() : TEPackStatus.TE_PKG_NONE.ToString()); teObj.SetProperty(TE.TELengthPropertyName, length ?? teTypeObj.GetProperty(TEType.LengthPropertyName)); teObj.SetProperty(TE.TEWidthPropertyName, width ?? teTypeObj.GetProperty(TEType.WidthPropertyName)); teObj.SetProperty(TE.TEHeightPropertyName, height ?? teTypeObj.GetProperty(TEType.HeightPropertyName)); teObj.SetProperty(TE.TETareWeightPropertyName, tareWeight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName)); teObj.SetProperty(TE.TEMaxWeightPropertyName, tareWeight ?? teTypeObj.GetProperty(TEType.MaxWeightPropertyName)); teObj.SetProperty(TE.TEWeightPropertyName, weight ?? teTypeObj.GetProperty(TEType.TareWeightPropertyName)); ((ISecurityAccess)teManager).SuspendRightChecking(); teManager.Insert(ref teObj); ExceptionResult.Set(context, null); TeCode.Set(context, teCode); OutTe.Set(context, teObj); Exist.Set(context, false); Result.Set(context, true); } catch (Exception ex) { TeCode.Set(context, teCode); ExceptionResult.Set(context, ex); OutTe.Set(context, null); Exist.Set(context, false); Result.Set(context, false); } finally { if (suspendNotifyCollectionChanged) { teManager.ResumeNotifications(); } ((ISecurityAccess)teManager).ResumeRightChecking(); } }
protected override void Execute(NativeActivityContext context) { const string isnullerrorformat = "Свойство '{0}' должно быть задано."; _context = context; var workerId = WorkerId.Get(context); if (!workerId.HasValue) { throw new DeveloperException(isnullerrorformat, WorkingIdPropertyName); } string filter = null; var excludedOperations = ExcludedOperations.Get(context); if (!string.IsNullOrEmpty(excludedOperations)) { var ops = excludedOperations.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (ops.Length > 0) { filter = string.Format(" and w.operationcode_r not in ({0})", string.Join(",", ops.Select(p => string.Format("'{0}'", p)))); } } var workhelper = new WorkHelper(); var result = workhelper.ClosingWorking(workerId: workerId.Value, filter: filter, dialogTitle: "Подтверждение", workername: WorkerFullName.Get(context), dialogMessageHandler: ActivityHelpers.ClosingWorkingDialogMessage, dialogWorkerDateTillHandler: ShowDialogWorkerDateTill, fontSize: FontSize.Get(context)); Result.Set(context, result); }
private DialogSourceViewModel GetTimerFormModel() { var result = new DialogSourceViewModel { PanelCaption = DialogTitle.Get(_context), FontSize = FontSize.Get(_context), IsMenuVisible = false, }; var footerMenu = new List <ValueDataField>(); var menuNext = new ValueDataField { Name = "Menu0", Caption = "Далее", Value = Key.Enter.ToString() }; menuNext.Set(ValueDataFieldConstants.Row, 0); menuNext.Set(ValueDataFieldConstants.Column, 1); footerMenu.Add(menuNext); ValueDataField field; var message = Message.Get(_context); if (!string.IsNullOrEmpty(message)) { field = new ValueDataField { Name = "txtMessage", FieldType = typeof(string), LabelPosition = "None", IsEnabled = false, Value = message }; field.FieldName = field.Name; field.SourceName = field.Name; result.Fields.Add(field); } var dateFrom = DateFrom.Get(_context); if (dateFrom.HasValue) { field = new ValueDataField { Name = "dtDateFrom", Caption = "С", FieldType = typeof(DateTime), LabelPosition = "Left", Value = dateFrom.Value, DisplayFormat = DefaultDateTimeFormat, IsEnabled = false, SetFocus = false, CloseDialog = false }; field.FieldName = field.Name; field.SourceName = field.Name; result.Fields.Add(field); } var timevalue = TimeSpan.FromSeconds(dateFrom.HasValue ? (DateTime.Now - dateFrom.Value).TotalSeconds - TimerOffset.Get(_context) : 0); field = new ValueDataField { Name = TimerFieldName, Caption = "Таймер", FieldType = typeof(TimeSpan), LabelPosition = "Left", DisplayFormat = "hh\\:mm\\:ss", Value = timevalue, IsEnabled = false, SetFocus = false, CloseDialog = false }; field.FieldName = field.Name; field.SourceName = field.Name; result.Fields.Add(field); var fieldFooterMenu = new ValueDataField { Name = "footerMenu", FieldType = typeof(IFooterMenu) }; fieldFooterMenu.FieldName = fieldFooterMenu.Name; fieldFooterMenu.SourceName = fieldFooterMenu.Name; fieldFooterMenu.Properties["FooterMenu"] = footerMenu.ToArray(); result.Fields.Add(fieldFooterMenu); result.UpdateSource(); return(result); }