コード例 #1
0
        public Fields GetResultFields(PropertySet PropMods)
        {
            ServiceMethod <Fields> method = (client) =>
            {
                using (var contextScope = new OperationContextScope(client.InnerChannel))
                {
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                        _CreateRequestMessageProperty();

                    return(client.GetResultFields(PropMods));
                }
            };

            return(Invoke <Fields>(method));
        }
コード例 #2
0
        public DownloadFileResponse DownloadFile(string jobId, string fileReferenceId)
        {
            using (var scope = new OperationContextScope(this.InnerChannel))
            {
                var httpRequest = _Wrapper.CreateRequestMessageProperty("downloadFile");
                OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, httpRequest);

                var downloadFileRequest = new DownloadFileRequest();
                downloadFileRequest.fileReferenceId = fileReferenceId;
                downloadFileRequest.taskReferenceId = jobId;

                var rez = base.downloadFile(downloadFileRequest);
                return(rez);
            }
        }
コード例 #3
0
        public RecordSet FindAddressCandidates(PropertySet Address, PropertySet PropMods)
        {
            ServiceMethod <RecordSet> method = (client) =>
            {
                using (var contextScope = new OperationContextScope(client.InnerChannel))
                {
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                        _CreateRequestMessageProperty();

                    return(client.FindAddressCandidates(Address, PropMods));
                }
            };

            return(Invoke <RecordSet>(method));
        }
コード例 #4
0
        private BuyStockResponseInternal BuyStockInternal(BuyStockRequestInternal internalRequest)
        {
            Log(Logger.LogMessageType.Info, "->   -------------------- Comienza la ejecución del método Stock.BuyStockInternal", Logger.LoggingLevelType.Medium);
            BuyStockResponseInternal internalResponse = null;

            try
            {
                UMarketSCClient  utibaClient           = new UMarketSCClient();
                buyStockResponse utibaBuyStockResponse = null;
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);
                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos Stock.BuyStockInternal: " +
                                                                                                 "SessionID={0}, DeviceType={1}, Amount={2}", internalRequest.SessionID, internalRequest.DeviceType, internalRequest.Amount), Logger.LoggingLevelType.Low);

                    utibaBuyStockResponse = utibaClient.buyStock(new buyStock()
                    {
                        buyStockRequest = new buyStockRequestType()
                        {
                            sessionid   = internalRequest.SessionID,
                            amount      = internalRequest.Amount,
                            device_type = internalRequest.DeviceType
                        }
                    });
                }
                if (utibaBuyStockResponse != null)
                {
                    internalResponse = new BuyStockResponseInternal()
                    {
                        ResponseCode    = utibaBuyStockResponse.buyStockReturn.result,
                        ResponseMessage = utibaBuyStockResponse.buyStockReturn.result_message,
                        Fee             = utibaBuyStockResponse.buyStockReturn.fee,
                        TransactionID   = utibaBuyStockResponse.buyStockReturn.transid
                    };
                }
                Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido Stock.BuyStockInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                             "Fee={3}", internalResponse.ResponseCode, internalResponse.ResponseMessage, internalResponse.TransactionID, internalResponse.Fee), Logger.LoggingLevelType.Low);
            }
            catch (Exception ex)
            {
                Log(Logger.LogMessageType.Error, "Ocurrio una exception procesando el metodo Stock.BuyStockInternal, los detalles son: " + ex.ToString(), Logger.LoggingLevelType.Low);
                return(null);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- Termina la ejecución del método Stock.BuyStockInternal", Logger.LoggingLevelType.Medium);
            return(internalResponse);
        }
コード例 #5
0
ファイル: KBDAPIService.cs プロジェクト: LProvalov/SUNTDLite
        public string CreateCard(List <CreateCardAttribute> listofattributes)
        {
            LOG_TRACE($"CreateCard, client:{_client != null}");
            if (_client != null)
            {
                string stringOfAttributes = string.Empty;
                string formatOfAttributes = "json";

                StringBuilder sb = new StringBuilder();
                sb.Append("[");
                for (int i = 0; i < listofattributes.Count; i++)
                {
                    sb.Append($"{{\"attrnum\":{listofattributes[i].attrnum},\"value\":\"{listofattributes[i].value}\"}}");
                    if (i < listofattributes.Count - 1)
                    {
                        sb.Append(",");
                    }
                }
                sb.Append("]");
                stringOfAttributes = sb.ToString();
                LOG_TRACE($"String of attributes: {stringOfAttributes}");
                if (!string.IsNullOrEmpty(stringOfAttributes))
                {
                    string guid;

                    using (OperationContextScope scope = new OperationContextScope(_client.InnerChannel))
                    {
                        HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                        httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                                                                                                  Convert.ToBase64String(Encoding.ASCII.GetBytes(_client.ClientCredentials.UserName.UserName + ":" + _client.ClientCredentials.UserName.Password));
                        OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                        guid = _client.CreateCard(stringOfAttributes, formatOfAttributes);
                    }

                    _requestGUIDList.Add(guid);
                    sb.Clear();
                    foreach (var item in _requestGUIDList)
                    {
                        sb.Append(item).Append(",\t");
                    }
                    LOG_TRACE($"RequestGUIDList: {sb.ToString()}");
                    Thread.Sleep(10 * 1000);
                    LOG_TRACE($"wait 10 seconds");
                    return(guid);
                }
            }
            return(null);
        }
コード例 #6
0
        public bool IsAppointmentProgressive(long appointmentRefRecId)
        {
            //HMAppointmentSchedulingServiceClient client = new HMAppointmentSchedulingServiceClient();

            //CallContext callContext = new CallContext { Company = AppSettings.GetByKey("axCompany") };
            //client.ClientCredentials.Windows.ClientCredential = new NetworkCredential { Domain = AppSettings.GetByKey("axDomain"), UserName = AppSettings.GetByKey("axUserName"), Password = AppSettings.GetByKey("axPassword") };

            //bool contract = client.isAppointmentProgressive(callContext, appointmentRefRecId);
            //client.Close();

            //return contract;

            bool ret = false;

            try
            {
                var endpointAddress = SoapHelper.GetEndPointAddress();
                var binding         = SoapHelper.GetBinding();

                var client  = new HMAppointmentSchedulingServiceClient(binding, endpointAddress);
                var channel = client.InnerChannel;

                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    SoapHelper.channelHelper();

                    isAppointmentProgressiveResponse obj = ((HMAppointmentSchedulingService)channel).isAppointmentProgressive(new isAppointmentProgressive()
                    {
                        _appointmentRecId = appointmentRefRecId
                    });

                    if (obj.result)
                    {
                        ret = obj.result;
                    }
                    else
                    {
                        throw new ValidationException(CommonRepository.getErrorMessage(obj.Infolog));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(ret);
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: liuhonglei/WCFStudy
        private void Form1_Load(object sender, EventArgs e)
        {
            string header = string.Format(" {0,-13} {1,-22} {2} ", "Client", "Time", "Event");

            listBox1.Items.Add(header);
            _syncContext    = SynchronizationContext.Current;
            _channelFactory = new ChannelFactory <ICalculator>("calculatorservice");

            EventMonitor.MonitoringNotificationSended += ReceiveMonitoringNotification;
            this.Disposed += Form1_Disposed;
            ICalculator proxy = _channelFactory.CreateChannel();

            (proxy as ICommunicationObject).Open(); //显式开启可以 服务调用可以及时处理
            for (int i = 0; i < 5; i++)
            {
                ThreadPool.QueueUserWorkItem((state) =>
                {
                    #region   的代理进行调用
                    //int clientId = Interlocked.Increment(ref clientIndex);
                    //ICalculator proxy = _channelFactory.CreateChannel();
                    //using (proxy as IDisposable)
                    //{
                    //    EventMonitor.Send(clientId, EventType.StartCall);
                    //    using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
                    //    {
                    //        MessageHeader<int> messageHeader = new MessageHeader<int>(clientId);
                    //        OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.ClientIdHeaderLocalName, EventMonitor.ClientIdHeaderNamespace));
                    //        proxy.Add(1, 2);

                    //    }
                    //    EventMonitor.Send(clientId, EventType.EndCall);
                    //}
                    #endregion
                    int clientId = Interlocked.Increment(ref clientIndex);
                    EventMonitor.Send(clientId, EventType.StartCall);
                    using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
                    {
                        MessageHeader <int> messageHeader = new MessageHeader <int>(clientId);
                        OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.ClientIdHeaderLocalName, EventMonitor.ClientIdHeaderNamespace));
                        proxy.Add(1, 2);
                    }
                    EventMonitor.Send(clientId, EventType.EndCall);
                    #region

                    #endregion
                }, null);
            }
        }
コード例 #8
0
        public string getDocumentsBase64(long docuRefRecId)
        {
            string file = string.Empty;

            //HMCommonClient client = new HMCommonClient();

            //CallContext callContext = new CallContext { Company = AppSettings.GetByKey("axCompany") };
            //client.ClientCredentials.Windows.ClientCredential = new NetworkCredential { Domain = AppSettings.GetByKey("axDomain"), UserName = AppSettings.GetByKey("axUserName"), Password = AppSettings.GetByKey("axPassword") };

            //string file = client.getDocumentsBase64(callContext, docuRefRecId);

            //client.Close();

            //return file;

            try
            {
                var endpointAddress = SoapHelper.GetEndPointAddress();
                var binding         = SoapHelper.GetBinding();

                var client  = new HMCommonClient(binding, endpointAddress);
                var channel = client.InnerChannel;
                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    SoapHelper.channelHelper();

                    getDocumentsBase64Response obj = ((HMCommon)channel).getDocumentsBase64(new getDocumentsBase64()
                    {
                        docuRefRecId = docuRefRecId
                    });

                    if (!string.IsNullOrEmpty(obj.result))
                    {
                        file = obj.result;
                    }
                    else
                    {
                        throw new ValidationException(CommonRepository.getErrorMessage(obj.Infolog));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(file);
        }
コード例 #9
0
        public HMCaseTransContract getCaseTransDetails(long caseTransRecId)
        {
            HMCaseTransContract contract = new HMCaseTransContract();

            //HMCaseServiceClient client = new HMCaseServiceClient();

            //CallContext callContext = new CallContext { Company = AppSettings.GetByKey("axCompany") };
            //client.ClientCredentials.Windows.ClientCredential = new NetworkCredential { Domain = AppSettings.GetByKey("axDomain"), UserName = AppSettings.GetByKey("axUserName"), Password = AppSettings.GetByKey("axPassword") };

            //HMCaseTransContract contract = client.getCaseTransDetails(callContext, caseTransRecId);
            //client.Close();

            //return contract;

            try
            {
                var endpointAddress = SoapHelper.GetEndPointAddress();
                var binding         = SoapHelper.GetBinding();

                var client  = new HMCaseServiceClient(binding, endpointAddress);
                var channel = client.InnerChannel;

                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    SoapHelper.channelHelper();

                    getCaseTransDetailsResponse obj = ((HMCaseService)channel).getCaseTransDetails(new getCaseTransDetails()
                    {
                        _recId = caseTransRecId
                    });

                    if (obj.result != null)
                    {
                        contract = obj.result;
                    }
                    else
                    {
                        throw new ValidationException(CommonRepository.getErrorMessage(obj.Infolog));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(contract);
        }
コード例 #10
0
        public ActionResult executeMessagePost(string project, string message)
        {
            var client       = this.GetClient();
            var channel      = client.InnerChannel;
            var clientConfig = ClientConfiguration.getClientConfiguration();

            var context = new BisMessageHttpActionServiceReference.CallContext()
            {
                Language = clientConfig.LanguageId,
                Company  = clientConfig.CompanyId
            };

            var oauthHeader = OAuthHelper.GetAuthenticationHeader(clientConfig);

            var result  = "<xml>Empty</xml>";
            var content = "";

            try
            {
                Response.ContentType = @"text/plain";

                content = this.GetInputContent();

                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    HttpRequestMessageProperty requestMessage = new HttpRequestMessageProperty();
                    requestMessage.Headers[OAuthHelper.OAuthHeader] = oauthHeader;
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestMessage;

                    result = ((BisMessageHttpActionServiceReference.BisMessageStartFromHttp)channel).executeMessage(new BisMessageHttpActionServiceReference.executeMessage(context, content, message, project)).result;
                }

                return(Content(result));
            }
            catch (Exception ex)
            {
                result = String.Format("<xml>Error: {0}</xml>", ex.Message);

                return(Content(result));
            }
            finally
            {
                if (client != null)
                {
                    client.Close();
                }
            }
        }
コード例 #11
0
ファイル: Class1.cs プロジェクト: joeiren/smarths
 public static string Test()
 {
     SmartHsServiceProxy.SmartHsServiceClient smartClient = new SmartHsServiceClient();
     using (var scope = new OperationContextScope(smartClient.InnerChannel))
     {
         // 注意namespace必须和ServiceContract中定义的namespace保持一致,默认是:http://smarths-ndtv.com
         var myNamespace = "http://smarths-ndtv.com";
         // 注意Header的名字中不能出现空格,因为要作为Xml节点名。
         var user = MessageHeader.CreateHeader("user", myNamespace, "test");
         var pwd  = MessageHeader.CreateHeader("pwd", myNamespace, "test123");
         OperationContext.Current.OutgoingMessageHeaders.Add(user);
         OperationContext.Current.OutgoingMessageHeaders.Add(pwd);
         var result = smartClient.AddMember(string.Empty);
         return(null);
     }
 }
コード例 #12
0
ファイル: ServicesHelper.cs プロジェクト: jouvane/Main
        protected virtual void GetServices <T>(Action <T> service, T channel, Dictionary <string, string> namedParameters = null, string ns = null)
        {
            IContextChannel contextChannelService = channel as IContextChannel;

            if (contextChannelService != null && namedParameters != null)
            {
                using (OperationContextScope scope = OperationContextHelper.Current.CreateOperationContextScope(namedParameters, contextChannelService, ns))
                {
                    service(channel);
                }
            }
            else
            {
                service(channel);
            }
        }
コード例 #13
0
ファイル: FE_MOL.cs プロジェクト: pmacri/NPCE_Client
        public void MOL_RecuperaStatoCover()
        {
            RecuperaStatoCoverRequest recuperaStatoCoverRequest = new RecuperaStatoCoverRequest
            {
                CodiceContratto = "40000015977",
                IdCover         = new string[] {
                    "HH800112_MOL_154"
                }
            };
            IRaccomandataMarketService _proxy = GetProxy <IRaccomandataMarketService>(ambiente.MolUri);
            var fake = new OperationContextScope((IContextChannel)_proxy);
            HttpRequestMessageProperty headers = GetHttpHeaders(ambiente);

            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = headers;
            var invioResult = _proxy.RecuperaStatoCover(recuperaStatoCoverRequest);
        }
コード例 #14
0
ファイル: FrmMain.cs プロジェクト: wj60387/ESkin2
 void FrmMain_Load(object sender, EventArgs e)
 {
     using (OperationContextScope scope = new OperationContextScope(remoteService.InnerChannel))
     {
         MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", SN);
         OperationContext.Current.OutgoingMessageHeaders.Add(header);
         header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", MAC);
         OperationContext.Current.OutgoingMessageHeaders.Add(header);
         string sql = @"SELECT  Version FROM " + VersionMajor + " WHERE Enable=1";
         var    ds  = remoteService.ExecuteDataset(sql, null);
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             ucTextBoxEx1.Text = ds.Tables[0].Rows[0][0] + "";
         }
     }
 }
コード例 #15
0
        public void TestSTSogFMKAssertionAsXml()
        {
            //Seal kort oprettes
            //FMK kaldes
            //Assertion overføres via SealCard som XML
            var rsc = SealCard.Create(AssertionMaker.MakeAssertionForSTS(Global.MocesCprGyldig));
            var sc  = SealUtilities.SignIn(rsc, "http://www.ribeamt.dk/EPJ", Settings.Default.SecurityTokenService);

            var client = new proxy.MedicineCardPortTypeClient("localFMK");

            using (var scope = new OperationContextScope(client.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(new SealCardMessageHeader(sc));
                client.GetMedicineCard_20120101(null, MakeHeader());
            }
        }
コード例 #16
0
        public void ReverseGeocodeAsync(Point Location, bool ReturnIntersection, PropertySet PropMods, object userState)
        {
            Guid          id     = Guid.NewGuid();
            ServiceMethod method = (client) =>
            {
                using (var contextScope = new OperationContextScope(client.InnerChannel))
                {
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                        _CreateRequestMessageProperty();

                    client.ReverseGeocodeAsync(Location, ReturnIntersection, PropMods, id);
                }
            };

            InvokeAsync(method, id, userState);
        }
コード例 #17
0
        /// <summary>
        /// Executes the actual web request while applying appropriate security credentials
        /// </summary>
        /// <typeparam name="TClient">The type of client being called</typeparam>
        /// <typeparam name="TRequest">The type of request being made</typeparam>
        /// <typeparam name="TResponse">The type of response received</typeparam>
        /// <param name="client">The client to use to make the service call</param>
        /// <param name="request">The request object being sent</param>
        /// <param name="requestDelegate">The method to use to actually make the call from the provided client</param>
        /// <returns></returns>
        public TResponse ExecuteRequest <TClient, TRequest, TResponse>(ClientBase <TClient> client, TRequest request, Func <TRequest, TResponse> requestDelegate)
            where TClient : class
            where TRequest : class
            where TResponse : class
        {
            client.Endpoint.EndpointBehaviors.Add(new InvalidResponseMessageHandlingBehavior());

            var securityHeader = CreateSecurityHeader(_username, _password);

            using (var operationContextScope = new OperationContextScope(client.InnerChannel))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(securityHeader);

                return(ExecuteRequest(request, requestDelegate));
            }
        }
コード例 #18
0
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (operationContextScope != null)
                    {
                        operationContextScope.Dispose();
                        operationContextScope = null;
                    }
                }

                disposed = true;
            }
        }
コード例 #19
0
        protected void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    if (this.operationContextScope != null)
                    {
                        this.operationContextScope.Dispose();
                        this.operationContextScope = null;
                    }
                }

                this.disposed = true;
            }
        }
コード例 #20
0
        public void Current()
        {
            Assert.IsNull(WebOperationContext.Current, "#1");
            var binding = new WebHttpBinding();
            var address = new EndpointAddress("http://localhost:37564");
            var ch      = (IContextChannel)WebChannelFactory <IHogeService> .CreateChannel(binding, address);

            using (var ocs = new OperationContextScope(ch)) {
                Assert.IsNotNull(WebOperationContext.Current, "#2");
                Assert.IsNotNull(WebOperationContext.Current.OutgoingRequest, "#3");
                Assert.IsNotNull(WebOperationContext.Current.IncomingRequest, "#4");
                Assert.IsNotNull(WebOperationContext.Current.IncomingResponse, "#5");
                Assert.IsNotNull(WebOperationContext.Current.OutgoingResponse, "#6");                  // pointless though.
            }
            ch.Close();
        }
コード例 #21
0
    static public void deliverMessageTo(int from, int to, int tok, int pay)
    {
        String key       = from.ToString() + "-" + to.ToString();
        int    delayTime = Node.map["-"];

        if (Node.map.ContainsKey(key))
        {
            delayTime = Node.map[key];
        }

        Thread.Sleep(delayTime);

        WebChannelFactory <INodeService> wcf   = null;
        OperationContextScope            scope = null;

        try
        {
            String arcUrl           = "http://localhost:" + Node.map[to.ToString()].ToString();
            var    myChannelFactory = new WebChannelFactory <INodeService>(new Uri(arcUrl));
            var    channel          = myChannelFactory.CreateChannel();

            Func <double> Millis = () => DateTime.Now.TimeOfDay.TotalMilliseconds;

            scope = new OperationContextScope((IContextChannel)channel);
            Console.WriteLine($"... {Millis():F2} {Node.ThisNode} > {from} {to} {tok} {pay}");
            channel.Message(from, to, tok, pay);
        }
        catch (Exception ex)
        {
            var msg = ($"*** Exception {ex.Message}");
            Console.Error.WriteLine(msg);
            Console.WriteLine(msg);
            wcf   = null;
            scope = null;
        }
        finally
        {
            if (wcf != null)
            {
                ((IDisposable)wcf).Dispose();
            }
            if (scope != null)
            {
                ((IDisposable)scope).Dispose();
            }
        }
    }
コード例 #22
0
        public HMPatientInfoContract GetPatientBasicDetails(string patientRecId)
        {
            HMPatientInfoContract contract = new HMPatientInfoContract();

            //HMPatientServiceClient client = new HMPatientServiceClient();

            //CallContext callContext = new CallContext { Company = AppSettings.GetByKey("axCompany") };
            //client.ClientCredentials.Windows.ClientCredential = new NetworkCredential { Domain = AppSettings.GetByKey("axDomain"), UserName = AppSettings.GetByKey("axUserName"), Password = AppSettings.GetByKey("axPassword") };

            //HMPatientInfoContract contract = new HMPatientInfoContract();

            //client.getPatientBasicDetails(callContext, patientRecId, contract);
            //client.Close();

            //return contract;

            try
            {
                var endpointAddress = SoapHelper.GetEndPointAddress();
                var binding         = SoapHelper.GetBinding();

                var client  = new HMPatientServiceClient(binding, endpointAddress);
                var channel = client.InnerChannel;
                using (OperationContextScope operationContextScope = new OperationContextScope(channel))
                {
                    SoapHelper.channelHelper();
                    getPatientBasicDetailsResponse response = ((HMPatientService)channel).getPatientBasicDetails(new getPatientBasicDetails()
                    {
                        _patientRecId = patientRecId
                    });
                    if (response.result != null)
                    {
                        contract = response.result;
                    }
                    else
                    {
                        new ValidationException(CommonRepository.getErrorMessage(response.Infolog));
                    }
                    //var result = ((HMPatientService)channel).getPatientBasicDetails(new getPatientBasicDetails() { _patientRecId = "0" }).result;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(contract);
        }
コード例 #23
0
ファイル: FrmAuscultation.cs プロジェクト: wj60387/ESkin2
       public void HandleMessage(RemoteEnterCode message)
       {
           if (this.IsDisposed || this.Disposing)
           {
               return;
           }
           Invoke(new MethodInvoker(() =>
           {
               if (message.Guid != this.Guid)
               {
                   return;
               }
               Mediator.ShowMsg(string.Format("远程机器{0}加入了远程听诊", message.SrcMac));
               if (this.isSender && message.SrcMac != Setting.authorizationInfo.MachineCode)
               {
                   foreach (var mac in this.DgvTable.Select().Select(r => r["MAC"] + "").ToArray().Distinct())
                   {
                       var code = new RemoteEnterCode()
                       {
                           Guid    = message.Guid,
                           SrcMac  = Setting.authorizationInfo.MachineCode,
                           DestMac = mac
                       };
                       var _bytes = ProtocalData.Utilities.SerializaHelper.Serialize(code);
                       Mediator.SuperSocket.Send(_bytes);
                   }
               }
               else
               {
                   string sql = @"select b.StetName,b.MAC,b.PCName,b.StetChineseName,b.Owner from RemoteAuscultateList a left join StethoscopeManager b
 on a.Acceptor=b.StetName and a.MAC=b.MAC where a.SrcGUID={0} and a.isAccept=1 and isExit=0";
                   using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                   {
                       MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                       OperationContext.Current.OutgoingMessageHeaders.Add(header);
                       header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                       OperationContext.Current.OutgoingMessageHeaders.Add(header);
                       var ds = Mediator.remoteService.ExecuteDataset(sql, new string[] { this.Guid });
                       dgvRemote.Rows.Clear();
                       foreach (DataRow row in ds.Tables[0].Rows)
                       {
                           dgvRemote.Rows.Add(row["StetChineseName"], row["StetName"], row["PCName"], row["MAC"], row["Owner"], true);
                       }
                   }
               }
           }));
       }
コード例 #24
0
        public void NewHostedServiceProcess()
        {
            string                   serviceName;
            Action <string>          action = null;
            CreateHostedServiceInput createHostedServiceInput = new CreateHostedServiceInput();

            createHostedServiceInput.ServiceName = this.ServiceName;
            if (string.IsNullOrEmpty(this.Label))
            {
                serviceName = this.ServiceName;
            }
            else
            {
                serviceName = this.Label;
            }
            string str = serviceName;

            createHostedServiceInput.Label         = ServiceManagementHelper.EncodeToBase64String(str);
            createHostedServiceInput.Description   = this.Description;
            createHostedServiceInput.AffinityGroup = this.AffinityGroup;
            createHostedServiceInput.Location      = this.Location;
            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                try
                {
                    CmdletExtensions.WriteVerboseOutputForObject(this, createHostedServiceInput);
                    NewAzureServiceCommand newAzureServiceCommand = this;
                    if (action == null)
                    {
                        action = (string s) => base.Channel.CreateHostedService(s, createHostedServiceInput);
                    }
                    ((CmdletBase <IServiceManagement>)newAzureServiceCommand).RetryCall(action);
                    Operation operation = base.WaitForOperation(base.CommandRuntime.ToString());
                    ManagementOperationContext managementOperationContext = new ManagementOperationContext();
                    managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString());
                    managementOperationContext.set_OperationId(operation.OperationTrackingId);
                    managementOperationContext.set_OperationStatus(operation.Status);
                    ManagementOperationContext managementOperationContext1 = managementOperationContext;
                    base.WriteObject(managementOperationContext1, true);
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    this.WriteErrorDetails(communicationException);
                }
            }
        }
コード例 #25
0
ファイル: FrmMain.TZPZ.cs プロジェクト: wj60387/ESkin2
        public void ConfigStet(string StetName)
        {
            var info         = Setting.GetStetInfoByStetName(StetName);
            var formStetInfo = new FrmStetInfo()
            {
                StetOwner        = info.Owner,
                StetName         = info.StetName,
                StetChineseName  = info.StetChineseName,
                StetFuncDescript = info.FuncDescript,
                StetRemark       = info.ReMark,
                StetType         = info.StetType
            };

            formStetInfo.StartPosition = FormStartPosition.CenterParent;
            if (DialogResult.OK == formStetInfo.ShowDialog())
            {
                StetInfoCode stetInfoCode = new StetInfoCode()
                {
                    StetName        = formStetInfo.StetName,
                    StetChineseName = formStetInfo.StetChineseName,
                    SN           = Setting.authorizationInfo.AuthorizationNum,
                    PCName       = CommonUtil.GetMachineName(),
                    MAC          = Setting.authorizationInfo.MachineCode,
                    Owner        = formStetInfo.StetOwner,
                    FuncDescript = formStetInfo.StetFuncDescript,
                    ReMark       = formStetInfo.StetRemark,
                    StetType     = formStetInfo.StetType
                };
                var code = Newtonsoft.Json.JsonConvert.SerializeObject(stetInfoCode);
                using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
                {
                    MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);
                    header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                    OperationContext.Current.OutgoingMessageHeaders.Add(header);

                    if (Mediator.remoteService.UpdateStetInfo(code))
                    {
                        HandleMessage(stetInfoCode);
                        Mediator.ShowMsg("新增听诊器 " + formStetInfo.StetName + " 信息,并上传服务器成功...");
                        return;
                    }
                    Mediator.ShowMsg("新增听诊器 " + formStetInfo.StetName + " 信息,并上传服务器失败...");
                }
            }
            LoadStetInfoTZPZ();
        }
コード例 #26
0
ファイル: KBDAPIService.cs プロジェクト: LProvalov/SUNTDLite
        public ClassificatorDescModel GetClassificatorExpDesc(CardAttributeModel cardAttribute)
        {
            LOG_TRACE($"GetClassificatorExpDesc");
            if (_client != null && cardAttribute.AttributeType == AttributeType.ClassificatorExp)
            {
                ClassificatorDesc classificatorDesc;

                using (OperationContextScope scope = new OperationContextScope(_client.InnerChannel))
                {
                    HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                    httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                                                                                              Convert.ToBase64String(Encoding.ASCII.GetBytes(_client.ClientCredentials.UserName.UserName + ":" + _client.ClientCredentials.UserName.Password));
                    OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                    classificatorDesc = _client.GetClassificatorDesc((int)cardAttribute.AttributeNumber, 0);
                }

                if (classificatorDesc != null)
                {
                    ClassificatorDescModel ret = new ClassificatorDescModel(classificatorDesc);
                    foreach (var item in classificatorDesc.values)
                    {
                        try
                        {
                            ClassificatorDesc extDesc;

                            using (OperationContextScope scope = new OperationContextScope(_client.InnerChannel))
                            {
                                HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
                                httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                                                                                                          Convert.ToBase64String(Encoding.ASCII.GetBytes(_client.ClientCredentials.UserName.UserName + ":" + _client.ClientCredentials.UserName.Password));
                                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
                                extDesc = _client.GetClassificatorDesc((int)cardAttribute.AttributeNumber, item.oid);
                            }

                            if (extDesc != null && extDesc.values.Any())
                            {
                                ret.AddChilds(item.oid, extDesc.values);
                            }
                        }
                        catch (InvalidCastException)
                        { }
                    }
                    return(ret);
                }
            }
            return(null);
        }
コード例 #27
0
 private string RecuperaIdRichiesta()
 {
     try
     {
         var proxy = GetProxy <ROLServiceSoap>(ambiente.RolUri);
         var fake  = new OperationContextScope((IContextChannel)proxy);
         HttpRequestMessageProperty headers = GetHttpHeaders(ambiente);
         OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = headers;
         var result      = proxy.RecuperaIdRichiesta();
         var idRichiesta = result.IDRichiesta;
         return(idRichiesta);
     }
     catch (Exception)
     {
         throw;
     }
 }
        public override void InterceptSynchronous(IInvocation invocation)
        {
            if (!IsServiceMethodInvocation(invocation))
            {
                invocation.Proceed();                 // Dispose()
                return;
            }

            // This async syntax doesn't block WinForms UI
            string accessToken = Task.Run(async() =>
                                          await m_TokenService.GetTokenAsync()).Result;

            var channel = m_GetClientChannel();

            using (var scope = new OperationContextScope(channel))
            {
                var httpRequestProperty = new HttpRequestMessageProperty();
                httpRequestProperty.Headers[HttpRequestHeader.Authorization] =
                    $"Bearer {accessToken}";
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                    httpRequestProperty;

                try
                {
                    invocation.Proceed();
                }
                catch (FaultException ex)
                {
                    if (!Helpers.CouldBeExpiredTokenException(ex))
                    {
                        throw;
                    }

                    // Try to refresh token and replay the invocation
                    string newToken = Task.Run(async() =>
                                               await m_TokenService.GetTokenAsync()).Result;
                    if (newToken != accessToken)
                    {
                        httpRequestProperty.Headers[HttpRequestHeader.Authorization] =
                            $"Bearer {newToken}";

                        invocation.Proceed();
                    }
                }
            }
        }
コード例 #29
0
        static void Main(string[] args)
        {
            AppTourWSClient authService  = new AppTourWebService.AppTourWSClient();
            string          cookieHeader = "";

            using (OperationContextScope scope = new OperationContextScope(authService.InnerChannel))
            {
                HttpRequestMessageProperty requestProperty = new HttpRequestMessageProperty();
                OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = requestProperty;

                UserModel isGood = authService.Authentication("jonas", "jona");

                MessageProperties           properties       = OperationContext.Current.IncomingMessageProperties;
                HttpResponseMessageProperty responseProperty = (HttpResponseMessageProperty)properties[HttpResponseMessageProperty.Name];
                cookieHeader = responseProperty.Headers[HttpResponseHeader.SetCookie];
            }
        }
コード例 #30
0
        public static bool IsLoggedIn()
        {
            bool result = false;

            AuthenticationServiceClient client = new AuthenticationServiceClient();
            OperationContextScope       scope  = new OperationContextScope(client.InnerChannel);
            var prop = new HttpRequestMessageProperty();

            prop.Headers.Add(HttpRequestHeader.Cookie, ModelLocator.getInstance().SessionModel.SessionCookie);
            OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = prop;

            result = client.IsLoggedIn();

            client.Close();

            return(result);
        }
コード例 #31
0
            bool DoInvoke()
            {
                bool finishNow = false;

                try
                {
                    IAsyncResult result = null;

                    using (OperationContextScope operationScope = new OperationContextScope(this.operationContext))
                    {
                        result = this.invoker.innerInvoker.InvokeBegin(this.serviceInstance, this.inputs, invokeCallback, this);
                    }

                    if (result.CompletedSynchronously)
                    {
                        this.returnValue = this.invoker.innerInvoker.InvokeEnd(this.serviceInstance, out this.outputs, result);
                        finishNow = true;
                    }
                }
                catch (Exception e)
                {
                    if (Fx.IsFatal(e))
                    {
                        throw;
                    }

                    ServiceErrorHandler.MarkException(e);
                    this.completionException = e;
                    finishNow = true;
                }

                if (finishNow)
                {
                    if (DoFinish())
                    {
                        return true;
                    }
                }

                return false;
            }