Example #1
0
        protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var files = Files.Get <string[]>(context);
            var t     = new Workitem();

            t.wiqid       = wiqid.Get <string>(context);
            t.wiq         = wiq.Get <string>(context);
            t.name        = Name.Get <string>(context);
            t.priority    = Priority.Get <int>(context);
            t.nextrun     = NextRun.Get <DateTime?>(context);
            t.success_wiq = Success_wiq.Get <string>(context);
            t.failed_wiq  = Failed_wiq.Get <string>(context);
            if (t.payload == null)
            {
                t.payload = new Dictionary <string, object>();
            }
            foreach (var item in Payload)
            {
                t.payload.Add(item.Key, item.Value.Get(context));
            }
            Workitem result = null;
            await RobotInstance.instance.WaitForSignedIn(TimeSpan.FromSeconds(10));

            result = await global.webSocketClient.AddWorkitem <Workitem>(t, files);

            return(result);
        }
Example #2
0
        protected async override Task <object> ExecuteAsync(AsyncCodeActivityContext context)
        {
            var status           = new string[] { "failed", "successful", "abandoned", "retry", "processing" };
            var files            = Files.Get <string[]>(context);
            var t                = Workitem.Get(context);
            var ex               = Exception.Get(context);
            var ignoremaxretries = IgnoreMaxretries.Get(context);

            if (t == null)
            {
                throw new Exception("Missing Workitem");
            }
            t.success_wiq = Success_wiq.Get <string>(context);
            t.failed_wiq  = Failed_wiq.Get <string>(context);
            if (State != null && State.Expression != null)
            {
                var state = State.Get(context);
                if (!string.IsNullOrEmpty(state))
                {
                    t.state = state;
                }
            }
            if (ex != null)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                t.errormessage = ex.Message; t.errortype = "application";
                t.errorsource  = ex.Source;
                if (ex is BusinessRuleException)
                {
                    t.errortype = "business";
                }
            }
            t.state = t.state.ToLower();
            if (!status.Contains(t.state))
            {
                throw new Exception("Illegal state on Workitem, must be failed, successful, abandoned or retry");
            }
            await RobotInstance.instance.WaitForSignedIn(TimeSpan.FromSeconds(10));

            var result = await global.webSocketClient.UpdateWorkitem <Workitem>(t, files, ignoremaxretries);

            return(result);
        }
Example #3
0
 protected override void AfterExecute(AsyncCodeActivityContext context, object result)
 {
     Workitem.Set(context, result);
 }