public FeedQueryMatch Match(Orchard.Core.Feeds.Models.FeedContext context)
        {
            var idValue = context.ValueProvider.GetValue("id");
            if (idValue == null)
                return null;
            var connectorValue = context.ValueProvider.GetValue("connector");
            if (connectorValue == null)
                return null;

            var typeDef = _contentDefinitionManager.GetTypeDefinition((String)connectorValue.ConvertTo(typeof(String)));
            if (typeDef == null)
                return null;

            var connectorDef = typeDef.Parts.FirstOrDefault(p => p.PartDefinition.Name == "ConnectorPart");
            if (connectorDef == null)
                return null;

            var settings = connectorDef.Settings.GetModel<AggregationTypePartSettings>();
            if (!settings.ExposeFeed) {
                return null;
            }
            // TODO: Could additionally check a user permission specifically for feeds, and of course view permissions for both parent and child items

            return new FeedQueryMatch {FeedQuery= this, Priority = 10 };
        }
        public static IDisposable InlineEdit(this HtmlHelper htmlhelper,
            Orchard.Mvc.ViewEngines.Razor.WebViewPage<dynamic> webViewPage) {

            var viewModel = (InlineViewModel)webViewPage.Model;
            
            TagBuilder tagBuilder = null;

            Shape shape = (Shape)viewModel.DisplayShape;

            var contentPart = shape.Properties["ContentPart"] as ContentPart;
            var contentField = shape.Properties["ContentField"] as ContentField;

            if (contentPart != null && contentField == null) {
                tagBuilder = InlineEditForPartTagBuilder(webViewPage, viewModel, contentPart.GetType().Name);
            }
            else if (contentPart != null && contentField != null) {
                tagBuilder = InlineEditForFieldTagBuilder(webViewPage, viewModel, contentPart.GetType().Name, contentField.Name);
            }
            else
                return null;
            
            return webViewPage.Capture(html => {
                webViewPage.Output.Write(tagBuilder.ToString(TagRenderMode.StartTag));
                webViewPage.Output.Write(html);
                webViewPage.Output.Write(webViewPage.Display.ExternalShapes(Shapes: viewModel.ExternalShapes));
                webViewPage.Output.Write(webViewPage.Display.ShapeEditorActions());
                webViewPage.Output.Write(htmlhelper.AntiForgeryTokenOrchard());
                webViewPage.Output.Write(tagBuilder.ToString(TagRenderMode.EndTag));
            });
        }
        public async Task <IActionResult> Edit(int id, [Bind("OrchardID,UserID,OrchardName,OrchardMapDataUrl")] Orchard orchard)
        {
            if (id != orchard.OrchardID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(orchard);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrchardExists(orchard.OrchardID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(orchard));
        }
Esempio n. 4
0
        public void Describe(Orchard.Forms.Services.DescribeContext context)
        {
            Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = _shapeFactory.Form(
                        Id: "SearchFilterForm",
                        _Index: _shapeFactory.SelectList(
                            Id: "Index", Name: "Index",
                            Title: T("Index"),
                            Description: T("The selected index will be queried."),
                            Size: 5,
                            Multiple: false),
                        _SearchQuery: _shapeFactory.Textbox(
                            Id: "SearchQuery", Name: "SearchQuery",
                            Title: T("Search query"),
                            Description: T("The search query to match against."),
                            Classes: new[] { "tokenized" }),
                        _HitCountLimit: _shapeFactory.Textbox(
                            Id: "HitCountLimit", Name: "HitCountLimit",
                            Title: T("Hit count limit"),
                            Description: T("For performance reasons you can limit the maximal number of search hits used in the query. Having thousands of search hits will result in poor performance and increased load on the database server."))
                        );

                    foreach (var index in _indexProvider.List())
                    {
                        f._Index.Add(new SelectListItem { Value = index, Text = index });
                    }

                    return f;
                };

            context.Form("SearchFilter", form);
        }
Esempio n. 5
0
 public IEnumerable<DocumentPart> Get(Orchard.ContentManagement.VersionOptions versionOptions)
 {
     return _contentManager.Query<DocumentPart, DocumentPartRecord>(versionOptions)
         .Join<TitlePartRecord>()
         .OrderBy(br => br.Title)
         .List();
 }
 public IEnumerable<Models.DocumentContentPart> Get(Models.DocumentPart documentPart, int skip, int count, Orchard.ContentManagement.VersionOptions versionOptions)
 {
     return GetDocumentQuery(documentPart, versionOptions)
             .Slice(skip, count)
             .ToList()
             .Select(ci => ci.As<DocumentContentPart>());
 }
 public void BuildEditorShape(object model, dynamic root, Orchard.ContentManagement.IUpdateModel updater, string prefix, string displayType, string stereotype, ModelShapeContext parentContext = null)
 {
     var context = new ModelEditorShapeContext(model, root, Shape, prefix, displayType, updater, parentContext);
     BindPlacement(context, displayType, stereotype);
     foreach (var driver in Drivers)
     {
         ModelDriverResult result = null;
         if (updater != null)
         {
             result = driver.UpdateEditor(context);
         }
         else {
             result = driver.BuildEditor(context);
         }
         // Null check, there must be a performance advantage to not instancing loads of empty ModelDriverResults
         if (result != null)
         {
             result.Apply(context);
         }
     }
     // Chain sub results?
     // They are applied to the same base object (as opposed to rendering an entirely new shape with its own zones)
     foreach (var chain in context.ChainedResults)
     {
         BuildEditorShape(chain.Model, chain.Root ?? root, updater, chain.Prefix, chain.DisplayType ?? displayType, stereotype, context);
         // Fire an event so parent shape can perform work after the update
         chain.OnCompleted(context);
     }
     // Invoke Updated event now all drivers have been executed
     if (updater != null)
     {
         context.InvokeUpdated();
     }
     // Done
 }
Esempio n. 8
0
        public void Delete(int id)
        {
            Orchard entity = this.GetEntity(id);

            db.Entry(entity).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
        }
 public RawConcurrentIndexed(int sizeInBit)
 {
     this.arrayMask         = (1 << sizeInBit) - 1;
     this.sizeInBit         = sizeInBit;
     this.arraySize         = 1 << sizeInBit;
     this.orchard           = new Orchard(new object[16], 4, 0b1111);
     this.targetOrchardSize = orchard.items.Length;
 }
 public DriverResult BuildDisplay(Orchard.ContentManagement.Handlers.BuildDisplayContext context)
 {
     var sockets = context.ContentItem.As<SocketsPart>();
     if (sockets != null) {
         _mechanicsDisplay.Value.ApplyDisplay(context);
     }
     // Shapes are now being applied directly in Origami (since this is all that normally happens on return from driver anyway)
     return new DriverResult();
 }
 public void GetMenu(Orchard.ContentManagement.IContent menu, NavigationBuilder builder)
 {
     // builder.Add(T("Affiliate Home"), "2", item => item.Action("Index", "Affiliate", new { area = "Liveo.Platform" }));
     // builder.Add(T("My Groups"), "2", item => item.Action("Index", "Groups", new { area = "Liveo.Platform" }));
     // builder.Add(T("My Albums"), "2", item => item.Action("Index", "Album", new { area = "Liveo.Platform" }));
     //builder.Add(T("My Gallery"), "2", item => item.Action("Index", "Gallery", new { area = "Liveo.Platform" }));
     // builder.Add(T("My Health Plan"), "2", item => item.Action("Index", "Fitness", new { area = "Liveo.Platform" }));
    // builder.Add(T("My Health Tracker"), "2", item => item.Action("Index", "Fitness", new { area = "Liveo.Platform" }));
 }
 static void Main(string[] args)
 {
     Console.Title = "不断更新的种植方法";
     Orchard appleOrchard = new Orchard(new Apple());        //创建苹果园实例
     appleOrchard.Plant();                                   //种植苹果
     Orchard orangeOrchard = new Orchard(new Orange());      //创建桔子园实例
     orangeOrchard.Plant();                                  //种植桔子
     Console.Read();
 }
 static void Main(string[] args)
 {
     Console.Title = "果园的监控";
     Orchard orchard = new Orchard();                        //创建果园实例
     IMonitor bjMonitor = new Monitor(orchard, "北京果园监控员");//北京果园监控员
     IMonitor shMonitor = new Monitor(orchard, "上海果园监控员");//上海果园监控员
     orchard.State = "苹果园!";                               //将果园监控状态改为苹果园
     orchard.Notify();                                       //通知监控员更新监控状态
     Console.Read();
 }
 static void Main(string[] args)
 {
     Console.Title = "果农培育果树";
     Orchard orchard = new Orchard();                             //创建果园实例
     orchard.Attach(new Apple());                                 //向果园中添加苹果树
     orchard.Attach(new Orange());                                //向果园中添加桔子树
     orchard.Accept(new LoosenOrchardist());                      //松土果农为果树松土
     orchard.Accept(new ManureOrchardist());                      //浇水果农为果树浇水
     Console.Read();
 }
 public void GetMenu(Orchard.ContentManagement.IContent menu, NavigationBuilder builder)
 {
     builder.Add(T("Lifestyle"), "2", item => item.Action("Index", "Lifestyle", new { area = "Pharmalto.Ecosystem" }));
     builder.Add(T("Supplements"), "2", item => item.Action("Index", "Supplements", new { area = "Pharmalto.Ecosystem" }));
     //builder.Add(T("My Groups"), "2", item => item.Action("Index", "Groups", new { area = "Pharmalto.Ecosystem" }));
     //builder.Add(T("My Albums"), "2", item => item.Action("Index", "Album", new { area = "Pharmalto.Ecosystem" }));
     //builder.Add(T("My Gallery"), "2", item => item.Action("Index", "Gallery", new { area = "Pharmalto.Ecosystem" }));
     //builder.Add(T("My Health Plan"), "2", item => item.Action("Index", "HealthPlan", new { area = "Pharmalto.Ecosystem" }));
     //builder.Add(T("My Health Tracker"), "2", item => item.Action("Index", "Fitness", new { area = "Pharmalto.Ecosystem" }));
 }
        static void Main(string[] args)
        {
            Console.Title = "果农培育果树";
            Orchard orchard = new Orchard();                             //创建果园实例

            orchard.Attach(new Apple());                                 //向果园中添加苹果树
            orchard.Attach(new Orange());                                //向果园中添加桔子树
            orchard.Accept(new LoosenOrchardist());                      //松土果农为果树松土
            orchard.Accept(new ManureOrchardist());                      //浇水果农为果树浇水
            Console.Read();
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            Console.Title = "不断更新的种植方法";
            Orchard appleOrchard = new Orchard(new Apple());        //创建苹果园实例

            appleOrchard.Plant();                                   //种植苹果
            Orchard orangeOrchard = new Orchard(new Orange());      //创建桔子园实例

            orangeOrchard.Plant();                                  //种植桔子
            Console.Read();
        }
Esempio n. 18
0
        public async Task <IActionResult> Create([Bind("OrchardID,UserID,OrchardName,OrchardMapDataUrl")] Orchard orchard)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orchard);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orchard));
        }
        static void Main(string[] args)
        {
            Console.Title = "果园的监控";
            Orchard  orchard   = new Orchard();                   //创建果园实例
            IMonitor bjMonitor = new Monitor(orchard, "北京果园监控员"); //北京果园监控员
            IMonitor shMonitor = new Monitor(orchard, "上海果园监控员"); //上海果园监控员

            orchard.State = "苹果园!";                               //将果园监控状态改为苹果园
            orchard.Notify();                                     //通知监控员更新监控状态
            Console.Read();
        }
Esempio n. 20
0
        public async Task <ActionResult> GetOrchardMap(String OrchardName)
        {
            //var OrchardN = this.OrchardName;
            Orchard orchard = await _context.Orchards.SingleOrDefaultAsync(m => m.OrchardName == OrchardName);

            if (orchard == null)
            {
                return(NotFound());
            }

            return(Json(orchard.OrchardMapDataUrl));
        }
        private void DefineSiteStyle(Orchard.UI.Resources.ResourceManifest manifest, string area)
        {
            var formatted = area.Replace('-', '_');

            manifest.DefineStyle("site_" + formatted)
                .SetUrl("site-" + area + ".min.css", "site-" + area + ".css")
                .SetDependencies("nyroModal");

            manifest.DefineStyle("site_" + formatted + "_rtl")
                .SetUrl("site-" + area + "-rtl.min.css", "site-" + area + "-rtl.css")
                .SetDependencies("site_" + formatted);
        }
 public override void PlantRemote(Orchard orchard)
 {
     if (orchard == this.bjOrchard)
     {
     Console.Write("北京果园");
     shOrchard.Plant();                          //种植上海水果
     }
     else if (orchard == this.shOrchard)
     {
     Console.Write("上海果园");
     bjOrchard.Plant();                          //种植北京水果
     }
 }
 static void Main(string[] args)
 {
     Console.Title = "建造同样的果园";
     Orchard bjOrchard = new Orchard();                      //建造北京果园
     bjOrchard.Name = "北京";                                  //给果园名称赋值
     bjOrchard.Apple = "北京苹果";                               //给苹果赋值
     bjOrchard.Orange = "北京桔子";                              //给桔子赋值
     bjOrchard.Plant();                                            //北京果园种植水果
     Orchard shOrchard = bjOrchard.Clone() as Orchard;       //通过复制北京果园创建上海果园实例
     shOrchard.Name = "上海";                                  //给果园名称赋值
     shOrchard.Plant();                                      //上海果园种植水果
     Console.Read();
 }
Esempio n. 24
0
 public override void PlantRemote(Orchard orchard)
 {
     if (orchard == this.bjOrchard)
     {
         Console.Write("北京果园");
         shOrchard.Plant();                      //种植上海水果
     }
     else if (orchard == this.shOrchard)
     {
         Console.Write("上海果园");
         bjOrchard.Plant();                      //种植北京水果
     }
 }
Esempio n. 25
0
        public async Task <int> SaveOrchardAsync(Orchard orchard)
        {
            var item = await database.Table <Orchard>().Where(i => i.news_id == orchard.news_id).FirstOrDefaultAsync();

            int idResult = 0;

            if (item == null)
            {
                idResult = await database.InsertAsync(orchard);
            }

            return(idResult);
        }
Esempio n. 26
0
 static void Postfix(Orchard __instance)
 {
     if (DroughtEvent.droughtRunning)
     {
         Building b = __instance.GetComponent <Building>();
         b.Yield = foodBuildingYields[b.UniqueName] - Settings.droughtFoodPenalty;
     }
     else
     {
         Building b = __instance.GetComponent <Building>();
         b.Yield = foodBuildingYields[b.UniqueName];
     }
 }
Esempio n. 27
0
 public void Alter(Orchard.DisplayManagement.Descriptors.PlacementInfo placement, string property, string value) {
     if (property == "cache") {
         // TODO: Could accept more behaviour options than just "true"; this might help us extend validation triggers (altho we can just do that by shape)
         var cache = value == "true";
         var model = placement as ModelPlacementInfo;
         if (model != null) {
             model.AddMutator(
                 (placementInfo, parentShape, shape, metadata, context) => {
                     var socketModel = context.Model as SocketDisplayContext;
                     socketModel.CacheSocket = cache;
                 });
         }
     }
 }
        private async Task SelectItemOrchard()
        {
            bool answer = await Application.Current.MainPage.DisplayAlert("Notificación", "¿Deseas que tu producto sea de: " + orchardSelected.news_name + "?", "Si", "No");

            if (answer)
            {
                App.ItemSelectedOrchard = orchardSelected;
                await PopupNavigation.PopAllAsync();
            }
            else
            {
                orchardSelected = null;
            }
        }
Esempio n. 29
0
        public async Task <int> DeleteOrchar(Orchard orchard)
        {
            var orch = await database.Table <Orchard>().Where(i => i.news_id == orchard.news_id).ToListAsync();

            if (orch != null)
            {
                foreach (var item in orch)
                {
                    var id = await database.DeleteAsync(item);
                }
            }

            return(0);
        }
        public override void Displaying(Orchard.Layouts.Framework.Display.ElementDisplayingContext context)
        {
            (context.ElementShape as IShape).Metadata.OnDisplaying((displaying =>
            {
                var typeName = context.Element.GetType().Name;
                var category = context.Element.Category.ToSafeName();

                if (context.Content != null)
                {
                    displaying.ShapeMetadata.Alternates.Add(String.Format("Elements_{0}_ContentType__{1}",
                        typeName, context.Content.ContentItem.ContentType));
                }

                if (context.Element is MediaItem)
                {
                    displaying.ShapeMetadata.Alternates.Add(String.Format("Elements_{0}_{1}", typeName, (context.Element as MediaItem).DisplayType));
                }

                if (context.Element is ContentItem)
                {
                    displaying.ShapeMetadata.Alternates.Add(String.Format("Elements_{0}_{1}", typeName, (context.Element as ContentItem).DisplayType));
                }

                if (context.Element.HtmlClass != null && context.Element.HtmlClass.StartsWith("DisplayType:"))
                {
                    string displayType;
                    var indexOfSpace = context.Element.HtmlClass.IndexOf(' ');
                    if (indexOfSpace < 0)
                    {
                        displayType = context.Element.HtmlClass.Substring("DisplayType:".Length);
                        context.ElementShape.TokenizeHtmlClass = (Func<string>)(() =>
                                _tokenizer.Replace(null, new { Content = context.Content }));
                    }
                    else
                    {
                        displayType = context.Element.HtmlClass.Substring("DisplayType:".Length, indexOfSpace - "DisplayType:".Length);
                        context.ElementShape.TokenizeHtmlClass = (Func<string>)(() =>
                                _tokenizer.Replace(context.Element.HtmlClass.Substring(indexOfSpace + 1), new { Content = context.Content }));
                    }

                    displaying.ShapeMetadata.Alternates.Add(String.Format("Elements_{0}_{1}", typeName, displayType));
                    displaying.ShapeMetadata.Alternates.Add(String.Format("Elements_{0}_{1}__{2}", typeName, displayType, category));

                    if ((context.Element is Menu) && (context.ElementShape.Menu is IShape)) {
                        context.ElementShape.Menu.DisplayType = displayType;   
                    }
                }
            }));
        }
        static void Main(string[] args)
        {
            Console.Title = "建造不同的果园";
            //创建北京果园建造指导者
            OrchardDirector bjOrchardDirector = new OrchardDirector(new BJOrchardBuilder());
            Orchard         bjOrchard         = bjOrchardDirector.Construct(); //北京果园指导者建造北京果园

            bjOrchard.Plant();                                                 //北京果园种植水果
            //创建上海果园建造指导者
            OrchardDirector shOrchardDirector = new OrchardDirector(new SHOrchardBuilder());
            Orchard         shOrchard         = shOrchardDirector.Construct(); //上海果园指导者建造上海果园

            shOrchard.Plant();                                                 //上海果园种植水果
            Console.Read();
        }
Esempio n. 32
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Orchard = await _context.Orchards.SingleOrDefaultAsync(m => m.OrchardID == id);

            if (Orchard == null)
            {
                return(NotFound());
            }
            return(Page());
        }
 /// <summary>
 /// Allow injecting a new paradigm with ";paradigm=..."
 /// </summary>
 /// <param name="placement"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 public void Alter(Orchard.DisplayManagement.Descriptors.PlacementInfo placement, string property, string value) {
     var model = placement as ModelPlacementInfo;
     if (model!=null) {
         if (property == "paradigm") {
             model.AddMutator((place, parentShape, shape, metadata, context) => {
                 context.Paradigms.Add(value);
             });
         }
         if (property == "group") {
             model.AddMutator((place, parentShape, shape, metadata, context) => {
                 context.GroupId = value;
             });
         }
     }
 }
        static void Main(string[] args)
        {
            Console.Title = "建造同样的果园";
            Orchard bjOrchard = new Orchard();                      //建造北京果园

            bjOrchard.Name   = "北京";                                //给果园名称赋值
            bjOrchard.Apple  = "北京苹果";                              //给苹果赋值
            bjOrchard.Orange = "北京桔子";                              //给桔子赋值
            bjOrchard.Plant();                                      //北京果园种植水果
            Orchard shOrchard = bjOrchard.Clone() as Orchard;       //通过复制北京果园创建上海果园实例

            shOrchard.Name = "上海";                                  //给果园名称赋值
            shOrchard.Plant();                                      //上海果园种植水果
            Console.Read();
        }
        private void RegisterLocalizedVersionOfJavascriptFiles(Orchard.UI.Resources.ResourceManifest manifest)
        {
            string currentCultureName = _workContextAccessor.GetContext().CurrentSite.SiteCulture;

            if (string.IsNullOrEmpty(currentCultureName)) {
                RegisterDefaultLocalizedVersionOfJavascriptFiles(manifest);
            } else {
                try {
                    var ci = new CultureInfo(currentCultureName);
                    // Until I can het the culture stuff plugged in.
                    RegisterDefaultLocalizedVersionOfJavascriptFiles(manifest);
                } catch (CultureNotFoundException) {
                    RegisterDefaultLocalizedVersionOfJavascriptFiles(manifest);
                }
            }
        }
        private async Task SelectItemOrchard()
        {
            bool answer = await Application.Current.MainPage.DisplayAlert("Notificación", "¿Deseas que tu producto sea de: " + orchardSelected.news_name + "?", "Si", "No");

            if (answer)
            {
                App.ItemSelectedOrchard = orchardSelected;
                var mdp     = (Application.Current.MainPage as MasterDetailPage);
                var navPage = mdp.Detail as NavigationPage;
                await navPage.PopAsync();
            }
            else
            {
                orchardSelected = null;
            }
        }
        public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(Orchard.ContentManagement.MetaData.Builders.ContentTypePartDefinitionBuilder builder, Orchard.ContentManagement.IUpdateModel updateModel)
        {
            if (builder.Name != "HeadPart")
                yield break;

            var model = new HeadTypePartSettings ();
            updateModel.TryUpdateModel(model, "HeadTypePartSettings", null, new string[] { "RawElements" });

            model.Elements = model.Elements.Where(e => !e.Deleted).ToList();
            model.RawElements = HeadElementSerializer.Serialize(model.Elements);

            builder.WithSetting("HeadTypePartSettings.RawElements", model.RawElements);

            yield return DefinitionTemplate(model);

        }
Esempio n. 38
0
        public OrchardDetailPage(Orchard orchard)
        {
            InitializeComponent();

            BindingContext       = viewModel = new OrchardDetailPageViewModels();
            viewModel.Navigation = this.Navigation;

            orchard.news_description = "<body style='background-color: transparent; '>" +
                                       orchard.news_description +
                                       "</body>";

            viewModel.ItemSelectedOrchard = orchard;

            IErrorHandler errorHandler = null;

            viewModel.CommandInitialize.ExecuteAsync().FireAndForgetSafeAsync(errorHandler);
        }
Esempio n. 39
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Orchard = await _context.Orchards.FindAsync(id);

            if (Orchard != null)
            {
                _context.Orchards.Remove(Orchard);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Esempio n. 40
0
        public AdminController(
            IOrchardServices services,
            Orchard.Recipes.Services.IRecipeManager recipeManager,
            ITenantService tenantService,
            ITenantWorkContextAccessor tenantWorkContextAccessor,
            MainBit.Recipes.Services.IRecipeManager mainBitRecipeManager,
            IRecipeEventHandler recipeEventHandler)
        {
            Services = services;
            _tenantService = tenantService;
            _tenantWorkContextAccessor = tenantWorkContextAccessor;
            _mainBitRecipeManager = mainBitRecipeManager;
            _recipeEventHandler = recipeEventHandler;

            T = NullLocalizer.Instance;
            Logger = NullLogger.Instance;
        }
        public void Execute(Orchard.Core.Feeds.Models.FeedContext context)
        {
            var idValue = context.ValueProvider.GetValue("id");
            var connectorValue = context.ValueProvider.GetValue("connector");

            var limitValue = context.ValueProvider.GetValue("limit");
            var limit = 20;
            if (limitValue != null)
            {
                limit = (int)limitValue.ConvertTo(typeof(int));
            }

            var id = (int)idValue.ConvertTo(typeof(int));
            var connectorName = (string)connectorValue.ConvertTo(typeof(string));
            
            var item = Services.ContentManager.Get(id);

            var socket = item.As<SocketsPart>();

            var connectors = socket.Sockets[connectorName].Connectors.List(
                q => q.ForPart<CommonPart>().OrderBy<CommonPartRecord>(c => c.CreatedUtc),
                q=>q.ForPart<ConnectorPart>().Slice(0,limit));
            var site = Services.WorkContext.CurrentSite;
            var url = new UrlHelper(_requestContext);
            if (context.Format == "rss")
            {
                var link = new XElement("link");
                context.Response.Element.SetElementValue("title", GetTitle(item.GetTitle(), site));
                context.Response.Element.Add(link);
                context.Response.Element.SetElementValue("description", item.GetBody());
                context.Response.Contextualize(requestContext => link.Add(url.AbsoluteAction(()=>url.ItemDisplayUrl(item))));
            }
            else
            {
                context.Builder.AddProperty(context, null, "title", GetTitle(item.GetTitle(), site));
                context.Builder.AddProperty(context, null, "description", item.GetBody());
                context.Response.Contextualize(requestContext => context.Builder.AddProperty(context, null, "link", url.AbsoluteAction(() => url.ItemDisplayUrl(item))));
            }

            foreach (var child in connectors)
            {
                context.Builder.AddItem(context, child.RightContent.ContentItem);
            }

        }
Esempio n. 42
0
        public ConnectorDescriptor(Orchard.ContentManagement.MetaData.Models.ContentTypeDefinition connectorDefinition, ConnectorTypePartSettings settings = null) {

            // Store def
            Definition = connectorDefinition;

            // Initialize lazies
            _PartDefinition = new Lazy<ContentTypePartDefinition>(() => {
                var partDef = Definition.Parts.Where(p => p.PartDefinition.Name == "ConnectorPart").FirstOrDefault();
                if (partDef == null) throw new ArgumentException("Connector definition must have ConnectorPart");
                return partDef;
            });
            if (settings != null) {
                _Settings = new Lazy<ConnectorTypePartSettings>(() => settings);
            }
            else {
                _Settings = new Lazy<ConnectorTypePartSettings>(() => PartDefinition.Settings.GetModel<ConnectorTypePartSettings>());
            }
        }
 public DriverResult UpdateEditor(Orchard.ContentManagement.Handlers.UpdateEditorContext context)
 {
     var sockets = context.ContentItem.As<SocketsPart>();
     if (sockets != null)
     {
         var origamiContext = context as UpdateContentEditorContext;
         if (origamiContext != null) {
             SocketParentContext parentContext = null;
             if (origamiContext.ParentContext != null) {
                 origamiContext.ParentContext.With<SocketParentContext>(s => {
                     parentContext = s;
                 });
             }
             _mechanicsDisplay.Value.ApplyEditors(context, parentContext);
         }
     }
     // Shapes are now being applied directly in Origami (since this is all that normally happens on return from driver anyway)
     return new DriverResult();
 }
        public void Vote(Orchard.ContentManagement.ContentItem contentItem, string userName, string hostname, double value, string dimension = null) {
            var vote = new VoteRecord {
                Dimension = dimension,
                ContentItemRecord = contentItem.Record,
                ContentType = contentItem.ContentType,
                CreatedUtc = _clock.UtcNow,
                Hostname = hostname,
                Username = userName,
                Value = value
            };

            _voteRepository.Create(vote);

            foreach(var function in _functions) {
                _calculator.Calculate(new CreateCalculus { Dimension = dimension, ContentId = contentItem.Id, FunctionName = function.Name, Vote = value});
            }

            _eventHandler.Voted(vote);
        }
Esempio n. 45
0
        public void Describe(Orchard.Forms.Services.DescribeContext context)
        {
            Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = _shapeFactory.Form(
                        Id: "IdsInFilterForm",
                        _Parts: _shapeFactory.Textbox(
                            Id: "ContentIds", Name: "ContentIds",
                            Title: T("Contents Ids"),
                            Description: T("A comma-separated list of the ids of contents to match. Items should have CommonPart attached."),
                            Classes: new[] { "tokenized" })
                        );


                    return f;
                };

            context.Form("IdsInFilter", form);

        }
Esempio n. 46
0
        public void Describe(Orchard.Forms.Services.DescribeContext context)
        {
            Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = _shapeFactory.Form(
                        Id: "ContainedByFilterForm",
                        _Parts: _shapeFactory.Textbox(
                            Id: "ContainerId", Name: "ContainerId",
                            Title: T("Container Id"),
                            Description: T("The numerical id of the content item containing the items to fetch."),
                            Classes: new[] { "tokenized" })
                        );


                    return f;
                };

            context.Form("ContainedByFilter", form);

        }
 public QuickLogOn.Models.QuickLogOnUserInfo GetUserInfo(Orchard.Security.IUser user)
 {
     var part = user.As<QQUserInfoPart>();
     if (part != null)
     {
         part.Record.Loader(
          () => _repository
          .Fetch(x => x.UserId == user.Id).FirstOrDefault());
         var record = part.Record.Value;
         if (record != null)
         {
             var model = new QuickLogOnUserInfo
             {
                 UniqueId = record.openid,
                 NickName = record.nickname,
                 HeadimgUrl = record.figureurl_qq_1,
                 Sex = record.gender,
                 Original = record
             };
             return model;
         }
     }
     return null;
 }
Esempio n. 48
0
 public void Update(Orchard entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Esempio n. 49
0
        public void mainloop()
        {
            Console.WriteLine("Press enter to start");
            Console.ReadLine();
            Console.WriteLine("..or..");
            Console.ReadLine();
            Console.WriteLine(".. Hold enter to find balance");
            Console.ReadLine();

            var attempt   = 1;
            var totalLoss = 0;

            while (true)
            {
                Console.WriteLine($"Planting eden attempt #{attempt}..");
                var eden = new Orchard();

                Console.WriteLine("Success.");
                Console.WriteLine("Initializing forbidden fruit...");
                var fruitful = new Counter <cart <apple> >();

                Console.WriteLine("Success.");
                Console.WriteLine("Locating Tree of knowledge...");
                var TreeOfKnowledge = eden.GenoCider();
                Console.WriteLine("Success.");

                Console.WriteLine("Commencing fall...");
                foreach (var cart in TreeOfKnowledge)
                {
                    fruitful.Add(cart);
                }

                Console.WriteLine($"manual count of casualties : {eden.countApplesula}");
                Console.WriteLine($"fruitful count of casualties : {fruitful.Count}");
                totalLoss += fruitful.Count;
                Console.WriteLine("Counting divisons..");

                var allApples = new List <apple>();

                foreach (var _cart in TreeOfKnowledge)
                {
                    foreach (var _box in _cart.items)
                    {
                        _box.items.ForEach(allApples.Add);
                    }
                }

                Console.WriteLine("checking for lost casualties...");
                var findings = allApples.Count() == fruitful.Count ? "none found." : (fruitful.Count - allApples.Count) + " are missing";
                Console.WriteLine(findings);

                var redDivision   = new Counter <apple>(i => i.Colour == Enums.Colour.Red);
                var greenDivision = new Counter <apple>(i => i.Colour == Enums.Colour.Green);

                allApples.ForEach(redDivision.Add);
                allApples.ForEach(greenDivision.Add);

                Console.WriteLine($"{redDivision.Count} casualties were from the red division");
                Console.WriteLine($"{greenDivision.Count} casualties were from the green division");
                Console.WriteLine($"totaling {greenDivision.Count + redDivision.Count} lives lost");

                if (redDivision.Count == greenDivision.Count)
                {
                    Console.WriteLine($"balance was achived after {attempt} attempts");
                    Console.WriteLine($"costing a total of {totalLoss} lives");
                    var cost = Convert.ToDouble(totalLoss) * 0.22;
                    Console.WriteLine($"Given the average cost of apples in london on 11th of May 2018 this would cost £{cost}");
                    Console.WriteLine();
                    Console.WriteLine("..wow.");
                    Console.WriteLine();
                    Console.WriteLine();
                    while (true)
                    {
                    }
                }
                Console.WriteLine("Press any key to beggin new universe...");
                Console.ReadLine();
                attempt++;
            }
        }
            private Orchard orchard; //果园实例引用

            #endregion Fields

            #region Constructors

            public Monitor(Orchard myClass, string name)
            {
                this.orchard = myClass;
                this.orchard.Add(this);                         //将自身添加到果园监控者列表中
                this.name = name;
            }
Esempio n. 51
0
 public abstract void PlantRemote(Orchard orchard); //种植异地水果
        public void Describe(Orchard.Forms.Services.DescribeContext context)
        {
            Func<IShapeFactory, object> form =
                shape =>
                {
                    var f = _shapeFactory.Form(
                        Id: "AssociativySearchFilterForm",
                        _GraphName: _shapeFactory.SelectList(
                            Id: "GraphName", Name: "GraphName",
                            Title: T("Graph"),
                            Description: T("Select a graph to fetch the connections from."),
                            Size: 10,
                            Multiple: false
                            ),
                        _Labels: _shapeFactory.Textbox(
                            Id: "associativy-search-filter-labels", Name: "Labels",
                            Title: T("Search terms"),
                            Description: T("Enter labels of Associativy terms here."),
                            Classes: new[] { "text textMedium tokenized" }),
                        _IncludeSearched: _shapeFactory.Checkbox(
                            Id: "associativy-search-filter-include-searched", Name: "IncludeSearched",
                            Title: T("Include searched nodes"),
                            Description: T("If checked, the nodes searched will be included in the result themselves too."),
                            Value: "on"),
                        _SearchForm: _shapeFactory.ProjectorFilterSearchFormDynamics()
                        );

                    foreach (var graph in _graphManager.FindGraphs(GraphContext.Empty))
                    {
                        f._GraphName.Add(new SelectListItem { Value = graph.Name, Text = graph.DisplayName.Text });
                    }

                    return f;
                };

            context.Form("AssociativySearchFilter", form);
        }
Esempio n. 53
0
 public void Delete(Orchard entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Deleted;
     db.SaveChanges();
 }
Esempio n. 54
0
 public void Add(Orchard entity)
 {
     db.Orchards.Add(entity);
     db.SaveChanges();
 }
 private string name;                            //监控者名称
 public Monitor(Orchard myClass, string name)
 {
     this.orchard = myClass;
     this.orchard.Add(this);                     //将自身添加到果园监控者列表中
     this.name = name;
 }