Ejemplo n.º 1
0
 private void Scanner_ProgressChanged(object sender, InvokationResult ir)
 {
     this.Invoke((Action) delegate
     {
         this.cloudObjects.Update(ir);
         this.listViewFound.VirtualListSize = this.cloudObjects.Count;
         this.progressMessages.Add(new ProgressMessage(ir));
         this.listViewMessages.VirtualListSize = this.progressMessages.Count;
         listViewMessages.EnsureVisible(this.progressMessages.Count - 1);
         UpdateStatusBar(ir);
     });
 }
Ejemplo n.º 2
0
 public void Update(InvokationResult ir)
 {
     if (ir.IsError())
     {
         return;
     }
     foreach (CloudObject cobo in ir.Operation.CollectedObjects)
     {
         CloudObject exists = this.FirstOrDefault(item => item.Source.Equals(cobo.Source));
         if (exists == null)
         {
             Add(cobo);
         }
     }
 }
Ejemplo n.º 3
0
            protected override void Run()
            {
                try
                {
                    while (client.Connected)
                    {
                        try
                        {
                            string routine   = reader.ReadString();
                            string argString = reader.ReadString();

                            JToken arg = null;
                            if (argString.Length > 0)
                            {
                                arg = JToken.Parse(argString);
                            }

                            InvokationResult result = receiver.RaiseInvokationReceived(routine, arg);
                            if (result.Exception != null) //exception
                            {
                                writer.Write((byte)0);
                                writer.Write(result.Exception.ToString());
                            }
                            else if (result.ReturnValue != null) //success with returnvalue
                            {
                                writer.Write((byte)1);
                                writer.Write(result.ReturnValue.ToString());
                            }
                            else //success without returnvalue or null
                            {
                                writer.Write((byte)2);
                            }
                        }
                        catch (Exception ex) when(!(ex is ThreadInterruptedException))
                        {
                            logger.Warn(nameof(TCPServiceInvokationReceiver) + " threw an exception when receiving: " + ex.ToString());
                        }
                    }
                }
                catch (ThreadInterruptedException)
                {
                    //end
                }
                receiver.RemoveReceiver(this);
                Dispose();
            }
Ejemplo n.º 4
0
 public ProgressMessage(InvokationResult ir)
 {
     this.time              = ir.Time;
     this.operation         = ir.Operation.Name;
     this.service           = ir.Operation.ServiceName;
     this.regionSystemName  = ir.Operation.Region.SystemName;
     this.regionDisplayName = ir.Operation.Region.DisplayName;
     if (ir.IsError())
     {
         this.result     = ir.Ex.Message;
         this.imageIndex = 2;
     }
     else
     {
         this.result     = ir.ResultText();
         this.imageIndex = 0;
     }
 }
Ejemplo n.º 5
0
        public static InvokationResult Invoke <T>(Type controller, string methodName, T scope,
                                                  string statement, ContextBundle context = null, Func <object, bool> proceed = null)
        {
            if (proceed == null)
            {
                proceed = o => false;
            }
            context = context ?? new ContextBundle();
            var method           = GetMethod(controller, methodName);
            var statementHandler = new ReflectionStatementDefinition(method, controller);
            var invokationResult = new InvokationResult()
            {
                Context          = context,
                Statement        = statement,
                MatchingCriteria = statementHandler.GetMatchingCriteria(),
                Attachments      = new ContextBundle()
            };

            invokationResult.Match = statementHandler.Matches(new MatchingContext()
            {
                Statement = statement,
                ScopeType = typeof(T)
            });
            if (!invokationResult.Matched)
            {
                return(invokationResult);
            }
            var link = statementHandler.Link(statement);

            if (link == null)
            {
                throw new Exception("If matched, should have linked, but didn't");
            }
            invokationResult.Result = link.Execute(new InvokationContext()
            {
                Context     = invokationResult.Context,
                Attachments = invokationResult.Attachments,
                Scope       = scope,
                Proceed     = proceed
            });
            return(invokationResult);
        }
Ejemplo n.º 6
0
 private void UpdateStatusBar(InvokationResult ir)
 {
     this.progressBar.Value = ir.Progress;
     this.statusLabel.Text  = ir.ResultText();
 }