Exemplo n.º 1
0
        public ServiceTask Auth <T>(T authIn)
        {
            var task = new ServiceTask(() =>
            {
                ServiceResponse response = ServiceManager.Resolve <IMessageService>().Push(MessageType.Security, authIn).ConfigureAwait(true).GetAwaiter().GetResult();
                if (response != null)
                {
                    if (response.IsSuccess)
                    {
                        var authResponse = response.Get <AuthResponse>();
                        if (authResponse != null && authResponse.Success)
                        {
                            IProtocolService protocol = ServiceManager.Resolve <IProtocolService>();
                            protocol.Config.Token     = response.Token;

                            return(response);
                        }
                    }

                    return(response);
                }

                return(new ServiceResponse()
                {
                    IsSuccess = false,
                    Error = new System.Exception()
                });
            });

            task.Start();

            return(task);
        }
            public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings)
            {
                ISSHLoginParameter ssh = (ISSHLoginParameter)destination.GetAdapter(typeof(ISSHLoginParameter));

                if (ssh.LetUserInputPassword && ssh.AuthenticationType != Granados.AuthenticationType.KeyboardInteractive) //ダイアログで入力を促して接続
                {
                    SSHShortcutLoginDialog dlg = new SSHShortcutLoginDialog(window, ssh, settings);
                    if (dlg.ShowDialog(window.AsForm()) == DialogResult.OK)
                    {
                        ITerminalConnection con = dlg.Result;
                        AdjustCaptionAndText(settings, ((ITCPParameter)con.Destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection);
                        return(con);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else   //主にReproduceやマクロ。設定済みのパスワードで接続
                {
                    IProtocolService       protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;
                    ISynchronizedConnector conn            = protocolservice.CreateFormBasedSynchronozedConnector(window);
                    IInterruptable         r = protocolservice.AsyncSSHConnect(conn.InterruptableConnectorClient, ssh);
                    AdjustCaptionAndText(settings, ((ITCPParameter)destination.GetAdapter(typeof(ITCPParameter))).Destination, StartCommandIcon.NewConnection);
                    return(conn.WaitConnection(r, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout)); //時間?
                }
            }
Exemplo n.º 3
0
        public override void InitializePlugin(IPoderosaWorld poderosa)
        {
            base.InitializePlugin(poderosa);

            Instance = this;

            IPluginManager pm = poderosa.PluginManager;

            _optionSupplier = new MRUOptionsSupplier();
            _coreServices   = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));
            _coreServices.PreferenceExtensionPoint.RegisterExtension(_optionSupplier);

            _protocolService         = (IProtocolService)pm.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));
            _terminalSessionsService = (ITerminalSessionsService)pm.FindPlugin("org.poderosa.terminalsessions", typeof(ITerminalSessionsService));

            //接続成功時にリスト更新
            _mruList = new MRUList(this, pm);
            _coreServices.SessionManager.AddSessionListener(_mruList);
            pm.FindExtensionPoint("org.poderosa.menu.file").RegisterExtension(_mruList);
            pm.FindExtensionPoint("org.poderosa.terminalsessions.telnetSSHLoginDialogInitializer").RegisterExtension(_mruList);
            pm.FindExtensionPoint("org.poderosa.terminalsessions.loginDialogUISupport").RegisterExtension(_mruList);
            pm.FindExtensionPoint("org.poderosa.terminalsessions.terminalParameterStore").RegisterExtension(_mruList);

            _mruCommand = new OpenMRUCommand();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SearchControllerHelper" /> class.
 /// </summary>
 /// <param name="cacheProvider">The cache provider.</param>
 /// <param name="programService">The program service.</param>
 /// <param name="protocolService">The protocol service.</param>
 /// <param name="measurementElementsService">The measurement elements service.</param>
 /// <param name="assessmentElementsService"></param>
 /// <param name="questionElementService">The question element service.</param>
 /// <param name="textMediaElementsService">The text media elements service.</param>
 /// <param name="scaleAnswerSetService">The scale answer set service.</param>
 /// <param name="selectionAnswerSetService">The selection answer set service.</param>
 /// <param name="careElementRequestContext">The care element request context.</param>
 /// <param name="openEndedAnswerSetsService">The open ended answer set service</param>
 public GlobalSearchCacheHelper(
     ICacheProvider cacheProvider,
     IProgramService programService,
     IProtocolService protocolService,
     IMeasurementElementsService measurementElementsService,
     IAssessmentElementsService assessmentElementsService,
     IQuestionElementService questionElementService,
     ITextMediaElementsService textMediaElementsService,
     IScaleAnswerSetService scaleAnswerSetService,
     ISelectionAnswerSetService selectionAnswerSetService,
     ICareElementRequestContext careElementRequestContext,
     IOpenEndedAnswerSetsService openEndedAnswerSetsService
     )
 {
     this.cacheProvider              = cacheProvider;
     this.programService             = programService;
     this.protocolService            = protocolService;
     this.measurementElementsService = measurementElementsService;
     this.assessmentElementsService  = assessmentElementsService;
     this.questionElementService     = questionElementService;
     this.textMediaElementsService   = textMediaElementsService;
     this.scaleAnswerSetService      = scaleAnswerSetService;
     this.selectionAnswerSetService  = selectionAnswerSetService;
     this.careElementRequestContext  = careElementRequestContext;
     this.openEndedAnswerSetsService = openEndedAnswerSetsService;
 }
        public LogicService(IProtocolService protocolService, IConfigService configService)
        {
            _protocolService = protocolService;
            _configService = configService;
            _queryTimmer.Interval = _configService.ConfigInfos.UpdateRate;

        }
        public InfosPanelViewModel(IProtocolService protocolService, IEventAggregator eventAggregator)
        {
            _protocolService = protocolService;
            _eventAggregator = eventAggregator;
            _protocolService.LineChangeEvent += OnLineChanged;
            _protocolService.NodeChangeEvent += OnNodeChanged;

            _eventAggregator.GetEvent <SelNodeEvent>().Subscribe(SelectChanged);
        }
 public TextMediaElementsService(
     IUnitOfWork unitOfWork,
     IProtocolService protocolService
     )
 {
     this.unitOfWork = unitOfWork;
     this.textMediaElementsRepository = this.unitOfWork.CreateGenericRepository <TextMediaElement>();
     this.protocolService             = protocolService;
 }
Exemplo n.º 8
0
        /// <summary>
        /// Initiates the SSH connection process by getting the <see cref="IProtocolService"/> instance and calling
        /// <see cref="IProtocolService.AsyncSSHConnect"/>.  This is an asynchronous process:  the <see cref="SuccessfullyExit"/> method is called when the
        /// connection is established successfully and <see cref="ConnectionFailed"/> method is called when we are unable to establish the connection.
        /// </summary>
        public void AsyncConnect()
        {
            ITerminalEmulatorService terminalEmulatorService =
                (ITerminalEmulatorService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.terminalemulator", typeof(ITerminalEmulatorService));
            IProtocolService protocolService = (IProtocolService)_poderosaWorld.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));

            // Create and initialize the SSH login parameters
            ISSHLoginParameter sshLoginParameter = protocolService.CreateDefaultSSHParameter();

            sshLoginParameter.Account = Username;

            if (!String.IsNullOrEmpty(IdentityFile))
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.PublicKey;
                sshLoginParameter.IdentityFileName   = IdentityFile;
            }

            else
            {
                sshLoginParameter.AuthenticationType = AuthenticationType.Password;

                if (Password != null && Password.Length > 0)
                {
                    IntPtr passwordBytes = Marshal.SecureStringToGlobalAllocAnsi(Password);
                    sshLoginParameter.PasswordOrPassphrase = Marshal.PtrToStringAnsi(passwordBytes);
                }
            }

            sshLoginParameter.Method = (SSHProtocol)Enum.Parse(typeof(SSHProtocol), SshProtocol.ToString("G"));

            // Create and initialize the various socket connection properties
            ITCPParameter tcpParameter = (ITCPParameter)sshLoginParameter.GetAdapter(typeof(ITCPParameter));

            tcpParameter.Destination = HostName;
            tcpParameter.Port        = Port;

            // Set the UI settings to use for the terminal itself
            terminalEmulatorService.TerminalEmulatorOptions.RightButtonAction = MouseButtonAction.Paste;
            _settings = terminalEmulatorService.CreateDefaultTerminalSettings(tcpParameter.Destination, null);

            _settings.BeginUpdate();
            _settings.TerminalType            = (ConnectionParam.TerminalType)Enum.Parse(typeof(ConnectionParam.TerminalType), TerminalType.ToString("G"));
            _settings.RenderProfile           = terminalEmulatorService.TerminalEmulatorOptions.CreateRenderProfile();
            _settings.RenderProfile.BackColor = BackColor;
            _settings.RenderProfile.ForeColor = ForeColor;
            _settings.RenderProfile.FontName  = Font.Name;
            _settings.RenderProfile.FontSize  = Font.Size;
            _settings.EndUpdate();

            ITerminalParameter param = (ITerminalParameter)tcpParameter.GetAdapter(typeof(ITerminalParameter));

            param.SetTerminalName(_settings.TerminalType.ToString("G").ToLower());

            // Initiate the connection process
            protocolService.AsyncSSHConnect(this, sshLoginParameter);
        }
 public CreateProtocolViewModel(CreateProtocolPage protocolPage)
 {
     Title      = "Protokoll erstellen";
     this.model = new Protocol {
         Created = DateTime.Now
     };
     this.protocolPage    = protocolPage;
     this.protocolService = new ProtocolService();
     safeCommand          = new Command(o => SafeMethod());
 }
        public  InfosPanelViewModel(IProtocolService protocolService, IEventAggregator eventAggregator)
        {
            _protocolService = protocolService;
            _eventAggregator = eventAggregator;
            _protocolService.LineChangeEvent += OnLineChanged;
            _protocolService.NodeChangeEvent += OnNodeChanged;

            _eventAggregator.GetEvent<SelNodeEvent>().Subscribe(SelectChanged);

        }
 public ProtocolOverviewViewModel(ProtocolOverviewPage protocolPage)
 {
     IsBusy = true;
     OnPropertyChanged(nameof(IsBusy));
     Title = "Protokollübersicht";
     createProtocolCommand = new Command(o => CreateMethod());
     this.protocolPage     = protocolPage;
     this.protocolService  = new ProtocolService();
     RefreshList();
 }
Exemplo n.º 12
0
 public void Init() {
     try {
         _poderosaApplication = PoderosaStartup.CreatePoderosaApplication(CreatePluginManifest(), new StructuredText("Poderosa"));
         _poderosaWorld = _poderosaApplication.Start();
         _protocolService = ProtocolsPlugin.Instance;
     }
     catch(Exception ex) {
         Debug.WriteLine(ex.StackTrace);
     }
 }
Exemplo n.º 13
0
        protected override void StartConnection()
        {
            IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;

            _connector = protocolservice.AsyncSSHConnect(this, _sshParam);

            if (_connector == null)
            {
                ClearConnectingState();
            }
        }
Exemplo n.º 14
0
 public void Init()
 {
     try {
         _poderosaApplication = PoderosaStartup.CreatePoderosaApplication(CreatePluginManifest(), new StructuredText("Poderosa"));
         _poderosaWorld       = _poderosaApplication.Start();
         _protocolService     = ProtocolsPlugin.Instance;
     }
     catch (Exception ex) {
         Debug.WriteLine(ex.StackTrace);
     }
 }
Exemplo n.º 15
0
            public ITerminalConnection EstablishConnection(IPoderosaMainWindow window, ITerminalParameter destination, ITerminalSettings settings)
            {
                ITCPParameter          tcp = (ITCPParameter)destination.GetAdapter(typeof(ITCPParameter));
                IProtocolService       ps  = TerminalSessionsPlugin.Instance.ProtocolService;
                ISynchronizedConnector sc  = ps.CreateFormBasedSynchronozedConnector(window);
                IInterruptable         t   = ps.AsyncTelnetConnect(sc.InterruptableConnectorClient, tcp);
                ITerminalConnection    con = sc.WaitConnection(t, TerminalSessionsPlugin.Instance.TerminalSessionOptions.TerminalEstablishTimeout);

                AdjustCaptionAndText(settings, tcp.Destination, StartCommandIcon.NewConnection);
                return(con);
            }
Exemplo n.º 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProtocolsControllerHelper" /> class.
 /// </summary>
 /// <param name="protocolService">The protocol service.</param>
 /// <param name="tagsService">The tags service.</param>
 /// <param name="careElementContext">The care element context.</param>
 /// <param name="globalSearchCacheHelper">The global search cache helper.</param>
 /// <param name="tagsSearchCacheHelper">The tags search cache helper.</param>
 public ProtocolsControllerHelper(
     IProtocolService protocolService,
     ITagsService tagsService,
     ICareElementContext careElementContext,
     IGlobalSearchCacheHelper globalSearchCacheHelper,
     ITagsSearchCacheHelper tagsSearchCacheHelper
     )
 {
     this.protocolService         = protocolService;
     this.tagsService             = tagsService;
     this.careElementContext      = careElementContext;
     this.globalSearchCacheHelper = globalSearchCacheHelper;
     this.tagsSearchCacheHelper   = tagsSearchCacheHelper;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProgramControllerHelper" /> class.
 /// </summary>
 /// <param name="programService">The program service.</param>
 /// <param name="tagsService">The tags service.</param>
 /// <param name="globalSearchCacheHelper">The global search cache helper.</param>
 /// <param name="tagsSearchCacheHelper">The tags search cache helper.</param>
 /// <param name="protocolService">The protocol service.</param>
 public ProgramControllerHelper(
     IProgramService programService,
     ITagsService tagsService,
     IGlobalSearchCacheHelper globalSearchCacheHelper,
     ITagsSearchCacheHelper tagsSearchCacheHelper,
     IProtocolService protocolService
     )
 {
     this.programService          = programService;
     this.tagsService             = tagsService;
     this.globalSearchCacheHelper = globalSearchCacheHelper;
     this.tagsSearchCacheHelper   = tagsSearchCacheHelper;
     this.protocolService         = protocolService;
 }
Exemplo n.º 18
0
        static SshConnectionForm()
        {
            PoderosaApplication = (IPoderosaWorld)PoderosaStartup.CreatePoderosaApplication(new string[] {});
            PoderosaApplication.InitializePlugins();

            IRootExtension preferencesPlugin = (IRootExtension)PoderosaApplication.PluginManager.FindPlugin("org.poderosa.core.preferences", typeof(IPreferences));

            preferencesPlugin.InitializeExtension();

            PoderosaProtocolService         = (IProtocolService)PoderosaApplication.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));
            PoderosaTerminalEmulatorService = (ITerminalEmulatorService)PoderosaApplication.PluginManager.FindPlugin("org.poderosa.terminalemulator", typeof(ITerminalEmulatorService));
            PoderosaSessionManagerPlugin    = (SessionManagerPlugin)PoderosaApplication.PluginManager.FindPlugin("org.poderosa.core.sessions", typeof(ISessionManager));

            PoderosaTerminalEmulatorService.TerminalEmulatorOptions.RightButtonAction = MouseButtonAction.Paste;
        }
Exemplo n.º 19
0
        public bool Connect(ConnectCallback callback)
        {
            _connectCallback = callback;
            var ssh = new SSHLoginParameter();

            ssh.Method               = SSHProtocol.SSH2;
            ssh.AuthenticationType   = AuthenticationType.Password;
            ssh.Account              = "cxn2356";
            ssh.PasswordOrPassphrase = "Jumanji123.";
            //--- X11 forwarding settings
            ssh.EnableX11Forwarding = false;
            ssh.X11Forwarding       = null;
            //--- Agent forwarding settings
            ssh.EnableAgentForwarding          = false;
            ssh.AgentForwardingAuthKeyProvider = null;
            // -- tcp
            var tcp = (ITCPParameter)ssh.GetAdapter(typeof(ITCPParameter));

            tcp.Destination = "10.93.1.255";
            tcp.Port        = 22;
            //--- Log settings
            ISimpleLogSettings logSettings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultSimpleLogSettings();

            logSettings.LogType = Poderosa.ConnectionParam.LogType.None;
            if (logSettings.LogType != Poderosa.ConnectionParam.LogType.None)
            {
                logSettings.LogPath   = Path.GetTempFileName();
                logSettings.LogAppend = true;
            }
            // -- terminal settings
            _terminalSettings = TerminalSessionsPlugin.Instance.TerminalEmulatorService.CreateDefaultTerminalSettings("Terminal", null);
            _terminalSettings.BeginUpdate();
            _terminalSettings.EnabledCharTriggerIntelliSense = false;
            _terminalSettings.Encoding     = Poderosa.ConnectionParam.EncodingType.UTF8;
            _terminalSettings.LocalEcho    = false;
            _terminalSettings.TransmitNL   = Poderosa.ConnectionParam.NewLine.CR;
            _terminalSettings.TerminalType = Poderosa.ConnectionParam.TerminalType.XTerm;
            _terminalSettings.LogSettings.Reset(logSettings);
            _terminalSettings.EndUpdate();
            IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;

            mreConnect.Reset();
            IInterruptable interruptable = protocolservice.AsyncSSHConnect(this, ssh);

            Task.Factory.StartNew(() => AwaitConnectResult());

            return(true);
        }
Exemplo n.º 20
0
 public OrderController(
     IOrderService orderService,
     IEmployeeService employeeService,
     IInvoiceService invoiceService,
     IProductService productService,
     IProtocolService protocolService,
     IClientService clientService
     )
 {
     this.orderService    = orderService;
     this.employeeService = employeeService;
     this.invoiceService  = invoiceService;
     this.productService  = productService;
     this.protocolService = protocolService;
     this.clientService   = clientService;
 }
Exemplo n.º 21
0
        public override void InitializePlugin(IPoderosaWorld poderosa) {
            base.InitializePlugin(poderosa);
            _instance = this;
            ICoreServices cs = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));

            _commandManager = cs.CommandManager;
            _windowManager = cs.WindowManager;
            _sessionService = (ITerminalSessionsService)poderosa.PluginManager.FindPlugin("org.poderosa.terminalsessions", typeof(ITerminalSessionsService));
            _protocolService = (IProtocolService)poderosa.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));
            _cygwinService = (ICygwinPlugin)poderosa.PluginManager.FindPlugin("org.poderosa.cygwin", typeof(ICygwinPlugin));
            Debug.Assert(_sessionService != null);
            Debug.Assert(_protocolService != null);
            Debug.Assert(_cygwinService != null);

            cs.PreferenceExtensionPoint.RegisterExtension(this);
            poderosa.PluginManager.FindExtensionPoint(WindowManagerConstants.MAINWINDOWEVENTHANDLER_ID).RegisterExtension(this);
        }
Exemplo n.º 22
0
        public override void InitializePlugin(IPoderosaWorld poderosa)
        {
            base.InitializePlugin(poderosa);
            _instance = this;
            ICoreServices cs = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));

            _commandManager  = cs.CommandManager;
            _windowManager   = cs.WindowManager;
            _sessionService  = (ITerminalSessionsService)poderosa.PluginManager.FindPlugin("org.poderosa.terminalsessions", typeof(ITerminalSessionsService));
            _protocolService = (IProtocolService)poderosa.PluginManager.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));
            _cygwinService   = (ICygwinPlugin)poderosa.PluginManager.FindPlugin("org.poderosa.cygwin", typeof(ICygwinPlugin));
            Debug.Assert(_sessionService != null);
            Debug.Assert(_protocolService != null);
            Debug.Assert(_cygwinService != null);

            cs.PreferenceExtensionPoint.RegisterExtension(this);
            poderosa.PluginManager.FindExtensionPoint(WindowManagerConstants.MAINWINDOWEVENTHANDLER_ID).RegisterExtension(this);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Start opening session
        /// </summary>
        /// <remarks>
        /// The implementation of this method also do validation of the input values.
        /// </remarks>
        /// <param name="client">an instance who receive the result of opening session.</param>
        /// <param name="terminalSettings">terminal settings is set if this method returns true.</param>
        /// <param name="interruptable">an object for cancellation is set if this method returns true.</param>
        /// <returns>true if the opening session has been started, or false if failed.</returns>
        public bool OpenSession(IInterruptableConnectorClient client, out ITerminalSettings terminalSettings, out IInterruptable interruptable)
        {
            ISSHLoginParameter loginParam;
            ITerminalSettings  termSettings;
            string             errorMessage;

            if (!Validate(out loginParam, out termSettings, out errorMessage))
            {
                client.ConnectionFailed(errorMessage);
                terminalSettings = null;
                interruptable    = null;
                return(false);
            }

            IProtocolService protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;

            interruptable    = protocolservice.AsyncSSHConnect(client, loginParam);
            terminalSettings = termSettings;
            return(true);
        }
Exemplo n.º 24
0
        protected override void StartConnection()
        {
            ISSHLoginParameter ssh             = (ISSHLoginParameter)_param.GetAdapter(typeof(ISSHLoginParameter));
            ITCPParameter      tcp             = (ITCPParameter)_param.GetAdapter(typeof(ITCPParameter));
            IProtocolService   protocolservice = TerminalSessionsPlugin.Instance.ProtocolService;

            if (ssh != null)
            {
                _connector = protocolservice.AsyncSSHConnect(this, ssh);
            }
            else
            {
                _connector = protocolservice.AsyncTelnetConnect(this, tcp);
            }

            if (_connector == null)
            {
                ClearConnectingState();
            }
        }
Exemplo n.º 25
0
        public override void InitializePlugin(IPoderosaWorld poderosa) {
            base.InitializePlugin(poderosa);

            Instance = this;

            IPluginManager pm = poderosa.PluginManager;
            _optionSupplier = new MRUOptionsSupplier();
            _coreServices = (ICoreServices)poderosa.GetAdapter(typeof(ICoreServices));
            _coreServices.PreferenceExtensionPoint.RegisterExtension(_optionSupplier);

            _protocolService = (IProtocolService)pm.FindPlugin("org.poderosa.protocols", typeof(IProtocolService));
            _terminalSessionsService = (ITerminalSessionsService)pm.FindPlugin("org.poderosa.terminalsessions", typeof(ITerminalSessionsService));

            //接続成功時にリスト更新
            _mruList = new MRUList(this, pm);
            _coreServices.SessionManager.AddSessionListener(_mruList);
            pm.FindExtensionPoint("org.poderosa.menu.file").RegisterExtension(_mruList);
            pm.FindExtensionPoint("org.poderosa.terminalsessions.telnetSSHLoginDialogInitializer").RegisterExtension(_mruList);
            pm.FindExtensionPoint("org.poderosa.terminalsessions.loginDialogUISupport").RegisterExtension(_mruList);

            _mruCommand = new OpenMRUCommand();
        }
Exemplo n.º 26
0
        public BuySellCommandHandler(IMongoDatabase database, IBittrexExchange exchange, IProtocolService protocolService)
        {
            _exchange = exchange;
//      _protocol = database.GetCollection<BsonDocument>("protocol");
            _protocolService = protocolService;
        }
Exemplo n.º 27
0
 public ProtocolsController(IProtocolService protocolService, IServiceProvider serviceProvider) : base(
         serviceProvider)
 {
     this.protocolService = protocolService;
 }
 public ProtocolsController(IProtocolService protocolService, IMapper mapper)
 {
     _protocolService = protocolService;
     _mapper          = mapper;
 }
Exemplo n.º 29
0
 public LogicService(IProtocolService protocolService, IConfigService configService)
 {
     _protocolService      = protocolService;
     _configService        = configService;
     _queryTimmer.Interval = _configService.ConfigInfos.UpdateRate;
 }
Exemplo n.º 30
0
 public ProtocolController(IProtocolService protocolService, IEmployeeService employeeService, IOrderService orderService)
 {
     this.protocolService = protocolService;
     this.employeeService = employeeService;
     this.orderService    = orderService;
 }
Exemplo n.º 31
0
        public Task <ServiceResponse> Push(MessageType messageType, object messageData)
        {
            IProtocolService protocolService = ServiceManager.Resolve <IProtocolService>();

            MessageIn msgIn = new MessageIn()
            {
                Id    = meesageSeed++,
                Type  = messageType,
                Token = protocolService.Config.Token,
                Data  = JsonConvert.SerializeObject(messageData)
            };

            MessageQueueItem queueItem = new MessageQueueItem()
            {
                Id = msgIn.Id
            };

            queue.Add(msgIn.Id, queueItem);

            ServiceTask task = new ServiceTask(() =>
            {
                IConnectionService service = ServiceManager.Resolve <IConnectionService>();
                service.Send(msgIn);

                try
                {
                    DateTime start = DateTime.Now;
                    while (true)
                    {
                        if ((DateTime.Now - start).TotalSeconds > 2)
                        {
                            break;
                        }

                        if (queueItem.Result != null)
                        {
                            queue.Remove(msgIn.Id);

                            if (queueItem.Result.Success == MessageSuccess.Success)
                            {
                                return(new ServiceResponse()
                                {
                                    IsSuccess = true,
                                    Token = queueItem.Result.Token,
                                    Data = queueItem.Result.Data
                                });
                            }
                            else
                            {
                                var data           = JsonConvert.DeserializeObject <MessageError>(queueItem.Result.Data);
                                ExceptionCode code = ExceptionCode.Unknown;

                                if (queueItem.Result.Success == MessageSuccess.SeverError)
                                {
                                    code = ExceptionCode.ServerError;
                                }
                                else if (queueItem.Result.Success == MessageSuccess.DataInvalid)
                                {
                                    code = ExceptionCode.DataInvalid;
                                }

                                return(new ServiceResponse()
                                {
                                    IsSuccess = false,
                                    Token = queueItem.Result.Token,
                                    Error = new MessageException(code, data.ErrorMessage ?? code.ToString())
                                });
                            }
                        }

                        Task.Delay(10).Wait();
                    }

                    queue.Remove(msgIn.Id);

                    throw new MessageException(ExceptionCode.Timeout);
                }
                catch (Exception ex)
                {
                    return(new ServiceResponse()
                    {
                        IsSuccess = false,
                        Error = ex
                    });
                }
            });

            task.Start();

            return(task);
        }
Exemplo n.º 32
0
 public ReportGeneratorService(IProtocolService protocolService)
 {
     _protocolService = protocolService;
 }
Exemplo n.º 33
0
 public ProtocolsController(IProtocolService protocolService)
 {
     this.protocolService = protocolService;
 }