예제 #1
0
 /// <summary>
 /// Skonfiguruj, autoryzuj i pobierz klienta do serwisu ICASA
 /// Set up, authorize and download the client to the ICASA service
 /// </summary>
 /// <returns>
 /// Klient serwisu ICASA jako IcasaMutationServiceReference.MutationServiceClient
 /// ICASA client as IcasaMutationServiceReference.MutationServiceClient
 /// </returns>
 public IcasaMutationServiceReference.MutationServiceClient GetIcasaMutationServiceClient()
 {
     try
     {
         BasicHttpBinding basicHttpBinding = GetBasicHttpBinding();
         WSHttpBinding    wSHttpBinding    = GetWSHttpBinding();
         CustomBinding    customBinding    = GetCustomBinding();
         var endpointAddress       = new EndpointAddress(EndpointAddress);
         var mutationServiceClient = new IcasaMutationServiceReference.MutationServiceClient(wSHttpBinding, endpointAddress);
         mutationServiceClient.Endpoint.Address = endpointAddress;
         mutationServiceClient.ClientCredentials.UserName.UserName = MutationServiceClientCredentialsUserName;
         mutationServiceClient.ClientCredentials.UserName.Password = MutationServiceClientCredentialsPassword;
         mutationServiceClient.Endpoint.EndpointBehaviors.Add(new NetAppCommon.Logging.SoapEndpointBehavior());
         var operationContextScope              = new OperationContextScope(mutationServiceClient.InnerChannel);
         var httpRequestMessageProperty         = new HttpRequestMessageProperty();
         var authenticationHeaderToBase64String = Convert.ToBase64String(Encoding.ASCII.GetBytes(string.Format("{0}:{1}", MutationServiceClientCredentialsUserName, MutationServiceClientCredentialsPassword)));
         httpRequestMessageProperty.Headers.Add("Authorization", $"Basic { authenticationHeaderToBase64String }");
         OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestMessageProperty;
         return(mutationServiceClient);
     }
     catch (Exception e)
     {
         Log4net.Error(string.Format("{0}, {1}", e.Message, e.StackTrace), e);
     }
     return(null);
 }
예제 #2
0
        //#region public static IcasaMutationServiceReference.MutationServiceClient IcasaMutationServiceClientN()
        ///// <summary>
        ///// Skonfiguruj, autoryzuj i pobierz klienta do serwisu ICASA
        ///// Set up, authorize and download the client to the ICASA service
        ///// </summary>
        ///// <returns>
        ///// Klient serwisu ICASA jako IcasaMutationServiceReference.MutationServiceClient
        ///// ICASA client as IcasaMutationServiceReference.MutationServiceClient
        ///// </returns>
        //public static IcasaMutationServiceN.MutationServiceClient GetIcasaMutationServiceClientN()
        //{
        //    try
        //    {
        //        //BasicHttpBinding basicHttpBinding = GetBasicHttpBinding();
        //        //WSHttpBinding wSHttpBinding = GetWSHttpBinding();
        //        //CustomBinding customBinding = GetCustomBinding();
        //        EndpointAddress endpointAddress = new EndpointAddress(EndpointAddress);
        //        //IcasaMutationServiceN.MutationServiceClient mutationServiceClient = new IcasaMutationServiceN.MutationServiceClient(wSHttpBinding, endpointAddress);
        //        IcasaMutationServiceN.MutationServiceClient mutationServiceClient = new IcasaMutationServiceN.MutationServiceClient();
        //        mutationServiceClient.Endpoint.Address = endpointAddress;
        //        mutationServiceClient.ClientCredentials.UserName.UserName = MutationServiceClientCredentialsUserName;
        //        mutationServiceClient.ClientCredentials.UserName.Password = MutationServiceClientCredentialsPassword;
        //        mutationServiceClient.Endpoint.EndpointBehaviors.Add(new NetAppCommon.Logging.SoapEndpointBehavior());
        //        //OperationContextScope operationContextScope = new OperationContextScope(mutationServiceClient.InnerChannel);
        //        //HttpRequestMessageProperty httpRequestMessageProperty = new HttpRequestMessageProperty();
        //        //string authenticationHeaderToBase64String = Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", MutationServiceClientCredentialsUserName, MutationServiceClientCredentialsPassword)));
        //        //httpRequestMessageProperty.Headers.Add("Authorization", $"Basic { authenticationHeaderToBase64String }");
        //        //OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestMessageProperty;
        //        return mutationServiceClient;
        //    }
        //    catch (Exception e)
        //    {
        //        log4net.Error(string.Format("{0}, {1}", e.Message, e.StackTrace), e);
        //    }
        //    return null;
        //}
        //#endregion

        #region public static async Task TestAsync()

        /* Niescalona zmiana z projektu „IcasaMutationServiceData (net5.0)”
         * Przed:
         *      public async Task TestAsync()
         * Po:
         *      public async Task Test()
         */

        /* Niescalona zmiana z projektu „IcasaMutationServiceData (netstandard2.1)”
         * Przed:
         *      public async Task TestAsync()
         * Po:
         *      public async Task Test()
         */
        public void Test()
        {
            try
            {
                Console.WriteLine("Begin");
                IcasaMutationServiceReference.MutationServiceClient mutationServiceClient = GetIcasaMutationServiceClient();
                if (null != mutationServiceClient)
                {
                    var storesRequest = new IcasaMutationServiceReference.GetStoresRequest();
                    Task <IcasaMutationServiceReference.GetStoresResponse> stores = mutationServiceClient.GetStoresAsync(storesRequest);
                    Console.WriteLine(stores.Result.GetStoresResult.OperationSuccess);
                    Console.WriteLine(stores.Result.GetStoresResult.Data.Length);
                    foreach (IcasaMutationServiceReference.StoreOut store in stores.Result.GetStoresResult.Data)
                    {
                        Console.WriteLine(store.CAIC);
                    }

                    var blockDebtorRequest = new IcasaMutationServiceReference.BlockDebtorRequest
                    {
                        DebtorExternalID = "",
                        Notes            = "Notes"
                    };
                    Task <IcasaMutationServiceReference.BlockDebtorResponse> blockDebtorResponse = mutationServiceClient.BlockDebtorAsync(blockDebtorRequest);
                    Console.WriteLine(blockDebtorResponse.Result.BlockDebtorResult.ErrorType);
                }

                Console.WriteLine("End");
            }
            catch (Exception e)
            {
                Log4net.Error(string.Format("{0}, {1}", e.Message, e.StackTrace), e);
                if (null != e.InnerException)
                {
                    Log4net.Error(string.Format("{0}, {1}", e.InnerException.Message, e.InnerException.StackTrace), e.InnerException);
                    if (null != e.InnerException.InnerException)
                    {
                        Log4net.Error(string.Format("{0}, {1}", e.InnerException.InnerException.Message, e.InnerException.InnerException.StackTrace), e.InnerException.InnerException);
                    }
                }
            }
        }