예제 #1
0
        public ArticleStruct SaveStubToSitecore(string articleName, DateTime publicationDate, Guid publicationID)
        {
            using (var client = new HttpClient(_handler, false))
            {
                publicationDate = TimezoneUtil.ConvertDateToServerTimezone(publicationDate);
                //Passing string format to create Article(Ticket IIS-589)
                var publicationDateString = publicationDate.ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US"));
                var article = new CreateArticleRequest()
                {
                    Name = articleName, PublicationID = publicationID, PublicationDate = publicationDateString
                };
                var response = client.PostAsJsonAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}CreateArticle", article).Result;

                if (response?.StatusCode != HttpStatusCode.OK)
                {//If the response is not OK, place the status code into the remote error message for logging
                    return(new ArticleStruct {
                        RemoteErrorMessage = response?.StatusCode.ToString()
                    });
                }
                else
                {
                    var articleItem = JsonConvert.DeserializeObject <ArticleStruct>(response.Content.ReadAsStringAsync().Result, new IsoDateTimeConverter());
                    TimezoneUtil.ConvertArticleDatesToLocalTimezone(articleItem);
                    return(articleItem);
                }
            }
        }
예제 #2
0
 public static ArticlePreviewInfo GetArticlePreviewInfo(string articleNumber)
 {
     using (var client = new HttpClient(_handler, false))
     {
         var response    = client.PostAsJsonAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}GetArticlePreviewInfo", articleNumber).Result;
         var previewInfo = JsonConvert.DeserializeObject <ArticlePreviewInfo>(response.Content.ReadAsStringAsync().Result, new IsoDateTimeConverter());
         TimezoneUtil.ConvertArticleDatesToLocalTimezone(previewInfo);
         return(previewInfo);
     }
 }
예제 #3
0
 public static bool DoesArticleNameAlreadyExistInIssue(ArticleStruct articleDetails)
 {
     TimezoneUtil.ConvertArticleDatesToServerTimezone(articleDetails);
     using (var client = new HttpClient(_handler, false))
     {
         var response = client.GetAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}DoesArticleNameAlreadyExistInIssue").Result;
         var flag     = JsonConvert.DeserializeObject <bool>(response.Content.ReadAsStringAsync().Result);
         TimezoneUtil.ConvertArticleDatesToLocalTimezone(articleDetails);
         return(flag);
     }
 }
예제 #4
0
 public static void SaveArticleText(Guid articleGuid, string text, ArticleStruct articleStruct)
 {
     TimezoneUtil.ConvertArticleDatesToServerTimezone(articleStruct);
     using (var client = new HttpClient(_handler, false))
     {
         var article = new SaveArticleTextByGuid()
         {
             ArticleGuid = articleGuid, ArticleData = articleStruct, WordText = text
         };
         var response = client.PostAsJsonAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}SaveArticleTextByGuid", article).Result;
         TimezoneUtil.ConvertArticleDatesToLocalTimezone(articleStruct);
     }
 }
예제 #5
0
 public static List <ArticlePreviewInfo> GetArticlePreviewInfo(List <Guid> guids)
 {
     using (var client = new HttpClient(_handler, false))
     {
         var response = client.PostAsJsonAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}GetArticlePreviewInfoByGuids", guids).Result;
         var articlePreviewCollection = JsonConvert.DeserializeObject <List <ArticlePreviewInfo> >(response.Content.ReadAsStringAsync().Result, new IsoDateTimeConverter());
         if (articlePreviewCollection != null)
         {
             articlePreviewCollection.ForEach(f => TimezoneUtil.ConvertArticleDatesToLocalTimezone(f));
         }
         return(articlePreviewCollection);
     }
 }
예제 #6
0
 public static void SaveMetadataToSitecore(string articleID, ArticleStruct articleData)
 {
     TimezoneUtil.ConvertArticleDatesToServerTimezone(articleData);
     using (var client = new HttpClient(_handler, false))
     {
         var article = new SaveArticleDetails()
         {
             ArticleNumber = articleID, ArticleData = articleData
         };
         var response = client.PostAsJsonAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}" + "/api/"}SaveArticleDetails", article).Result;
         TimezoneUtil.ConvertArticleDatesToLocalTimezone(articleData);
     }
 }
예제 #7
0
        private static ArticleStruct GetArticleDetails(Guid articleGuid)
        {
            Globals.SitecoreAddin.Log("Getting article details from Sitecore...");
            using (var client = new HttpClient(_handler, false))
            {
                var response      = client.GetAsync($"{$"{Constants.EDITOR_ENVIRONMENT_SERVERURL}/api/"}GetArticleDetailsBg?articleGuid={articleGuid}").Result;
                var articleStruct = JsonConvert.DeserializeObject <ArticleStruct>(response.Content.ReadAsStringAsync().Result);
                TimezoneUtil.ConvertArticleDatesToLocalTimezone(articleStruct);
                return(articleStruct);
            }

            /*
             *          var sctree = new SCTree();
             *          return sctree.GetArticleDetailsBG(articleGuid, _sitecoreUser.Username, _sitecoreUser.Password);
             */
        }