示例#1
0
 public DeviceMediaManager(IDeviceMediaRepo mediaRepo, IDeviceMediaItemRepo mediaItemRepo, IDeviceManager deviceManager,
                           IAdminLogger logger, IAppConfig appConfig, IDependencyManager depmanager, ISecurity security,
                           IProxyFactory proxyFactory) :
     base(logger, appConfig, depmanager, security)
 {
     _defaultMediaRepo     = mediaRepo;
     _defaultMediaItemRepo = mediaItemRepo;
     _deviceManager        = deviceManager;
     _proxyFactory         = proxyFactory;
 }
        static public void Initialize()
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;

            Logger = new AdminLogger(new ConsoleLogWriter(), HostId);

            AsyncCoupler = new AsyncCoupler <IMessage>(Logger, new UsageMetrics(HostId, InstanceId, PipelineModuleId));

            TransceiverSettings.RpcClientReceiver.AccountId = System.Environment.GetEnvironmentVariable("RPC_TESTS_SERVICE_BUS", EnvironmentVariableTarget.User);
            Assert.IsNotNull(TransceiverSettings.RpcClientReceiver.AccountId, "Please add environment variable for [RPC_TESTS_RECEIVE_KEY] with read acess to service bus");

            TransceiverSettings.RpcClientReceiver.UserName  = "******";
            TransceiverSettings.RpcClientReceiver.AccessKey = System.Environment.GetEnvironmentVariable("RPC_TESTS_RECEIVE_KEY", EnvironmentVariableTarget.User);
            Assert.IsNotNull(TransceiverSettings.RpcClientReceiver.AccessKey, "Please add environment variable for [RPC_TESTS_RECEIVE_KEY] with read acess to service bus");
            TransceiverSettings.RpcClientReceiver.ResourceName = "rpc_test";
            TransceiverSettings.RpcClientReceiver.Uri          = "application";

            TransceiverSettings.RpcClientTransmitter.AccountId = TransceiverSettings.RpcClientReceiver.AccountId;
            TransceiverSettings.RpcClientTransmitter.UserName  = "******";
            TransceiverSettings.RpcClientTransmitter.AccessKey = System.Environment.GetEnvironmentVariable("RPC_TESTS_SEND_KEY", EnvironmentVariableTarget.User);
            Assert.IsNotNull(TransceiverSettings.RpcClientReceiver.AccessKey, "Please add environment variable for [RPC_TESTS_RECEIVE_KEY] with read acess to service bus");
            TransceiverSettings.RpcClientTransmitter.ResourceName     = "rpc_test";
            TransceiverSettings.RpcClientTransmitter.TimeoutInSeconds = 30;

            TransceiverSettings.RpcServerTransmitter.AccountId = TransceiverSettings.RpcClientReceiver.AccountId;
            TransceiverSettings.RpcServerTransmitter.UserName  = "******";
            TransceiverSettings.RpcServerTransmitter.AccessKey = System.Environment.GetEnvironmentVariable("RPC_TESTS_SEND_KEY", EnvironmentVariableTarget.User);
            Assert.IsNotNull(TransceiverSettings.RpcServerTransmitter.AccessKey, "Please add environment variable for [RPC_TESTS_RECEIVE_KEY] with read acess to service bus");
            TransceiverSettings.RpcServerTransmitter.ResourceName     = "rpc_test";
            TransceiverSettings.RpcServerTransmitter.TimeoutInSeconds = 30;

            TransceiverSettings.RpcServerReceiver.AccountId    = System.Environment.GetEnvironmentVariable("RPC_TESTS_SERVICE_BUS", EnvironmentVariableTarget.User);
            TransceiverSettings.RpcServerReceiver.UserName     = "******";
            TransceiverSettings.RpcServerReceiver.AccessKey    = System.Environment.GetEnvironmentVariable("RPC_TESTS_RECEIVE_KEY", EnvironmentVariableTarget.User);
            TransceiverSettings.RpcServerReceiver.ResourceName = "rpc_test";
            TransceiverSettings.RpcServerReceiver.Uri          = "application";

            RpcTransceiver = new ServiceBusProxyClient(AsyncCoupler, Logger);
            RpcTransceiver.StartAsync(TransceiverSettings).Wait();

            ProxySettings = new ProxySettings
            {
                OrganizationId = OrganizationId,
                InstanceId     = InstanceId
            };

            ProxyFactory = new ProxyFactory(TransceiverSettings, RpcTransceiver, AsyncCoupler, Logger);

            DeviceManagementRepoProxy = ProxyFactory.Create <IDeviceManagementRepo>(ProxySettings);
            DeviceArchiveRepoProxy    = ProxyFactory.Create <IDeviceArchiveRepo>(ProxySettings);
            DeviceLogRepo             = ProxyFactory.Create <IDeviceLogRepo>(ProxySettings);
            DevicePEMRepo             = ProxyFactory.Create <IDevicePEMRepo>(ProxySettings);

            DeviceGroupRepo           = ProxyFactory.Create <IDeviceGroupRepo>(ProxySettings);
            DeviceMediaRepo           = ProxyFactory.Create <IDeviceMediaRepo>(ProxySettings);
            DeviceMediaItemRepo       = ProxyFactory.Create <IDeviceMediaItemRepo>(ProxySettings);
            DeviceMediaRepoRemote     = ProxyFactory.Create <IDeviceMediaRepoRemote>(ProxySettings);
            DeviceMediaItemRepoRemote = ProxyFactory.Create <IDeviceMediaItemRepoRemote>(ProxySettings);
        }