public void Add(double x, double y) { double result = x + y; ICalculatorCallback callback = OperationContext.Current.GetCallbackChannel <ICalculatorCallback>(); callback.DisplayResult(result, x, y); }
private void EnsureWorkflowStarted() { if (instance == null) { // we need to manage the service's subscription to the dataexchangeservice with the lifetime of the workflow // Aquire the callback from the current OperationContext callback = OperationContext.Current.GetCallbackChannel <ICalculatorCallback>(); //grab the version of the incoming message in case we need to create a fault later version = OperationContext.Current.IncomingMessageVersion; // retrieve the WorkflowRuntime from our WFServiceHostExtension WorkflowRuntime workflowRuntime = OperationContext.Current.Host.Extensions.Find <WFServiceHostExtension>().WorkflowRuntime; // grab a reference to our mathService ExternalDataExchangeService dataExchangeService = workflowRuntime.GetService <ExternalDataExchangeService>(); mathService = (MathDataExchangeService)dataExchangeService.GetService(typeof(MathDataExchangeService)); // if it is null set it up if (mathService == null) { mathService = new MathDataExchangeService(); dataExchangeService.AddService(mathService); } //register with the ResultReceived event mathService.ResultReceived += HandleResultReceived; //register to get signaled when the workflow completes workflowRuntime.WorkflowCompleted += this.OnWorkflowCompleted; workflowRuntime.WorkflowTerminated += this.OnWorkflowTerminated; //create and start the Workflow instance = workflowRuntime.CreateWorkflow(typeof(Workflow1)); instance.Start(); } }
/// <summary> /// Performs the calculation by executing the pre-expression and expression. /// </summary> /// <param name="source">The source.</param> /// <param name="filter">The filter used to access the rows on which the calculation will be performed.</param> /// <param name="fieldName">Field to perform the calculation on.</param> /// <param name="expression">Expression or value applied to a field in each row of the cursor.</param> /// <param name="preExpression"> /// A pre-calculation determination of a value or variable that may be used as the expression /// (or value) of the calculation. /// </param> /// <param name="showErrorPrompt">if set to <c>true</c> show a message prompt when an error occurs during calculation.</param> /// <param name="callback">The call back routine.</param> /// <returns> /// Returns a <see cref="IEnvelope" /> representing the features that have been modified by the calculation. This /// envelope can be used to refresh the display for the calculated area only. If the table used in the calculate is /// non-spatial, a null is returned. /// </returns> public static IEnvelope Calculate(this ITable source, IQueryFilter filter, string fieldName, string expression, string preExpression, bool showErrorPrompt, ICalculatorCallback callback) { ICalculator calculator = new CalculatorClass(); calculator.Callback = callback; calculator.Cursor = source.Search(filter, false); calculator.Field = fieldName; calculator.Expression = expression; calculator.PreExpression = preExpression; calculator.ShowErrorPrompt = showErrorPrompt; return(calculator.Calculate()); }
public CalculatorService() { // встановлюємо зв'язок для доступу до каналу зворотнього зв'язку callback = OperationContext.Current.GetCallbackChannel <ICalculatorCallback>(); }
public Service2() { call = OperationContext.Current.GetCallbackChannel<ICalculatorCallback>(); }
/// <summary> /// Performs the calculation by executing the pre-expression and expression. /// </summary> /// <param name="source">The source.</param> /// <param name="filter">The filter used to access the rows on which the calculation will be performed.</param> /// <param name="fieldName">Field to perform the calculation on.</param> /// <param name="expression">Expression or value applied to a field in each row of the cursor.</param> /// <param name="preExpression"> /// A pre-calculation determination of a value or variable that may be used as the expression /// (or value) of the calculation. /// </param> /// <param name="showErrorPrompt">if set to <c>true</c> show a message prompt when an error occurs during calculation.</param> /// <param name="callback">The call back routine.</param> /// <returns> /// Returns a <see cref="IEnvelope" /> representing the features that have been modified by the calculation. This /// envelope can be used to refresh the display for the calculated area only. If the table used in the calculate is /// non-spatial, a null is returned. /// </returns> public static IEnvelope Calculate(this IFeatureClass source, IQueryFilter filter, string fieldName, string expression, string preExpression, bool showErrorPrompt, ICalculatorCallback callback) { return(((ITable)source).Calculate(filter, fieldName, expression, preExpression, showErrorPrompt, callback)); }
public CalculatorService() { callback = OperationContext.Current.GetCallbackChannel <ICalculatorCallback>(); //це зробили проксі із служби на клієнт }