Esempio n. 1
0
 internal static void trace(String prefix, String message, Object arg)
 {
     Trace.WriteLine(message, prefix);
     if (arg != null)
     {
         Trace.Indent();
         if (arg is string)
         {
             Trace.WriteLine(arg);
         }
         else if (arg is Store)
         {
             Trace.WriteLine(SemWebHelper.storeToString(arg as Store));
         }
         else if (arg is IEnumerable)
         {
             foreach (Object o in arg as IEnumerable)
             {
                 Trace.WriteLine(o.ToString());
             }
         }
         else if (arg != null)
         {
             Trace.WriteLine(arg.ToString());
         }
         Trace.Unindent();
     }
     Trace.Flush();
 }
        private void InvokeServicesWorker_DoWork(object threadContext)
        {
            ServiceCallStatus call    = threadContext as ServiceCallStatus;
            SADIService       service = call.Data as SADIService;

            try
            {
                call.Status = "Assembling input";
                MasterWorker.ReportProgress(1, call);
                MemoryStore input = assembleInput(SelectedNodes, service);

                call.Status = "Calling service";
                call.Data   = "Assembled input:\r\n" + SemWebHelper.storeToString(input);
                MasterWorker.ReportProgress(33, call);
                Store output = service.invokeService(input);

                call.Status = "Storing output";
                call.Data   = "Received output:\r\n" + SemWebHelper.storeToString(output);
                MasterWorker.ReportProgress(66, call);
                ICollection <IStatement> statements = KE.Import(output);
                showNewStatements(statements);

                call.Status = "Done";
                call.Data   = service;
                MasterWorker.ReportProgress(100, call);
            }
            catch (Exception err)
            {
                SADIHelper.error("ServiceCall", "error calling service", service, err);
                call.Status = "Error";
                call.Data   = "Error:\r\n" + err.Message;
                MasterWorker.ReportProgress(100, call);
            }
            finally
            {
                Interlocked.Decrement(ref NumWorkers);
            }
        }