예제 #1
0
        public async Task <IEnumerable <RevitElement> > GetRevitElementsInPeriod(string versionId, string startDate, string endDate)
        {
            Regex regex = new Regex(@"^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$");

            if (regex.Match(startDate) == Match.Empty || regex.Match(endDate) == Match.Empty)
            {
                throw new FormatException("Bad format of startDate or endDate.");
            }
            var           route   = new RevitElementRoute(versionId);
            RestSharpBase reqBase = new RestSharpBase(route.GetEleInPeriodUrl, Method.GET);
            RestRequest   req     = reqBase.Request;

            req.AddQueryParameter("startDate", startDate);
            req.AddQueryParameter("endDate", endDate);

            IRestResponse <IEnumerable <RevitElement> > response = await _client.ExecuteAsync <IEnumerable <RevitElement> >(req);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new Exception(response.StatusDescription);
            }
        }
예제 #2
0
        public async Task <IEnumerable <Project> > GetProjects()
        {
            RestSharpBase requestBase = new RestSharpBase(ProjectRoute.ProjectsOfUserUrl, Method.GET);
            IRestResponse <IEnumerable <Project> > response = await _client.ExecuteAsync <IEnumerable <Project> >(requestBase.Request);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new System.Exception(response.StatusDescription);
            }
        }
예제 #3
0
        public async Task <IEnumerable <RevitElement> > GetAllElementsOfVersion(string versionId)
        {
            var           route   = new RevitElementRoute(versionId);
            RestSharpBase reqBase = new RestSharpBase(route.GetElementsUrl, Method.GET);
            IRestResponse <IEnumerable <RevitElement> > response = await _client.ExecuteAsync <IEnumerable <RevitElement> >(reqBase.Request);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new Exception(response.ErrorMessage);
            }
        }
예제 #4
0
        public async Task <User> GetMeAsync()
        {
            RestSharpBase        reqBase  = new RestSharpBase(UserRoute.GetMe, Method.GET);
            RestRequest          req      = reqBase.Request;
            IRestResponse <User> response = await _client.ExecuteAsync <User>(req);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new System.Exception(response.StatusDescription);
            }
        }
예제 #5
0
        public async Task <IEnumerable <Synchronization> > GetSynchronizations(string modelId)
        {
            var           url         = new SynchronizationRoute(modelId);
            RestSharpBase requestBase = new RestSharpBase(url.PostGetUrl, Method.GET);
            var           response    = await _client.ExecuteAsync <IEnumerable <Synchronization> >(requestBase.Request);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new System.Exception(response.StatusDescription);
            }
        }
예제 #6
0
        public async Task <IEnumerable <ModelVersion> > GetVersions(string modelId)
        {
            var           route       = new VersionRoute();
            RestSharpBase requestBase = new RestSharpBase(route.GetVersions, Method.GET);
            RestRequest   req         = requestBase.Request;

            req.AddHeader("modelid", modelId);
            IRestResponse <IEnumerable <ModelVersion> > response = await _client.ExecuteAsync <IEnumerable <ModelVersion> >(req);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new System.Exception(response.StatusDescription);
            }
        }
예제 #7
0
        public async Task <SynchroResponse> CreateSynchronization(string modelId, SynchroBody body)
        {
            var           route         = new SynchronizationRoute(modelId);
            RestSharpBase restSharpBase = new RestSharpBase(route.PostGetUrl, Method.POST);
            RestRequest   req           = restSharpBase.Request;

            req.AddJsonBody(body);
            var response = await _client.ExecuteAsync <SynchroResponse>(req);

            switch ((int)response.StatusCode)
            {
            case 200:
                return(response.Data);

            default:
                throw new System.Exception(response.StatusDescription);
            }
        }