Пример #1
0
        public static PhysioAthletesViewModel Create(Umbraco.Web.UmbracoHelper umbraco, int physioNodeId, int?maxAthletesToDisplay)
        {
            var assignedItem = umbraco.AssignedContentItem;
            var physio       = umbraco.Content(physioNodeId) as Physiotherapist;

            return(new PhysioAthletesViewModel(assignedItem, physio?.Physio_name, maxAthletesToDisplay ?? 0));
        }
Пример #2
0
        private async void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, PublishEventArgs <IContent> e)
        {
            foreach (var content in e.PublishedEntities.Where(c => c.ContentType.Alias.Equals("question")).Where(c => c.WasPropertyDirty("Id")))
            {
                var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var node          = umbracoHelper.TypedContent(content.Id);
                var question      = (string)node.GetProperty("questionaire").Value;
                var category      = (string)node.GetProperty("category").Value;
                var listAnswer    = (IEnumerable <IPublishedContent>)node.GetProperty("listAnswer").Value;

                var client           = new Firebase.Database.FirebaseClient("https://qcmapp-4d7b3.firebaseio.com/");
                var categoryFirebase = await client.Child("category").OrderBy("name").EqualTo(category).LimitToFirst(1).OnceAsync <Category>();

                var catId = categoryFirebase.First().Key;

                var data = await client.Child("question").PostAsync(new Question {
                    CategoryId = catId, Value = question
                });

                foreach (var list in listAnswer)
                {
                    //listAns = new List<Listanswer>();
                    var answer = (string)list.GetProperty("answer").Value;
                    var isTrue = (bool)list.GetProperty("isTrueAnswer").Value;
                    await client.Child("reponse").PostAsync(new Reponse {
                        QuestionId = data.Key, Value = answer, IsTrue = isTrue
                    });
                }
            }
        }
Пример #3
0
        protected string GetDictionaryValue(String key)
        {
            int CultureId = Session["CultureId"] != null ? (int)Session["CultureId"] : System.Threading.Thread.CurrentThread.CurrentUICulture.LCID;

            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(CultureId);
            Umbraco.Web.UmbracoHelper helper = new Umbraco.Web.UmbracoHelper(UmbracoContext);
            return(helper.GetDictionaryValue(key));
        }
Пример #4
0
 /// <summary>
 /// Initialises the BlogAuthor Object
 /// </summary>
 /// <param name="NodeId">Umbraco NodeId of the Author</param>
 public BlogAuthor(int NodeId)
 {
     var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
     IPublishedContent authorNode = umbracoHelper.Content(NodeId);
     Name = authorNode.Name;
     PhotoUrl = JsonConvert.DeserializeObject<ImageCropDataSet>(authorNode.GetProperty("photo").Value.ToString());
     Blurb = (HtmlString)authorNode.GetProperty("blurb").Value;
     UrlName = authorNode.UrlName;
 }
Пример #5
0
        public static Umbraco.Core.Models.IPublishedContent GetContentRoot(this Umbraco.Web.UmbracoHelper helper, IPublishedContent Model, IEnumerable <IPublishedContent> rootContents)
        {
            var topRoot = Model.Parent;

            while (rootContents.Any(o => o.Id == topRoot.Id) == false)
            {
                topRoot = topRoot.Parent;
            }
            return(topRoot);
        }
        private void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            int nodeId;

            if (!int.TryParse(e.NodeId, out nodeId))
            {
                return;
            }

            var selectedMedia = ApplicationContext.Current.Services.MediaService.GetById(nodeId);
            var mediaType     = selectedMedia != null ? selectedMedia.ContentType.Alias : string.Empty;

            if (sender.TreeAlias == "media" && (mediaType.Equals("Folder") || nodeId == Constants.System.Root))
            {
                var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var menuItemTitle = umbracoHelper.GetDictionaryValue("ZippyMedia.Labels.UploadZipFile");

                if (string.IsNullOrWhiteSpace(menuItemTitle))
                {
                    menuItemTitle = "Upload and Unpack ZIP";
                }
                var menuItem = new MenuItem("uploadZipFile", menuItemTitle)
                {
                    Icon            = "compress",
                    SeperatorBefore = true
                };
                menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Upload-Zip.html", menuItemTitle);

                e.Menu.Items.Add(menuItem);
            }



            //Upload from server AKA ftp upload comming soon
            //if (sender.TreeAlias == "media" && mediaType.Equals("Folder") && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);
            //}

            //if (sender.TreeAlias == "media" && Convert.ToInt32(e.NodeId) == Constants.System.Root && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);

            //}
        }
        public bool Undo(string packageName, System.Xml.XmlNode xmlData)
        {
            var ret = true;

            try
            {
                var ms  = ApplicationContext.Current.Services.MediaService;
                var cs  = ApplicationContext.Current.Services.ContentService;
                var oia = ms.GetChildren(-1).FirstOrDefault(m => m.Name == "OrderItemAttachments");
                if (oia != null)
                {
                    ms.Delete(oia);
                }

                var uh          = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var rootContent = uh.ContentAtXPath("//ChalmersILL").FirstOrDefault();
                if (rootContent != null && rootContent.Id != 0)
                {
                    Access.RemoveMembershipRoleFromDocument(rootContent.Id, "Administrator");
                    Access.RemoveMembershipRoleFromDocument(rootContent.Id, "Viewer");
                    Access.RemoveProtection(rootContent.Id);
                    cs.UnPublish(rootContent);
                }

                var mga = MemberGroup.GetByName("Administrator");
                if (mga != null)
                {
                    mga.delete();
                }

                var mgv = MemberGroup.GetByName("Viewer");
                if (mgv != null)
                {
                    mgv.delete();
                }

                var mt = MemberType.GetByAlias("Standard");
                if (mt != null)
                {
                    mt.delete();
                }

                umbraco.uQuery.SqlHelper.ExecuteNonQuery(string.Format("DELETE FROM umbracoRelationType WHERE alias='{0}'", "memberLocked"));
            }
            catch (Exception e)
            {
                LogHelper.Error <ChillinInitialConfiguration>("Error in ChillinInitialConfiguration.Undo: ", e);
                ret = false;
            }

            return(ret);
        }
Пример #8
0
        public static string GetTagNameFromId(this string id)
        {
            var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);

            var tag = umbracoHelper.TypedContent(id);

            if (tag == null)
            {
                return("");
            }

            return(tag.Name);
        }
Пример #9
0
        public RssModel(RenderModel model, string[] parameters)
            : base(model.Content, model.CurrentCulture)
        {
            var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
            Title = Content.Name;
            IntroContent = (Content.GetProperty("content").HasValue)?StripHtml(Content.GetProperty("content").Value.ToString()):"";
            SiteURL = "http://" + HttpContext.Current.Request.Url.Host;

            AllPosts = Content.Children.OrderByDescending(r => r.GetProperty("entryDate").Value);
            var latestPost = AllPosts.OrderByDescending(r => r.UpdateDate).FirstOrDefault();
            //var latestPost = AllPosts.FirstOrDefault();
            LatestUpdate = (latestPost != null) ? latestPost.UpdateDate : DateTime.Now;
        }
        private void TreeControllerBase_MenuRendering(TreeControllerBase sender, MenuRenderingEventArgs e)
        {
            int nodeId;
            if (!int.TryParse(e.NodeId, out nodeId)) return;

            var selectedMedia = ApplicationContext.Current.Services.MediaService.GetById(nodeId);
            var mediaType = selectedMedia != null ? selectedMedia.ContentType.Alias : string.Empty;

            if (sender.TreeAlias == "media" && (mediaType.Equals("Folder") || nodeId == Constants.System.Root))
            {
                var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var menuItemTitle = umbracoHelper.GetDictionaryValue("ZippyMedia.Labels.UploadZipFile");

                if (string.IsNullOrWhiteSpace(menuItemTitle)) menuItemTitle = "Upload and Unpack ZIP";
                var menuItem = new MenuItem("uploadZipFile", menuItemTitle)
                {
                    Icon = "compress",
                    SeperatorBefore = true
                };
                menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Upload-Zip.html", menuItemTitle);

                e.Menu.Items.Add(menuItem);
            }



            //Upload from server AKA ftp upload comming soon 
            //if (sender.TreeAlias == "media" && mediaType.Equals("Folder") && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);
            //}

            //if (sender.TreeAlias == "media" && Convert.ToInt32(e.NodeId) == Constants.System.Root && sender.Security.CurrentUser.UserType.Alias.Equals("admin"))
            //{
            //    var menuItem = new MenuItem("unpackZipFileFromServer", "Unpack ZIP from server");
            //    menuItem.Icon = "server";
            //    menuItem.SeperatorBefore = false;
            //    menuItem.LaunchDialogView("/App_Plugins/zippyMedia/Views/Unpack-Zip.html", "Unpack ZIP archive from server");

            //    e.Menu.Items.Add(menuItem);

            //}

        }
        public bool Execute(string packageName, System.Xml.XmlNode xmlData)
        {
            var ret = true;

            try
            {
                var ms = ApplicationContext.Current.Services.MediaService;
                var attachmentsFolder = ms.CreateMedia("OrderItemAttachments", -1, "Folder");
                ms.Save(attachmentsFolder);

                var mga = MemberGroup.MakeNew("Administrator", umbraco.BusinessLogic.User.GetUser(0));
                var mgv = MemberGroup.MakeNew("Viewer", umbraco.BusinessLogic.User.GetUser(0));

                MemberType.MakeNew(umbraco.BusinessLogic.User.GetUser(0), "Standard");

                var cs          = ApplicationContext.Current.Services.ContentService;
                var uh          = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
                var rootContent = cs.GetByLevel(1).First();

                cs.PublishWithChildren(rootContent);

                var loginPage = uh.TypedContentAtXPath("//ChalmersILLLoginPage").First();

                Access.ProtectPage(false, rootContent.Id, loginPage.Id, loginPage.Id);
                Access.AddMembershipRoleToDocument(rootContent.Id, "Administrator");
                Access.AddMembershipRoleToDocument(rootContent.Id, "Viewer");

                umbraco.uQuery.SqlHelper.ExecuteNonQuery(
                    string.Format("INSERT INTO umbracoRelationType ([dual], parentObjectType, childObjectType, name, alias) VALUES ({0}, '{1}', '{2}', '{3}', '{4}')",
                                  1,
                                  "39EB0F98-B348-42A1-8662-E7EB18487560",
                                  "C66BA18E-EAF3-4CFF-8A22-41B16D66A972",
                                  "Member Locked",
                                  "memberLocked"));
            }
            catch (Exception e)
            {
                LogHelper.Error <ChillinInitialConfiguration>("Error in ChillinInitialConfiguration.Execute: ", e);
                ret = false;
            }

            return(ret);
        }
Пример #12
0
    public Case(IPublishedContent content)
    {
        Id          = content.Id;
        Description = content.GetPropertyValue <string>("description");
        Title       = content.GetPropertyValue <string>("title");
        //image
        string image   = content.GetPropertyValue <string>("image");
        int    imageId = 0;

        int.TryParse(image, out imageId);
        if (imageId != 0)
        {
            var umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
            Image = umbracoHelper.Media(imageId).GetCropUrl("umbracoFile", "image");
        }
        //Team
        string teamID = content.GetPropertyValue <string>("teamMember");

        Team = DAL.GetTeamProperties(teamID);
    }
Пример #13
0
        private void ContentService_Saving(IContentService sender, SaveEventArgs <IContent> e)
        {
            // var textAnalyticsService = new TextAnalyticsService(_textAnalyticsApiKey);

            CarPriceService service       = new CarPriceService(_apiKey);
            var             umbracoHelper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);


            foreach (IContent content in e.SavedEntities.Where(a => a.ContentType.Alias == "carAdvert"))
            {
                var model = umbracoHelper.TypedContent(content.GetValue("car"));

                var inputModel = new CarPriceService.InputRequest();
                inputModel.Year    = content.GetValue <int>("year");
                inputModel.Mileage = content.GetValue <int>("mileage");
                inputModel.Model   = model.Name;
                inputModel.Make    = model.Parent.Name;

                var result = AsyncHelpers.RunSync(() => service.InvokeRequestResponseService(inputModel));

                content.SetValue("suggestedPrice", result);
            }
        }
        public override object ConvertSourceToObject(PublishedPropertyType propertyType, object source, bool preview)
        {
            if (source == null)
            {
                return(new List <ViewModels.SpecialDaysOfBusinessViewModel>());
            }



            var data = JsonConvert.DeserializeObject <IEnumerable <ViewModels.SpecialDaysOfBusinessViewModel> >((string)source);


            var umbracoHelper     = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
            var dataTypePrevalues = umbracoHelper.DataTypeService.GetPreValuesCollectionByDataTypeId(propertyType.DataTypeId);

            bool removeOldDates = dataTypePrevalues.PreValuesAsDictionary.First(x => x.Key == "removeOldDates").Value.Value == "1";

            //Only all dates in the future
            if (removeOldDates)
            {
                return(data.Where(x => x.Date != null && x.Date.Date >= DateTime.Now.Date.Date).ToList());
            }
            return(data);
        }
Пример #15
0
 public static MvcHtmlString GetbreadcrumbPath(this Umbraco.Web.UmbracoHelper helper, IPublishedContent content)
 {
     // <li><i class="fa fa-home pr-10"></i><a href="index.html">Home</a></li>
     //<li class="active">Page Services 2</li>
     return(null);
 }
        /// <summary>
        /// Gets the prevalues.
        /// </summary>
        public override List<PreValue> GetPreValues(Field field)
        {

            // Variables.
            var prevalues = new List<PreValue>();


            // Only proceed if a content type has been chosen.
            if (!string.IsNullOrWhiteSpace(PrimaryContentType))
            {

                // Variables.
                var helper = new UmbracoHelper(UmbracoContext.Current);
                var typeService = Umbraco.Core.ApplicationContext.Current.Services.ContentTypeService;
                var contentService = Umbraco.Core.ApplicationContext.Current.Services.ContentService;
                var separators = new string[] { ", ", ",", " " };
                var removeEmpties = StringSplitOptions.RemoveEmptyEntries;
                var splitTypes = (AdditionalContentTypes ?? string.Empty).Split(separators, removeEmpties);
                var secondaryAliases = (SecondaryProperty ?? string.Empty).Split(separators, removeEmpties);
                var typeIds = new List<int>();


                // Get content type ID's.
                typeIds.Add(int.Parse(PrimaryContentType));
                foreach (var typeAlias in splitTypes)
                {
                    var extraType = typeService.GetContentType(typeAlias);
                    if (extraType != null && extraType.Id > 0)
                    {
                        typeIds.Add(extraType.Id);
                    }
                }
                typeIds = typeIds.Distinct().ToList();


                // Get published content nodes of specified types.
                var nodes = new List<IContent>();
                foreach (var typeId in typeIds)
                {
                    nodes.AddRange(contentService.GetContentOfContentType(typeId));
                }
                var nodeIds = nodes.Select(x => x.Id).Distinct().ToArray();
                var publishedNodes = helper.TypedContent(nodeIds).Where(x => x != null);


                // Get prevalues.
                foreach (var node in publishedNodes)
                {

                    // Variables.
                    string prop1 = null;
                    string prop2 = null;


                    // First property value.
                    if (PrimaryProperty == "*")
                    {
                        prop1 = node.Name;
                    }
                    else
                    {
                        prop1 = node.LocalizedPropertyValue<string>(PrimaryProperty);
                    }


                    // Second property value.
                    foreach (var alias in secondaryAliases)
                    {
                        if (alias == "*")
                        {
                            prop2 = node.Name;
                        }
                        else
                        {
                            prop2 = node.LocalizedPropertyValue<string>(alias);
                        }
                        if (!string.IsNullOrWhiteSpace(prop2))
                        {
                            break;
                        }
                    }


                    // Remove leading property values.
                    if (string.IsNullOrWhiteSpace(prop1))
                    {
                        prop1 = prop2;
                        prop2 = null;
                    }


                    // Combine property values.
                    string valueName = prop1 + (string.IsNullOrWhiteSpace(prop2)
                        ? string.Empty
                        : string.Format(" ({0})", prop2));
                    if (string.IsNullOrWhiteSpace(valueName))
                    {
                        valueName = node.Name;
                    }


                    // Create prevalue.
                    if (!string.IsNullOrWhiteSpace(valueName))
                    {
                        prevalues.Add(new PreValue() { Id = node.Id, Value = valueName });
                    }

                }

            }


            // Sort and finalize prevalues.
            prevalues = prevalues.OrderBy(x => x.Value).ToList();
            int sort = 0;
            foreach (var prevalue in prevalues)
            {
                if (field != null)
                {
                    prevalue.Field = field.Id;
                }
                prevalue.SortOrder = sort;
                sort++;
            }


            // Return prevalues.
            return prevalues;

        }
Пример #17
0
 public static IEnumerable <ILanguage> GetAllLanguage(this Umbraco.Web.UmbracoHelper helper)
 {
     return(ApplicationContext.Current.Services.LocalizationService.GetAllLanguages());
 }
Пример #18
0
 public static string GetUrl(this Umbraco.Web.UmbracoHelper helper, string root, string url)
 {
     return(root + url);
 }