Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jose L 4 posts 74 karma points
    Jul 11, 2018 @ 08:04
    Jose L
    0

    Saving and Publishing content programatically takes ages

    Hi all,

    I need some help. I am trying to create some nodes on Umbraco programatically, and everything works fine. The only issue is that when I make this call...

    ApplicationContext.Current.Services.ContentService.Save(content);
    

    Takes up to 30 seconds to save the content, I don“t know how to reduce this time or if someone else has had this issue before.

    Please bring some ligth to me!!! :D

    try
            {
                var content = ApplicationContext.Current.Services.ContentService.CreateContent((model.Name.Trim() + model.Surname.Trim()).Trim(), parentId, "TherapistProfile", userID);
    
                //#region Therapist Profile Data
                var urlAlias = Regex.Replace(model.Name + "-" + model.Surname.Trim(), @"\s+", "");
                content.SetValue("umbracoUrlAlias", urlAlias);
                content.SetValue("therapistName", model.Name);
                content.SetValue("therapistSurname", model.Surname);
                content.SetValue("therapistEmail", model.Email);
                content.SetValue("therapistDateOfBirth", model.DateOfBirth);
                content.SetValue("therapistTelephone", model.Telephone);
                content.SetValue("therapistCity", model.City);
                content.SetValue("therapistTimeZone", model.TherapistTimeZone);
                content.SetValue("therapistNumber", model.TherapistNumber);
                content.SetValue("therapistUserIdBBDD", userID);
                content.SetValue("therapistYearsExperience", model.YearsExperience);
                content.SetValue("therapistCountry", model.IdCountry);
                content.SetValue("therapistGender", model.IdGender);
                content.SetValue("therapistType", model.IdTherapistType);
                content.SetValue("therapistAboutMe", model.LongDescription);
                content.SetValue("therapistSkype", model.SkypeID);
                content.SetValue("therapistHangout", model.HangoutsID);
                content.SetValue("therapistSpecialities", !string.IsNullOrEmpty(model.SpecialitiesSelected) ? model.SpecialitiesSelected : "0");
                content.SetValue("therapistTimeSession", model.DurationOfSessionMinutes);
                content.SetValue("therapistPriceVideoConference", model.PricePerSession);
                content.SetValue("therapistPriceChat", model.PricePerSessionChat);
    
                #region Uploading Profile Picture
                if (model.ProfileImage != null)
                {
                    HttpPostedFileBase file = model.ProfileImage;
                    ImageService _imageService = new ImageService();
                    var uploadedImage = await _imageService.CreateUploadedImage(file);
                    model.PhotoPath = uploadedImage.Url;
                    await _imageService.AddImageToBlobStorageAsync(uploadedImage);
                }
                #endregion
    
                content.SetValue("therapistImagePhotoPath", model.PhotoPath);
    
                #endregion
                ApplicationContext.Current.Services.ContentService.Save(content);
    
                Services.ContentService.Publish(content);
                return content.Id;
            }
            catch (Ex
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies