/// <summary>Hit when the users wants to get projects from the server or cancel an existing connection.</summary>
        /// <param name="sender">btnConnect</param>
        /// <param name="e">EventArgs</param>
        private void btnConnect_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            //They asked for it!
            if ((bool)btnConnect.Tag)
            {
                //Cancel the operation
                this._Client.Abort();
            }
            else
            {
                //Error check, first.
                if (this.CheckEntryFields())
                {
                    //Set display.
                    this.setDisplayforProgress(true);

                    //Save in settings
                    Properties.Settings.Default.SpiraUrl      = this.txbServer.Text.Trim();
                    Properties.Settings.Default.SpiraLogin    = this.txbUserID.Text.Trim();
                    Properties.Settings.Default.SpiraPassword = (chkRememberPassword.IsChecked.Value) ? this.txbUserPass.Password : "";

                    //Fire off a new client.
                    this._numRunning              = 0;
                    this.msgStatus.Text           = "Connecting to server...";
                    this._Client                  = new SpiraSoapService.SoapServiceClient();
                    this._Client.Endpoint.Address = new EndpointAddress(this.txbServer.Text + URI_APPEND);
                    BasicHttpBinding httpBinding = (BasicHttpBinding)this._Client.Endpoint.Binding;
                    WcfUtils.ConfigureBinding(httpBinding, this._Client.Endpoint.Address.Uri);
                    this._Client.Connection_Authenticate2Completed += new EventHandler <SpiraSoapService.Connection_Authenticate2CompletedEventArgs>(Client_Connection_Authenticate2Completed);
                    this._Client.Connection_Authenticate2Async(this.txbUserID.Text, this.txbUserPass.Password, Properties.Resources.Global_ApplicationName, this._numRunning++);
                }
            }
        }
示例#2
0
        private void OnGetLocalViewCompleted(IAsyncResult ar)
        {
            GroupQueuesDataProvider.GetLocalViewAsyncState getLocalViewAsyncState = (GroupQueuesDataProvider.GetLocalViewAsyncState)ar.AsyncState;
            DiagnosticsAggregationServiceClient            client = getLocalViewAsyncState.Client;
            ADObjectId        server       = getLocalViewAsyncState.Server;
            Stopwatch         stopwatch    = getLocalViewAsyncState.Stopwatch;
            LocalViewResponse response     = null;
            string            errorMessage = null;

            try
            {
                response = client.EndGetLocalView(ar);
            }
            catch (FaultException <DiagnosticsAggregationFault> faultException)
            {
                errorMessage = faultException.Detail.ToString();
            }
            catch (CommunicationException ex)
            {
                errorMessage = ex.Message;
            }
            catch (TimeoutException ex2)
            {
                errorMessage = ex2.Message;
            }
            finally
            {
                WcfUtils.DisposeWcfClientGracefully(client, false);
            }
            stopwatch.Stop();
            this.UpdateSnapshotForServer(server, getLocalViewAsyncState.RequestSessionId, stopwatch.Elapsed, response, errorMessage);
        }
示例#3
0
        public void Install(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden)
        {
            object extension = GetInstance(kernel, burden);

            if (extension is IServiceBehavior)
            {
                serviceHost.Description.Behaviors.Add((IServiceBehavior)extension);
            }
            else if (extension is IServiceHostAware)
            {
                WcfUtils.BindServiceHostAware(serviceHost, (IServiceHostAware)extension, true);
            }
            else if (extension is IErrorHandler)
            {
                WcfUtils.RegisterErrorHandler(serviceHost, (IErrorHandler)extension, true);
            }
            else if (extension is IExtension <ServiceHostBase> )
            {
                serviceHost.Extensions.Add((IExtension <ServiceHostBase>)extension);
            }
            else
            {
                WcfUtils.AttachExtension(serviceHost.Description.Behaviors, extension);
            }
        }
示例#4
0
 public override void AddDependencies(IKernel kernel, ComponentModel model)
 {
     WcfUtils.AddExtensionDependencies <IServiceBehavior>(kernel, WcfExtensionScope.Services, model);
     WcfUtils.AddExtensionDependencies <IServiceHostAware>(kernel, WcfExtensionScope.Services, model);
     WcfUtils.AddExtensionDependencies <IExtension <ServiceHostBase> >(kernel, WcfExtensionScope.Services, model);
     WcfUtils.AddExtensionDependencies <IErrorHandler>(kernel, WcfExtensionScope.Services, model);
 }
示例#5
0
        public override bool ChangePasswordQuestionAndAnswer(string username, string password, string newPasswordQuestion, string newPasswordAnswer)
        {
            WcfClientUtils.VerifyParameter("username", username);
            WcfClientUtils.VerifyParameter("password", password);
            WcfClientUtils.VerifyParameter("newPasswordQuestion", newPasswordQuestion);
            WcfClientUtils.VerifyParameter("newPasswordAnswer", newPasswordAnswer);

            using (_log.NewTrace())
            {
                try
                {
                    PasswordQAChangeRequest request = new PasswordQAChangeRequest();
                    request.NewAnswer           = newPasswordAnswer;
                    request.NewQuestion         = newPasswordQuestion;
                    request.Password            = password;
                    request.UserName            = username;
                    request.ServiceSessionToken = WcfClientUtils.SessionToken;
                    PasswordQAChangeReply response = _membershipService.CredentialChangePasswordQA(request);
                    return(response.Status == ActionStatus.OK && response.ResultStatus == true);
                }
                catch (Exception ex)
                {
                    throw WcfUtils.Extract(ex);
                }
            }
        }
        private static void AddErrorHandlers(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden)
        {
            var errorHandlers = new KeyedByTypeCollection <IErrorHandler>();

            WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, errorHandlers, burden, errorHandler =>
                                  WcfUtils.RegisterErrorHandler(serviceHost, errorHandler, true));
        }
示例#7
0
        private IInterceptor[] GetInterceptors(IKernel kernel, ComponentModel model, Type serviceContract, IWcfChannelHolder channelHolder, CreationContext context)
        {
            var interceptors = ObtainInterceptors(kernel, model, context);

            // TODO: this should be static and happen in IContributeComponentModelConstruction preferably
            var clientModel = (IWcfClientModel)model.ExtendedProperties[WcfConstants.ClientModelKey];

            Array.Resize(ref interceptors, interceptors.Length + (clientModel.WantsAsyncCapability ? 2 : 1));
            int index = interceptors.Length;

            interceptors[--index] = new WcfRemotingInterceptor(clients, channelHolder);

            if (clientModel.WantsAsyncCapability)
            {
                if (channelHolder.RealProxy == null)
                {
                    throw new InvalidOperationException(string.Format(
                                                            "Component {0} requested async support, but the channel does not support this capability.", model.Name));
                }
                var getAsyncType = WcfUtils.SafeInitialize(ref asyncType, () => AsyncType.GetAsyncType(serviceContract));
                interceptors[--index] = new WcfRemotingAsyncInterceptor(getAsyncType, clients, channelHolder);
            }

            return(interceptors);
        }
示例#8
0
        protected override void OnAfterStart()
        {
            try
            {
                _address = Constants.BaseAddress + Pid;

                var binding = WcfUtils.GetNetNamedPipeBinding();

                var ep = new EndpointAddress(_address);

                var type             = typeof(IRemoteVstService);
                var proxyCreatorType = MakeGenericType(type);
                var proxyCreator     = GetProxyCreator(proxyCreatorType, binding, ep);
                var x = _generator.CreateInterfaceProxyWithoutTarget(type, new[] { typeof(IContextChannel) },
                                                                     CreateInterceptor(proxyCreator, type));

                _vstService = x as IRemoteVstService;


                _vstService.Ping();
                _vstServiceAvailable = true;
                IsBusy = false;
                _pingTimer.Start();
            }
            catch (Exception ex)
            {
                ForceStop($"Failure when attempting to open the service channel: {ex}");
            }
        }
示例#9
0
 public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
 {
     using (_log.NewTrace())
     {
         //WcfClientUtils.VerifyParameter("username", username);
         //WcfClientUtils.VerifyParameter("password", password);
         //WcfClientUtils.VerifyParameter("email", email);
         //WcfClientUtils.VerifyParameter("passwordQuestion", passwordQuestion);
         //WcfClientUtils.VerifyParameter("passwordAnswer", passwordAnswer);
         try
         {
             IdentityCreateRequest request = new IdentityCreateRequest();
             request.ServiceSessionToken = WcfClientUtils.SessionToken;
             request.Answer   = passwordAnswer;
             request.User     = new MembershipUser("scrimpNetMembershipProvider", username, providerUserKey, email, passwordQuestion, "", isApproved, false, DateTime.UtcNow, Utils.Date.SqlMinDate, Utils.Date.SqlMinDate, DateTime.UtcNow, Utils.Date.SqlMinDate);
             request.Password = password;
             IdentityCreateReply response = _membershipService.IdentityCreate(request);
             status = response.CreateStatus;
             return(response.User);
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
示例#10
0
        public override bool ValidateUser(string username, string password)
        {
            using (_log.NewTrace())
            {
                //WcfClientUtils.VerifyParameter("username",username);  //validate user should not throw an error,simply return false
                //WcfClientUtils.VerifyParameter("password", password);

                try
                {
                    UserVerifyRequest request = new UserVerifyRequest();
                    request.ServiceSessionToken = WcfClientUtils.SessionToken;;
                    request.ChallengePrompt     = username;
                    request.ChallengeAnswer     = password;

                    UserVerifyReply response = _membershipService.CredentialVerify(request);
                    if (response.Context.IsAuthenticated == true)
                    {
                        _userSecurityToken = response.Context.IdentityToken;
                        return(true);
                    }

                    _log.Warning("User '{0}' is not validated with status '{1}'. {2}",
                                 username, response.Status, response.Messages.ToString());
                    _userSecurityToken = null;
                    return(false);
                }
                catch (Exception ex)
                {
                    throw WcfUtils.Extract(ex);
                }
            }
        }
示例#11
0
        public void Dispose()
        {
            var context = Channel as IContextChannel;

            if (context != null)
            {
                foreach (var cleanUp in context.Extensions.FindAll <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            var parameters = Channel.GetProperty <ChannelParameterCollection>();

            if (parameters != null)
            {
                foreach (var cleanUp in parameters.OfType <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            if (Channel != null)
            {
                WcfUtils.ReleaseCommunicationObject(Channel, CloseTimeout);
            }
        }
        public IRegistration Load(string key, Type service, Arguments arguments)
        {
            if (service == typeof(IWcfClientFactory))
            {
                throw new FacilityException(
                          "The IWcfClientFactory is only available with the TypedFactoryFacility.  " +
                          "Did you forget to register that facility? Also make sure that TypedFactoryFacility was registred before WcfFacility.");
            }

            if (service == null || WcfUtils.IsServiceContract(service) == false)
            {
                return(null);
            }

            var clientModel = WcfUtils.FindDependencies <IWcfClientModel>(arguments)
                              .FirstOrDefault() ?? new DefaultClientModel();

            var endpoint = WcfUtils.FindDependencies <IWcfEndpoint>(arguments).FirstOrDefault();

            if (endpoint != null)
            {
                clientModel = clientModel.ForEndpoint(endpoint);
            }
            else if (clientModel.Endpoint == null && string.IsNullOrEmpty(key) == false)
            {
                clientModel = clientModel.ForEndpoint(WcfEndpoint.FromConfiguration(key));
            }

            return(Component.For(service).Named(key).LifeStyle.Transient.AsWcfClient(clientModel));
        }
示例#13
0
        internal void AddServiceHostBuilder(Type builder, bool force)
        {
            if (typeof(IServiceHostBuilder).IsAssignableFrom(builder) == false)
            {
                throw new ArgumentException(string.Format(
                                                "The type {0} does not represent an IServiceHostBuilder.",
                                                builder.FullName), "builder");
            }

            var serviceHostBuilder = WcfUtils.GetClosedGenericDefinition(typeof(IServiceHostBuilder <>), builder);

            if (serviceHostBuilder == null)
            {
                throw new ArgumentException(string.Format(
                                                "The service model cannot be inferred from the builder {0}.  Did you implement IServiceHostBuilder<>?",
                                                builder.FullName), "builder");
            }

            if (kernel == null)
            {
                afterInit += () => RegisterServiceHostBuilder(serviceHostBuilder, builder, force);
            }
            else
            {
                RegisterServiceHostBuilder(serviceHostBuilder, builder, force);
            }
        }
示例#14
0
 public override void DisposeWebServiceClient(IDiagnosticsAggregationService client)
 {
     if (client != null)
     {
         WcfUtils.DisposeWcfClientGracefully((DiagnosticsAggregationServiceClient)client, false);
     }
 }
示例#15
0
        private static void ObtainServiceContract(ComponentModel model, IWcfClientModel clientModel)
        {
            var serviceContract = clientModel.Contract ??
                                  model.Services.Where(service => WcfUtils.IsServiceContract(service)).Single();

            model.ExtendedProperties[WcfConstants.ServiceContractKey] = serviceContract;
        }
示例#16
0
        public void Dispose()
        {
            if (Interlocked.CompareExchange(ref disposed, 1, 0) == 1)
            {
                return;
            }

            var context = channel as IContextChannel;

            if (context != null)
            {
                foreach (var cleanUp in context.CleanUp())
                {
                    cleanUp.CleanUp();
                }
            }

            var parameters = channel.GetProperty <ChannelParameterCollection>();

            if (parameters != null)
            {
                foreach (var cleanUp in parameters.OfType <IWcfCleanUp>())
                {
                    cleanUp.CleanUp();
                }
            }

            if (channel != null)
            {
                WcfUtils.ReleaseCommunicationObject(channel, closeTimeout);
            }
        }
示例#17
0
 private static void BindServiceHostAware(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden)
 {
     WcfUtils.AddBehaviors <IServiceHostAware>(kernel, WcfExtensionScope.Services, null, burden, serviceHostAware =>
     {
         WcfUtils.BindServiceHostAware(serviceHost, serviceHostAware, true);
         return(true);
     });
 }
示例#18
0
        public void Install(ChannelFactory channelFactory, IKernel kernel, IWcfBurden burden)
        {
            var extension = GetInstance(kernel, burden);

            if (extension is IChannelFactoryAware)
            {
                WcfUtils.BindChannelFactoryAware(channelFactory, (IChannelFactoryAware)extension, true);
            }
        }
示例#19
0
        private static void AddErrorHandlers(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden)
        {
            var errorHandlers = new List <IErrorHandler>();

            WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, errorHandlers, burden, errorHandler => WcfUtils.IsBehaviorExtension(errorHandler) == false);
            if (errorHandlers.Count > 0)
            {
                WcfUtils.RegisterErrorHandlers(serviceHost, errorHandlers);
            }
        }
 private static void BindChannelFactoryAware(ChannelFactory channelFactory, IKernel kernel, IWcfBurden burden)
 {
     WcfUtils.AddBehaviors <IWcfPolicy>(kernel, WcfExtensionScope.Undefined, null, burden, null);
     WcfUtils.AddBehaviors <IChannelFactoryAware>(kernel, WcfExtensionScope.Clients, null, burden,
                                                  channelFactoryAware =>
     {
         WcfUtils.BindChannelFactoryAware(channelFactory, channelFactoryAware, true);
         return(true);
     });
 }
示例#21
0
        private static void AddServiceHostExtensions(ServiceHost serviceHost, IKernel kernel, IWcfBurden burden)
        {
            var extensions = new KeyedByTypeCollection <IExtension <ServiceHostBase> >();

            WcfUtils.AddBehaviors(kernel, WcfExtensionScope.Services, extensions, burden, extension =>
            {
                serviceHost.Extensions.Add(extension);
                return(true);
            });
        }
示例#22
0
        protected override object Instantiate(CreationContext context)
        {
            var instance = base.Instantiate(context);

            var behavior = ProxyUtil.GetUnproxiedInstance(instance);
            var scope    = WcfUtils.GetScope(Model);

            WcfUtils.ExtendBehavior(Kernel, scope, behavior, context);

            return(instance);
        }
示例#23
0
        private bool CheckUserPass(string tokenString)
        {
            //获取消息发送的远程终结点IP和端口
            RemoteEndpointMessageProperty endpoint = WcfUtils.GetCurrentWCFClientEndpoint();

            string csname = string.Format("SystemWatchPass_{0}", endpoint.Address);
            string data   = SystemParameterHelper.GetSystemParms(csname);
            bool   ret    = (data == "") ? false : (data == tokenString);

            return(ret);
        }
示例#24
0
 private void ReleaseServiceHosts()
 {
     foreach (var serviceHost in hosts)
     {
         foreach (var cleanUp in serviceHost.Extensions.FindAll <IWcfCleanUp>())
         {
             cleanUp.CleanUp();
         }
         WcfUtils.ReleaseCommunicationObject(serviceHost, CloseTimeout);
     }
 }
示例#25
0
        public void RefreshChannel()
        {
            if (Channel == null || IsChannelUsable == false)
            {
                if (Channel != null)
                {
                    WcfUtils.ReleaseCommunicationObject(Channel, CloseTimeout);
                }

                CreateChannel();
            }
        }
示例#26
0
 public override Type[] GetInterfaces()
 {
     return(WcfUtils.SafeInitialize(ref interfaces, () =>
     {
         var effectiveInterfaces = syncType.GetInterfaces();
         for (int i = 0; i < effectiveInterfaces.Length; ++i)
         {
             effectiveInterfaces[i] = GetEffectiveType(effectiveInterfaces[i]);
         }
         return effectiveInterfaces;
     }));
 }
示例#27
0
        public void Install(ServiceEndpoint endpoint, bool withContract, IKernel kernel, IWcfBurden burden)
        {
            WcfUtils.AddBehaviors(kernel, scope, endpoint.Behaviors, burden);

            if (withContract)
            {
                WcfUtils.AddBehaviors(kernel, scope, endpoint.Contract.Behaviors, burden);

                foreach (var operation in endpoint.Contract.Operations)
                {
                    WcfUtils.AddBehaviors(kernel, scope, operation.Behaviors, burden);
                }
            }
        }
示例#28
0
 public override int GetNumberOfUsersOnline()
 {
     using (_log.NewTrace())
     {
         try
         {
             return(_membershipService.GetNumberOfUsersOnline());
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }
示例#29
0
        public void Install(ServiceEndpoint endpoint, bool withContract, IKernel kernel, IWcfBurden burden)
        {
            var extension = GetInstance(kernel, burden);

            if (extension is IEndpointBehavior)
            {
                endpoint.Behaviors.Add((IEndpointBehavior)extension);
            }
            else if (extension is IOperationBehavior)
            {
                if (withContract)
                {
                    foreach (var operation in endpoint.Contract.Operations)
                    {
                        operation.Behaviors.Add((IOperationBehavior)extension);
                    }
                }
            }
            else if (extension is IContractBehavior)
            {
                if (withContract)
                {
                    endpoint.Contract.Behaviors.Add((IContractBehavior)extension);
                }
            }
            else if (extension is IErrorHandler)
            {
                WcfUtils.RegisterErrorHandler(endpoint, (IErrorHandler)extension, true);
            }
            else if (WcfUtils.AttachExtension(endpoint.Behaviors, extension) == false)
            {
                if (withContract && !WcfUtils.AttachExtension(endpoint.Contract.Behaviors, extension))
                {
                    Type owner = null;

                    if (WcfUtils.IsExtension(extension, ref owner))
                    {
                        if (typeof(IOperationBehavior).IsAssignableFrom(owner))
                        {
                            foreach (var operation in endpoint.Contract.Operations)
                            {
                                WcfUtils.AttachExtension(operation.Behaviors, extension, owner);
                            }
                        }
                    }
                }
            }
        }
示例#30
0
 public override string[] GetAllRoles()
 {
     //using (_log.NewTrace())
     {
         try
         {
             RolesGetAllRequest request = new RolesGetAllRequest();
             request.ServiceSessionToken = _authenticationKey;
             return _appService.RolesGetAll(request).RoleNames;
         }
         catch (Exception ex)
         {
             throw WcfUtils.Extract(ex);
         }
     }
 }