当前位置: 首页>>代码示例>>C#>>正文


C# Internals.Primitive类代码示例

本文整理汇总了C#中BoxSocial.Internals.Primitive的典型用法代码示例。如果您正苦于以下问题:C# Primitive类的具体用法?C# Primitive怎么用?C# Primitive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Primitive类属于BoxSocial.Internals命名空间,在下文中一共展示了Primitive类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PrimitiveApplicationInfo

        public PrimitiveApplicationInfo(Core core, Primitive owner, long applicationId)
            : base(core)
        {
            this.owner = owner;
            ItemLoad += new ItemLoadHandler(PrimitiveApplicationInfo_ItemLoad);

            SelectQuery query = new SelectQuery(PrimitiveApplicationInfo.GetTable(typeof(PrimitiveApplicationInfo)));
            query.AddFields(PrimitiveApplicationInfo.GetFieldsPrefixed(core, typeof(PrimitiveApplicationInfo)));
            query.AddCondition("application_id", applicationId);
            query.AddCondition("item_id", owner.Id);
            query.AddCondition("item_type_id", owner.TypeId);

            DataTable appDataTable = db.Query(query);

            if (appDataTable.Rows.Count == 1)
            {
                DataRow appRow = appDataTable.Rows[0];
                try
                {
                    loadItemInfo(appRow);
                }
                catch (InvalidItemException)
                {
                    throw new InvalidPrimitiveAppInfoException();
                }
            }
            else
            {
                throw new InvalidPrimitiveAppInfoException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:31,代码来源:PrimitiveApplicationInfo.cs

示例2: EventInvite

        public EventInvite(Core core, long eventId, Primitive invitee)
            : base(core)
        {
            this.ItemLoad += new ItemLoadHandler(EventInvite_ItemLoad);

            SelectQuery query = EventInvite.GetSelectQueryStub(core, typeof(EventInvite));
            query.AddCondition("event_id", eventId);
            query.AddCondition("item_id", invitee.Id);
            query.AddCondition("item_type_id", invitee.TypeId);

            System.Data.Common.DbDataReader inviteReader = db.ReaderQuery(query);

            try
            {
                if (inviteReader.HasRows)
                {
                    inviteReader.Read();

                    loadItemInfo(inviteReader);
                }

                inviteReader.Close();
                inviteReader.Dispose();
            }
            catch (InvalidItemException)
            {
                inviteReader.Close();
                inviteReader.Dispose();

                throw new InvalidEventInviteException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:32,代码来源:EventInvite.cs

示例3: Calendar

        public Calendar(Core core, Primitive owner)
            : base(core)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            if (owner == null)
            {
                throw new InvalidUserException();
            }

            this.owner = owner;
            ItemLoad += new ItemLoadHandler(Calendar_ItemLoad);

            try
            {
                LoadItem("calendar_item_id", "calendar_item_type_id", owner);
            }
            catch (InvalidItemException)
            {
                throw new InvalidCalendarException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:25,代码来源:Calendar.cs

示例4: ControlPanelSubModule

        /// <summary>
        /// Initializes a new instance of the ControlPanelSubModule class. 
        /// </summary>
        /// <param name="core">The Core token.</param>
        public ControlPanelSubModule(Core core, Primitive owner)
        {
            this.core = core;
            this.db = core.Db;
            this.session = core.Session;
            this.tz = core.Tz;
            this.LoggedInMember = session.LoggedInMember;
            this.Owner = owner;

            core.Prose.AddApplication(Assembly.GetAssembly(this.GetType()).GetName().Name);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:15,代码来源:ControlPanelSubModule.cs

示例5: Access

        internal Access(Core core, ItemKey key, Primitive leafOwner)
        {
            if (core == null)
            {
                throw new NullCoreException();
            }

            this.core = core;
            this.item = null;
            this.owner = leafOwner;
            this.itemKey = key;
            this.viewer = core.Session.LoggedInMember;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:13,代码来源:Access.cs

示例6: Project

        public Project(Core core, Primitive owner, string key)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(Project_ItemLoad);

            try
            {
                LoadItem("project_item_id", "project_item_type_id", owner, new FieldValuePair("project_key", key));
            }
            catch (InvalidItemException)
            {
                throw new InvalidProjectException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:14,代码来源:Project.cs

示例7: DnsRecord

        public DnsRecord(Core core, Primitive owner)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(DnsRecord_ItemLoad);

            try
            {
                LoadItem("dns_owner_id", "dns_owner_type", owner);
            }
            catch (InvalidItemException)
            {
                throw new InvalidDnsRecordException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:14,代码来源:DnsRecord.cs

示例8: ForumMember

        public ForumMember(Core core, Primitive owner, User user)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(ForumMember_ItemLoad);

            // load the info into a the new object being created
            this.userInfo = user.UserInfo;
            this.userProfile = user.Profile;
            this.userStyle = user.Style;
            this.userId = user.UserId;
            this.userName = user.UserName;
            this.domain = user.UserDomain;
            this.emailAddresses = user.EmailAddresses;

            SelectQuery sQuery = ForumMember.GetSelectQueryStub(core, typeof(ForumMember));
            sQuery.AddCondition("user_id", user.Id);
            sQuery.AddCondition("item_id", owner.Id);
            sQuery.AddCondition("item_type_id", owner.TypeId);

            try
            {
                System.Data.Common.DbDataReader memberReader = core.Db.ReaderQuery(sQuery);

                if (memberReader.HasRows)
                {
                    memberReader.Read();

                    loadItemInfo(memberReader);

                    memberReader.Close();
                    memberReader.Dispose();
                }
                else
                {
                    memberReader.Close();
                    memberReader.Dispose();

                    throw new InvalidForumMemberException();
                }
            }
            catch (InvalidItemException)
            {
                throw new InvalidForumMemberException();
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:45,代码来源:ForumMember.cs

示例9: BlogEntry

        public BlogEntry(Core core, Blog blog, Primitive owner, System.Data.Common.DbDataReader postEntryReader)
            : base(core)
        {
            ItemLoad += new ItemLoadHandler(BlogEntry_ItemLoad);

            this.blog = blog;
            this.owner = owner;

            loadItemInfo(postEntryReader);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:10,代码来源:BlogEntry.cs

示例10: GetEvents

        public List<Event> GetEvents(Core core, Primitive owner, long startTimeRaw, long endTimeRaw)
        {
            List<Event> events = new List<Event>();

            SelectQuery sQuery = Item.GetSelectQueryStub(core, typeof(Event));
            sQuery.AddCondition("event_item_id", owner.Id);
            sQuery.AddCondition("event_item_type_id", owner.TypeId);
            QueryCondition sqc2 = sQuery.AddCondition("event_time_start_ut", ConditionEquality.GreaterThanEqual, startTimeRaw);
            sqc2.AddCondition("event_time_start_ut", ConditionEquality.LessThanEqual, endTimeRaw);
            QueryCondition sqc3 = sqc2.AddCondition(ConditionRelations.Or, "event_time_end_ut", ConditionEquality.GreaterThanEqual, startTimeRaw);
            sqc3.AddCondition("event_time_end_ut", ConditionEquality.LessThanEqual, endTimeRaw);
            QueryCondition sqc4 = sqc3.AddCondition(ConditionRelations.Or, "event_time_start_ut", ConditionEquality.LessThan, startTimeRaw);
            sqc4.AddCondition("event_time_end_ut", ConditionEquality.GreaterThan, endTimeRaw);
            sQuery.AddSort(SortOrder.Ascending, "event_time_start_ut");

            {
                System.Data.Common.DbDataReader eventsReader = db.ReaderQuery(sQuery);

                while (eventsReader.Read())
                {
                    events.Add(new Event(core, eventsReader));
                }

                eventsReader.Close();
                eventsReader.Dispose();
            }

            if (owner.TypeId == ItemKey.GetTypeId(core, typeof(User)))
            {
                // now select events invited to
                SelectQuery query = Event.GetSelectQueryStub(core, typeof(Event));
                query.AddFields("event_invites.item_id", "event_invites.item_type_id", "event_invites.inviter_id", "event_invites.event_id");
                query.AddJoin(JoinTypes.Left, new DataField(typeof(Event), "event_id"), new DataField("event_invites", "event_id"));
                query.AddCondition("item_id", core.LoggedInMemberId);
                query.AddCondition("item_type_id", ItemKey.GetTypeId(core, typeof(User)));
                QueryCondition qc2 = query.AddCondition("event_time_start_ut", ConditionEquality.GreaterThanEqual, startTimeRaw);
                qc2.AddCondition("event_time_start_ut", ConditionEquality.LessThanEqual, endTimeRaw);
                QueryCondition qc3 = qc2.AddCondition(ConditionRelations.Or, "event_time_end_ut", ConditionEquality.GreaterThanEqual, startTimeRaw);
                qc3.AddCondition("event_time_end_ut", ConditionEquality.LessThanEqual, endTimeRaw);
                QueryCondition qc4 = qc3.AddCondition(ConditionRelations.Or, "event_time_start_ut", ConditionEquality.LessThan, startTimeRaw);
                qc4.AddCondition("event_time_end_ut", ConditionEquality.GreaterThan, endTimeRaw);

                System.Data.Common.DbDataReader eventsReader = db.ReaderQuery(sQuery);

                while (eventsReader.Read())
                {
                    events.Add(new Event(core, eventsReader));
                }

                eventsReader.Close();
                eventsReader.Dispose();

                User user = (User)owner;
                List<UserRelation> friends = user.GetFriendsBirthdays(startTimeRaw, endTimeRaw);

                foreach (UserRelation friend in friends)
                {
                    try
                    {
                        events.Add(new BirthdayEvent(core, user, friend, core.Tz.DateTimeFromMysql(startTimeRaw).Year));
                    }
                    catch (InvalidEventException)
                    {
                        // Not a reciprocol friend, ignore
                    }
                }
            }

            events.Sort();

            return events;
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:72,代码来源:Calendar.cs

示例11: Show

        public static void Show(Core core, TPage page, Primitive owner, int year, int month, int day)
        {
            core.Template.SetTemplate("Calendar", "viewcalendarday");

            // 15 year window
            if (year < DateTime.Now.Year - 10 || year > DateTime.Now.Year + 5)
            {
                core.Functions.Generate404();
            }

            if (month < 1 || month > 12)
            {
                core.Functions.Generate404();
            }

            if (day < 1 || day > DateTime.DaysInMonth(year, month))
            {
                core.Functions.Generate404();
            }

            /* pages */
            core.Display.ParsePageList(owner, true);

            core.Template.Parse("PAGE_TITLE", day.ToString() + " " + core.Functions.IntToMonth(month) + " " + year.ToString());

            core.Template.Parse("CURRENT_DAY", day.ToString());
            core.Template.Parse("CURRENT_MONTH", core.Functions.IntToMonth(month));
            core.Template.Parse("CURRENT_YEAR", year.ToString());

            long startTime = core.Tz.GetUnixTimeStamp(new DateTime(year, month, day, 0, 0, 0));
            long endTime = startTime + 60 * 60 * 24;

            Calendar cal = null;
            try
            {
                cal = new Calendar(core, owner);
            }
            catch (InvalidCalendarException)
            {
                cal = Calendar.Create(core, owner);
            }

            if (cal.Access.Can("CREATE_EVENTS"))
            {
                core.Template.Parse("U_NEW_EVENT", core.Hyperlink.BuildAccountSubModuleUri(owner, "calendar", "new-event", true,
                    string.Format("year={0}", year),
                    string.Format("month={0}", month),
                    string.Format("day={0}", day)));
            }

            List<Event> events = cal.GetEvents(core, owner, startTime, endTime);

            bool hasAllDaysEvents = false;

            foreach (Event calendarEvent in events)
            {
                if (calendarEvent.AllDay)
                {
                    hasAllDaysEvents = true;
                    VariableCollection eventVariableCollection = core.Template.CreateChild("event");

                    eventVariableCollection.Parse("TITLE", calendarEvent.Subject);
                    eventVariableCollection.Parse("URI", calendarEvent.Uri);
                }
            }

            if (hasAllDaysEvents)
            {
                core.Template.Parse("ALL_DAY_EVENTS", "TRUE");
            }

            VariableCollection[] hours = new VariableCollection[24];

            for (int hour = 0; hour < 24; hour++)
            {
                VariableCollection timeslotVariableCollection = core.Template.CreateChild("timeslot");

                DateTime hourTime = new DateTime(year, month, day, hour, 0, 0);

                timeslotVariableCollection.Parse("TIME", hourTime.ToString("h tt").ToLower());
                hours[hour] = timeslotVariableCollection;
            }

            showHourEvents(core, owner, year, month, day, hours, events);

            List<string[]> calendarPath = new List<string[]>();
            calendarPath.Add(new string[] { "calendar", core.Prose.GetString("CALENDAR") });
            calendarPath.Add(new string[] { year.ToString(), year.ToString() });
            calendarPath.Add(new string[] { month.ToString(), core.Functions.IntToMonth(month) });
            calendarPath.Add(new string[] { day.ToString(), day.ToString() });
            owner.ParseBreadCrumbs(calendarPath);
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:92,代码来源:Calendar.cs

示例12: showHourEvents

        private static void showHourEvents(Core core, Primitive owner, int year, int month, int day, VariableCollection[] timeslotVariableCollections, List<Event> events)
        {
            bool hasEvents = false;

            long startOfDay = core.Tz.GetUnixTimeStamp(new DateTime(year, month, day, 0, 0, 0));
            long endOfDay = startOfDay + 60 * 60 * 24;

            long[] heights = new long[events.Count];
            long[] tops = new long[events.Count];
            double[] widths = new double[events.Count];
            double[] lefts = new double[events.Count];
            int[] eventCount = new int[96];
            int[] eventNumber = new int[96];

            int hourHeight = 32;

            List<Event> expired = new List<Event>();
            int i = 0;
            foreach (Event calendarEvent in events)
            {
                if (calendarEvent.AllDay)
                {
                    continue;
                }

                long startTime = calendarEvent.StartTimeRaw;
                long endTime = calendarEvent.EndTimeRaw;

                if (endTime > endOfDay)
                {
                    endTime = endOfDay;
                }

                if (startTime < startOfDay)
                {
                    startTime = startOfDay;
                }

                DateTime startDateTime = core.Tz.DateTimeFromMysql(startTime);
                DateTime endDateTime = core.Tz.DateTimeFromMysql(endTime - 1);
                long startMinute = startDateTime.Minute;
                long startHour = startDateTime.Hour;
                long endMinute = endDateTime.Minute;
                long endHour = endDateTime.Hour;
                int startFifteen = (int)Math.Floor(startHour * 4.0 + startMinute / 15.0);
                int endFifteen = (int)Math.Floor(endHour * 4.0 + endMinute / 15.0);

                for (int j = startFifteen; j <= endFifteen; j++)
                {
                    eventCount[j]++;
                }

                heights[i] = (endTime - startTime) * hourHeight / 60 / 60;
                tops[i] = startMinute * 36 / 60;
                widths[i] = 100.0;
                lefts[i] = 100 - 100.0 / Math.Max(1, eventCount[startFifteen]);

                i++;
            }

            i = 0;
            foreach (Event calendarEvent in events)
            {
                if (calendarEvent.AllDay)
                {
                    continue;
                }

                long startTime = calendarEvent.StartTimeRaw;
                long endTime = calendarEvent.EndTimeRaw;

                if (endTime > endOfDay)
                {
                    endTime = endOfDay;
                }

                if (startTime < startOfDay)
                {
                    startTime = startOfDay;
                }

                DateTime startDateTime = core.Tz.DateTimeFromMysql(startTime);
                DateTime endDateTime = core.Tz.DateTimeFromMysql(endTime - 1);
                long startMinute = startDateTime.Minute;
                long startHour = startDateTime.Hour;
                long endMinute = endDateTime.Minute;
                long endHour = endDateTime.Hour;
                int startFifteen = (int)Math.Floor(startHour * 4.0 + startMinute / 15.0);
                int endFifteen = (int)Math.Floor(endHour * 4.0 + endMinute / 15.0);

                int maxEventsOnFifteen = 0;
                for (int j = startFifteen; j <= endFifteen; j++)
                {
                    eventNumber[j]++;
                    if (eventCount[j] > maxEventsOnFifteen)
                    {
                        maxEventsOnFifteen = eventCount[j];
                    }
                }

//.........这里部分代码省略.........
开发者ID:smithydll,项目名称:boxsocial,代码行数:101,代码来源:Calendar.cs

示例13: DisplayMiniCalendar

        private static void DisplayMiniCalendar(Core core, Template template, VariableCollection vc1, Primitive owner, int year, int month)
        {
            int days = DateTime.DaysInMonth(year, month);
            DayOfWeek firstDay = new DateTime(year, month, 1).DayOfWeek;
            int offset = Calendar.GetFirstDayOfMonthOffset(firstDay);
            int weeks = (int)Math.Ceiling((days + offset) / 7.0);

            if (template != null)
            {
                template.Parse("CURRENT_MONTH", core.Functions.IntToMonth(month));
                template.Parse("CURRENT_YEAR", year.ToString());
            }
            else
            {
                vc1.Parse("MONTH", core.Functions.IntToMonth(month));
                vc1.Parse("U_MONTH", BuildMonthUri(core, owner, year, month));
            }

            for (int week = 0; week < weeks; week++)
            {
                VariableCollection weekVariableCollection;
                if (template != null)
                {
                    weekVariableCollection = template.CreateChild("week");
                }
                else
                {
                    weekVariableCollection = vc1.CreateChild("week");
                }

                weekVariableCollection.Parse("WEEK", (week + 1).ToString());

                if (week + 1 == 1)
                {
                    int daysPrev = DateTime.DaysInMonth(year - (month - 1) / 12, (month - 1) % 12 + 1);
                    for (int i = offset - 1; i >= 0; i--)
                    {
                        int day = daysPrev - i;

                        VariableCollection dayVariableCollection = weekVariableCollection.CreateChild("day");
                        dayVariableCollection.Parse("DATE", day.ToString());
                        dayVariableCollection.Parse("URI", Calendar.BuildDateUri(core, owner, year - (month - 2) / 12, (month - 2) % 12 + 1, day));
                    }
                    for (int i = offset; i < 7; i++)
                    {
                        int day = i - offset + 1;

                        VariableCollection dayVariableCollection = weekVariableCollection.CreateChild("day");
                        dayVariableCollection.Parse("DATE", day.ToString());
                        dayVariableCollection.Parse("URI", Calendar.BuildDateUri(core, owner, year, month, day));
                    }
                }
                else if (week + 1 == weeks)
                {
                    for (int i = week * 7 - offset; i < days; i++)
                    {
                        int day = i + 1;

                        VariableCollection dayVariableCollection = weekVariableCollection.CreateChild("day");
                        dayVariableCollection.Parse("DATE", day.ToString());
                        dayVariableCollection.Parse("URI", Calendar.BuildDateUri(core, owner, year, month, day));
                    }
                    for (int i = 0; i < weeks * 7 - days - offset; i++)
                    {
                        int day = i + 1;

                        VariableCollection dayVariableCollection = weekVariableCollection.CreateChild("day");
                        dayVariableCollection.Parse("DATE", day.ToString());
                        dayVariableCollection.Parse("URI", Calendar.BuildDateUri(core, owner, year + (month) / 12, (month) % 12 + 1, day));
                    }
                }
                else
                {
                    for (int i = 0; i < 7; i++)
                    {
                        int day = week * 7 + i + 1 - offset;

                        VariableCollection dayVariableCollection = weekVariableCollection.CreateChild("day");
                        dayVariableCollection.Parse("DATE", day.ToString());
                        dayVariableCollection.Parse("URI", Calendar.BuildDateUri(core, owner, year, month, day));
                    }
                }
            }
        }
开发者ID:smithydll,项目名称:boxsocial,代码行数:84,代码来源:Calendar.cs

示例14: BuildDateUri

 internal static string BuildDateUri(Core core, Primitive owner, int year, int month, int day)
 {
     return core.Hyperlink.AppendSid(string.Format("{0}calendar/{1}/{2}/{3}",
         owner.UriStub, year, month, day));
 }
开发者ID:smithydll,项目名称:boxsocial,代码行数:5,代码来源:Calendar.cs

示例15: GetTasks

 public List<Task> GetTasks(Core core, Primitive owner, long startTimeRaw, long endTimeRaw)
 {
     return GetTasks(core, owner, startTimeRaw, endTimeRaw, false);
 }
开发者ID:smithydll,项目名称:boxsocial,代码行数:4,代码来源:Calendar.cs


注:本文中的BoxSocial.Internals.Primitive类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。