private static void TraceOperation(ref Message request, IClientChannel channel, InstanceContext instanceContext) { if (_configSection.IsEnabled) { if (!request.IsEmpty) { // Enter your custom code in this block... string to = OperationContext.Current.IncomingMessageHeaders.To.ToString(); string action = OperationContext.Current.IncomingMessageHeaders.Action; string operationName = action.Substring(action.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1); string logLine = string.Format( "Request from {0} -> {1} (operationName = {2})", WcfHelper.GetClientIpAddress(), to, operationName); if (_configSection.WithMessageLogging) { logLine = string.Concat( logLine, Environment.NewLine, WcfHelper.MessageToString(ref request)); } LoggerServiceHelper.Current.WriteLine("WcfServiceTracking", LogStatusEnum.Info, logLine); } } }
public void BaseSetUp() { string url = "net.pipe://localhost/signing"; _host = WcfHelper.StartHost <ifPOS.v0.IATSSCD>(url, new DummyATSSCD()); _client = WcfHelper.GetProxy <ifPOS.v0.IATSSCD>(url); }
public void Initialize() { var view = new MainWindow(); mViewModel = new MainWindowViewModel { SelectedTab = 0, Bettors = new ObservableCollection <WcfBettor>(), Teams = new ObservableCollection <WcfTeam>(), Seasons = new ObservableCollection <WcfSeason>(), ButtonAdd = new RelayCommand(AddCommandExecute), ButtonEdit = new RelayCommand(EditCommandExecute, CommandCanExecute), ButtonDelete = new RelayCommand(DeleteCommandExecute, CommandCanExecute) }; view.DataContext = mViewModel; WcfHelper.Initialize(); // Erstelle Wcf Service // Daten Laden ReloadBettors(); ReloadSeasons(); ReloadTeams(); view.ShowDialog(); }
protected override void StartHost() { if (_serviceHost == null) { _serviceHost = WcfHelper.StartRestHost <ifPOS.v1.de.IDESSCD>(_url, new DummyDESSCD()); } }
private void SetAddressBinding(string replyAddress, NodeType peerNodeType) { _peerNodeType = peerNodeType; _peerAddressBinding = WcfHelper.CreateAddressBinding( replyAddress, WcfConst.LimitMultiplier, WcfConst.ExpressMsgLifetime); // dispose any existing client base DisposeHelper.SafeDispose(ref _clientBase); }
/// <summary> /// <see cref="Client" />クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="address">サービスのエンドポイントURI。</param> internal Client(Uri address) : base( new ServiceEndpoint( ContractDescription.GetContract(typeof(TGeneratedService)), WcfHelper.CreateBinding(), new EndpointAddress(address))) { }
private static void DumpMessage(ref Message message, Direction direction) { // Debug, Logger, etc... Debug.WriteLine("WcfMessageDumpInspector({0})", direction); Debug.WriteLine("---------------------------------------"); Debug.WriteLine(WcfHelper.MessageToString(ref message)); Debug.WriteLine("---------------------------------------"); }
/// <summary> /// <see cref="Client" />クラスの新しいインスタンスを初期化します。 /// </summary> /// <param name="callback">コールバックコントラクトのインスタンス。</param> /// <param name="address">サービスのエンドポイントURI。</param> internal Client(TGeneratedCallback callback, Uri address) : base( new InstanceContext(callback), new ServiceEndpoint( ContractDescription.GetContract(typeof(TGeneratedService)), WcfHelper.CreateBinding(), new EndpointAddress(address))) { }
private static void Main() { Title("Inheritance [Server]"); using var serviceHost = WcfHelper.CreateServiceHost <QueryService>() .AddNetNamedPipeEndpoint <Common.ServiceContracts.IQueryService>("net.pipe://localhost/8080/query") .OpenService(); PrintServerReady(); WaitForEnterKey(); }
private static void Main() { Title("Custom Type Resolver [Server]"); using var serviceHost = WcfHelper.CreateServiceHost <QueryService>() .AddNetNamedPipeEndpoint <IQueryService>("net.pipe://localhost/8080/query") .OpenService(); PrintServerReady(); WaitForEnterKey(); }
private static void Main() { Title("Async [Server]"); using var serviceHost = WcfHelper.CreateServiceHost <QueryService>() .IncludeExceptionDetailInFaults() .AddNetNamedPipeEndpoint <IQueryService>("net.pipe://localhost/8080/query") .OpenService(); PrintServerReady(); WaitForEnterKey(); }
public void Initialize() { mView = new WindowLogin(); mViewModel = new WindowLoginViewModel { LoginCommand = new RelayCommand(ExecuteLoginCommand), }; mView.DataContext = mViewModel; WcfHelper.Initialize(); mView.ShowDialog(); }
public static void Main() { Title("Simple Remote Query [Server]"); using var dataServiceHost = WcfHelper.CreateServiceHost <TraditionalDataService>() .AddNetTcpEndpoint <ITraditionalDataService>("net.tcp://localhost:8080/traditionaldataservice") .OpenService(); using var remoteLinqDataServiceHost = WcfHelper.CreateServiceHost <RemoteLinqDataService>() .AddNetTcpEndpoint <IRemoteLinqDataService>("net.tcp://localhost:8080/remotelinqdataservice") .OpenService(); PrintSetup("The server is ready."); WaitForEnterKey(); }
/// <summary> /// 构造函数 /// </summary> static YCJCService() { //原始地址调用方式 //typeClient = new SaveYCJCService01.SaveYCJCServicePortTypeClient().ChannelFactory.CreateChannel; //自定义地址调用方式(格式必须和原有的相同) List <KeyValuePair <string, string> > webServiceUrls = DataTransferEnvironment.GetInstance().WebServiceUrls; string url = ""; foreach (var item in webServiceUrls) { url = string.Format("{0}/{1}", item.Value, serviceName); typeClients.Add(item.Key, new SaveYCJCServiceUrlModel(url, WcfHelper.CreateWcfServiceByUrl(url, "basicHttpBinding"))); } }
private static void Main() { Title("Async"); const string url = "net.pipe://localhost/8080/query"; PrintSetup("Starting WCF service..."); using var serviceHost = WcfHelper.CreateServiceHost <Server.QueryService>() .AddNetNamedPipeEndpoint <Common.ServiceContracts.IQueryService>(url) .OpenService(); PrintSetup("Staring client demo..."); PrintSetup("-------------------------------------------------"); new Client.AsyncDemo(() => new Client.RemoteRepository(url)).RunAsync().Wait(); PrintSetup(); PrintSetup("-------------------------------------------------"); PrintSetup("Done."); WaitForEnterKey(); }
private static void Main() { Title("Custom Result Handler"); const string url = "net.pipe://localhost/8080/query"; PrintSetup("Starting WCF service..."); using var serviceHost = WcfHelper.CreateServiceHost <QueryService>() .AddNetNamedPipeEndpoint <IQueryService>(url) .OpenService(); PrintSetup("Staring client demo..."); PrintSetup("-------------------------------------------------"); new Demo(() => new RemoteRepository(url)).Run(); PrintSetup(); PrintSetup("-------------------------------------------------"); PrintSetup("Done."); WaitForEnterKey(); }
private static void Main(string[] args) { ParseContextArgs(args); Title("Server Defined Projection"); const string url = "net.pipe://localhost/8080/query"; PrintSetup("Starting WCF service..."); using var serviceHost = WcfHelper.CreateServiceHost <Server.QueryService>() .AddNetNamedPipeEndpoint <Common.ServiceContracts.IQueryService>(url) .OpenService(); PrintSetup("Staring client demo..."); PrintSetup("-------------------------------------------------"); new Client.Demo(() => new Client.RemoteRepository(url, accessToken: "secure1234")).RunDemo(); PrintSetup(); PrintSetup("-------------------------------------------------"); PrintSetup("Done."); WaitForEnterKey(); }
private static void Main() { Title("Simple Remote Query [Server]"); PrintSetup("Starting WCF service..."); using var dataServiceHost = WcfHelper.CreateServiceHost <Server.TraditionalDataService>() .AddNetTcpEndpoint <Common.ServiceContract.ITraditionalDataService>("net.tcp://localhost:8080/traditionaldataservice") .OpenService(); using var remoteLinqDataServiceHost = WcfHelper.CreateServiceHost <Server.RemoteLinqDataService>() .AddNetTcpEndpoint <Common.ServiceContract.IRemoteLinqDataService>("net.tcp://localhost:8080/remotelinqdataservice") .OpenService(); PrintSetup("Staring client demo..."); PrintSetup("-------------------------------------------------"); Client.Program.RunQueries(); PrintSetup(); PrintSetup("-------------------------------------------------"); PrintSetup("Done."); WaitForEnterKey(); }
private void Upload() { Boolean ExThrown = false; var dlgProgress = ProgressDialog.Show(this, "Uploading", "Please wait...", true); Save(true); Task.Factory.StartNew(() => { if (mobjForm != null) { WcfService.SurveySheetFormInput objUploadInput = new WcfService.SurveySheetFormInput(); objUploadInput.SheetName = mobjForm.SheetName; objUploadInput.SheetUID = mobjForm.SheetUID; objUploadInput.JobNumber = mobjForm.JobNumber; objUploadInput.Address = mobjForm.Address; objUploadInput.Client = mobjForm.Client; objUploadInput.Surveyor = mobjForm.Surveyor; objUploadInput.Date = mobjForm.Date; objUploadInput.ReasonForSurvey = mobjForm.ReasonForSurvey; objUploadInput.TotalSamplesTaken = mobjForm.TotalSamplesTaken; objUploadInput.Water = mobjForm.Water; objUploadInput.Power = mobjForm.Power; objUploadInput.Parking = mobjForm.Parking; objUploadInput.GeneralComments = mobjForm.GeneralComments; var lstInputItems = new List <WcfService.SurveySheetRoom>(); mobjForm.LoadItemsForForm(); //ensure form has newly created items for import foreach (BusinessLogic.SurveySheetRoom room in mobjForm.Rooms) { var currItem = new WcfService.SurveySheetRoom(); currItem.RoomUID = room.RoomUID; currItem.Room = room.Room; currItem.AreaBeingSampled = room.AreaBeingSampled; currItem.TotalSize = room.TotalSize; currItem.SampleTaken = room.SampleTaken; currItem.SampleNumber = room.SampleNumber; currItem.SpecificComments = room.SpecificComments; lstInputItems.Add(currItem); } objUploadInput.Items = lstInputItems.ToArray(); var uriSketch = Code.URI.FromPath(mobjForm.SketchPath); byte[] SketchBitmap; using (var stream = new MemoryStream()) { uriSketch.GetImage(this).Compress(Bitmap.CompressFormat.Png, 0, stream); SketchBitmap = stream.ToArray(); } objUploadInput.Sketch = SketchBitmap; objUploadInput.UploadingUserID = LoggedInUser.ID; if (!WcfHelper.Service().UploadSurveySheetForm(objUploadInput)) { mobjForm.Uploaded = false; new AlertDialog.Builder(this) .SetIcon(Resource.Drawable.Icon) .SetTitle("Upload failed.") .SetMessage("Survey Sheet failed to upload.") .Show(); return; } } }) .ContinueWith(t => { // Remove the progress spinner. if (dlgProgress != null) { dlgProgress.Dismiss(); } if (ExThrown) { new AlertDialog.Builder(this) .SetIcon(Resource.Drawable.Icon) .SetTitle("Unexpected Error") .SetMessage("an unexpected error while uploading the document has occurred, if the problem persists please contact your administrator.") .SetPositiveButton("Retry", (sender, args) => { Upload(); }) .SetNegativeButton("Cancel", (sender, args) => { }) .Show(); } else { //set statement to Uploaded mobjForm.Uploaded = true; Save(true); new AlertDialog.Builder(this) .SetIcon(Resource.Drawable.Icon) .SetTitle("Upload Complete.") .SetMessage("Survey Sheet uploaded successfully.") .SetNeutralButton("OK.", (sender, args) => { }) .Show(); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected override void StartHost() => _serviceHost = WcfHelper.StartRestHost <IDummyPOS>(_url, new DummyPOS());
protected override void StartHost() => _serviceHost = WcfHelper.StartHost <ifPOS.v1.IPOS>(_url, new DummyPOSV1());
protected override ifPOS.v0.IPOS CreateClient() => WcfHelper.GetProxy <ifPOS.v1.IPOS>(_url);
public TestClient(string host, int port) : base(WcfHelper.CreateAddressBinding( WcfConst.NetTcp, host, port, "Test", typeof(ITestService).Name)) { }
protected override void StartHost() => _serviceHost = WcfHelper.StartHost <ifPOS.v1.de.IDESSCD>(_url, new DummyDESSCD());
protected override ifPOS.v1.de.IDESSCD CreateClient() => WcfHelper.GetProxy <ifPOS.v1.de.IDESSCD>(_url);
/// <summary> /// Gets an OracleConnection instance given the connection string using the WcfHelper component. /// </summary> /// <param name="connectionString">The connection string</param> /// <returns>An OracleConnection instance</returns> internal static OracleConnection GetConnection(string connectionString) { Profile profile = WcfHelper.GetProfileFromContext(OperationContext.Current); return(OracleConnectionHelper.GetPooledConnection(profile.UserID, connectionString)); }
public static void Main(string[] args) { string _path = WcfHelper <IFileEngine> .CreateChannel().GetPath(); Tuple <List <Sievo>, List <string> > tupleData = null; try { // Necessary argument controls if (args.Length != 0) { if (args.Length == 1) { if (args[0] == "SortByStartDate") { if (string.IsNullOrEmpty(_path)) { Console.WriteLine("First File <Path> command must be executed!"); return; } else { tupleData = WcfHelper <IFileEngine> .CreateChannel().SortByStartDate(); } } else if (args[0] == "File") { Console.WriteLine("This command needs a <path> argument!"); return; } else if (args[0] == "Project") { Console.WriteLine("This command needs a <ID> argument!"); return; } else { Console.WriteLine("Undefined Command!"); return; } } else if (args.Length == 2) { if (args[0] == "File") { tupleData = WcfHelper <IFileEngine> .CreateChannel().File(args[1]); _path = WcfHelper <IFileEngine> .CreateChannel().GetPath(); } else if (args[0] == "Project") { if (string.IsNullOrEmpty(_path)) { Console.WriteLine("First File <Path> command must be executed!"); return; } else { tupleData = WcfHelper <IFileEngine> .CreateChannel().Project(int.Parse(args[1])); } } } else { Console.WriteLine("Unsupported command!"); return; } } else { Console.WriteLine("Necessary commands for this program : File <path>, SortByStartDate, Project <id>"); return; } WriteToConSole(tupleData); } catch (Exception e) { Console.Write(e.Message + "\nPress any key to exit."); } }
public object BeforeCall(string operationName, object[] inputs) { // Get the UserContext... IUserContext userContext = GetUserContext(inputs); if (userContext == null) { this.ThrowSecurityException( "WCF operations cannot be invoked without IUserContext instance!"); } if (!_configSection.IsEnabled) { return(null); } var mi = WcfHelper.GetInvokedMethodInfoFromOperationContext(); if (mi != null) { // Retrieve the method required roles (from cache first)... string key = string.Format("WcfOperationSecurityInspectorAttribute.{0}.{1}.RequiredRoles", mi.DeclaringType.FullName, operationName); IList <string> requiredRoles = CacheServiceHelper.Current.Get <List <string> >(key); if (requiredRoles == null) { lock (_locker) { requiredRoles = CacheServiceHelper.Current.Get <List <string> >(key); if (requiredRoles == null) { requiredRoles = new List <string>(); // Using Reflection to get the required roles... OperationSecurityAttribute attr = mi.GetCustomAttribute <OperationSecurityAttribute>(); if (attr != null) { requiredRoles = attr.Roles; } CacheServiceHelper.Current.Add(key, requiredRoles, TimeSpan.FromHours(1)); } } } if (requiredRoles.Count() == 0) // No specific role required -> exit. { return(null); } // Retrieve the User roles (from cache first)... key = string.Format("WcfOperationSecurityInspectorAttribute.UserRoles.{0}", userContext.Identifier); IList <string> userRoles = CacheServiceHelper.Current.Get <List <string> >(key); if (userRoles == null) { lock (_locker) { userRoles = CacheServiceHelper.Current.Get <List <string> >(key); if (userRoles == null) { // Write your custom code here to retrieve the User roles... // ------------------------------------------------------------ User user = null; if (ServiceContext.AuthenticationService.IsRegistered(userContext, out user)) { userRoles = user.UserRoleCollection.Select(i => i.Role).Select(j => j.CodeRef).ToList(); CacheServiceHelper.Current.Add(key, userRoles, TimeSpan.FromHours(1)); } else { this.ThrowSecurityException( "To execute the '{0}.{1}' operation the user '{2}' must be authenticated", mi.DeclaringType.FullName, mi.Name, userContext.Identifier); } // ------------------------------------------------------------ } } } // Check if the WCF operation can be invoked by the User... bool hasRole = false; foreach (string role in userRoles) { if (requiredRoles.Any(i => i == role)) { hasRole = true; break; } } if (!hasRole) { this.ThrowSecurityException( "To execute the '{0}.{1}' operation the user '{2}' must have at least one on the following roles: '{3}'", mi.DeclaringType.FullName, mi.Name, userContext.Identifier, string.Join(", ", requiredRoles)); } } return(null); }