public JsonRpcDispatcher(IService service)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;
        }
Esempio n. 2
4
 public SearchController(IService<SearchRequest, SearchModel> service, IStudentSchoolAreaLinks studentSchoolLinks, ICurrentUserClaimInterrogator currentUserClaimInterrogator, IGradeLevelUtilitiesProvider gradeLevelUtilitiesProvider)
 {
     this.service = service;
     this.studentSchoolLinks = studentSchoolLinks;
     this.currentUserClaimInterrogator = currentUserClaimInterrogator;
     this.gradeLevelUtilitiesProvider = gradeLevelUtilitiesProvider;
 }
Esempio n. 3
0
 protected override void EstablishContext()
 {
     base.EstablishContext();
     Project = new Mock<IProject>();
     TimeService = new Mock<ITimeService>();
     Service = new Service(Project.Object, null, TimeService.Object);
 }
Esempio n. 4
0
 protected JsonRpcServiceFeature(IService service)
 {
     if (service == null)
         throw new ArgumentNullException("service");
     
     _service = service;
 }
Esempio n. 5
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="blogservices">Blog Services application methods</param>
 /// <param name="commentservices">Generic Comment Application Services</param>
 /// <param name="userservices">Generic User Service</param>
 /// <param name="postservices">Generic Post Service</param>
 public CommentController(IBlogServices blogservices, IService<Comment> commentservices, IService<User> userservices, IService<Post> postservices)
 {
     this.BlogServices = blogservices;
     this.CommentServices = commentservices;
     this.UserServices = userservices;
     this.PostServices = postservices;
 }
Esempio n. 6
0
 public ServiceRunner(IService service, string server, IDefaultBindingFactory defaultBindingFactory, IServerUriFactory serverUriFactory)
 {
     _service = service;
     _server = server;
     _defaultBindingFactory = defaultBindingFactory;
     _serverUriFactory = serverUriFactory;
 }
        /// <summary>
        /// Generates all schema classes for the specified service
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        public CodeNamespace GenerateSchemaClasses(IService service)
        {
            service.ThrowIfNull("service");

            logger.Debug("Starting to generate schemas for {1} in namespace {0}", schemaNamespace, service.Name);
            LogDecorators();
            var codeNamespace = new CodeNamespace(schemaNamespace);
            codeNamespace.Imports.Add(new CodeNamespaceImport("System"));
            codeNamespace.Imports.Add(new CodeNamespaceImport("System.Collections"));
            codeNamespace.Imports.Add(new CodeNamespaceImport("System.Collections.Generic"));
            SchemaGenerator generator = new SchemaGenerator(decorators);

            // Generate implementation details
            IDictionary<JsonSchema, SchemaImplementationDetails> implementationDetails =
                implementationDetailsGenerator.GenerateDetails(service);

            // Generate schemas
            foreach (var schemaPair in service.Schemas)
            {
                logger.Debug("Generating Schema {0}", schemaPair.Key);

                // Create schema
                codeNamespace.Types.Add(
                    generator.CreateClass(schemaPair.Value, implementationDetails, service.Schemas.Keys));
            }
            return codeNamespace;
        }
        private void submitButton_Click(object sender, RoutedEventArgs e)
        {
            var login = loginTextBox.Text;
            var pass = passwordTextBox.Password;

            Action<String> status = s => {
                statusLabel.Content = s;
                statusLabel.ToolTip = s;
            };

            try {
                channelFactory = new DuplexChannelFactory<IService>(new ClientImplementation(_MainWindow), "DnDServiceEndPoint");
                server = channelFactory.CreateChannel();

                if (server.Login(login, pass)) {
                    _MainWindow.InitializeServer(channelFactory, server);
                    this.DialogResult = true;
                } else {
                    statusLabel.Content = "Login lub hasło nie są poprawne!";
                    return;
                }

            } catch (Exception ex) {
                statusLabel.Content = "Nastąpił błąd! Spróbuj ponownie";
                System.IO.StreamWriter file = new System.IO.StreamWriter("log.txt");
                file.WriteLine(ex.ToString());
                file.Close();
                return;
            }
            this.Close();
        }
        public JsonRpcDispatcher(IService service, IServiceProvider serviceProvider)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            _service = service;

            if (serviceProvider == null)
            {
                //
                // No service provider supplied so check if the RPC service
                // itself is our service provider.
                //

                serviceProvider = service as IServiceProvider;

                //
                // If no service provider found so far, then create a default
                // one.
                //

                if (serviceProvider == null)
                    serviceProvider = new ServiceContainer();
            }

            _serviceProvider = serviceProvider;
        }
Esempio n. 10
0
 public GetHandler(IService service)
     : base("GET", "/slipstream")
 {
     Service = service;
     Count = 0;
     m_log.Info("[SLIPSTREAM]: Handler Loading");
 }
Esempio n. 11
0
        /// <summary>
        /// Add the given service (<paramref name="a_service"/>) to this listing.
        /// </summary>
        /// <param name="a_service">Service to add.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="a_service"/> is null.</exception>
        public void Add(IService a_service)
        {
            #region Argument Validation

            if (a_service == null)
                throw new ArgumentNullException(nameof(a_service));

            #endregion

            if (a_service.Contract == null)
                throw new InvalidOperationException("Service does not have a contract type.");

            lock (l_servicesByTypeGuid)
            {
                List<IService> services;
                if (_servicesByTypeGuid.ContainsKey(a_service.Contract.GUID))
                    services = _servicesByTypeGuid[a_service.Contract.GUID];
                else
                    services = _servicesByTypeGuid[a_service.Contract.GUID] = new List<IService>();

                services.Add(a_service);
            }

            if (a_service.Name != null)
            {
                var name = CreateServiceName(a_service.Contract, a_service.Name);

                lock (l_serviceByName)
                {
                    if (!_servicesByName.ContainsKey(name))
                        _servicesByName.Add(name, a_service);
                }
            }
        }
Esempio n. 12
0
 public void Initialize()
 {
     _clientRepositoryMock = new Mock<IClientRepository>();
     _chainMock = new Mock<IChain>();
     _invoiceRepositoryMock = new Mock<IInvoiceRepository>();
     _service = new Service(_invoiceRepositoryMock.Object, _clientRepositoryMock.Object, _chainMock.Object);
 }
        public void SetUp()
        {
            _lastService = null;
            _manager = null;

            _defaultRegistry = (registry =>
            {
                //registry.ForRequestedType<IService>()
                //    .AddInstances(
                //    Instance<ColorService>().WithName("Red").WithProperty("color").
                //        EqualTo(
                //        "Red"),
                //    Object<IService>(new ColorService("Yellow")).WithName("Yellow"),
                //    ConstructedBy<IService>(
                //        delegate { return new ColorService("Purple"); })
                //        .WithName("Purple"),
                //    Instance<ColorService>().WithName("Decorated").WithProperty("color")
                //        .
                //        EqualTo("Orange")
                //    );

                registry.ForRequestedType<IService>().AddInstances(x =>
                {
                    x.OfConcreteType<ColorService>().WithName("Red").WithProperty("color").EqualTo("Red");

                    x.Object(new ColorService("Yellow")).WithName("Yellow");

                    x.ConstructedBy(() => new ColorService("Purple")).WithName("Purple");

                    x.OfConcreteType<ColorService>().WithName("Decorated").WithProperty("color").EqualTo("Orange");
                });
            });
        }
        protected override void EstablishContext()
        {
            //Prepare supplied data collections
            suppliedListOfSchoolMetricModel = GetListOfSchoolMetricModel();

            //Set up the mocks
            schoolMetricTableService = mocks.StrictMock<IService<SchoolMetricTableRequest, SchoolMetricTableModel>>();
            metadataListIdResolver = mocks.StrictMock<IMetadataListIdResolver>();
            listMetadataProvider = mocks.StrictMock<IListMetadataProvider>();

            //Set expectations
            Expect.Call(schoolMetricTableService.Get(null))
                .Constraints(
                    new ActionConstraint<SchoolMetricTableRequest>(x =>
                    {
                        Assert.That(x.LocalEducationAgencyId == suppliedLocalEducationAgencyId);
                        Assert.That(x.MetricVariantId == suppliedMetricVariantId);
                    })
                ).Return(new SchoolMetricTableModel { SchoolMetrics = suppliedListOfSchoolMetricModel, ListMetadata = new List<MetadataColumnGroup>() });

            Expect.Call(metadataListIdResolver.GetListId(ListType.SchoolMetricTable, SchoolCategory.None)).Return(
                MetadataListIdResolver.SchoolMetricTableListId);

            Expect.Call(listMetadataProvider.GetListMetadata(MetadataListIdResolver.SchoolMetricTableListId)).Return(getSuppliedMetadataColumnGroups());
        }
Esempio n. 15
0
 public ServiceRunner(IService service, string serviceName)
 {
     if (service == null) throw new ArgumentNullException("service");
     if (serviceName == null) throw new ArgumentNullException("serviceName");
     _service = service;
     ServiceName = serviceName;
 }
Esempio n. 16
0
        /// <summary>
        /// It build connection request instance based on the service descriptor object
        /// </summary>
        /// <param name="service">Instance of IService</param>
        /// <returns>IConnectionRequest instance</returns>
	    public static IConnectionRequest PrepareConnectionRequest(IService service) 
        {

		    /*
		     * Resolve All Referring Resources
		     */
		    ServiceDescriptor serviceDescriptor = service.GetServiceDescriptor();
		    Connect.Model.ServiceDescriptor.Request request = serviceDescriptor.GetRequest(service.GetRequest());
		
		    String url = FormUrl(service);
		
		    IEnumerator<Connect.Model.ServiceDescriptor.Request.QueryParameter> queryParameters = FormQueryParameters(service);
		    IEnumerator<Connect.Model.ServiceDescriptor.Request.HeaderParameter> headerParameters = FormHeaderParameters(service);
		
		    byte[] dataStream = FormDataStream(service);
		
		    IConnectionRequest connectionRequest = new ConnectionRequest();
		    connectionRequest.SetUrl(url);
		    connectionRequest.SetProtocol(serviceDescriptor.GetProtocol());
		    connectionRequest.SetType(request.GetType());
		
		    while(queryParameters.MoveNext()) 
            {
			    connectionRequest.AddQueryParameter(queryParameters.Current);
		    }
		
		    while(headerParameters.MoveNext()) 
            {
			    connectionRequest.AddHeaderParameter(headerParameters.Current);
		    }

		    connectionRequest.SetDataStream(dataStream);

		    return connectionRequest;
	    }
Esempio n. 17
0
 public CategoryController(
     IService<Category> categoriesService,
     ICategoriesService categories)
 {
     this.categoriesService = categoriesService;
     this.categories = categories;
 }
Esempio n. 18
0
 public TeachersController(IService<TeachersRequest, TeachersModel> service, IListMetadataProvider listMetadataProvider, IMetadataListIdResolver metadataListIdResolver, ISchoolCategoryProvider schoolCategoryProvider)
 {
     this.service = service;
     this.listMetadataProvider = listMetadataProvider;
     this.metadataListIdResolver = metadataListIdResolver;
     this.schoolCategoryProvider = schoolCategoryProvider;
 }
        public SybilleWordPredictorEngine( IService<IWordPredictorFeature> wordPredictionFeature, string languageFileName, string userLanguageFileName, string userTextsFileName )
        {
            _currentRetryCount = NB_RETRY;

            try
            {
                //Sybille can throw an exception "Loading error"
                LoadSybilleWordPredictor( languageFileName, userLanguageFileName, userTextsFileName );

                //the plugin can be stopped before the construction have finished
                if( wordPredictionFeature.Status < InternalRunningStatus.Starting )
                {
                    _constructionSuccess = false;
                }
                else
                {
                    _sybille.FilterAlreadyShownWords = wordPredictionFeature.Service.FilterAlreadyShownWords;

                    _wordPredictionFeature = wordPredictionFeature;
                    _wordPredictionFeature.Service.PropertyChanged += OnWordPredictionFeaturePropertyChanged;
                    _constructionSuccess = true;
                }
            }
            catch( Exception e ) //Cannot instanciate the engine
            {
                _constructionSuccess = false;
            }
        }
Esempio n. 20
0
        public async Task RunService(IService service, CancellationToken token)
        {
            _logger.InfoFormat("Running service {0}", service.Name);

            await TaskEx.Yield();

            var blobs = _client.GetContainerReference("locks");
            await blobs.CreateIfNotExistAsync();

            var blob = blobs.GetBlobReference(service.Name);

            while (!token.IsCancellationRequested)
            {
                try
                {
                    if (service is IScheduledService)
                        await HandleScheduledService((IScheduledService)service, blob, token);
                    else if (service is IClusteredService)
                        await HandleClusteredService((IClusteredService)service, blob, token);
                    else if (service is IContinuousService)
                        await HandleContinuousService((IContinuousService)service, blob, token);
                }
                catch (OperationCanceledException)
                {
                    // no-op
                }
                catch (Exception e)
                {
                    _logger.ErrorFormat("The main task of service \"{0}\" threw an exception.", e, service.Name);
                }
            }

            _logger.InfoFormat("Service {0} stopped", service.GetType().Name);
            throw new OperationCanceledException(token);
        }
Esempio n. 21
0
        public object Invoke(IService service, object[] args)
        {
            if (service == null)
                throw new ArgumentNullException("service");

            try
            {
                if (Method.IsStatic)
                {
                    object[] argz = new object[args.Length + 1];
                    argz[0] = service;
                    args.CopyTo(argz, 1);
                    return Method.Invoke(null, argz);
                }
                else
                {
                    return Method.Invoke(service, args);
                }
            }
            catch (ArgumentException e)
            {
                throw TranslateException(e);
            }
            catch (TargetParameterCountException e)
            {
                throw TranslateException(e);
            }
            catch (TargetInvocationException e)
            {
                throw TranslateException(e);
            }
        }
 internal CodeMemberField CreateNameField(IService service)
 {
     var name = new CodeMemberField(typeof(string), NameName);
     name.Attributes = MemberAttributes.Const | MemberAttributes.Private;
     name.InitExpression = new CodePrimitiveExpression(service.Name);
     return name;
 }
		public CharacteristicDetail_TISensor (IAdapter adapter, IDevice device, IService service, ICharacteristic characteristic)
		{
			InitializeComponent ();
			this.characteristic = characteristic;

			Title = characteristic.Name;
		}
Esempio n. 24
0
        public LogInAsController(IService<CanLogInAsUserRequest, CanLogInAsUserModel> service, ILocalEducationAgencyAreaLinks localEducationAgencyAreaLinks,
			ISignInRequestMessageProvider signInRequestMessageProvider)
        {
            this.service = service;
            this.localEducationAgencyAreaLinks = localEducationAgencyAreaLinks;
            this.signInRequestMessageProvider = signInRequestMessageProvider;
        }
Esempio n. 25
0
 public SessionController()
 {
     this.accounts = new AccountService();
     this.selectionCards = new SelectionCardService();
     this.sessions = new SessionService();
     this.sessionCards = new SessionCardService();
 }
Esempio n. 26
0
   public CommandServicePresenter(IView view, IService service,
 ICommandExecutor executor)
   {
       _view = view;
         _service = service;
         _executor = executor;
   }
 public MultipleServiceManager(ILog log, IService[] services)
 {
     this.log = log;
     this.services = services.OrderBy(s => s.StartIndex).ToArray();
     ServiceName = "IronFoundryDEA"; // NB: must match installer Product.wxs
     AutoLog = true;
 }
 public void DecorateClass(IService service, CodeTypeDeclaration serviceClass)
 {
     serviceClass.Members.Add(CreateVersionField(service));
     serviceClass.Members.Add(CreateNameField(service));
     serviceClass.Members.Add(CreateUriField(service));
     serviceClass.Members.Add(CreateDiscoveryVersionField(service));
 }
 internal CodeMemberField CreateUriField(IService service)
 {
     var uri = new CodeMemberField(typeof(string), BaseUriName);
     uri.Attributes = MemberAttributes.Const | MemberAttributes.Private;
     uri.InitExpression = new CodePrimitiveExpression(service.BaseUri.ToString());
     return uri;
 }
Esempio n. 30
0
        public void Init()
        {
            container = new UnityContainer();
            ContainerBootstrap.RegisterTypes(container);

            service = container.Resolve<IService>();
        }
 public LoginController(IService <User> userService, IService <UserType> userTypeService)
 {
     _userService     = userService;
     _userTypeService = userTypeService;
 }
 /** <inheritDoc /> */
 public void DeployKeyAffinitySingleton <TK>(string name, IService service, string cacheName, TK affinityKey)
 {
     _services.DeployKeyAffinitySingletonAsync(name, service, cacheName, affinityKey).Wait();
 }
Esempio n. 33
0
 public override bool Pass(IService test)
 {
     return(true);
 }
Esempio n. 34
0
 public override bool Match(IService test)
 {
     return(true);
 }
Esempio n. 35
0
 public abstract bool Match(IService test);
Esempio n. 36
0
 public virtual bool Pass(IService test)
 {
     return(Match(test));
 }
Esempio n. 37
0
 public LoginController(IService service)
 {
     this.service = service;
 }
 /** <inheritDoc /> */
 public Task DeployKeyAffinitySingletonAsync <TK>(string name, IService service, string cacheName, TK affinityKey)
 {
     return(_services.DeployKeyAffinitySingletonAsync(name, service, cacheName, affinityKey));
 }
 /** <inheritDoc /> */
 public void DeployNodeSingleton(string name, IService service)
 {
     _services.DeployNodeSingletonAsync(name, service).Wait();
 }
 /** <inheritDoc /> */
 public Task DeployNodeSingletonAsync(string name, IService service)
 {
     return(_services.DeployNodeSingletonAsync(name, service));
 }
Esempio n. 41
0
 public JsonRpcGetProtocol(IService service) :
     base(service)
 {
 }
 /** <inheritDoc /> */
 public Task DeployMultipleAsync(string name, IService service, int totalCount, int maxPerNodeCount)
 {
     return(_services.DeployMultipleAsync(name, service, totalCount, maxPerNodeCount));
 }
Esempio n. 43
0
		internal void AddService(IService service)
		{
			_services[service.id] = service;
		}
Esempio n. 44
0
		/// <summary>
		/// Call this method in order to send a message from your code into the message routing system.
		/// The message is routed to a service that is defined to handle messages of this type.
		/// Once the service is identified, the destination property of the message is used to find a destination configured for that service.
		/// The adapter defined for that destination is used to handle the message.
		/// </summary>
		/// <param name="message">The message to be routed to a service.</param>
		/// <param name="endpoint">This can identify the endpoint that is sending the message but it is currently not used so you may pass in null.</param>
        /// <returns>The result of the message routing.</returns>
		internal IMessage RouteMessage(IMessage message, IEndpoint endpoint)
		{
			IService service = null;
			object result = null;
			IMessage responseMessage = null;

            if( log.IsDebugEnabled )
                log.Debug(__Res.GetString(__Res.MessageBroker_RoutingMessage, message.ToString()));

			CommandMessage commandMessage = message as CommandMessage;
			if( commandMessage != null && (commandMessage.operation == CommandMessage.LoginOperation || commandMessage.operation == CommandMessage.LogoutOperation) )//Login, Logout
			{
				try
				{
					service = GetService(AuthenticationService.ServiceId);
					result = service.ServiceMessage(commandMessage);
					responseMessage = result as IMessage;
				}
                catch (UnauthorizedAccessException uae)
                {
                    if (log.IsDebugEnabled)
                        log.Debug(uae.Message);
                    responseMessage = ErrorMessage.GetErrorMessage(message, uae);
                }
                catch (SecurityException exception)
                {
                    if (log.IsDebugEnabled)
                        log.Debug(exception.Message);
                    responseMessage = ErrorMessage.GetErrorMessage(message, exception);
                }
				catch(Exception exception)
				{
					if(log.IsErrorEnabled)
						log.Error(__Res.GetString(__Res.MessageBroker_RoutingError), exception);
					responseMessage = ErrorMessage.GetErrorMessage(message, exception);
				}
			}
            else if (commandMessage != null && commandMessage.operation == CommandMessage.ClientPingOperation)
            {
                responseMessage = new AcknowledgeMessage();
                responseMessage.body = true;
            }
            else
            {
				//The only case when context is not set should be when one starts a new thread in the backend
                //if( FluorineContext.Current != null )
                //    FluorineContext.Current.RestorePrincipal(this.LoginCommand);
                _loginManager.RestorePrincipal();
				service = GetService(message);
                if (service != null)
                {
                    try
                    {
                        service.CheckSecurity(message);
                        result = service.ServiceMessage(message);
                    }
                    catch (UnauthorizedAccessException uae)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(uae.Message);
                        result = ErrorMessage.GetErrorMessage(message, uae);
                    }
                    catch (SecurityException exception)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(exception.Message);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                    catch (ServiceException exception)
                    {
                        if (log.IsDebugEnabled)
                            log.Debug(exception.Message);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                    catch (Exception exception)
                    {
                        if (log.IsErrorEnabled)
                            log.Error(exception.Message, exception);
                        result = ErrorMessage.GetErrorMessage(message, exception);
                    }
                }
                else
                {
                    string msg = __Res.GetString(__Res.Destination_NotFound, message.destination);
                    if (log.IsErrorEnabled)
                        log.Error(msg);
                    result = ErrorMessage.GetErrorMessage(message, new FluorineException(msg));
                }
                if (!(result is IMessage))
                {
                    responseMessage = new AcknowledgeMessage();
                    responseMessage.body = result;
                }
                else
                    responseMessage = result as IMessage;
            }

			if( responseMessage is AsyncMessage )
			{
				((AsyncMessage)responseMessage).correlationId = message.messageId;
			}
			responseMessage.destination = message.destination;
			responseMessage.clientId = message.clientId;

			//Debug
			if( message.HeaderExists(AMFHeader.DebugHeader) )
			{
				log.Debug("MessageBroker processing debug header");
				ArrayList traceStack = NetDebug.GetTraceStack();
				responseMessage.SetHeader(AMFHeader.DebugHeader, traceStack.ToArray(typeof(object)) as object[]);
				NetDebug.Clear();
			}
            //The only case when we do not have context should be when the server side initiates a push
            if( FluorineContext.Current != null && FluorineContext.Current.Client != null )
                responseMessage.SetHeader(MessageBase.FlexClientIdHeader, FluorineContext.Current.Client.Id);

            if (log.IsDebugEnabled)
                log.Debug(__Res.GetString(__Res.MessageBroker_Response, responseMessage.ToString()));

			return responseMessage;
		}
Esempio n. 45
0
 public UniversityController(IService <UniversityDTO> universityService)
 {
     _universityService = universityService;
 }
Esempio n. 46
0
		internal void RegisterDestination(Destination destination, IService service)
		{
			_destinationServiceMap[destination.Id] = service.id;
            _destinations[destination.Id] = destination;
		}
Esempio n. 47
0
 public EmployeesController(IServiceUnitOfWork service)
 {
     _service = service.EmployeeService;
 }
Esempio n. 48
0
 /// <summary>
 /// Executed immediately after a service is executed. Use return to change response used.
 /// </summary>
 public virtual object OnPostExecuteServiceFilter(IService service, object response, IRequest httpReq, IResponse httpRes)
 {
     return(response);
 }
Esempio n. 49
0
 public CreateUser(IService service)
 {
     _service = service;
 }
Esempio n. 50
0
 public UsersController(IService iService, Users users)
 {
     this.IService = iService;
     this.users    = users;
 }
Esempio n. 51
0
 public StudentsController()
 {
     this.studentService = new StudentService();
 }
Esempio n. 52
0
        }     // HubEventHandler()

        //
        //
        //
        // *************************************************
        // ****             Process Request()           ****
        // *************************************************
        private void ProcessRequest(RequestEventArg <RequestCode> eventArgs)
        {
            switch (eventArgs.RequestType)
            {
            case RequestCode.RequestServers:
                // This is trigger automatically at Start() request.
                // Here, we make all the conenctions necessary for collecting market data, info, etc.

                // Connect to the desired database.
                if (m_DatabaseReader == null)
                {
                    // Search for database service.
                    IService iService = null;
                    if (AppServices.GetInstance().TryGetService("DatabaseReaderWriter", out iService))
                    {       // Found database writer already in services.
                        m_DatabaseReader = (DB.DatabaseReaderWriter)iService;
                        m_DatabaseReader.QueryResponse += new EventHandler(this.HubEventEnqueue);
                    }
                    else
                    {       // Create db our own writer.
                        m_DBInfo = DB.DatabaseInfo.Create(m_DBLocation);
                        AppServices.GetInstance().TryAddService(m_DBInfo);
                        m_DatabaseReader = new DB.DatabaseReaderWriter(m_DBInfo);
                        m_DatabaseReader.QueryResponse += new EventHandler(this.HubEventEnqueue);
                        m_DatabaseReader.Start();
                    }
                    // Request info about exchanges and all products.
                    DB.Queries.QueryBase query = new DB.Queries.ExchangeInfoQuery();
                    m_DatabaseReader.SubmitAsync(query);
                    query = new DB.Queries.ProductInfoQuery();
                    m_DatabaseReader.SubmitAsync(query);
                }
                else
                {
                    Log.NewEntry(LogLevel.Major, "ProcessRequest: Ignoring additional call to RequestServers.");
                }
                break;

            case RequestCode.RequestProducts:
                if (!m_IsDatabaseInitialized)
                {
                    m_PendingRequests.Add(eventArgs);
                }
                else
                {
                }
                break;

            case RequestCode.RequestInstruments:
                if (!m_IsDatabaseInitialized)
                {
                    m_PendingRequests.Add(eventArgs);
                }
                else
                {
                    foreach (object o in eventArgs.Data)
                    {       // Validate this instrument request
                        if (!(o is InstrumentName))
                        {
                            continue;
                        }
                        InstrumentName    instrName = (InstrumentName)o;
                        InstrumentDetails instrDetails;
                        if (!TryGetInstrumentDetails(instrName, out instrDetails) && m_PendingInstrumentQueries.Contains(instrName) != true)
                        {                                              // Details not exist yet and we have not requested them yet.  Request them.
                            Log.NewEntry(LogLevel.Minor, "ProcessRequest: Requesting instr details for {0}.", instrName);
                            m_PendingInstrumentQueries.Add(instrName); // add to pending list (so we can't spam db).
                            DB.Queries.InstrumentInfoQuery query = new DB.Queries.InstrumentInfoQuery();
                            query.InstrumentName = instrName;
                            m_DatabaseReader.SubmitAsync(query);
                        }
                    }    //next data object o
                }
                break;

            case RequestCode.RequestInstrumentPriceSubscription:
                if (!m_IsDatabaseInitialized)
                {
                    m_PendingRequests.Add(eventArgs);
                }
                else
                {
                    foreach (object o in eventArgs.Data)
                    {
                        // Validate this instrument request
                        if (!(o is InstrumentName))
                        {
                            continue;
                        }
                        InstrumentName    instrName = (InstrumentName)o;
                        int               instrId   = 0;
                        InstrumentDetails instrDetails;
                        if (TryLookupInstrumentID(instrName, out instrId) && instrId > -1)
                        {
                            continue;                                   // instrument already has a book id!
                        }
                        // Get the isntrument details first, and make sure details exist.
                        if (!TryGetInstrumentDetails(instrName, out instrDetails))
                        {                                     // Details not exist yet.  Request them.
                            Log.NewEntry(LogLevel.Minor, "ProcessRequest: Need instr details for {0}. Delaying mkt subscription.", instrName);
                            m_PendingRequests.Add(eventArgs); // push onto pending list for later resubmission.
                            base.RequestInstruments(instrName);
                        }
                        else
                        {
                            // Make sure we have not already requested this data.
                            bool isRequestAlreadyPending = false;
                            foreach (DB.Queries.MarketDataQuery query in m_PendingMarketDataQueries)
                            {
                                if (query.InstrumentName == instrName)
                                {
                                    isRequestAlreadyPending = true;
                                    break;
                                }
                            }
                            if (isRequestAlreadyPending)
                            {
                                Log.NewEntry(LogLevel.Major, "ProcessRequest: Market data for {0} pending. Ignore", instrName);
                            }
                            else
                            {       // This request is NOT already pending, so request data now.
                                DB.Queries.MarketDataQuery query = new DB.Queries.MarketDataQuery();
                                query.InstrumentName = instrName;
                                query.StartDate      = m_MktDataStartDateTime.ToUniversalTime(); // Query times in UTC.
                                query.EndDate        = query.StartDate.AddHours(m_MktDataBlockSize);
                                m_PendingMarketDataQueries.Add(query);                           // add to pending list (so we can't spam db).
                                Log.NewEntry(LogLevel.Major, "ProcessRequest: Requesting mkt data for {0} from {1} ({2} hours).", instrName, query.StartDate.ToString("MMM-dd-yyyy HH:mm:ss"), m_MktDataBlockSize);

                                m_DatabaseReader.SubmitAsync(query);
                            }
                        }
                    }
                }

                break;

            case RequestCode.RequestShutdown:
                if (m_DatabaseReader != null)
                {
                    m_DatabaseReader.RequestStop();
                    m_DatabaseReader = null;
                }
                base.Stop();
                break;

            default:
                Log.NewEntry(LogLevel.Major, "ProcessRequest: Unknown request.");
                break;
            } //switch on request type.
        }     // ProcessRequest()
 public IPrincipal AssertIdentity(object oToken, IService service)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 54
0
 public PersonsController(IService <Person> service)
 {
     _personService = service;
 }
 public ScreenWithoutInterfaceViewModel(IService service)
 {
     _service = service;
     Title    = "Screen without Interface";
 }
 public object TransformIdentity(IPrincipal principal, IService service)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 57
0
 public PedidoDetalleController(
     IService <PedidoDetalle> service,
     ILogger <PedidoDetalleController> logger)
     : base(service, logger)
 {
 }
Esempio n. 58
0
 public static void Register(IService service)
 {
     Services.Add(service);
 }
Esempio n. 59
0
 public DocsController(IService service)
 {
     _service = service;
 }
 public Behavior1(IService service, IServiceLocator services, GuyWithService guy)
 {
     _service  = service;
     _services = services;
     _guy      = guy;
 }