Exemple #1
0
        public JsonResult OPCWebTest(string opcIp)
        {
            OPCService oPCService = new OPCService();

            return(Json(new {
                success = true,
                fVal = oPCService.button1_Click(opcIp)
            }));
        }
        public object Invoke(object instance, object[] inputs, out object[] outputs)
        {
            string invokeContext = "";

            Interlocked.Increment(ref InvokeBalancer);
            Stopwatch stopwatch = new Stopwatch();

            try
            {
                try
                {
                    OPCService service = instance as OPCService;
                    if (service != null && inputs.Length == 1)
                    {
                        object      input     = inputs[0];
                        Type        inputType = input.GetType();
                        FieldInfo[] fields    = inputType.GetFields();
                        if (fields != null && fields.Length > 0)
                        {
                            invokeContext = fields[0].Name;
                        }
                    }
                    stopwatch.Start();
                    object result = innerOperationInvoker.Invoke(instance,
                                                                 inputs, out outputs);
                    stopwatch.Stop();
                    if (service != null && invokeContext != "")
                    {
                        string serverUrl = ServiceManager.SharedInstance.ServerUrlForChannel(OperationContext.Current.Channel);
                        ServiceManager.LogMessage("[OperationInvoker] {0}() {1} processed - {2} item(s), {3} ms.",
                                                  invokeContext, serverUrl, service.NumProcessed, stopwatch.ElapsedMilliseconds);
                    }
                    return(result);
                }
                catch (FaultException fault)
                {
                    ServiceManager.LogMessage("[OperationInvoker] Fault was thrown during {0}: ({1}) {2}",
                                              invokeContext, fault.Code.Name, fault.Reason.ToString());
                    throw;
                }
                catch (Exception ex)
                {
                    ServiceManager.LogMessage("[OperationInvoker] {0} was thrown during {1}:\n{2}", ex.GetType().Name, invokeContext, ex.Message);
                    throw new FaultException(ex.Message, new FaultCode("E_FAIL"));
                }
            }
            finally
            {
                Interlocked.Decrement(ref InvokeBalancer);
            }
        }