public ReportClenilCompositumForte(EquipamentType eqtype)


        {
            this.eqFact = EquipamentFactory.GetEquipamentFactory();


            this.txt = new Text();
            op1      = new BeginOfManipulation(eqtype, "BeginOfManipulation", "Clenil Compositum Forte");
            op2      = new ZeroLoadCell(eqtype);
            op3      = new FirstLoading(eqtype, "1º Carregamento de Álcool Etílico Anidro", "1.2", "3", 0);
            op4      = new FirstLoading(eqtype, "2º Carregamento de Álcool Etílico Anidro", "1.2", "3", 1);
            op5      = new TempMonitoringClass(eqtype, false);
            op6      = new AdditionClass(eqtype, "Adição de Excipiente pelo Bocal T2", false, false, 0);
            op7      = new AdditionClass(eqtype, "Adição de Dipropionato de Baclometasoma", false, false, 1);
            op8      = new HighSpeedMix(eqtype, "30", "0", "1500", "2000", true, true, false, "5", 0);
            op9      = new LowSpeedMix(eqtype, "20", "30", false);
            op10     = new AdditionClass(eqtype, "Adição de Sulfato de Salbutamol Micronizado", true, false, 2);
            op11     = new HighSpeedMix(eqtype, "30", "0", "2000", "2500", true, true, false, "20", 1);
            op12     = new TankFinalWeight(eqtype, "", false);
            op13     = new ValveClass(eqtype, "15", true, true, "200", "494", "V8", "18");
            op14     = new EndOfManipulation(eqtype, false, true);

            StartReport();
        }
 protected static Operation InitiateResetPassword()
 {
     return(OperationHandler.PostAsync("reset-password", new
     {
         email = TestEmail
     }).WaitForResult());
 }
        /// <summary>
        /// Fetches the URL value and creates multiple operations based on optional parameters.
        /// </summary>
        /// <param name="paths">The paths to be updated.</param>
        /// <param name="element">The xml element representing an operation in the annotation xml.</param>
        /// <param name="settings">The operation filter settings.</param>
        /// <returns>The list of generation errors, if any produced when processing the filter.</returns>
        public IList <GenerationError> Apply(
            OpenApiPaths paths,
            XElement element,
            PreProcessingOperationFilterSettings settings)
        {
            var generationErrors = new List <GenerationError>();

            try
            {
                var paramElements = element.Elements()
                                    .Where(
                    p => p.Name == KnownXmlStrings.Param)
                                    .ToList();

                // We need both the full URL and the absolute paths for processing.
                // Full URL contains all path and query parameters.
                // Absolute path is needed to get OperationId parsed out correctly.
                var fullUrl = element.Elements()
                              .FirstOrDefault(p => p.Name == KnownXmlStrings.Url)
                              ?.Value;

                var absolutePath = fullUrl.UrlStringToAbsolutePath();

                var operationMethod = (OperationType)Enum.Parse(
                    typeof(OperationType),
                    element.Elements().FirstOrDefault(p => p.Name == KnownXmlStrings.Verb)?.Value,
                    ignoreCase: true);

                var allGeneratedPathStrings = GeneratePossiblePaths(
                    absolutePath,
                    paramElements.Where(
                        p => p.Attribute(KnownXmlStrings.In)?.Value == KnownXmlStrings.Path)
                    .ToList());

                foreach (var pathString in allGeneratedPathStrings)
                {
                    if (!paths.ContainsKey(pathString))
                    {
                        paths[pathString] = new OpenApiPathItem();
                    }

                    paths[pathString].Operations[operationMethod] =
                        new OpenApiOperation
                    {
                        OperationId = OperationHandler.GetOperationId(pathString, operationMethod)
                    };
                }
            }
            catch (Exception ex)
            {
                generationErrors.Add(
                    new GenerationError
                {
                    Message       = ex.Message,
                    ExceptionType = ex.GetType().Name
                });
            }

            return(generationErrors);
        }
Пример #4
0
        protected override void Run()
        {
            if (!MonoDroidFramework.EnsureSdksInstalled())
            {
                return;
            }

            var proj      = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var configSel = IdeApp.Workspace.ActiveConfiguration;

            OperationHandler createApk = delegate {
                using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) {
                    MonoDroidUtility.SignAndCopy(monitor, proj, configSel);
                }
            };

            if (proj.NeedsBuilding(configSel))
            {
                IdeApp.ProjectOperations.Build(proj).Completed += createApk;
            }
            else
            {
                createApk(null);
            }
        }
Пример #5
0
 // Create wallet with non-zero balance
 public Wallet(string str, Currency val, decimal sum, InputPurpose pur)
 {
     if (str == null || str.Length < 1)
     {
         throw new ArgumentException("Such name can't be used");
     }
     name     = str;
     currency = val;
     if (sum <= 0)
     {
         throw new ArgumentException("Amount of your wallet can't be less than 0");
     }
     amount  = sum;
     history = new List <Payment>();
     history.Add(new InputPayment(sum, pur));
     // Add events
     if (SuccesOperation == null)
     {
         SuccesOperation += new OperationHandler(DisplaySucces);
     }
     if (ErrorMessage == null)
     {
         ErrorMessage += new OperationHandler(DisplayError);
     }
     // Show succes
     SuccesOperation?.Invoke($"Wallet \"{this.name}\" has been created \n" +
                             "Amount of this wallet is: ", amount);
 }
Пример #6
0
        public static SVNAsyncOperation <TResult> Start(OperationHandler operationHandler)
        {
            var op = new SVNAsyncOperation <TResult>(operationHandler);

            op.Start();
            return(op);
        }
    static void Main(String[] args)
    {
        // With dependency injection.
        //var operationHandler = DependencyServiceProvider.Get().GetService<IOperationHandler>();

        var operationHandler = new OperationHandler(new BuySellOperationHandler());

        while (true)
        {
            var argument = Console.ReadLine();
            if (string.IsNullOrEmpty(argument))
            {
                break;
            }
            if (argument.ToUpper() == OperationType.Print)
            {
                operationHandler.Print();
            }
            else
            {
                var operation = OperationsFactory.Get(argument);
                operationHandler.Process(operation);
            }
        }
    }
        public ReportFostair(EquipamentType eqtype)
        {
            this.eqFact = EquipamentFactory.GetEquipamentFactory();

            txt    = new Text();
            op1    = new BeginOfManipulation(eqtype, "BeginOfManipulation", "Fostair");
            op2    = new ZeroLoadCell(eqtype);
            op3    = new FirstLoading(eqtype, "1º Carregamento de Álcool Etílico Anidro", "1.2", "3", 0);
            op4    = new TempMonitoringClass(eqtype, true);
            op5    = new SecondLoadingClass(eqtype, "2º Carregamento de Álcool Etílico Anidro + Formoterol", "1.2", "3", true, false, 0);
            op7    = new AdditionClass(eqtype, "Adição de Dipropionato de Beclometasona", false, false, 0);
            op8    = new HighSpeedMix(eqtype, "30", "1500", "0", "0", false, false, true, "10", 0);
            op9    = new LowSpeedMix(eqtype, "10", "30", false);
            op10   = new AdditionClass(eqtype, "Adição de Excipiente pelo Bocal T2", false, false, 1);
            op11   = new LowSpeedMix(eqtype, "10", "30", false, true);
            op12   = new TankFinalWeight(eqtype, "0", true);
            op13_1 = new ValveClass(eqtype, "5", true, false, "200", "494", "V10", "20");
            op13_2 = new ValveClass(eqtype, "5", false, true, "200", "494", "V9", "19");
            op14   = new RecirculationHoseDrain(eqtype);
            op13_3 = new ValveClass(eqtype, "1", true, true, "200", "494", "V8", "18");
            op15   = new EndOfManipulation(eqtype, true, false);
            op16   = new AdditionClass(eqtype, "Retirada de Amostra para Umidade e Titulação de HCL", false, true, 2);

            StartReport();
        }
Пример #9
0
 public ScheduledTask(DateTime starttime, OperationHandler operation1, OperationHandler operation2)
 {
     _starttime            = starttime;
     _operation_delegate_1 = operation1;
     _operation_delegate_2 = operation2;
     Initialization();
 }
Пример #10
0
        private void InitSimulation()
        {
            if (NetTools.UrlTools.IsUsingRestrictedFeatures)
            {
                return;
            }

            OperationHandler.Add(new OperationHandler($"/{Database.QueryScriptPath}news/query_all_news.php", OnQueryNews));
        }
Пример #11
0
        /// -----------------------------------------------------------------
        /// <summary>
        /// </summary>
        // -----------------------------------------------------------------
        public bool RegisterPreOperationHandler(Type messagetype, OperationHandler handler)
        {
            UnregisterPreOperationHandler(messagetype);

            m_PreHandlerRegistry.Add(messagetype.FullName, handler);
            RegisterMessageType(messagetype);

            return(true);
        }
Пример #12
0
        private void InitSimulation()
        {
            if (NetTools.UrlTools.IsUsingRestrictedFeatures)
            {
                return;
            }

            OperationHandler.Add(new OperationHandler($"/{Database.UpdateScriptPath}feedback/update_feedback.php", OnCompleteSendFeedback));
        }
Пример #13
0
        private void InitSimulation()
        {
            if (NetTools.UrlTools.IsUsingRestrictedFeatures)
            {
                return;
            }

            OperationHandler.Add(new OperationHandler($"/{Database.QueryScriptPath}features/query_sample_code.php", OnQuerySampleCode));
        }
Пример #14
0
        public void Constructor_Should_CreateOperationHandler()
        {
            var handler = new OperationHandler <PersonStub>(
                new ActionHandler <PersonStub>(x => x.Initials = x.FirstName.Substring(0, 1)),
                OrderDirective.Pre,
                new[] { OperationDirective.Create, OperationDirective.Undefined, OperationDirective.Update });

            handler.OperationDirectives.Count().Should().Be(2);
            handler.OrderDirective.Should().Be(OrderDirective.Pre);
        }
Пример #15
0
 protected static Operation ResolveRemark(Guid remarkId,
                                          double latitude    = 1.0, double longitude        = 1.0,
                                          bool validatePhoto = false, bool validateLocation = false)
 => OperationHandler.PutAsync($"remarks/{remarkId}/resolve", new
 {
     Photo            = GeneratePhoto(),
     Latitude         = latitude,
     Longitude        = longitude,
     ValidatePhoto    = validatePhoto,
     ValidateLocation = validateLocation
 }).WaitForResult();
Пример #16
0
 public override void ApplyEvent(OperationHandler operationHandler)
 {
     if (!SuppressNotification)
     {
         operationHandler.ResourceNotificationCallback(ResourceAdded);
     }
     for (int ii = 0; ii < Amount; ii++)
     {
         operationHandler.ResourceAddedCallback(ResourceAdded);
     }
 }
Пример #17
0
        private void InitSimulation()
        {
            if (NetTools.UrlTools.IsUsingRestrictedFeatures)
            {
                return;
            }

            OperationHandler.Add(new OperationHandler($"/{Database.QueryScriptPath}eqmlp/query_all_release_notes.php", OnQueryReleases));
            OperationHandler.Add(new OperationHandler($"/{Database.QueryScriptPath}eqmlp/query_all_bugs.php", OnQueryBugs));
            OperationHandler.Add(new OperationHandler($"/{Database.QueryScriptPath}eqmlp/query_all_organizations.php", OnQueryOrganizations));
        }
Пример #18
0
        private bool DoRegisterOperationHandler(string opkey, Type messagetype, OperationHandler handler)
        {
            m_log.DebugFormat("[Dispatcher] register handler for {0}", opkey);

            // Make sure we get rid of any old versions in either registry
            DoUnregisterOperationHandler(opkey, messagetype);

            m_HandlerRegistry.Add(opkey, handler); // Save it in the handler registry
            RegisterMessageType(messagetype);      // And save it in the type registry

            return(true);
        }
Пример #19
0
        public void Initialization()
        {
            Debug.WriteLine("RecObj Initialed.");

            StrStartTime = GetStrDateTime(StartTime);
            StrEndTime   = GetStrDateTime(EndTime);
            OperationHandler handler = (Status != RecordStatus.WaitForRetry) ?
                                       (OperationHandler)Record : (OperationHandler)RetryRecord;

            Task = new ScheduledTask(CommonFunc.ConvertDateTime2Local(TimeZoneId, StartTime), handler);
            Task.ArrangeTask();
        }
Пример #20
0
		void OnExited (object sender, EventArgs args)
		{
			lock (lockObj) {
				done = true;
				try {
					OperationHandler handler = completedEvent;
					if (handler != null)
						handler (this);
				} catch {
					// Ignore
				}
			}
		}
Пример #21
0
        public static bool PrepareShutDown(Window window)
        {
            winCustom         wincustom         = new winCustom();
            ShutDownDialog_UC shutdownDialog_uc = new ShutDownDialog_UC();
            OperationHandler  shutdown          = new OperationHandler(ShutDown);

            shutdownDialog_uc.window             = window;
            shutdownDialog_uc.Operation_delegate = shutdown;
            wincustom.winContent            = shutdownDialog_uc;
            wincustom.Title                 = "Warning";
            wincustom.CloseButtonVisible    = false;
            wincustom.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            wincustom.Topmost               = true;
            wincustom.ShowInTaskbar         = false;
            return(wincustom.ShowDialog() == true);
        }
Пример #22
0
        protected static Operation CreateRemark(double latitude = 1.0, double longitude = 1.0, string categoryName = null)
        {
            var categories = GetCategories().ToList();
            var photo      = GeneratePhoto();
            var category   = categories.FirstOrDefault(x => x.Name == categoryName) ?? categories.First();

            return(OperationHandler.PostAsync("remarks", new
            {
                Address = "test",
                Category = category.Name,
                Description = "test",
                Latitude = latitude,
                Longitude = longitude,
                Photo = photo
            }).WaitForResult());
        }
        public ReportPlacebosClenil(EquipamentType eqtype)
        {
            this.eqFact = EquipamentFactory.GetEquipamentFactory();


            txt  = new Text();
            op1  = new BeginOfManipulation(eqtype, "BeginOfManipulation", "Placebos");
            op2  = new ZeroLoadCell(eqtype);
            op3  = new FirstLoading(eqtype, "1º Carregamento de Álcool Etílico Anidro", "1.2", "3", 0);
            op4  = new TempMonitoringClass(eqtype, true);
            op5  = new SecondLoadingClass(eqtype, "2º Carregamento de Álcool Etílico Anidro + Glicerol", "1.2", "3", false, false, 0);
            op7  = new HighSpeedMix(eqtype, "30", "1500", "0", "0", false, false, false, "5", 0);
            op10 = new TankFinalWeight(eqtype, "Peso final do Produto no Tanque", true);
            op11 = new ValveClass(eqtype, "5", true, true, "200", "494", "V8", "18");
            op12 = new EndOfManipulation(eqtype, false, true);
            StartReport();
        }
Пример #24
0
        public ReportPlacebosCompositum(EquipamentType eqtype)
        {
            this.eqFact = EquipamentFactory.GetEquipamentFactory();


            txt  = new Text();
            op1  = new BeginOfManipulation(eqtype, "BeginOfManipulation", "Placebos");
            op2  = new ZeroLoadCell(eqtype);
            op3  = new FirstLoading(eqtype, "1º Carregamento de Álcool Etílico Anidro", "1.2", "3", 0);
            op4  = new TempMonitoringClass(eqtype, true);
            op8  = new AdditionClass(eqtype, "Adição de Excipiente pelo Bocal T2", false, false, 0);
            op9  = new LowSpeedMix(eqtype, "15", "30", false);
            op10 = new TankFinalWeight(eqtype, "Peso final do Produto no Tanque", false);
            op11 = new ValveClass(eqtype, "5", true, true, "200", "494", "V8", "18");
            op12 = new EndOfManipulation(eqtype, true, true);
            StartReport();
        }
Пример #25
0
        public static void RunWithProcessingUC(OperationHandler operation, string message)
        {
            winCustom     wincustom     = new winCustom();
            Processing_UC processing_uc = new Processing_UC();

            processing_uc.window             = wincustom;
            processing_uc.Operation_delegate = operation;
            processing_uc.Message            = message;
            processing_uc.ShowProgressBar    = true;
            wincustom.winContent             = processing_uc;
            wincustom.Topmost = true;
            wincustom.Owner   = _window;
            wincustom.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            wincustom.WindowStyle           = WindowStyle.None;
            wincustom.AllowsTransparency    = true;
            wincustom.ShowInTaskbar         = false;
            wincustom.ShowDialog();
        }
Пример #26
0
        public static bool WaitForRunningTools(IProgressMonitor monitor)
        {
            IAsyncOperation[] operations;
            lock (runningTasks) {
                operations = runningTasks.Values.ToArray();
            }

            if (operations.Length == 0)
            {
                return(true);
            }

            monitor.BeginTask("Waiting for custom tools...", operations.Length);

            var evt = new AutoResetEvent(false);

            monitor.CancelRequested += delegate {
                evt.Set();
            };

            OperationHandler checkOp = delegate {
                monitor.Step(1);
                if (operations.All(op => op.IsCompleted))
                {
                    evt.Set();
                }
            };

            foreach (var o in operations)
            {
                o.Completed += checkOp;
            }

            evt.WaitOne();
            bool success = operations.All(op => op.Success);

            if (!success)
            {
                monitor.ReportError("Error in custom tool", null);
            }

            monitor.EndTask();
            return(success);
        }
Пример #27
0
        public static bool WaitForRunningTools(IProgressMonitor monitor)
        {
            IAsyncOperation[] operations;
            lock (runningTasks) {
                operations = runningTasks.Values.ToArray();
            }

            if (operations.Length == 0)
            {
                return(true);
            }

            monitor.BeginTask("Waiting for custom tools...", operations.Length);

            var evt = new AutoResetEvent(false);

            monitor.CancelRequested += delegate {
                evt.Set();
            };

            OperationHandler checkOp = delegate {
                monitor.Step(1);
                if (operations.All(op => op.IsCompleted))
                {
                    evt.Set();
                }
            };

            foreach (var o in operations)
            {
                o.Completed += checkOp;
            }

            evt.WaitOne();

            monitor.EndTask();

            //the tool operations display warnings themselves
            return(operations.Any(op => !op.SuccessWithWarnings));
        }
        public ReportClenilSubType3(EquipamentType eqtype)
        {
            this.eqFact = EquipamentFactory.GetEquipamentFactory();

            op1      = new BeginOfManipulation(eqtype, "BeginOfManipulation", "Clenil");
            op2      = new ZeroLoadCell(eqtype);
            op3      = new FirstLoading(eqtype, "1º Carregamento de Álcool Etílico Anidro ", "1.2", "3", 0);
            op4      = new TempMonitoringClass(eqtype, true);
            op5      = new SecondLoadingClass(eqtype, "2º Carregamento de Álcool Etílico Anidro + Glicerol", "1.2", "3", false, false, 0);
            op11     = new HighSpeedMix(eqtype, "30", "1500", "0", "0", false, false, true, "5", 0);
            op12     = new AdditionClass(eqtype, "Adição de Dipropionato de Beclometasona", false, false, 0);
            op13     = new HighSpeedMix(eqtype, "30", "1500", "0", "0", false, false, false, "10", 1);
            op14     = new LowSpeedMix(eqtype, "10", "30", false);
            op15     = new TankFinalWeight(eqtype, "TankFinalWeight", true);
            op16_1   = new ValveClass(eqtype, "5", true, false, "200", "494", "V10", "20");
            op16_2   = new ValveClass(eqtype, "5", false, true, "200", "494", "V9", "19");
            op17     = new RecirculationHoseDrain(eqtype);
            op16_3   = new ValveClass(eqtype, "1", true, true, "200", "494", "V8", "18");
            op18     = new EndOfManipulation(eqtype, true, true);
            this.txt = new Text();
            StartReport();
        }
Пример #29
0
        protected override void Run()
        {
            if (!MonoDroidFramework.EnsureSdksInstalled())
            {
                return;
            }

            // TODO: We may should check the current build profile and
            // show a warning if we are in a debug mode.
            var configSel = IdeApp.Workspace.ActiveConfiguration;
            var proj      = DefaultUploadToDeviceHandler.GetActiveExecutableMonoDroidProject();
            var conf      = proj.GetConfiguration(configSel);

            OperationHandler signOp = delegate {
                using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) {
                    var dlg = new MonoDevelop.MonoDroid.Gui.MonoDroidPublishDialog()
                    {
                        ApkPath       = conf.ApkPath,
                        BaseDirectory = proj.BaseDirectory
                    };

                    if (MessageService.ShowCustomDialog(dlg) == (int)Gtk.ResponseType.Ok)
                    {
                        MonoDroidUtility.PublishPackage(monitor, proj, configSel, dlg.SigningOptions,
                                                        conf.ApkPath, dlg.DestinationApkPath, dlg.CreateNewKey, dlg.DName, dlg.KeyValidity * 365);
                    }
                };
            };

            if (proj.NeedsBuilding(configSel))
            {
                IdeApp.ProjectOperations.Build(proj).Completed += signOp;
            }
            else
            {
                signOp(null);
            }
        }
Пример #30
0
        protected override void Run()
        {
            if (!MonoDroidFramework.EnsureSdksInstalled())
            {
                return;
            }

            var configSel = IdeApp.Workspace.ActiveConfiguration;
            var proj      = GetActiveExecutableMonoDroidProject();

            OperationHandler upload = delegate {
                using (var monitor = new MonoDevelop.Ide.ProgressMonitoring.MessageDialogProgressMonitor()) {
                    AndroidDevice device = null;

                    var conf     = (MonoDroidProjectConfiguration)proj.GetConfiguration(configSel);
                    var deviceId = proj.GetDeviceTarget(conf);
                    if (deviceId != null)
                    {
                        device = MonoDroidFramework.DeviceManager.GetDevice(deviceId);
                    }
                    if (device == null)
                    {
                        proj.SetDeviceTarget(conf, null);
                    }

                    MonoDroidUtility.SignAndUpload(monitor, proj, configSel, true, ref device);
                }
            };

            if (proj.NeedsBuilding(configSel))
            {
                IdeApp.ProjectOperations.Build(proj).Completed += upload;
            }
            else
            {
                upload(null);
            }
        }
Пример #31
0
 public OperationDescription(OperationHandler operationHandler, Type operationType, Type responseType)
 {
     OperationHandler = operationHandler;
     OperationType = operationType;
     ResponseType = responseType;
 }
        /// -----------------------------------------------------------------
        /// <summary>
        /// </summary>
        // -----------------------------------------------------------------
        public bool RegisterPreOperationHandler(Type messagetype, OperationHandler handler)
        {
            UnregisterPreOperationHandler(messagetype);

            m_PreHandlerRegistry.Add(messagetype.FullName,handler);
            RegisterMessageType(messagetype);

            return true;
        }
Пример #33
0
        void Run()
        {
            try {
                task ();
            } catch (ThreadAbortException ex) {
                result.UnhandledException = ex;
                Thread.ResetAbort ();
            } catch (Exception ex) {
                result.UnhandledException = ex;
            }

            OperationHandler c;
            lock (locker) {
                isCompleted = true;
                c = completed;
                completed = null;
            }

            if (c != null)
                c (this);
        }
        object PerformOperation(OperationHandler handler, Guid id, TimeSpan timeout, params object[] additionalParameters)
        {
            int resultCode;
            object returnValue = null;

            if (DiagnosticUtility.ShouldTraceInformation)
            {
                string traceText = SR2.GetString(SR2.SqlPrsistenceProviderOperationAndInstanceId, handler.OperationName, id.ToString());
                TraceUtility.TraceEvent(TraceEventType.Information,
                    TraceCode.SqlPersistenceProviderSQLCallStart, SR.GetString(SR.TraceCodeSqlPersistenceProviderSQLCallStart),
                    new StringTraceRecord("OperationDetail", traceText),
                    this, null);
            }

            try
            {
                TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

                using (SqlConnection connection = OpenConnection(timeoutHelper.RemainingTime()))
                {
                    SqlCommand command = CreateCommand(connection, timeoutHelper.RemainingTime());

                    try
                    {
                        handler.SetupCommand(command, id, additionalParameters);

                        if (handler.ExecuteReader)
                        {
                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                returnValue = handler.ProcessReader(reader);
                            }
                        }
                        else
                        {
                            command.ExecuteNonQuery();
                        }

                        resultCode = (int)command.Parameters["@result"].Value;
                    }
                    finally
                    {
                        CleanupCommand(command);
                    }
                }
            }
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }

                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                    new PersistenceException(
                    SR2.GetString(SR2.PersistenceOperationError, handler.OperationName),
                    e));
            }

            Exception toThrow = handler.ProcessResult(resultCode, id, returnValue);

            if (DiagnosticUtility.ShouldTraceInformation)
            {
                string traceText = SR2.GetString(SR2.SqlPrsistenceProviderOperationAndInstanceId, handler.OperationName, id.ToString());
                TraceUtility.TraceEvent(TraceEventType.Information,
                    TraceCode.SqlPersistenceProviderSQLCallEnd, SR.GetString(SR.TraceCodeSqlPersistenceProviderSQLCallEnd),
                    new StringTraceRecord("OperationDetail", traceText),
                    this, null);
            }

            if (toThrow != null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(toThrow);
            }

            return returnValue;
        }
            public OperationAsyncResult(OperationHandler handler, SqlPersistenceProviderFactory provider, Guid id, TimeSpan timeout, AsyncCallback callback, object state, params object[] additionalParameters)
                : base(callback, state)
            {
                Fx.Assert(provider != null,
                    "Provider should never be null.");

                this.handler = handler;
                this.provider = provider;
                this.id = id;

                if (this.handler.ShortcutExecution)
                {
                    Complete(true);
                    return;
                }

                TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);
                SqlConnection connection = this.provider.OpenConnection(timeoutHelper.RemainingTime());

                bool completeSelf = false;
                Exception delayedException = null;
                try
                {
                    this.command = this.provider.CreateCommand(connection, timeoutHelper.RemainingTime());

                    this.handler.SetupCommand(this.command, this.id, additionalParameters);

                    IAsyncResult result = null;

                    if (this.handler.ExecuteReader)
                    {
                        result = this.command.BeginExecuteReader(commandCallback, this);
                    }
                    else
                    {
                        result = this.command.BeginExecuteNonQuery(commandCallback, this);
                    }

                    if (result.CompletedSynchronously)
                    {
                        delayedException = CompleteOperation(result);

                        completeSelf = true;
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    try
                    {
                        connection.Close();
                        this.provider.CleanupCommand(this.command);
                    }
                    catch (Exception e1)
                    {
                        if (Fx.IsFatal(e1))
                        {
                            throw;
                        }
                        // do not rethrow non-fatal exceptions thrown from cleanup code
                    }
                    finally
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                            new PersistenceException(
                            SR2.GetString(SR2.PersistenceOperationError, this.handler.OperationName), e));
                    }
                }

                if (completeSelf)
                {
                    connection.Close();
                    this.provider.CleanupCommand(this.command);

                    if (delayedException != null)
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(delayedException);
                    }

                    Complete(true);
                }
            }
 public bool RegisterOperationHandler(string domain, Type messagetype, OperationHandler handler)
 {
     string opkey = domain + m_separator + messagetype.FullName;
     return DoRegisterOperationHandler(opkey,messagetype,handler);
 }
        private bool DoRegisterOperationHandler(string opkey, Type messagetype, OperationHandler handler)
        {
            m_log.DebugFormat("[Dispatcher] register handler for {0}",opkey);

            // Make sure we get rid of any old versions in either registry
            DoUnregisterOperationHandler(opkey, messagetype);

            m_HandlerRegistry.Add(opkey,handler); // Save it in the handler registry
            RegisterMessageType(messagetype); // And save it in the type registry

            return true;
        }
        /// -----------------------------------------------------------------
        /// <summary>
        /// </summary>
        /// -----------------------------------------------------------------
        private bool FindHandler(RequestBase req, out OperationHandler handler)
        {
            handler = null;

            string opkey = req._Domain + m_separator + req.GetType().FullName;
            
            // First look for a scene-specific handler
            if (! String.IsNullOrEmpty(req._Scene))
            {
                if (m_HandlerRegistry.TryGetValue(req._Scene + m_separator + opkey, out handler))
                    return true;
            }
            
            // Look for a scene-independent handler
            if (m_HandlerRegistry.TryGetValue(opkey, out handler))
                return true;
                
            return false;
        }