Example #1
0
        /// <summary>
        /// The NewElementAsync
        /// </summary>
        /// <returns>The <see cref="Task"/></returns>
        private async Task NewElementAsync()
        {
            if (ProjectProvider.Instance.CurrentProject == null ||
                New.Count == 0 ||
                AuthProvider.Instance.token == null)
            {
                return;
            }
            List <RevitElement> newElements = new List <RevitElement>();

            foreach (string guid in New)
            {
                newElements.Add(ModelProvider.Instance.DicRevitElements[guid]);
            }

            RevitElementRoute route = new RevitElementRoute(ProjectProvider.Instance.CurrentProject._id);
            RestRequest       req   = new RestRequest(route.url(), Method.POST);

            req.AddHeader("Content-Type", "application/json");
            req.AddHeader("Authorization", "Bearer " + AuthProvider.Instance.token.token);
            string body = JsonConvert.SerializeObject(newElements);

            req.RequestFormat = RestSharp.DataFormat.Json;
            req.AddJsonBody(body);
            Route.Client.Timeout = Int32.MaxValue;
            Task <IRestResponse> resTask = Route.Client.ExecuteTaskAsync(req);

            var res = await resTask;
        }
Example #2
0
        /// <summary>
        /// The ModifiedElementAsync
        /// </summary>
        /// <returns>The <see cref="Task"/></returns>
        private async Task ModifiedElementAsync()
        {
            if (Modified.Count == 0)
            {
                return;
            }

            RevitElementRoute route = new RevitElementRoute(ProjectProvider.Instance.CurrentProject._id);
            RestRequest       req   = new RestRequest(route.url(), Method.PUT);

            req.AddHeader("Content-Type", "application/json");
            req.AddHeader("Authorization", "Bearer " + AuthProvider.Instance.token.token);
            string body = JsonConvert.SerializeObject(ModifiedElementToSynchonize.Values);

            req.RequestFormat = RestSharp.DataFormat.Json;
            req.AddJsonBody(body);
            Route.Client.Timeout = Int32.MaxValue;
            Task <IRestResponse> resTask = Route.Client.ExecuteTaskAsync(req);
            var res = await resTask;
        }