Пример #1
0
        /// <summary>
        /// Evernoteのノートブック情報を取得する
        /// </summary>
        /// <param name="EvernoteToken">Evernoteトークン</param>
        /// <returns>ノートブック名とノートブックGuidのDictionary</returns>
        static public Dictionary <string, string> GetEvetnoteNotebook(string EvernoteToken)
        {
            string authToken = EvernoteToken;

            Uri        userStoreUrl       = new Uri("https://" + evernoteHost + "/edam/user");
            TTransport userStoreTransport = new THttpClient(userStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            UserStore.Client userStore = new UserStore.Client(userStoreProtocol);

            String noteStoreUrl = userStore.getNoteStoreUrl(authToken);

            TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
            TProtocol  noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);

            NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);

            List <Notebook> notebooks = noteStore.listNotebooks(authToken);

            Dictionary <string, string> notebookNames = new Dictionary <string, string>();

            foreach (var note in notebooks)
            {
                notebookNames.Add(note.Name, note.Guid);
            }

            return(notebookNames);
        }
        public EvernoteSyncServer()
        {
            TTransport userStoreTransport = new THttpClient(UserStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            _userStore = new UserStore.Client(userStoreProtocol);
        }
Пример #3
0
        public static MapD.Client get_client(string host_or_uri, int port, bool http)
        {
            THttpClient     httpTransport;
            TTransport      transport;
            TBinaryProtocol protocol;
            TJSONProtocol   jsonProtocol;

            MapD.Client client;

            try{
                if (http)
                {
                    Uri httpuri = new Uri(host_or_uri);
                    httpTransport = new THttpClient(httpuri);
                    jsonProtocol  = new TJSONProtocol(httpTransport);
                    client        = new MapD.Client(jsonProtocol);
                    httpTransport.Open();
                    return(client);
                }
                else
                {
                    transport = new TSocket(host_or_uri, port);
                    protocol  = new TBinaryProtocol(transport);
                    client    = new MapD.Client(protocol);
                    transport.Open();
                    return(client);
                }
            } catch (TException x) {
                Console.WriteLine(x.StackTrace);
            }
            return(null);
        }
Пример #4
0
 public ExchangeServiceWrapper.Client GetClient(string uri,int timeout)
 {
     var transport = new THttpClient(new Uri(uri));
     if (timeout > 0) transport.ConnectTimeout = timeout;
     var protocol = new TBinaryProtocol(transport);
     return new ExchangeServiceWrapper.Client(protocol);
 }
Пример #5
0
        public override long Send(IList <ILogEntity> logEntities)
        {
            if (logEntities == null || logEntities.Count <= 0)
            {
                return(0);
            }

            TLogPackage logPackage = this.CreateLogPackage(logEntities);

            var trans = new THttpClient(uri);

            trans.ConnectTimeout = SENDER_TIMEOUT;
            trans.DataSizeLimit  = TransDataSizeLimit;
            //var protocol = new TBinaryProtocol(httpClient);
            var protocol = new TCompactProtocol(trans);

            trans.Open();

            var client = new LogTransferService.Client(protocol);

            client.Log(logPackage);

            long data_size = trans.DataSize;

            trans.Close();
            return(data_size);
        }
Пример #6
0
        public static UserStore.Client GetUserStore()
        {
            var userStoreUrl       = new Uri(Configuration.EvernoteUrl + "/edam/user");
            var userStoreTransport = new THttpClient(userStoreUrl);
            var userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            return(new UserStore.Client(userStoreProtocol));
        }
Пример #7
0
        public Wrapper()
        {
            Uri        userStoreUrl       = new Uri("https://" + evernoteHost + "/edam/user");
            TTransport userStoreTransport = new THttpClient(userStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            userStore = new UserStore.Client(userStoreProtocol);
        }
Пример #8
0
        private UserStore.Client GetUserStore()
        {
            var userStoreUrl       = new Uri("https://www.evernote.com/edam/user");
            var userStoreTransport = new THttpClient(userStoreUrl);
            var userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            return(new UserStore.Client(userStoreProtocol));
        }
Пример #9
0
        internal static UserStore.Client GetUserStoreClient(string edamBaseUrl)
        {
            Uri        userStoreUrl       = new Uri(edamBaseUrl + "/edam/user");
            TTransport userStoreTransport = new THttpClient(userStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            UserStore.Client userStore = new UserStore.Client(userStoreProtocol);
            return(userStore);
        }
Пример #10
0
        internal static NoteStore.Client GetNoteStoreClient(String edamBaseUrl, User user)
        {
            Uri        noteStoreUrl       = new Uri(edamBaseUrl + "/edam/note/" + user.ShardId);
            TTransport noteStoreTransport = new THttpClient(noteStoreUrl);
            TProtocol  noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);

            NoteStore.Client noteStore = new NoteStore.Client(noteStoreProtocol);
            return(noteStore);
        }
Пример #11
0
        public EvernoteServiceSDK1(EFDbEvernoteCredentials credentials)
        {
            this.credentials = credentials;

            THttpClient     noteStoreTransport = new THttpClient(new Uri(credentials.NotebookUrl));
            TBinaryProtocol noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);

            noteStore = new NoteStore.Client(noteStoreProtocol);
        }
Пример #12
0
        private static Calculator.Iface CreateCalculatorClient()
        {
            var uri          = new Uri("http://localhost:43857/any-url.thrift");
            var httpClient   = new THttpClient(uri);
            var jsonProtocol = new TJSONProtocol(httpClient);
            var calculator   = new Calculator.Client(jsonProtocol);

            return(calculator);
        }
Пример #13
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            using (THttpClient transport = new THttpClient(new Uri("http://192.168.1.2:8080/api"))) {
                TProtocol      protocol = new TBinaryProtocol(transport);
                BookApi.Client client   = new BookApi.Client(protocol);

                transport.Open();
                txtResultDelete.Text = client.deleteWord(txtDeleteWord.Text);
            }
        }
            // ! DO NOT INSTANTIATE THIS OBJECT DIRECTLY. GET ONE FROM AN AUTHENTICATED ENSESSION !

            internal ENUserStoreClient(string userStoreUrl, string authToken)
            {
                Uri url = new Uri(userStoreUrl);

                TTransport transport = new THttpClient(url);
                TProtocol  protocol  = new TBinaryProtocol(transport);

                Client = new UserStore.Client(protocol);
                AuthenticationToken = authToken;
            }
Пример #15
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var result = await EvernoteAuthenticator.AuthenticateAsync(Host.Text, Key.Text, Secret.Text, Callback.Text);

            TTransport noteStoreTransport = new THttpClient(new Uri(result.EdamNoteStoreUrl));
            TProtocol  noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);
            var        noteStore          = new NoteStore.Client(noteStoreProtocol);
            var        defaultNotebook    = await Task.Run(() => noteStore.getDefaultNotebook(result.AuthToken));

            Output.Text = $"Your default notebook is {defaultNotebook.Name}";
        }
Пример #16
0
        /// <summary>
        /// Evernoteのユーザー名を取得する
        /// </summary>
        /// <param name="EvernoteToken">Evernoteトークン</param>
        /// <returns>ユーザー名</returns>
        static public string GetEvernoteUserName(string EvernoteToken)
        {
            string authToken = EvernoteToken;

            Uri        userStoreUrl       = new Uri("https://" + evernoteHost + "/edam/user");
            TTransport userStoreTransport = new THttpClient(userStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            UserStore.Client userStore = new UserStore.Client(userStoreProtocol);

            return(userStore.getUser(authToken).Username);
        }
Пример #17
0
 public DispatcherServiceWrapper.Client CreateDispatcherServiceClient(string uri, int timeout)
 {
     var transport = new THttpClient(new Uri(uri));
     var time = ConfigUtil.Instance.Timeout;
     if (time > 0)
     {
         transport.ConnectTimeout = time;
         transport.ReadTimeout = time;
     }
     var protocol = new TBinaryProtocol(transport);
     return new DispatcherServiceWrapper.Client(protocol);
 }
Пример #18
0
        public static NoteStore.Client GetNoteStore(string token)
        {
            if (string.IsNullOrEmpty(_noteStoreUrl))
            {
                var userStore = GetUserStore();
                _noteStoreUrl = userStore.getNoteStoreUrl(token);
            }

            var noteStoreTransport = new THttpClient(new Uri(_noteStoreUrl));
            var noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);

            return(new NoteStore.Client(noteStoreProtocol));
        }
Пример #19
0
        public override void Test(UpdateDelegate action)
        {
            string     myUri     = @"http://" + m_Ip + @":7913";
            TTransport transport = new THttpClient(new Uri(myUri));
            TProtocol  protocol  = new TJSONProtocol(transport);

            PrintServices.Client client = new PrintServices.Client(protocol);

            m_StrTransport = "THttpClient";
            m_StrProtocol  = "TBinaryProtocol";

            HandleAdd(transport, client, action);
        }
Пример #20
0
        /// <summary>
        /// 初始化请求类库实例
        /// </summary>
        /// <param name="config">config</param>
        private void InitRequestInstance(YouzikuConfig config)
        {
            switch (config.RequestBehavior)
            {
            case RequestBehaviorEnum.HttpClient:
                HttpRequestClient = new THttpClient();
                break;

            case RequestBehaviorEnum.HttpWebRequest:
                HttpRequestClient = new TWebRequest();
                break;
            }
        }
Пример #21
0
        static void Main(string[] args)
        {
            Uri         uri        = new Uri("http://localhost:8911/");
            THttpClient httpClient = new THttpClient(uri);
            TProtocol   protocol   = new TBinaryProtocol(httpClient);

            HelloService.Client client = new HelloService.Client(protocol);
            httpClient.Open();
            Console.WriteLine("Client calls .....");
            Console.WriteLine(client.hello("jian wang"));
            Console.WriteLine(client.add(1, 2));
            httpClient.Close();
            Console.ReadKey();
        }
Пример #22
0
 private NoteStore.Client GetNoteStore(UserStore.Client userStore, string authToken)
 {
     try {
         var noteStoreUrl       = userStore.getNoteStoreUrl(authToken);
         var noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
         var noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);
         return(new NoteStore.Client(noteStoreProtocol));
     }
     catch (Exception ex) {
         throw new EverpageException(
                   String.Format("Error occurred when getting note store: {0}", ex.Message),
                   ex);
     }
 }
Пример #23
0
 public static void Create(Action <Hades.Client> onCreate)
 {
     new Thread(() =>
     {
         var uri = new Uri(NativeBuildConfig.HadesUrl);
         using (var transport = new THttpClient(uri))
             using (var protocol = new TBinaryProtocol(transport))
                 using (var client = new Hades.Client(protocol))
                 {
                     transport.Open();
                     onCreate(client);
                 }
     }).Start();
 }
Пример #24
0
        /// <summary>
        /// Creates a new instance of a user client
        /// </summary>
        /// <returns></returns>
        UserStore.Client CreateInstance()
        {
            // override domain setting if we have one
            if (!String.IsNullOrWhiteSpace(System.Configuration.ConfigurationManager.AppSettings["EVERNOTE_DOMAIN"]))
            {
                EVERNOTE_DOMAIN = System.Configuration.ConfigurationManager.AppSettings["EVERNOTE_DOMAIN"];
            }

            // first the user info
            Uri        userStoreUrl       = new Uri(EVERNOTE_DOMAIN + "/edam/user");
            TTransport userStoreTransport = new THttpClient(userStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            return(new UserStore.Client(userStoreProtocol));
        }
 public static void Create(Action <Hades.Client> onCreate)
 {
     new Thread(() =>
     {
         ServicePointManager.ServerCertificateValidationCallback += (p1, p2, p3, p4) => true;
         var uri = new Uri(NativeBuildConfig.HadesUrl);
         using (var transport = new THttpClient(uri))
             using (var protocol = new TBinaryProtocol(transport))
                 using (var client = new Hades.Client(protocol))
                 {
                     transport.Open();
                     onCreate(client);
                 }
     }).Start();
 }
Пример #26
0
        public static TTransport GetTransport(string url)
        {
            TTransport transport;

            if (url.StartsWith("http"))
            {
                var uri        = new Uri(url);
                var httpClient = new THttpClient(uri);
                transport = httpClient;
            }
            else
            {
                var parts = url.Split(new[] { ':' });

                transport = new TSocket(parts[0], Convert.ToInt32(parts[1]));
            }
            return(transport);
        }
Пример #27
0
        protected void Dispose(bool disposing)
        {
            if (!disposed)
            {
                disposed = true;
                if (disposing)
                {
                    //dispose managed state
                    httpClient.Close();
                }
                else
                {
                    System.Diagnostics.Debug.Assert(false); // you MUST dispose this object explicitely or be doomed.
                }

                httpClient = null;
                protocol   = null;

                GC.SuppressFinalize(this);
            }
        }
Пример #28
0
        static void Main(string[] args)
        {
            try
            {
                TTransport             transport = new THttpClient(new Uri("http://*****:*****@justiceleague.com"
                        },
                        new Contact {
                            FirstName = "Clark", LastName = "Kent", Email = "*****@*****.**"
                        }
                    });
                    foreach (var e in contacts)
                    {
                        Console.WriteLine(e);
                    }
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException exception)
            {
                Console.WriteLine(exception.StackTrace);
            }
        }
Пример #29
0
        NoteStore.Client CreateInstance(string authToken)
        {
            // override domain setting if we have one
            if (!String.IsNullOrWhiteSpace(System.Configuration.ConfigurationManager.AppSettings["EVERNOTE_DOMAIN"]))
            {
                EVERNOTE_DOMAIN = System.Configuration.ConfigurationManager.AppSettings["EVERNOTE_DOMAIN"];
            }

            if (authToken != null)
            {
                // create a new user instance
                _UserInstance = new UserService(authToken);

                String noteStoreUrl = _UserInstance.Client.getNoteStoreUrl(authToken);

                // notebook info
                TTransport noteStoreTransport = new THttpClient(new Uri(noteStoreUrl));
                TProtocol  noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);
                return(new NoteStore.Client(noteStoreProtocol));
            }

            return(null);
        }
Пример #30
0
        public override void StartSync(IRemoteStorageSyncPersistance data, List <INote> localnotes, List <INote> localdeletednotes)
        {
            _data = (EvernoteData)data;

            RefreshToken();

            TTransport noteStoreTransport = new THttpClient(new Uri(@"https://sandbox.evernote.com/shard/s1/notestore"));            //TODO use url from OAuth
            TProtocol  noteStoreProtocol  = new TBinaryProtocol(noteStoreTransport);

            nsClient = new NoteStore.Client(noteStoreProtocol);

            var state = nsClient.getSyncState(_token);

            if (_data.SyncStateUpdateCount != state.UpdateCount)
            {
                _logger.Debug(EvernotePlugin.Name, string.Format("Remote has changed SyncState: {0} -> '{1}'", _data.SyncStateUpdateCount, state.UpdateCount));

                NoteFilter filter = new NoteFilter();
                filter.Order = (int)NoteSortOrder.UPDATED;

                NotesMetadataResultSpec spec = new NotesMetadataResultSpec();
                spec.IncludeUpdateSequenceNum = true;

                bucket = nsClient.findNotesMetadata(_token, filter, 0, 9999, spec);

                _data.SyncStateUpdateCount = state.UpdateCount;
            }
            else
            {
                _logger.Debug(EvernotePlugin.Name, "Remote has not changed - no need for download - SyncState := " + state.UpdateCount);

                bucket = null;
            }

            remoteDirty = false;
        }
Пример #31
0
        public static void Execute(string[] args)
        {
            try
            {
                string host = "localhost";
                int    port = 9090;
                string url = null, pipe = null;
                int    numThreads = 1;
                bool   buffered = false, framed = false, encrypted = false;

                try
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        if (args[i] == "-h")
                        {
                            string[] hostport = args[++i].Split(':');
                            host = hostport[0];
                            if (hostport.Length > 1)
                            {
                                port = Convert.ToInt32(hostport[1]);
                            }
                        }
                        else if (args[i] == "-u")
                        {
                            url = args[++i];
                        }
                        else if (args[i] == "-n")
                        {
                            numIterations = Convert.ToInt32(args[++i]);
                        }
                        else if (args[i] == "-b" || args[i] == "-buffered")
                        {
                            buffered = true;
                            Console.WriteLine("Using buffered sockets");
                        }
                        else if (args[i] == "-f" || args[i] == "-framed")
                        {
                            framed = true;
                            Console.WriteLine("Using framed transport");
                        }
                        else if (args[i] == "-pipe")                          // -pipe <name>
                        {
                            pipe = args[++i];
                            Console.WriteLine("Using named pipes transport");
                        }
                        else if (args[i] == "-t")
                        {
                            numThreads = Convert.ToInt32(args[++i]);
                        }
                        else if (args[i] == "-ssl")
                        {
                            encrypted = true;
                            Console.WriteLine("Using encrypted transport");
                        }
                        else if (args[i] == "-compact")
                        {
                            protocol = "compact";
                            Console.WriteLine("Using compact protocol");
                        }
                        else if (args[i] == "-json")
                        {
                            protocol = "json";
                            Console.WriteLine("Using JSON protocol");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.StackTrace);
                }

                //issue tests on separate threads simultaneously
                Thread[] threads = new Thread[numThreads];
                DateTime start   = DateTime.Now;
                for (int test = 0; test < numThreads; test++)
                {
                    Thread t = new Thread(new ParameterizedThreadStart(ClientThread));
                    threads[test] = t;
                    if (url == null)
                    {
                        // endpoint transport
                        TTransport trans = null;
                        if (pipe != null)
                        {
                            trans = new TNamedPipeClientTransport(pipe);
                        }
                        else
                        {
                            if (encrypted)
                            {
                                trans = new TTLSSocket(host, port, "../../../../../keys/client.pem");
                            }
                            else
                            {
                                trans = new TSocket(host, port);
                            }
                        }

                        // layered transport
                        if (buffered)
                        {
                            trans = new TBufferedTransport(trans as TStreamTransport);
                        }
                        if (framed)
                        {
                            trans = new TFramedTransport(trans);
                        }

                        //ensure proper open/close of transport
                        trans.Open();
                        trans.Close();
                        t.Start(trans);
                    }
                    else
                    {
                        THttpClient http = new THttpClient(new Uri(url));
                        t.Start(http);
                    }
                }

                for (int test = 0; test < numThreads; test++)
                {
                    threads[test].Join();
                }
                Console.Write("Total time: " + (DateTime.Now - start));
            }
            catch (Exception outerEx)
            {
                Console.WriteLine(outerEx.Message + " ST: " + outerEx.StackTrace);
            }

            Console.WriteLine();
            Console.WriteLine();
        }
Пример #32
0
        public static void ClientTest(string host, int port, string certPath, string url, string pipe, bool encrypted, bool buffered, bool framed)
        {
            TTransport trans = null;

            if (url == null)
            {
                // endpoint transport

                if (pipe != null)
                {
                    trans = new TNamedPipeClientTransport(pipe);
                }
                else
                {
                    if (encrypted)
                    {
                        trans = new TTLSSocket(host, port, certPath);
                    }
                    else
                    {
                        trans = new TSocket(host, port);
                    }
                }

                // layered transport
                if (buffered)
                {
                    trans = new TBufferedTransport(trans as TStreamTransport);
                }
                if (framed)
                {
                    trans = new TFramedTransport(trans);
                }

                //ensure proper open/close of transport
                trans.Open();
            }
            else
            {
                trans = new THttpClient(new Uri(url));
            }


            TProtocol proto;

            if (protocol == "compact")
            {
                proto = new TCompactProtocol(trans);
            }
            else if (protocol == "json")
            {
                proto = new TJSONProtocol(trans);
            }
            else
            {
                proto = new TBinaryProtocol(trans);
            }

            RPCDemoService.Client client = new RPCDemoService.Client(proto);
            try
            {
                if (!trans.IsOpen)
                {
                    trans.Open();
                }
            }
            catch (TTransportException ttx)
            {
                Console.WriteLine("Connect failed: " + ttx.Message);
                return;
            }

            var stopwatch = Stopwatch.StartNew();

            for (var i = 0; i < length; i++)
            {
                var reply = client.GetById(i);
                Console.WriteLine("receive" + JsonConvert.SerializeObject(reply));
            }
            stopwatch.Stop();

            Console.WriteLine(string.Format("repeat={0}, time={1} Milliseconds, time/repeat={2}", length, stopwatch.ElapsedMilliseconds, stopwatch.ElapsedMilliseconds / (float)length));
            Console.ReadKey();
        }