예제 #1
0
        private void getClientID()
        {
            string url = serviceURL_ + "clients";

            if (userID_ == null || whoToken_ == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            var bodyParameters = new
            {
                UserID           = userID_,
                WhoToken         = whoToken_,
                GraphID          = graphID_,
                ClientName       = "Plugin",
                GraphAccessToken = graphAccessToken_
            };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Post", bodyParameters);
            var responseDic = (Dictionary <string, object>)response;

            clientID_ = (int)responseDic["CreatedClientID"];
        }
예제 #2
0
        public int GetPermissionType()
        {
            string url = systemManager_.GetServiceURL() + "folders/" + id_;

            int?   userID   = systemManager_.__GetUserID();
            string whoToken = systemManager_.__GetWhoToken();

            if (userID == null || whoToken == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            urlParameters["UserID"]   = userID.ToString();
            urlParameters["WhoToken"] = whoToken;

            var bodyParameters = new { };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Get", bodyParameters);
            var dic = (Dictionary <string, object>)response;

            return((int)dic["PermissionType"]);
        }
예제 #3
0
        private void getGraphAccessToken()
        {
            string url = serviceURL_ + "graph-access-tokens";

            if (userID_ == null || whoToken_ == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            var bodyParameters = new
            {
                UserID         = userID_,
                WhoToken       = whoToken_,
                GraphID        = graphID_,
                PermissionType = 1
            };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Post", bodyParameters);
            var responseDic = (Dictionary <string, object>)response;

            graphAccessToken_ = (string)responseDic["GraphAccessToken"];
        }
예제 #4
0
        /// <summary>
        /// receives incomming commands from the server
        /// </summary>
        private void syncIncommingCommands()
        {
            while (true)
            {
                string url = serviceURL_ + "commands";

                if (userID_ == null || whoToken_ == null)
                {
                    throw new AuthenicationException();
                }

                var urlParameters = new Dictionary <string, string>();
                urlParameters["UserID"]           = userID_.ToString();
                urlParameters["WhoToken"]         = whoToken_;
                urlParameters["GraphID"]          = graphID_.ToString();
                urlParameters["LastCommandID"]    = lastCommandIDReceived_.ToString();
                urlParameters["GraphAccessToken"] = graphAccessToken_;

                var bodyParameters = new { };

                var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                             "Get", bodyParameters);
                processResponse(response);

                Thread.Sleep(20);
            }
        }
예제 #5
0
        public int CreateGraph(string graphName, int folderID, string renderEngineGUID)
        {
            string url = serviceURL_ + "graphs";

            if (userID_ == null || whoToken_ == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            var bodyParameters = new
            {
                UserID           = userID_,
                WhoToken         = whoToken_,
                GraphName        = graphName,
                FolderID         = folderID,
                RenderEngineGUID = renderEngineGUID
            };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Post", bodyParameters);
            var responseDic = (Dictionary <string, object>)response;

            return((int)responseDic["CreatedGraphID"]);
        }
예제 #6
0
        public List <Folder> GetFolders()
        {
            var result = new List <Folder>();

            string url = serviceURL_ + "folders";

            if (userID_ == null || whoToken_ == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            urlParameters["UserID"]   = userID_.ToString();
            urlParameters["WhoToken"] = whoToken_;

            var bodyParameters = new { };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Get", bodyParameters);
            var responseArray = (object[])response;

            foreach (var responseItem in responseArray)
            {
                var itemDic = (Dictionary <string, object>)responseItem;
                var folder  = new Folder((int)itemDic["ID"], (string)itemDic["Name"], this);
                result.Add(folder);
            }

            return(result);
        }
예제 #7
0
        public void Login(string username, string password)
        {
            string url = serviceURL_ + "who-tokens";

            var urlParameters = new Dictionary <string, string>();

            var bodyParameters = new
            {
                Username = username,
                Password = password
            };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Post", bodyParameters);
            var responseDic = (Dictionary <string, object>)response;

            this.userID_   = (int)responseDic["UserID"];
            this.whoToken_ = (string)responseDic["WhoToken"];
        }
예제 #8
0
        public void DeleteGraph(int graphID)
        {
            string url = serviceURL_ + "graphs/" + graphID;

            if (userID_ == null || whoToken_ == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            urlParameters["UserID"]   = userID_.ToString();
            urlParameters["WhoToken"] = whoToken_;
            urlParameters["GraphID"]  = graphID.ToString();

            var bodyParameters = new { };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Delete", bodyParameters);
        }
예제 #9
0
        public List <GraphInfo> GetChildren()
        {
            var result = new List <GraphInfo>();

            string url = systemManager_.GetServiceURL() + "folders/" + id_;

            int?   userID   = systemManager_.__GetUserID();
            string whoToken = systemManager_.__GetWhoToken();

            if (userID == null || whoToken == null)
            {
                throw new AuthenicationException();
            }

            var urlParameters = new Dictionary <string, string>();

            urlParameters["UserID"]   = userID.ToString();
            urlParameters["WhoToken"] = whoToken;

            var bodyParameters = new { };

            var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                         "Get", bodyParameters);
            var dic         = (Dictionary <string, object>)response;
            var graphsArray = (object[])dic["Graphs"];

            foreach (var item in graphsArray)
            {
                var itemDic   = (Dictionary <string, object>)item;
                var graphInfo = new GraphInfo(
                    (int)itemDic["ID"],
                    (string)itemDic["Name"],
                    (int)itemDic["CommandSetVersion"],
                    (string)itemDic["RenderEngineGUID"]);
                result.Add(graphInfo);
            }

            return(result);
        }
예제 #10
0
        /// <summary>
        /// sends a commands to the server
        /// </summary>
        private bool sendCommand(Command command)
        {
            try
            {
                var parameters = command.GetParameters();

                string url = serviceURL_ + "commands";

                var urlParameters = new Dictionary <string, string>();

                var bodyParameters = new
                {
                    UserID           = userID_,
                    WhoToken         = whoToken_,
                    GraphID          = graphID_,
                    CommandName      = command.GetName(),
                    ClientID         = clientID_,
                    GraphAccessToken = graphAccessToken_,
                    Param1           = parameters[0],
                    Param2           = parameters[1],
                    Param3           = parameters[2],
                    Param4           = parameters[3],
                    Param5           = parameters[4]
                };

                var response = RESTHelper.SendTypicalRequest(url, urlParameters,
                                                             "Post", bodyParameters);

                return(true);
            }
            catch
            {
                return(false);
            }

            return(false);
        }