private void ShowBatchComplete(CompleteContext ctx)
        {
            try
            {
                // обработаем ошибку
                if (ctx.Exception != null)
                {
                    throw ctx.Exception;
                }

                // получим распаршеные параметры
                var bpContext = ctx.Parameters[BpContext.BpContextArgumentName] as BpContext;
                if (bpContext == null)
                {
                    throw new DeveloperException("Неопределен BpContext. Проверьте процесс разбора.");
                }

                var desc = bpContext.Get <string>("ParseResult");
                if (string.IsNullOrEmpty(desc))
                {
                    throw new DeveloperException("Описание не может быть пустым. Проверьте процесс разбора.");
                }

                ShowInfo(string.Format("{0}:{1}{2}", Source.IWBPosInputBatch, Environment.NewLine,
                                       desc.Replace(';', '\n')));
            }
            catch (Exception ex)
            {
                ShowError(string.Format("Ошибка определения batch-кода '{0}'. {1}", Source.IWBPosInputBatch,
                                        ExceptionHelper.GetErrorMessage(ex)));
            }
        }
 private void ApplyBatchComplete(CompleteContext ctx)
 {
     if (ctx.Exception != null)
     {
         var message = string.Format("Ошибка применения batch-кода '{0}'. {1}",
                                     Source.IWBPosInputBatch,
                                     ExceptionHelper.GetErrorMessage(ctx.Exception));
         ShowError(message);
     }
 }
Beispiel #3
0
        protected virtual void DefaultCompletedHandler(CompleteContext context)
        {
            WaitIndicatorVisible = false;
            var handler = DefaultCompletedActionHandler;

            if (handler != null)
            {
                DispatcherHelper.Invoke(handler);
            }
        }
Beispiel #4
0
        private string ProcessBP(ImportObject impObj, string xml)
        {
            if (string.IsNullOrEmpty(impObj.Action))
            {
                throw new DeveloperException("Action not set.");
            }
            var bpMgr = IoC.Instance.Resolve <IBPProcessManager>();

            if (bpMgr == null)
            {
                throw new DeveloperException("IBPProcessManager not registered.");
            }

            var context = new BpContext {
                Items = impObj.Content.Items
            };

            context.Set("DialogVisible", true); // признак того, что надо показывать диалоги
            context.Set(RootName, xml);
            bpMgr.Parameters.Add(BpContext.BpContextArgumentName, context);
            CompleteContext resCtx = null;

            bpMgr.Run(code: impObj.Action, completedHandler: ctx => { WaitHandle.Set(); resCtx = ctx; });
            WaitHandle.WaitOne();
            var result = string.Empty;

            if (resCtx != null)
            {
                if (resCtx.Exception != null)
                {
                    //Избавляемся от & в сообщении об ошибке
                    var errmessage = resCtx.Exception.Message;
                    if (!string.IsNullOrEmpty(errmessage))
                    {
                        errmessage = errmessage.Replace("&", "&amp;");
                    }
                    result = string.Format("<ERROR>{0}</ERROR>", errmessage);
                }
                else
                {
                    // оставил старую логику
                    result = resCtx.Parameters.ContainsKey("RESULT") ? resCtx.Parameters["RESULT"].ToString() : null;
                }
            }
            if (result != null)
            {
                return(result);
            }
            return("<STATUS>OK</STATUS>");
        }
        private void CompletedBp(CompleteContext ctx)
        {
            try
            {
                _isBpResultOk = false;
                if (ctx.Parameters != null && ctx.Parameters.ContainsKey(BpContext.BpContextArgumentName))
                {
                    const string isResultOk = "IsResultOk";
                    var          bpcontext  = ctx.Parameters[BpContext.BpContextArgumentName] as BpContext;
                    if (bpcontext != null)
                    {
                        _isBpResultOk = bpcontext.Get <bool>(isResultOk);
                        if (_isBpResultOk)
                        {
                            PLPos[] plposes;
                            using (var mgr = IoC.Instance.Resolve <IBaseManager <PLPos> >())
                            {
                                plposes = mgr.GetFiltered(string.Format("plid_r = {0} ", _plid), GetModeEnum.Partial).ToArray();
                            }

                            var inputPlPoses = new ObservableCollection <InputPlPos>();
                            foreach (var plpos in plposes)
                            {
                                var item = new InputPlPos(plpos);
                                inputPlPoses.Add(item);
                            }
                            ((IModelHandler)this).SetSource(inputPlPoses);

                            ViewService.ShowDialog(PanelCaption
                                                   , string.Format(StringResources.WfClosePickSuccessFormat, _plid)
                                                   , MessageBoxButton.OK
                                                   , MessageBoxImage.Asterisk, MessageBoxResult.OK);
                        }
                    }
                }
            }
            finally
            {
                WaitStop();
            }
        }
Beispiel #6
0
        //Обновляемся после окончания БП
        protected override void OnBpProcessEnd(CompleteContext context)
        {
            try
            {
                if (Application.Current == null)
                {
                    return;
                }

                DispatcherHelper.Invoke(new Action(() => RefreshData(false)));
            }
            catch (Exception ex)
            {
                if (Application.Current != null)
                {
                    DispatcherHelper.Invoke(new Action(() => ExceptionHandler(ex, ExceptionResources.ItemCantRefresh)));
                }
            }
            finally
            {
                WaitStop();
            }
        }
Beispiel #7
0
        public CompleteContext ExecuteWfByCode(string wfcode, Dictionary <string, object> parameters, TimeSpan?timeout)
        {
            var executionContext = new Objects.Processes.ExecutionContext(string.Empty, parameters);

            var             engine = IoC.Instance.Resolve <IProcessExecutorEngine>(WorkflowProcessExecutorConstants.Workflow);
            CompleteContext resCtx = null;

            engine.Run(workflowXaml: wfcode, context: executionContext, completedHandler: ctx =>
            {
                WaitHandle.Set();
                resCtx = ctx;
            });

            if (timeout.HasValue)
            {
                WaitHandle.WaitOne(timeout.Value);
            }
            else
            {
                WaitHandle.WaitOne();
            }

            return(resCtx);
        }
 protected virtual void OnBpProcessEnd(CompleteContext context)
 {
     WaitStopInternal();
     _log.DebugFormat("End process: {0} in {1}", _bpCode, DateTime.Now - _bpStartTime);
 }
 protected override void OnBpProcessEnd(CompleteContext context)
 {
     _log.DebugFormat("End process: {0} in {1}", BpCode, DateTime.Now - _bpStartTime);
     WaitStop();
 }
		public CompleteQueryProvider(DbConnection conn, CompleteContext context)
		{
			_Connection = conn;
			_Context = context;
		}
		public CompleteQueryProvider(CompleteContext context)
		{
			_Connection = null;
			_Context = context;
		}
Beispiel #12
0
 protected override void OnBpProcessEnd(CompleteContext completeContext)
 {
     WaitStop();
 }