Mono Support Event Viewer. 

Viewed 109300 time(s), 23 post(s), 7/29/2011 1:18:13 AM - by shawndg
8/11/2011 1:15:30 AM
1871 Reputation 252 Total posts

I modified the code behind file for the EventSimpleViewExt

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MonoSoftware.MonoX.Utilities;
using MonoSoftware.MonoX.ModuleGallery;
using MonoSoftware.MonoX.Controls;
using MonoSoftware.MonoX.Repositories;
using SD.LLBLGen.Pro.ORMSupportClasses;
using MonoSoftware.MonoX.DAL.HelperClasses;
using MonoSoftware.MonoX.DAL.EntityClasses;
 
namespace TheScene.Web.TheScene.WebParts.EventModuleExt
{
    public partial class EventSimpleViewExt : MonoSoftware.MonoX.ModuleGallery.EventSimpleView
    {
 
        public override void DataBind()
        {
            // Fetch filter, we can ignore module filter in this case as we have full control over fetching
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(CalendarEventFields.CalendarId == this.CalendarId);
            filter.PredicateExpression.Add(CalendarEventFields.StartTime >= this.SelectedDate.Date);
            filter.PredicateExpression.Add(CalendarEventFields.StartTime < this.SelectedDate.Date.AddDays(1));
 
            // Set sorter, here you'll change sort direction by changing SortOperator
            ISortExpression sorter = new SortExpression(new SortClause(CalendarEventFields.StartTime, null, SortOperator.Descending));
 
            EntityCollection<CalendarEventEntity> items = new EntityCollection<CalendarEventEntity>();
            BaseMonoXRepository.GetInstance().FetchEntityCollection(items, filter, 0, sorter, null, pager.CurrentPageIndex + 1, pager.PageSize);
            int recordCount = this.GetDbCount(items, filter);
 
            PagerUtility.BindPager(pager, DataBind, lvItems, items, recordCount);
        }
 
 
    }
}

Im closer.. but still not there..

Errors :
Error 12 The name 'Mode' does not exist in the current context C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventModuleExt.ascx.cs 34 13 Portal
Error 5 The best overloaded method match for 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression.Add(SD.LLBLGen.Pro.ORMSupportClasses.IPredicate)' has some invalid arguments C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 24 13 Portal
Error 8 The best overloaded method match for 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicateExpression.Add(SD.LLBLGen.Pro.ORMSupportClasses.IPredicate)' has some invalid arguments C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 25 13 Portal
Error 6 Argument 1: cannot convert from 'bool' to 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate' C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 24 44 Portal
Error 9 Argument 1: cannot convert from 'bool' to 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate' C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 25 44 Portal
Error 13 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' does not contain a definition for 'SelectedDay' and no extension method 'SelectedDay' accepting a first argument of type 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' could be found (are you missing a using directive or an assembly reference?) C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventModuleExt.ascx.cs 42 49 Portal
Error 7 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' does not contain a definition for 'SelectedDate' and no extension method 'SelectedDate' accepting a first argument of type 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' could be found (are you missing a using directive or an assembly reference?) C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 24 82 Portal
Error 10 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' does not contain a definition for 'SelectedDate' and no extension method 'SelectedDate' accepting a first argument of type 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' could be found (are you missing a using directive or an assembly reference?) C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 25 81 Portal
Error 11 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' does not contain a definition for 'GetDbCount' and no extension method 'GetDbCount' accepting a first argument of type 'TheScene.Web.TheScene.WebParts.EventModuleExt.EventSimpleViewExt' could be found (are you missing a using directive or an assembly reference?) C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventSimpleViewExt.ascx.cs 32 36 Portal

Not sure.. Im down to 9 errors..
am I still missing using decs or is there a problem with the code ?

11
8/11/2011 9:09:56 AM
629 Reputation 83 Total posts

Hi Shawndg,

You were missing SelectedDay property, and there was a mistake in code I have gave you GetDbCount is a MonoXRepositroy method so instead this.GetDbCount you need to call BaseMonoXRepository.GetInstance().GetDbCount, sorry for that. So your EventSimpleViewExt should look like this(this time I have added all the references you would need):

// Add these using statement to avoid reference issue
using SD.LLBLGen.Pro.ORMSupportClasses;
using MonoSoftware.MonoX.DAL.HelperClasses;
using MonoSoftware.MonoX.DAL.EntityClasses;
using MonoSoftware.MonoX.Repositories;
using MonoSoftware.MonoX.Utilities;
 
namespace TheScene.Web.TheScene.WebParts.EventModuleExt
{
    public partial class EventSimpleViewExt : MonoSoftware.MonoX.ModuleGallery.EventSimpleView
    {
        /// <summary>
        /// Gets or sets day to display
        /// </summary>
        public DateTime SelectedDay { get; set; }
 
        public override void DataBind()
        {
            // Fetch filter, we can ignore module filter in this case as we have full control over fetching
            IRelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add(CalendarEventFields.CalendarId == this.CalendarId);
            filter.PredicateExpression.Add(CalendarEventFields.StartTime >= this.SelectedDay.Date);
            filter.PredicateExpression.Add(CalendarEventFields.StartTime < this.SelectedDay.Date.AddDays(1));
 
            // Set sorter, here you'll change sort direction by changing SortOperator
            ISortExpression sorter = new SortExpression(new SortClause(CalendarEventFields.StartTime, null, SortOperator.Descending));
 
            EntityCollection<CalendarEventEntity> items = new EntityCollection<CalendarEventEntity>();
            BaseMonoXRepository.GetInstance().FetchEntityCollection(items, filter, 0, sorter, null, pager.CurrentPageIndex + 1, pager.PageSize);
            int recordCount = BaseMonoXRepository.GetInstance().GetDbCount(items, filter);
 
            PagerUtility.BindPager(pager, DataBind, lvItems, items, recordCount);
        }
    }
}

Also in your markup for EventModuleExt you need to change MonoX EventSimpleView with MyControls EventSimpleView. I think you have already figure it out, but just in case you need to replace:

<MonoX:SimpleEventView ID="ctlSimpleView" runat="server"></MonoX:SimpleEventView>

with:

<MyControls:SimpleEventViewExt ID="ctlSimpleView" runat="server"></MyControls:SimpleEventViewExt>

Everything else looks good.

12
8/11/2011 12:28:44 PM
1871 Reputation 252 Total posts

I updated all the code..
Now im only getting one error..

Mode = MonoSoftware.MonoX.ModuleGallery.EventModuleMode.Simple;
Error 5 The name 'Mode' does not exist in the current context C:\#ThePittsburghScene\TheScene\WebParts\EventModuleExt\EventModuleExt.ascx.cs 35 13 Portal

13
8/11/2011 1:03:22 PM
629 Reputation 83 Total posts

Hi,

I believe the problem is you have inherited EventSimpleView instead of EventModule in your EventModuleExt class. You should replace:

public partial class EventModuleExt : MonoSoftware.MonoX.ModuleGallery.EventSimpleView

with

public partial class EventModuleExt : MonoSoftware.MonoX.ModuleGallery.EventModule

14
8/11/2011 1:25:19 PM
1871 Reputation 252 Total posts

Ok..

well I just remed the mode out for now...
No errors.. compiles ok..

Its NOT showing up in webparts.. I set the path in the web config but it dont show up so I cant use it..

Now I remember something a long the line of..
MonoSoftware.MonoX.BaseAutoRegisterPart

But im not sure how to wrap it to make it work..

15
8/11/2011 1:41:23 PM
1871 Reputation 252 Total posts

I tried hard coding with no luck either..

I got the simple view to display but when you click on anything tons of errors..

Any help turning this into a web part ?

16
8/11/2011 1:54:50 PM
7207 Reputation 956 Total posts

Shawn,
This already is a Web part. The EventSimpleView that you initially inherited from is not "auto-registrable" part - but the EventModule (which you should inherit from) is, and it should show in the web part catalog if you correctly set up the ModuleGalleryPath property in web.config.
Is there a way to access your machine remotely? I feel that this can be solved in seconds, but we need to have a complete overview of your project.

17
8/11/2011 2:07:13 PM
1871 Reputation 252 Total posts

Ok Denis..

I will jump on Skyp..

I got it to show up in the list but cant add it to a page ?

18
8/11/2011 2:09:38 PM
7207 Reputation 956 Total posts

OK, send us your skype contact on our support address.Are you getting any errors when adding it to the page?

19
8/11/2011 2:20:02 PM
1871 Reputation 252 Total posts

I filled out the contact form on this site..

I sent it thru there..

The new error I get when i try to add my event viewer to the page is..

System.NullReferenceException: Object reference not set to an instance of an object.

at MonoSoftware.MonoX.ModuleGallery.EventModule.Page_Init(Object sender, EventArgs e)

at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)

at MonoSoftware.MonoX.BasePart.OnInit(EventArgs e)

at WebParts.EventModuleExt.EventModuleExt.OnInit(EventArgs e) in C:\#PittsburghSceneProd\CustomParts\EventModuleExt\EventModuleExt.ascx.cs:line 32

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Control.InitRecursive(Control namingContainer)

at System.Web.UI.Control.AddedControl(Control control, Int32 index)

at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPartHelper(WebPart webPart)

at System.Web.UI.WebControls.WebParts.WebPartManager.WebPartManagerControlCollection.AddWebPart(WebPart webPart)

at System.Web.UI.WebControls.WebParts.WebPartManager.AddDynamicWebPartToZone(WebPart webPart, WebPartZoneBase zone, Int32 zoneIndex)

at System.Web.UI.WebControls.WebParts.WebPartManager.AddWebPart(WebPart webPart, WebPartZoneBase zone, Int32 zoneIndex)

at System.Web.UI.WebControls.WebParts.CatalogZoneBase.AddWebParts(ArrayList webParts, WebPartZoneBase zone)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

20
1 2 3
This is a demo site for MonoX. Please visit Mono Software for more info.