private async Task <string> GetText(string method, string fileKey)
        {
            string str = null;

            using (var conn = new AuthenticHubConnection1(_cfg))
            {
                conn.Error += ex => _log.Add(ex);
                try
                {
                    var hub = await conn.ConnectToHub(VersionKeeperHub.Name);

                    //str     = await hub.Invoke<string>(method, fileKey);
                    str = await hub.InvokeUntilOK <string>(conn, method, fileKey);
                }
                catch (Exception ex) { _log.Add(ex); }
            }
            if (str.IsBlank())
            {
                //throw Fault.BadArg(nameof(fileKey), fileKey);
                //_client2.SendException("GetText by FileKey", Fault.BadArg(nameof(fileKey), fileKey));
                await Loggly.Post(Fault.BadArg(nameof(fileKey), fileKey), "GetText by FileKey");
            }

            return(str);
        }
Exemplo n.º 2
0
        public async Task <List <string> > GetRecords(string fileKey, long startId)
        {
            List <string> list   = null;
            var           method = nameof(IVersionKeeperServer.GetRecords);

            using (var conn = new AuthenticHubConnection1(_cfg))
            {
                conn.Error += ex => _log.Add(ex);
                try
                {
                    var hub = await conn.ConnectToHub(VersionKeeperHub.Name);

                    list = await hub.Invoke <List <string> >(method, fileKey, startId);
                }
                catch (Exception ex) { _log.Add(ex); }
            }
            if (list == null)
            {
                throw Fault.BadArg(nameof(fileKey), fileKey);
            }

            return(list);
        }
        private async Task <long> GetLong(string method, string fileKey)
        {
            long num = -1;

            using (var conn = new AuthenticHubConnection1(_cfg))
            {
                conn.Error += ex => _log.Add(ex);
                try
                {
                    var hub = await conn.ConnectToHub(VersionKeeperHub.Name);

                    num = await hub.Invoke <long>(method, fileKey);
                }
                catch (Exception ex) { _log.Add(ex); }
            }
            if (num < 0)
            {
                //throw Fault.BadArg(nameof(fileKey), fileKey);
                //_client2.SendException("GetLong by FileKey", Fault.BadArg(nameof(fileKey), fileKey));
                await Loggly.Post(Fault.BadArg(nameof(fileKey), fileKey), "GetLong by FileKey");
            }

            return(num);
        }