예제 #1
0
 public IHttpActionResult Get(string id)
 {
     try
     {
         UpdateModel updateModel = UpdateManager.GetItemsForUpdate(id, "");
         return(Ok(updateModel));
     }
     catch (WebException exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         return(BadRequest(exception.Message + " Please check your credentials"));
     }
     catch (Exception exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         return(BadRequest(exception.Message));
     }
 }
예제 #2
0
 public UpdateModel Get(string id)
 {
     try
     {
         UpdateModel updateModel = UpdateManager.GetItemsForUpdate(id, "");
         return(updateModel);
     }
     catch (WebException exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                                                                     exception.Message + " Please check your credentials"));
     }
     catch (Exception exception)
     {
         LogHelper.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exception.Message, exception);
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, exception.Message));
     }
 }
예제 #3
0
        public void Get(string id, string db)
        {
            object resultObject = null;

            try
            {
                var language        = Sitecore.Context.Language;
                var updateModel     = UpdateManager.GetItemsForUpdate(id, language.CultureInfo.TwoLetterISOLanguageName);
                var importViewModel = new UpdateViewModel {
                    Languages = this.GetLanguages(db)
                };

                foreach (var updateItemModel in updateModel.Items)
                {
                    importViewModel.Items.Add(new UpdateListItemViewModel
                    {
                        Id                    = updateItemModel.CmsId,
                        ScTitle               = updateItemModel.Title,
                        ScTemplateName        = updateItemModel.CmsTemplate.Name,
                        CmsLink               = updateItemModel.CmsLink,
                        GcLink                = updateItemModel.GcLink,
                        LastUpdatedInGc       = updateItemModel.GcItem.LastUpdatedInGc,
                        LastUpdatedInSitecore = updateItemModel.LastUpdatedInCms,
                        GcProject             = new ProjectViewModel
                        {
                            Id   = updateItemModel.Project.Id,
                            Name = updateItemModel.Project.Name
                        },
                        GcTemplate = new TemplateViewModel
                        {
                            Id   = updateItemModel.GcTemplate.Id,
                            Name = updateItemModel.GcTemplate.Name
                        },
                        Status = new StatusViewModel
                        {
                            Id    = updateItemModel.Status.Id,
                            Name  = updateItemModel.Status.Name,
                            Color = updateItemModel.Status.Color
                        },
                        GcItem = new ItemViewModel
                        {
                            Id   = updateItemModel.GcItem.Id,
                            Name = updateItemModel.GcItem.Title
                        },
                    });
                }

                importViewModel.Filters = this.GetFilters(updateModel.Filters);

                resultObject = importViewModel;

                //var model = JsonConvert.SerializeObject(importViewModel);
                //return model;
            }
            catch (WebException exception)
            {
                Log.Error("GatherContent message: " + exception.Message + exception.StackTrace, exception);
                resultObject = new { status = "error", message = exception.Message + " Please check your credentials" };
                //return exception.Message + " Please check your credentials";
            }
            catch (Exception exception)
            {
                Log.Error("GatherContent message: " + exception.Message + exception.StackTrace, exception);
                resultObject = new { status = "error", message = "GatherContent message: " + exception.Message };
                //return exception.Message;
            }
            finally
            {
                Context.Response.Clear();
                Context.Response.ContentType = "application/json";
                JavaScriptSerializer js = new JavaScriptSerializer();
                Context.Response.Write(js.Serialize(resultObject));
            }
        }
예제 #4
0
        public string Get(string id, string db)
        {
            try
            {
                var language        = Sitecore.Context.Language;
                var updateModel     = UpdateManager.GetItemsForUpdate(id, language.CultureInfo.TwoLetterISOLanguageName);
                var importViewModel = new UpdateViewModel {
                    Languages = this.GetLanguages(db)
                };

                foreach (var updateItemModel in updateModel.Items)
                {
                    importViewModel.Items.Add(new UpdateListItemViewModel
                    {
                        Id                    = updateItemModel.CmsId,
                        ScTitle               = updateItemModel.Title,
                        ScTemplateName        = updateItemModel.CmsTemplate.Name,
                        CmsLink               = updateItemModel.CmsLink,
                        GcLink                = updateItemModel.GcLink,
                        LastUpdatedInGc       = updateItemModel.GcItem.LastUpdatedInGc,
                        LastUpdatedInSitecore = updateItemModel.LastUpdatedInCms,
                        GcProject             = new ProjectViewModel
                        {
                            Id   = updateItemModel.Project.Id,
                            Name = updateItemModel.Project.Name
                        },
                        GcTemplate = new TemplateViewModel
                        {
                            Id   = updateItemModel.GcTemplate.Id,
                            Name = updateItemModel.GcTemplate.Name
                        },
                        Status = new StatusViewModel
                        {
                            Id    = updateItemModel.Status.Id,
                            Name  = updateItemModel.Status.Name,
                            Color = updateItemModel.Status.Color
                        },
                        GcItem = new ItemViewModel
                        {
                            Id   = updateItemModel.GcItem.Id,
                            Name = updateItemModel.GcItem.Title
                        },
                    });
                }

                importViewModel.Filters = this.GetFilters(updateModel.Filters);

                var model = JsonConvert.SerializeObject(importViewModel);
                return(model);
            }
            catch (WebException exception)
            {
                Log.Error("GatherContent message: " + exception.Message + exception.StackTrace, exception);
                return(exception.Message + " Please check your credentials");
            }
            catch (Exception exception)
            {
                Log.Error("GatherContent message: " + exception.Message + exception.StackTrace, exception);
                return(exception.Message);
            }
        }