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); }
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); }
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); } }
public byte[] GetImageFromPkr(string pkrPath) { using (var proxy = new WcfProxy <IPKRReport>()) { return(proxy.Service.BuildImageFromPKR(pkrPath)); } }
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); }
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))); }
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); } }
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 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()); }
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; } }
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); } }
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(); }
private void Button_Click(object sender, RoutedEventArgs e) { var selected = (ThemeDto)DataGridFilteredItems.SelectedItem; WcfProxy.GenerateDocx(selected.Id); }
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()); }
public override void Load() { //WcfProxy kullanarak Iproduct service için bana bir tane channel üret Bind <IProductService>().ToConstant(WcfProxy <IProductService> .CreateChannel()); }
public override void Load() { Bind <ICustomerService>().ToConstant(WcfProxy <ICustomerService> .CreatChannel()); Bind <IRoomService>().ToConstant(WcfProxy <IRoomService> .CreatChannel()); }