Esempio n. 1
0
 public string Stringify()
 {
     try
     {
         return(JsonConvert.SerializeObject(this, TSCloud.serializer_settings()));
     }
     catch
     {
         throw;
     }
 }
Esempio n. 2
0
        public frmMain(TSCloud TSCloud) : this()
        {
            Hash Configuraion = new Hash();

            Configuraion["PerPage"] = 10;
            ModelClient             = new ModelClient(TSCloud, Configuraion);
            PrinterClient           = new PrinterClient(TSCloud, Configuraion);

            CurrentUser = TSCloud.CurrentUser;
            getFileList();
            getPrinterList();
        }
Esempio n. 3
0
 public static Hash Parse(string strData)
 {
     try
     {
         Hash hash = JsonConvert.DeserializeObject <Hash>(strData, TSCloud.serializer_settings());
         return(hash);
     }
     catch (Exception ee)
     {
         throw ee;
     }
 }
Esempio n. 4
0
 public virtual void Initialize()
 {
     _TSCloud = new TSCloud("http://tp2staging.herokuapp.com");
     SetCurrentUser();
 }
Esempio n. 5
0
        public Comment CreateComment(string Content)
        {
            if (!IsSysInfoDefined())
            {
                throw new Exception("SysInfo is not defined");
            }
            if (!CheckExpiration())
            {
                throw new Exception("token refresh fails");
            }

            RestRequest request = new RestRequest(String.Format("{0}/folders/{1}/comments", SysInfo.ApiPath, Convert.ToString(this.Id)), Method.POST);

            request.AddParameter("api_token", SysInfo.ApiToken);
            request.AddParameter("content", Content);

            try
            {
                IRestResponse httpResponse = GetRestClient().Execute(request);
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    Comment response = JsonConvert.DeserializeObject <Comment>(httpResponse.Content, TSCloud.serializer_settings());
                    response.StatusCode = httpResponse.StatusCode;
                    response.Message    = httpResponse.ErrorMessage;
                    response.SysInfo    = this.SysInfo;

                    return(response);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ee)
            {
                throw ee;
            }
        }
Esempio n. 6
0
        public Model Update()
        {
            if (!IsSysInfoDefined())
            {
                throw new Exception("SysInfo is not defined");
            }
            if (this.Id == 0)
            {
                throw new Exception("Model ID Required");
            }
            if (!CheckExpiration())
            {
                throw new Exception("token refresh fails");
            }

            RestRequest request = new RestRequest(String.Format("{0}/folders/{1}", SysInfo.ApiPath, Convert.ToString(this.Id)), Method.PUT);

            request.AddParameter("api_token", SysInfo.ApiToken);
            request.AddParameter("name", this.Name);
            if (this.Meta != null)
            {
                request.AddParameter("meta", this.Meta.Stringify());
            }
            if (this.Acl != null)
            {
                request.AddParameter("acl", this.Acl.Stringify());
            }
            if (this.Ftype == Ftype.Page)
            {
                request.AddParameter("page", this.Content);
            }
            request.AddParameter("description", this.Description);

            try
            {
                IRestResponse httpResponse = GetRestClient().Execute(request);
                if (httpResponse.StatusCode == HttpStatusCode.OK)
                {
                    Model model_response = JsonConvert.DeserializeObject <Model>(httpResponse.Content, TSCloud.serializer_settings());
                    model_response.StatusCode = httpResponse.StatusCode;
                    model_response.Message    = httpResponse.ErrorMessage;
                    model_response.SysInfo    = this.SysInfo;

                    return(model_response);
                }
                else
                {
                    return(new Model(httpResponse.Content));
                }
            }
            catch (Exception ee)
            {
                return(new Model(ee.ToString()));
            }
        }
Esempio n. 7
0
 public void MyTestInitialize()
 {
     _TSCloud = new TSCloud(ApiHost);
     _TSCloud.Authenticate(Email, Password);
     Console.WriteLine(testValue);
 }
Esempio n. 8
0
        public void CurrentUserTest()
        {
            TSCloud target = _TSCloud;

            Assert.IsTrue(_TSCloud.CurrentUser.IsValid());
        }
Esempio n. 9
0
 public CommonItem()
 {
     m_sys_info = null;
 }