public static WcfProxy <T> WcfEndPoint <T>(this ServiceStub stub, string endpoint, T fallback) where T : class
        {
            WcfProxy <T> proxy = stub.WcfEndPoint <T>(endpoint);

            proxy.Fallback = fallback;
            return(proxy);
        }
示例#2
0
        private void SetCredential <TService>(WcfProxy <TService> proxy) where TService : class, IServiceContract
        {
            var credential = proxy.Endpoint.Behaviors.OfType <ClientCredentials>().FirstOrDefault();

            if (!proxy.Endpoint.Behaviors.Contains(typeof(EndpointBehavior)))
            {
                proxy.Endpoint.Behaviors.Add(new EndpointBehavior());
            }

            if (credential != null)
            {
                if (credential.UserName.UserName == null)
                {
                    if (ISE.Framework.Common.Service.Security.LoginContext.ServiceLogin != null)
                    {
                        credential.UserName.UserName = ISE.Framework.Common.Service.Security.LoginContext.ServiceLogin.UserName;
                        credential.UserName.Password = ISE.Framework.Common.Service.Security.LoginContext.ServiceLogin.Password;
                        var elements        = proxy.Endpoint.Binding.CreateBindingElements();
                        var securityElement = elements.Find <SecurityBindingElement>();
                        if (securityElement != null)
                        {
                            securityElement.EnableUnsecuredResponse = true;
                            proxy.Endpoint.Binding = new CustomBinding(elements);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Inicializacia hlavného okna
 /// </summary>
 public MainWindow()
 {
     this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
     InitializeComponent();
     WcfClient = new ChannelFactory <IWcfKangoService>("KangoClient");
     WcfProxy  = WcfClient.CreateChannel();
     Logika    = new Engine();
     if (Logika.GetVstup())
     {
         Logika.LoadDataXml();
     }
     else
     {
         try
         {
             Logika.LoadDataFromDb(WcfProxy.LoadPouzivatelia(), WcfProxy.LoadSkupiny());
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             MessageBox.Show("Neboli načítané dáta z DB! (chyba na strane Wcf Hosta)", "Upozornenie",
                             MessageBoxButton.OK, MessageBoxImage.Asterisk);
         }
     }
     PrihlasenyStav            = false;
     PrihlasenyMeno            = "";
     DelPravo                  = false;
     PotrebaUlozit             = false;
     MenuLoginOut.IsEnabled    = false;
     MenuNewGroup.IsEnabled    = false;
     MenuItemConfig.Visibility = Visibility.Hidden;
     MenuLoginIn_Click(this, null);
 }
示例#4
0
 public void Execute(Action <TService> command)
 {
     try
     {
         proxy = proxy ?? new WcfProxy <TService>();
         command.Invoke(proxy.WcfChannel);
     }
     catch (FaultException ex)
     {
         Trace.WriteLine("Communication channel is faulted.");
         Trace.WriteLine(ex.Code.Name + ": " + ex.Message);
         if (proxy.State == CommunicationState.Faulted)
         {
             proxy = null;
         }
     }
     catch (CommunicationException ex)
     {
         Trace.WriteLine("Communication error is occured.");
         Trace.WriteLine(ex.Message);
         proxy = null;
     }
     catch (Exception ex)
     {
         Trace.WriteLine(ex.Message);
     }
 }
示例#5
0
 public byte[] GetImageFromPkr(string pkrPath)
 {
     using (var proxy = new WcfProxy <IPKRReport>())
     {
         return(proxy.Service.BuildImageFromPKR(pkrPath));
     }
 }
示例#6
0
        public byte[] GetStoreFile(string filePath)
        {
            byte[] data = null;
            if (PkpmConfigService.IsWcfEnabled.IsNullOrEmpty() ? true : PkpmConfigService.IsWcfEnabled == "1")
            {
                //var rootPath =   System.IO.Path.GetPathRoot(filePath);
                //  //var patth = filePath - rootPath;
                //  //var startPath = filePath.Substring(0, 3);
                //  //filePath = PathsDict[startPath] + filePath.Substring(3);
                //  System.IO.Path.Combine(PathsDict[rootPath], filePath.Substring(3));
                //  using (var proxy = new WcfProxy<ICloudFileTransferService>())
                //  {
                //      data = proxy.Service.GetCloudStoreFile(filePath);
                //  }
                using (var proxy = new WcfProxy <IFileTransferService>())
                {
                    data = proxy.Service.GetStoreFile(filePath);
                }
            }
            else
            {
                data = System.IO.File.ReadAllBytes(filePath);
            }

            return(data);
        }
示例#7
0
        public static ContactDto CreateOrUpdate(ContactDto item)
        {
            var proxy = new WcfProxy();

            return(item.Id == 0
                ? proxy.PerformRemote <IContactService, ContactDto>(x => x.Create(item))
                : proxy.PerformRemote <IContactService, ContactDto>(x => x.Update(item)));
        }
示例#8
0
 public MainWindow()
 {
     this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
     InitializeComponent();
     WcfClient = new ChannelFactory <IDissertationThemesService>("WordClient");
     WcfProxy  = WcfClient.CreateChannel();
     ButtonGenerator.IsEnabled         = false;
     ComboBoxYear.ItemsSource          = WcfProxy.GetThemeYears();
     ComboBoxYear.SelectedIndex        = 0;
     ComboBoxStPrograms.ItemsSource    = WcfProxy.GetStudyPrograms();
     ComboBoxStPrograms.SelectedIndex  = 0;
     DataGridFilteredItems.ItemsSource = WcfProxy.GetThemes(2018, 60);
 }
 /// <summary>
 /// Handler pre kliknutie ukladania v Main okne
 /// </summary>
 private void MenuItem_Click_Save(object paSender, RoutedEventArgs paE)
 {
     try
     {
         WcfProxy.SavePouzivatelia(Logika.GetPouzivatalia());
         WcfProxy.SaveSkupiny(Logika.GetSkupiny());
         PotrebaUlozit = false;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         MessageBox.Show("Zmeny neboli uložené! (možná chyba v spojení s databázou)", "Upozornenie", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
示例#10
0
        public static void TestStartHurricaneServiceManager()
        {
            System.Diagnostics.Debugger.Launch();
            var m = new HurricaneServiceManager();

            m.Start();
            var p = new WcfProxy <IFileService>(m.NetNamedPipeServiceEndpoint);

            try {
                var pathStatus = p.Service.Echo("test");
                //Console.WriteLine(pathStatus.PathType);
            } catch (FaultException <ArgumentException> ex) {
                Console.WriteLine(ex);
            }
            Console.Read();
        }
示例#11
0
        public List <ContactDto> GetAllContacts()
        {
            var results = WcfProxy.PerformRemote <IContactService, List <ContactDto> >(x => x.GetAll());

            if (results == null)
            {
                return(new List <ContactDto>());
            }

            var filterToUse     = DetermineWhere();
            var filteredResults = filterToUse(results);
            var orderToUse      = DetermineOrderBy();
            var orderedResults  = orderToUse(filteredResults);

            return(orderedResults.ToList());
        }
示例#12
0
        public TResult ExecuteCommand <TService, TResult>(Func <TService, TResult> command)
            where TResult : IDtoResponseEnvelop
            where TService : class, IContract
        {
            var proxy = new WcfProxy <TService>();

            try
            {
                var result = command.Invoke(proxy.WcfChannel);
                proxy.Close();
                return(result);
            }
            catch (Exception)
            {
                proxy.Abort();
                throw;
            }
        }
示例#13
0
        public string GetLargeFilePath(string sFilePath, string dFilePath)
        {
            if (PkpmConfigService.IsWcfEnabled.IsNullOrEmpty() ? true : PkpmConfigService.IsWcfEnabled == "1")
            {
                using (var proxy = new WcfProxy <IFileTransferService>())
                {
                    using (FileStream fs = new FileStream(dFilePath, FileMode.Create))
                    {
                        proxy.Service.GetPKRReport(sFilePath).CopyTo(fs);
                    }

                    return(dFilePath);
                }
            }
            else
            {
                return(sFilePath);
            }
        }
示例#14
0
        protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
        {
            try
            {
                base.RaisePostBackEvent(source, eventArgument);
            }
            catch
            {
                this.ShowError("Error has occurred.");
            }
            if (eventArgument == "")
            {
                return;
            }
            if (!int.TryParse(eventArgument, out _))
            {
                return;
            }
            var grid = (RadGrid)source;

            if (grid.ID == "RadGrid1")
            {
                GridDataItem item      = (GridDataItem)RadGrid1.MasterTableView.Items[eventArgument];
                var          contactId = item.GetDataKeyValue("id").ToString();
                if (string.IsNullOrEmpty(contactId))
                {
                    return;
                }
                var contact = WcfProxy.PerformRemote <IContactService, ContactDto>(x => x.GetById(contactId.ToInt()));
                if (contact != null)
                {
                    personImage.Attributes["src"] = $@"~/images/{contactId.ToInt()}.jpg";
                    lblName.Text         = $@"{contact.FirstName} {contact.Mobile}";
                    tbMobile.Text        = contact.Mobile;
                    hlMobile.NavigateUrl = $@"tel:{contact.Mobile}";
                    var script =
                        "function g(){openItemWindow(); Sys.Application.remove_load(g);}Sys.Application.add_load(g);";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
                }
            }
        }
        public Wse3GenericClient(string uri, string @namespace, string userName, string password, string mashineName, IWsseSecurityMessageHeaderFactory securityMessageHeaderFactory)
        {
            _namespace = @namespace;
            _userName = userName;
            _password = password;
            _mashineName = mashineName;
            _securityMessageHeaderFactory = securityMessageHeaderFactory;

            _uri = uri;

            _binding = new CustomWsHttpBinding
            {
                MaxReceivedMessageSize = int.MaxValue,
                HostNameComparisonMode = HostNameComparisonMode.StrongWildcard,
                Security = { Mode = SecurityMode.None },
                AllowCookies = false
            };

            _wcfClient = new WcfProxy(_binding, _uri);
            _tagTypeNameConverter = new TypeTagSoap12Converter();
        }
示例#16
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var selected = (ThemeDto)DataGridFilteredItems.SelectedItem;

            WcfProxy.GenerateDocx(selected.Id);
        }
示例#17
0
 public static void TestStartHurricaneServiceManager()
 {
     System.Diagnostics.Debugger.Launch();
     var m = new HurricaneServiceManager();
     m.Start();
     var p = new WcfProxy<IFileService>(m.NetNamedPipeServiceEndpoint);
     try {
         var pathStatus = p.Service.Echo("test");
         //Console.WriteLine(pathStatus.PathType);
     } catch (FaultException<ArgumentException> ex) {
         Console.WriteLine(ex);
     }
     Console.Read();
 }
 public override void Load()
 {
     //http://localhost:53066/{0}.svc  -->http://localhost:53066/ProductService.svc dönüşüyor gibi düşünebilirsin.Yani aslında bu sayfa çağırıldığında ProductManagerın yaptığı işlemleri yapıyor.Yani listeleme veya ekleme gibi işlemleri WCF servisi olarak kullanıyoruz.
     Bind <IProductService>().ToConstant(WcfProxy <IProductService> .CreateChannel());
 }
示例#19
0
 public override void Load()
 {
     //WcfProxy kullanarak Iproduct service için bana bir tane channel üret
     Bind <IProductService>().ToConstant(WcfProxy <IProductService> .CreateChannel());
 }
示例#20
0
 public override void Load()
 {
     Bind <ICustomerService>().ToConstant(WcfProxy <ICustomerService> .CreatChannel());
     Bind <IRoomService>().ToConstant(WcfProxy <IRoomService> .CreatChannel());
 }