Beispiel #1
0
        public override void DataBind()
        {
            if (DataItem != null)
            {
                CalendarEventEntity ceo = (CalendarEventEntity)DataItem;
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId);
                fec.Add(fe);
                fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID);
                fec.Add(fe);

                EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventResourceEntity cero = (CalendarEventResourceEntity)list[0];
                    _resId = cero.PrimaryKeyId.Value;
                    if (cero.Status.HasValue)
                    {
                        if (cero.Status.Value == (int)eResourceStatus.Accepted)
                            btnAccept.Disabled = true;
                        if (cero.Status.Value == (int)eResourceStatus.Tentative)
                            btnTentative.Disabled = true;
                        if (cero.Status.Value == (int)eResourceStatus.Declined)
                            btnDecline.Disabled = true;
                    }
                }
            }
            base.DataBind();
        }
        public static CustomerContact GetOwner(string marketId, out bool foundOne)
        {
            //ToDo: create the field in BF for the contact
            // ...may not need the "out-part"
            FilterElementCollection fc = new FilterElementCollection
            {
                FilterElement.EqualElement("MarketToOwn", marketId)
            };

            EntityObject[] result = BusinessManager.List(CustomerContact.ClassName, fc.ToArray(), null);

            if (result != null)
            {
                if (result.Count() == 1)
                {
                    // got the contact
                    foundOne = true;
                    return((CustomerContact)result.FirstOrDefault());
                }
                else
                {
                }        // could be several owners, need some action
            }
            else
            {
            }        // empty

            foundOne = false;
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Resets the user settings by profile.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        public static void ResetUserSettingsByProfile(Guid uid, int profileId)
        {
            List <string> users = new List <string>();

            if (profileId > 0)
            {
                FilterElementCollection fec = new FilterElementCollection();
                fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                foreach (CustomizationProfileUserEntity entity in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                {
                    users.Add(entity.PrincipalId.ToString());
                }
            }
            else             // default profile
            {
                // 1. Get list all users
                using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                {
                    while (reader.Read())
                    {
                        users.Add(reader["UserId"].ToString());
                    }
                }

                // 2. Exclude users with non-default profile
                EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                foreach (CustomizationProfileUserEntity puEntity in entityList)
                {
                    users.Remove(puEntity.PrincipalId.ToString());
                }
            }

            // O.R. [2010-10-05]. Don't process profile without users
            if (users.Count > 0)
            {
                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                {
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                }
                filters.Add(orBlock);

                // Skip CustomPageNormalizationPlugin
                ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray());
                request.Parameters.Add("CustomPageNormalizationPlugin", false);
                ListResponse response = (ListResponse)BusinessManager.Execute(request);

                foreach (EntityObject page in response.EntityObjects)
                {
                    BusinessManager.Delete(page);
                }
            }
        }
        /// <summary>
        /// Gets the files.
        /// </summary>
        /// <param name="structureName">Name of the structure.</param>
        /// <param name="searchPattern">The search pattern.</param>
        /// <param name="selectors">The selectors (4st argument - profileId, 5nd argument - principalId).</param>
        /// <returns></returns>
        public override FileDescriptor[] GetFiles(string structureName, string searchPattern, Selector[] selectors)
        {
            List <FileDescriptor> files = new List <FileDescriptor>();

            if (string.Compare(structureName, "Navigation", StringComparison.OrdinalIgnoreCase) == 0 &&
                string.Compare(searchPattern, "*.xml", StringComparison.OrdinalIgnoreCase) == 0)
            {
                FilterElementCollection filters;
                EntityObject[]          items;
                PrimaryKeyId            profileId   = PrimaryKeyId.Empty;
                PrimaryKeyId            principalId = PrimaryKeyId.Empty;

                // 1. Global Layer
                filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));

                items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                ProcessItems(items, files, NavigationManager.CustomizationLayerGlobal);

                // 2. Profile Layer
                if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 3 && !string.IsNullOrEmpty(selectors[0].Items[3]))
                {
                    string profileSelector = selectors[0].Items[3];
                    if (PrimaryKeyId.TryParse(profileSelector, out profileId))
                    {
                        filters = new FilterElementCollection();
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId));
                        filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));

                        items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                        ProcessItems(items, files, NavigationManager.CustomizationLayerProfile);
                    }
                }

                // 3. User Layer
                if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 4 && !string.IsNullOrEmpty(selectors[0].Items[4]))
                {
                    string principalSelector = selectors[0].Items[4];
                    if (PrimaryKeyId.TryParse(principalSelector, out principalId))
                    {
                        filters = new FilterElementCollection();
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                        filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId));

                        items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                        ProcessItems(items, files, NavigationManager.CustomizationLayerUser);
                    }
                }
            }

            return(files.ToArray());
        }
Beispiel #5
0
        /// <summary>
        /// Gets the files.
        /// </summary>
        /// <param name="structureName">Name of the structure.</param>
        /// <param name="searchPattern">The search pattern.</param>
        /// <param name="selectors">The selectors (4st argument - profileId, 5nd argument - principalId).</param>
        /// <returns></returns>
        public override FileDescriptor[] GetFiles(string structureName, string searchPattern, Selector[] selectors)
        {
            List<FileDescriptor> files = new List<FileDescriptor>();

            if (string.Compare(structureName, "Navigation", StringComparison.OrdinalIgnoreCase) == 0
                && string.Compare(searchPattern, "*.xml", StringComparison.OrdinalIgnoreCase) == 0)
            {
                FilterElementCollection filters;
                EntityObject[] items;
                PrimaryKeyId profileId = PrimaryKeyId.Empty;
                PrimaryKeyId principalId = PrimaryKeyId.Empty;

                // 1. Global Layer
                filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));

                items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                ProcessItems(items, files, NavigationManager.CustomizationLayerGlobal);

                // 2. Profile Layer
                if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 3 && !string.IsNullOrEmpty(selectors[0].Items[3]))
                {
                    string profileSelector = selectors[0].Items[3];
                    if (PrimaryKeyId.TryParse(profileSelector, out profileId))
                    {
                        filters = new FilterElementCollection();
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId));
                        filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));

                        items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                        ProcessItems(items, files, NavigationManager.CustomizationLayerProfile);
                    }
                }

                // 3. User Layer
                if (selectors != null && selectors.Length != 0 && selectors[0].Items.Count > 4 && !string.IsNullOrEmpty(selectors[0].Items[4]))
                {
                    string principalSelector = selectors[0].Items[4];
                    if (PrimaryKeyId.TryParse(principalSelector, out principalId))
                    {
                        filters = new FilterElementCollection();
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
                        filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
                        filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId));

                        items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());
                        ProcessItems(items, files, NavigationManager.CustomizationLayerUser);
                    }
                }
            }

            return files.ToArray();
        }
Beispiel #6
0
        /// <summary>
        /// Deletes the custom page.
        /// </summary>
        /// <param name="uid">The uid.</param>
        public static void DeleteCustomPage(Guid uid)
        {
            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray());
            request.Parameters.Add("CustomPageNormalizationPlugin", false);
            ListResponse response = (ListResponse)BusinessManager.Execute(request);

            foreach (CustomPageEntity page in response.EntityObjects)
            {
                if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName))
                    BusinessManager.Delete(page);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Reads the right check.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ReadRightCheck(BusinessContext context)
        {
            //Если есть флаг отключить проверку авторизации то ничего не фильтруем
            if (!SkipSecurityCheckScope.IsActive)
            {
                string securityViewQuery = @"SELECT ObjectId FROM [dbo].[CalendarEvent_Security_Read]";
                //Добавляем в sql context текущего пользователя
                SetContextInfo(Security.CurrentUserId);
                //Для метода List необходимо отфильтровать список согласно security view
                if (context.GetMethod() == RequestMethod.List)
                {
                    ListRequest listRequest = context.Request as ListRequest;
                    FilterElementCollection filterColl = new FilterElementCollection();
                    foreach (FilterElement origFilterEl in listRequest.Filters)
                    {
                        filterColl.Add(origFilterEl);
                    }

                    FilterElement filterEl = new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery);
                    filterColl.Add(filterEl);
                    //перезаписываем старую коллекцию фильтров, новой
                    listRequest.Filters = filterColl.ToArray();

                }//Для метода Load необходмио предотвратить загрузку объета не имеющего соотв прав
                else if (context.GetMethod() == RequestMethod.Load)
                {

                    LoadRequest loadRequest = context.Request as LoadRequest;
                    PrimaryKeyId eventId = loadRequest.Target.PrimaryKeyId.Value;
                    VirtualEventId vEventId = (VirtualEventId)eventId;
                    if (vEventId.IsRecurrence)
                    {
                        eventId = vEventId.RealEventId;
                    }

                    if (BusinessObject.GetTotalCount(DataContext.Current.GetMetaClass(CalendarEventEntity.ClassName),
                                                      new FilterElement[] {
                                                                            new FilterElement("PrimaryKeyId", FilterElementType.Equal, eventId),
                                                                            new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery)
                                                                           }) == 0)
                    {
                        throw new Exception("Read access denied");
                    }
                }

            }
        }
        /// <summary>
        /// Возвращает список событий как виртуальных так и реальных.
        /// </summary>
        /// <param name="filterColl">The filter coll.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        private static IEnumerable <CalendarEventEntity> ListEvents(FilterElementCollection filterColl, CalendarEventListRequest request)
        {
            McEvent mcEvent = null;
            //Конструируем стандартный запрос LIST без критериев содержащих дату начала и конца события
            ListRequest moListRequest = (ListRequest)EventHelper.ConstructRequest <ListRequest>(request.Target, true);

            moListRequest.Filters = filterColl.ToArray();
            moListRequest.Sorting = request.Sorting;
            //выполняем стандартный запрос
            ListResponse listResp = (ListResponse)BusinessManager.Execute(moListRequest);

            if (listResp != null && listResp.EntityObjects != null)
            {
                //Пробегаем по реальным events
                foreach (CalendarEventEntity entity in listResp.EntityObjects)
                {
                    mcEvent = EventHelper.LoadCalEvent(entity.PrimaryKeyId.Value);
                    if (mcEvent.IsReccuring)
                    {
                        iCalDateTime dtReccurBase = mcEvent.DTStart;
                        //Пробегаем по виртуальным events
                        foreach (Occurrence occur in mcEvent.GetOccurrences(mcEvent.DTStart, mcEvent.RecurrenceSeriesEndDate))
                        {
                            //Создаем виртуальные события
                            VirtualEventId vEventId = (VirtualEventId)entity.PrimaryKeyId;
                            vEventId.RecurrenceId = EventHelper.iCalDateTime2Recurrence(dtReccurBase, occur.Period.StartTime);
                            //Set virtual id
                            mcEvent.UID = vEventId.ToString();
                            //Set recurrence-ID
                            mcEvent.Recurrence_ID = occur.Period.StartTime;
                            mcEvent.DTStart       = occur.Period.StartTime;
                            mcEvent.DTEnd         = occur.Period.EndTime;
                            EntityObjectHierarchy recurrenceEntity = EventHelper.ConstructEntityHierarchy(mcEvent);
                            CalendarEventEntity   occurEventEntity = recurrenceEntity.InnerEntity as CalendarEventEntity;
                            if (occurEventEntity != null)
                            {
                                yield return(occurEventEntity);
                            }
                        }
                    }
                    else
                    {
                        yield return(entity);
                    }
                }
            }
        }
Beispiel #9
0
        public override bool CheckVisibility(object dataItem)
        {
            if (dataItem != null)
            {
                CalendarEventEntity ceo = (CalendarEventEntity)dataItem;
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)ceo.PrimaryKeyId).RealEventId);
                fec.Add(fe);
                fe = FilterElement.EqualElement("PrincipalId", Mediachase.IBN.Business.Security.CurrentUser.UserID);
                fec.Add(fe);

                EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray());
                if (list.Length == 0)
                    return false;
            }
            return base.CheckVisibility(dataItem);
        }
Beispiel #10
0
        public override void DataBind()
        {
            DataTable dt = new DataTable();
            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("AssignmentId", typeof(string));
            dt.Columns.Add("Subject", typeof(string));
            dt.Columns.Add("User", typeof(string));
            dt.Columns.Add("State", typeof(string));
            dt.Columns.Add("Result", typeof(int));
            dt.Columns.Add("FinishDate", typeof(string));
            dt.Columns.Add("Comment", typeof(string));
            dt.Columns.Add("Indent", typeof(int));
            dt.Columns.Add("ClosedBy", typeof(string));

            WorkflowInstanceEntity wfEntity = (WorkflowInstanceEntity)DataItem;

            // Filter:
            //	1: WorkflowInstanceId = wfEntity.PrimaryKeyId,
            //	2: ParentAssignmentId IS NULL (other elements we'll get via the recursion)
            FilterElementCollection fec = new FilterElementCollection();
            fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value));
            fec.Add(FilterElement.IsNullElement(AssignmentEntity.FieldParentAssignmentId));

            // Sorting
            SortingElementCollection sec = new SortingElementCollection();
            sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc));

            EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray());

            ProcessCollection(dt, assignments, wfEntity, 0);

            AssignmentList.DataSource = dt;
            AssignmentList.DataBind();

            if (dt.Rows.Count > 0)
            {
                AssignmentList.Visible = true;
                NoAssignmentsLabel.Visible = false;
            }
            else
            {
                AssignmentList.Visible = false;
                NoAssignmentsLabel.Visible = true;
                NoAssignmentsLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NoAssignments").ToString();
            }
        }
Beispiel #11
0
        /// <summary>
        /// Reads the right check.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ReadRightCheck(BusinessContext context)
        {
            //Если есть флаг отключить проверку авторизации то ничего не фильтруем
            if (!SkipSecurityCheckScope.IsActive)
            {
                string securityViewQuery = @"SELECT ObjectId FROM [dbo].[CalendarEvent_Security_Read]";
                //Добавляем в sql context текущего пользователя
                SetContextInfo(Security.CurrentUserId);
                //Для метода List необходимо отфильтровать список согласно security view
                if (context.GetMethod() == RequestMethod.List)
                {
                    ListRequest             listRequest = context.Request as ListRequest;
                    FilterElementCollection filterColl  = new FilterElementCollection();
                    foreach (FilterElement origFilterEl in listRequest.Filters)
                    {
                        filterColl.Add(origFilterEl);
                    }

                    FilterElement filterEl = new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery);
                    filterColl.Add(filterEl);
                    //перезаписываем старую коллекцию фильтров, новой
                    listRequest.Filters = filterColl.ToArray();
                }                //Для метода Load необходмио предотвратить загрузку объета не имеющего соотв прав
                else if (context.GetMethod() == RequestMethod.Load)
                {
                    LoadRequest    loadRequest = context.Request as LoadRequest;
                    PrimaryKeyId   eventId     = loadRequest.Target.PrimaryKeyId.Value;
                    VirtualEventId vEventId    = (VirtualEventId)eventId;
                    if (vEventId.IsRecurrence)
                    {
                        eventId = vEventId.RealEventId;
                    }

                    if (BusinessObject.GetTotalCount(DataContext.Current.GetMetaClass(CalendarEventEntity.ClassName),
                                                     new FilterElement[] {
                        new FilterElement("PrimaryKeyId", FilterElementType.Equal, eventId),
                        new FilterElement("PrimaryKeyId", FilterElementType.In, securityViewQuery)
                    }) == 0)
                    {
                        throw new Exception("Read access denied");
                    }
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Deletes the custom page.
        /// </summary>
        /// <param name="uid">The uid.</param>
        public static void DeleteCustomPage(Guid uid)
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray());

            request.Parameters.Add("CustomPageNormalizationPlugin", false);
            ListResponse response = (ListResponse)BusinessManager.Execute(request);

            foreach (CustomPageEntity page in response.EntityObjects)
            {
                if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName))
                {
                    BusinessManager.Delete(page);
                }
            }
        }
Beispiel #13
0
        public CalendarItem[] LoadItems(string startDate, string endDate, object calendarExtension)
        {
            DateTime viewStartDate = DateTime.Now;
            DateTime viewEndDate = DateTime.Now;
            string[] arr = startDate.Split(new char[] { '.' });
            viewStartDate = new DateTime(int.Parse(arr[0]),int.Parse(arr[1]),
                                        int.Parse(arr[2]),int.Parse(arr[3]),int.Parse(arr[4]),
                                        int.Parse(arr[5]));
            arr = endDate.Split(new char[] { '.' });
            viewEndDate = new DateTime(int.Parse(arr[0]), int.Parse(arr[1]),
                                        int.Parse(arr[2]), int.Parse(arr[3]), int.Parse(arr[4]),
                                        int.Parse(arr[5]));

            List<CalendarItem> al = new List<CalendarItem>();
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement fe = new FilterElement();
            fe.Type = FilterElementType.GreaterOrEqual;
            fe.Source = CalendarEventEntity.FieldStart;
            fe.Value = viewStartDate;
            fec.Add(fe);
            fe = new FilterElement();
            fe.Type = FilterElementType.LessOrEqual;
            fe.Source = CalendarEventEntity.FieldStart;
            fe.Value = viewEndDate;
            fec.Add(fe);

            EntityObject[] calList = BusinessManager.List(CalendarEventEntity.ClassName, fec.ToArray());
            foreach (EntityObject eo in calList)
            {
                CalendarEventEntity info = eo as CalendarEventEntity;
                CalendarItem it = new CalendarItem();
                it.Uid = info.PrimaryKeyId.ToString();
                it.StartDate = info.Start.ToString("yyyy.M.d.H.m.s");
                it.EndDate = info.End.ToString("yyyy.M.d.H.m.s"); ;
                it.Title = String.Format("<div class=\"ibn-propertysheet2\"><a href='{1}{2}'>{0}</a></div>", info.Subject, CHelper.GetAbsolutePath("/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId="), it.Uid);
                it.Description = info.Body;
                it.Extensions = (info.RecurrenceId == DateTime.MinValue) ? "0" : "1";
                al.Add(it);

            }
            return al.ToArray();
        }
        /// <summary>
        /// Postcreate inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PostCreateInsideTransaction(BusinessContext context)
        {
            base.PostCreateInsideTransaction(context);

            int userId = (int)(PrimaryKeyId)context.Request.Target.Properties[CustomizationProfileUserEntity.FieldPrincipalId].Value;
            // New profile defines new Left Menu so we should empty cache.
            DataCache.RemoveByUser(userId.ToString());

            // Check WorkspacePersonalization flag in profile and clear user settings for dashboards if the value is False.
            CustomizationProfileUserEntity profileUserEntity = (CustomizationProfileUserEntity)context.Request.Target;
            PrimaryKeyId profileId = profileUserEntity.ProfileId;
            CustomizationProfileEntity profileEntity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, profileId);
            if (!profileEntity.WorkspacePersonalization)
            {
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                    BusinessManager.Delete(page);
            }
        }
		private int BindList()
		{
			int itemsCount = 0;

			FilterElementCollection filters = new FilterElementCollection();
			filters.Add(FilterElement.EqualElement(OwnerType, OwnerId));
			filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active));
//			if (AssignmentId != PrimaryKeyId.Empty)
//				filters.Add(FilterElement.NotEqualElement("PrimaryKeyId", AssignmentId));

			EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray());

			if (assignments != null && assignments.Length > 0)
			{
				itemsCount = assignments.Length;

				AssignmentGrid.DataSource = assignments;
				AssignmentGrid.DataBind();
			}

			return itemsCount;
		}
        protected void lbAddItems_Click(object sender, EventArgs e)
        {
            string s = Request["__EVENTARGUMENT"];

            if (!String.IsNullOrEmpty(s))
            {
                string[]     mas   = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]);
                foreach (string item in mas)
                {
                    PrimaryKeyId id        = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item));
                    string       className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item);

                    if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined)
                    {
                        FilterElementCollection fec = new FilterElementCollection();
                        fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"])));
                        fec.Add(FilterElement.EqualElement(Filter2FieldName, id));
                        EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray());
                        if (list.Length == 0)
                        {
                            EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                            eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                            eo[Filter2FieldName] = id;
                            BusinessManager.Create(eo);
                        }
                    }
                    else if (id != PrimaryKeyId.Empty)
                    {
                        EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                        eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                        eo[Filter2FieldName] = id;
                        BusinessManager.Create(eo);
                    }
                }
                CHelper.RequireDataBind();
            }
        }
		private int BindAssignment()
		{
			int itemsCount = 0;

			if (AssignmentId != PrimaryKeyId.Empty)
			{
				FilterElementCollection filters = new FilterElementCollection();
				filters.Add(FilterElement.EqualElement(OwnerType, OwnerId));
				filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active));
				filters.Add(FilterElement.EqualElement("PrimaryKeyId", AssignmentId));

				EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray());
				if (assignments != null && assignments.Length > 0)
				{
					AssignmentEntity assignment = (AssignmentEntity)assignments[0];

					SavedPath = AssignmentEntity.GetControlPath(assignment);

					MCDataBoundControl control = (MCDataBoundControl)LoadAssignment();
					if (control != null)
					{
						control.DataItem = assignment;
						control.DataBind();
					}

					itemsCount = 1;
				}
				else
				{
					SavedPath = String.Empty;
					MainPlaceHolder.Controls.Clear();
					itemsCount = 0;
				}
			}

			return itemsCount;
		}
Beispiel #18
0
        public bool IsEnable(object Sender, object Element)
        {
            bool retval = false;

            if (HttpContext.Current.Items.Contains("OwnerTypeId") && HttpContext.Current.Items.Contains("OwnerId"))
            {
                int ownerTypeId = (int)HttpContext.Current.Items["OwnerTypeId"];
                int ownerId     = (int)HttpContext.Current.Items["OwnerId"];

                bool canUpdate = false;
                if (ownerTypeId == (int)ObjectTypes.Document)
                {
                    canUpdate = Document.CanUpdate(ownerId);
                }
                else if (ownerTypeId == (int)ObjectTypes.Task)
                {
                    canUpdate = Task.CanUpdate(ownerId);
                }
                else if (ownerTypeId == (int)ObjectTypes.ToDo)
                {
                    canUpdate = ToDo.CanUpdate(ownerId);
                }
                else if (ownerTypeId == (int)ObjectTypes.Issue)
                {
                    canUpdate = Incident.CanUpdate(ownerId);
                }

                if (canUpdate)
                {
                    int projectId = CommonHelper.GetProjectIdByObjectIdObjectType(ownerId, ownerTypeId);

                    FilterElementCollection filters = new FilterElementCollection();
                    filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldSupportedIbnObjectTypes, ownerTypeId));
                    if (projectId > 0)
                    {
                        // O.R. [2010-02-03]: Allow to select non-project templates for a project
                        OrBlockFilterElement orBlock = new OrBlockFilterElement();
                        orBlock.ChildElements.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldProjectId, projectId));
                        orBlock.ChildElements.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
                        filters.Add(orBlock);
                    }
                    else
                    {
                        filters.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
                    }

                    EntityObject[] items = BusinessManager.List(WorkflowDefinitionEntity.ClassName, filters.ToArray());
                    if (items != null && items.Length > 0)
                    {
                        retval = true;
                    }
                }
            }

            return(retval);
        }
Beispiel #19
0
        /// <summary>
        /// Resets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        public static void ResetCustomPage(Guid uid, int?profileId, int?userId)
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)                // User layer
            {
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));
            }
            else if (profileId.HasValue)                // Profile layer
            {
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
            }
            else             // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            foreach (CustomPageEntity page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
            {
                if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName))
                {
                    BusinessManager.Delete(page);
                }
            }
        }
Beispiel #20
0
        private void BindValues()
        {
            CalendarEventEntity ceo = (CalendarEventEntity)DataItem;            //BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement           fe  = FilterElement.EqualElement("EventId", EventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    lblNoRecurrence.Visible = false;
                    ShowRecurrence.Visible  = true;
                    txtStartTime.Text       = ceo.Start.ToShortTimeString();
                    txtEndTime.Text         = ceo.End.ToShortTimeString();
                    Pattern = (byte)cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                        cero.DayOfWeekMask.HasValue &&
                        cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                    {
                        Pattern = (byte)eRecurrenceType.RecursDaily;
                    }

                    if (cero.Interval.HasValue)
                    {
                        Frequency = (byte)cero.Interval.Value;
                    }
                    if (cero.DayOfWeekMask.HasValue)
                    {
                        bWeekdays = (byte)cero.DayOfWeekMask;
                    }
                    if (cero.DayOfMonth.HasValue)
                    {
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    }
                    if (cero.Instance.HasValue)
                    {
                        bWeekNumber = (byte)cero.Instance.Value;
                    }
                    if (cero.MonthOfYear.HasValue)
                    {
                        MonthNumber = (byte)cero.MonthOfYear.Value;
                    }

                    if (cero.Occurrences.HasValue)
                    {
                        EndAfter = cero.Occurrences.Value;
                    }

                    int pattern = Pattern;
                    if (Pattern == 1)
                    {
                        pattern = (cero.DayOfWeekMask.HasValue &&
                                   cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays) ? 12 : 11;
                    }

                    Label lblControl = (Label)this.FindControl("txtInfo" + pattern);
                    if (lblControl != null)
                    {
                        lblControl.Visible = true;
                    }
                    if (EndAfter != 0)
                    {
                        lblEnd.Text = LocRM.GetString("Endafter") + ":";
                        txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences");
                    }
                    else if (cero.PatternEndDate.HasValue)
                    {
                        lblEnd.Text = LocRM.GetString("Endby") + ":";
                        txtEnd.Text = cero.PatternEndDate.Value.ToShortDateString();
                    }
                }
                else
                {
                    lblNoRecurrence.Text    = "<br>&nbsp; " + LocRM.GetString("NotSet") + "<br>&nbsp;";
                    lblNoRecurrence.Visible = true;
                    ShowRecurrence.Visible  = false;
                }
            }
        }
Beispiel #21
0
        private void BindDGOrganizations(string keyword)
        {
            FilterElement fe = CHelper.GetSearchFilterElementByKeyword(keyword, OrganizationEntity.GetAssignedMetaClassName());
            FilterElementCollection fec = new FilterElementCollection();
            fec.Add(fe);

            dgOrganizations.DataSource = BusinessManager.List(OrganizationEntity.GetAssignedMetaClassName(), fec.ToArray());
            dgOrganizations.DataBind();

            int RowCount = dgOrganizations.Items.Count;
            if (RowCount == 0)
            {
                Sep11.Visible = false;
                Pan11.Visible = false;
            }
            else
            {
                Sep11.Title = String.Format("{0} ({1})", LocRM.GetString("Organizations"), RowCount);
            }
        }
Beispiel #22
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("Id", typeof(string));
            dt.Columns.Add("Name", typeof(string));

            string sSearch = tbSearchString.Text.Trim();

            FilterElementCollection fec = new FilterElementCollection();
            if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]);
                FilterElement fe1 = FilterElement.IsNullElement(Request["filterName"]);
                FilterElement feOr = new OrBlockFilterElement();
                feOr.ChildElements.Add(fe);
                feOr.ChildElements.Add(fe1);
                fec.Add(feOr);
            }
            else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe = FilterElement.IsNullElement(Request["filterName"]);
                fec.Add(fe);
            }

            MetaObject[] list = MetaObject.List(mc, fec.ToArray());

            foreach (MetaObject obj in list)
            {
                DataRow row = dt.NewRow();
                row["Id"] = obj.PrimaryKeyId.ToString();
                if (obj.Properties[mc.TitleFieldName].Value != null)
                    row["Name"] = CHelper.GetResFileString(obj.Properties[mc.TitleFieldName].Value.ToString());
                dt.Rows.Add(row);
            }

            if (ViewState["SelectItem_Sort"] == null)
                ViewState["SelectItem_Sort"] = "Name";
            if (ViewState["SelectItem_CurrentPage"] == null)
                ViewState["SelectItem_CurrentPage"] = 0;
            if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize)
                grdMain.AllowPaging = false;
            else
                grdMain.AllowPaging = true;
            DataView dv = dt.DefaultView;
            if (sSearch != String.Empty)
            {
                dv.RowFilter = String.Format(CultureInfo.InvariantCulture, "Name LIKE '%{0}%'", sSearch);
            }
            dv.Sort = ViewState["SelectItem_Sort"].ToString();
            if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging)
                grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"];
            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (DataGridItem dgi in grdMain.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibRelate");
                if (ib != null)
                {
                    string sId = dgi.Cells[0].Text;
                    string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId));
                    ib.Attributes.Add("onclick", sAction);
                }
            }
        }
Beispiel #23
0
        private void GetObjectData()
        {
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement           fe  = FilterElement.EqualElement("EventId", _workObjectId);

            fec.Add(fe);
            EntityObject[] list = BusinessManager.List(CalendarEventResourceEntity.ClassName, fec.ToArray());

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(string)));
            dt.Columns.Add(new DataColumn("Name", typeof(string)));
            DataRow dr;

            foreach (EntityObject eo in list)
            {
                dr = dt.NewRow();
                CalendarEventResourceEntity cero = (CalendarEventResourceEntity)eo;
                if (cero.ContactId.HasValue)
                {
                    dr["Id"] = String.Format("{0}::{1}",
                                             cero.ContactId.Value.ToString(),
                                             ContactEntity.GetAssignedMetaClassName());
                    dr["Name"] = cero.Contact;
                }
                else if (cero.OrganizationId.HasValue)
                {
                    dr["Id"] = String.Format("{0}::{1}",
                                             cero.OrganizationId.Value.ToString(),
                                             OrganizationEntity.GetAssignedMetaClassName());
                    dr["Name"] = cero.Organization;
                }
                else if (cero.PrincipalId.HasValue)
                {
                    dr["Id"] = String.Format("{0}::{1}",
                                             cero.PrincipalId.Value.ToString(),
                                             Principal.GetAssignedMetaClass().Name);
                    dr["Name"] = cero.Principal;
                }
                else
                {
                    dr["Id"]   = String.Format("{0}::0", cero.Email);
                    dr["Name"] = cero.Email;
                }
                dt.Rows.Add(dr);
            }

            ViewState["Resources"] = dt;
        }
        private int BindList()
        {
            int itemsCount = 0;

            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(OwnerType, OwnerId));
            filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID));
            filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active));
            //			if (AssignmentId != PrimaryKeyId.Empty)
            //				filters.Add(FilterElement.NotEqualElement("PrimaryKeyId", AssignmentId));

            EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray());

            if (assignments != null && assignments.Length > 0)
            {
                itemsCount = assignments.Length;

                AssignmentGrid.DataSource = assignments;
                AssignmentGrid.DataBind();
            }

            return itemsCount;
        }
Beispiel #25
0
        /// <summary>
        /// Resets the user settings by profile.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        public static void ResetUserSettingsByProfile(Guid uid, int profileId)
        {
            List<string> users = new List<string>();

            if (profileId > 0)
            {
                FilterElementCollection fec = new FilterElementCollection();
                fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                foreach (CustomizationProfileUserEntity entity in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                    users.Add(entity.PrincipalId.ToString());
            }
            else // default profile
            {
                // 1. Get list all users
                using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                {
                    while (reader.Read())
                        users.Add(reader["UserId"].ToString());
                }

                // 2. Exclude users with non-default profile
                EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                foreach (CustomizationProfileUserEntity puEntity in entityList)
                {
                    users.Remove(puEntity.PrincipalId.ToString());
                }
            }

            // O.R. [2010-10-05]. Don't process profile without users
            if (users.Count > 0)
            {
                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                filters.Add(orBlock);

                // Skip CustomPageNormalizationPlugin
                ListRequest request = new ListRequest(CustomPageEntity.ClassName, filters.ToArray());
                request.Parameters.Add("CustomPageNormalizationPlugin", false);
                ListResponse response = (ListResponse)BusinessManager.Execute(request);

                foreach (EntityObject page in response.EntityObjects)
                    BusinessManager.Delete(page);
            }
        }
Beispiel #26
0
        /// <summary>
        /// Resets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        public static void ResetCustomPage(Guid uid, int? profileId, int? userId)
        {
            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)	// User layer
            {
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));
            }
            else if (profileId.HasValue)	// Profile layer
            {
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
            }
            else // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            foreach (CustomPageEntity page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
            {
                if (!page.Properties.Contains(LocalDiskEntityObjectPlugin.IsLoadDiskEntityPropertyName))
                    BusinessManager.Delete(page);
            }
        }
        protected void lbAddItems_Click(object sender, EventArgs e)
        {
            string s = Request["__EVENTARGUMENT"];
            if (!String.IsNullOrEmpty(s))
            {
                string[] mas = s.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                PrimaryKeyId objId = PrimaryKeyId.Parse(Request["ObjectId"]);
                foreach (string item in mas)
                {
                    PrimaryKeyId id = PrimaryKeyId.Parse(MetaViewGroupUtil.GetIdFromUniqueKey(item));
                    string className = MetaViewGroupUtil.GetMetaTypeFromUniqueKey(item);

                    if (!String.IsNullOrEmpty(className) && className != MetaViewGroupUtil.keyValueNotDefined)
                    {
                        FilterElementCollection fec = new FilterElementCollection();
                        fec.Add(FilterElement.EqualElement(Filter1FieldName, PrimaryKeyId.Parse(Request["ObjectId"])));
                        fec.Add(FilterElement.EqualElement(Filter2FieldName, id));
                        EntityObject[] list = BusinessManager.List(BridgeClassName, fec.ToArray());
                        if (list.Length == 0)
                        {
                            EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                            eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                            eo[Filter2FieldName] = id;
                            BusinessManager.Create(eo);
                        }
                    }
                    else if (id != PrimaryKeyId.Empty)
                    {
                        EntityObject eo = BusinessManager.InitializeEntity(BridgeClassName);
                        eo[Filter1FieldName] = PrimaryKeyId.Parse(Request["ObjectId"]);
                        eo[Filter2FieldName] = id;
                        BusinessManager.Create(eo);
                    }
                }
                CHelper.RequireDataBind();
            }
        }
Beispiel #28
0
        private void BindValues()
        {
            BindLists();

            SetDefaulValues();

            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                dtcDateStart.SelectedDate = ceo.Start;
                dtcDateEnd.SelectedDate   = ceo.End;

                FilterElementCollection fec = new FilterElementCollection();
                FilterElement           fe  = FilterElement.EqualElement("EventId", ((VirtualEventId)EventId).RealEventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    int pattern = cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                        cero.DayOfWeekMask.HasValue &&
                        cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                    {
                        pattern = 1;
                    }

                    Pattern = (byte)pattern;

                    if (cero.Interval.HasValue)
                    {
                        Frequency = (byte)cero.Interval.Value;
                    }
                    if (cero.DayOfWeekMask.HasValue)
                    {
                        Weekdays = (byte)cero.DayOfWeekMask;
                    }
                    if (cero.DayOfMonth.HasValue)
                    {
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    }
                    if (cero.Instance.HasValue)
                    {
                        WeekNumber = (byte)cero.Instance.Value;
                    }
                    if (cero.MonthOfYear.HasValue)
                    {
                        MonthNumber = (byte)cero.MonthOfYear.Value;
                    }

                    if (cero.PatternEndDate.HasValue)
                    {
                        rbEndBy.Checked         = true;
                        rbEndAfter.Checked      = false;
                        dtcDateEnd.SelectedDate = cero.PatternEndDate.Value.Date;
                    }
                    else if (cero.Occurrences.HasValue && cero.Occurrences.Value > 0)
                    {
                        rbEndAfter.Checked = true;
                        tbEndAfter.Text    = cero.Occurrences.Value.ToString();
                    }
                }
            }
        }
Beispiel #29
0
        /// <summary>
        /// Gets the customization item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        private static CustomizationItemEntity GetCustomizationItem(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            CustomizationItemEntity result = null;

            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldXmlFullId, fullId));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)structureType));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)commandType));

            // Filter by profile
            if (profileId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value));
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));
            }

            // Filter by principal
            if (principalId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value));
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));
            }

            EntityObject[] items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());

            if (items != null && items.Length > 0)
            {
                result = items[0] as CustomizationItemEntity;
            }

            return(result);
        }
Beispiel #30
0
        /// <summary>
        /// Deletes the navigation item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void DeleteNavigationItem(string fullId, PrimaryKeyId?profileId, PrimaryKeyId?principalId)
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(new FilterElement(CustomizationItemEntity.FieldXmlFullId, FilterElementType.Like, fullId + "%"));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)ItemCommandType.Add));

            // delete user level only
            if (principalId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value));
            }
            // delete profile and user level
            else if (profileId.HasValue)
            {
                OrBlockFilterElement block = new OrBlockFilterElement();
                block.ChildElements.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value));
                block.ChildElements.Add(FilterElement.IsNotNullElement(CustomizationItemEntity.FieldPrincipalId));
                filters.Add(block);
            }
            // else delete all - we don't use filter in that case

            using (TransactionScope transaction = DataContext.Current.BeginTransaction())
            {
                foreach (EntityObject item in BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()))
                {
                    BusinessManager.Delete(item);
                }

                transaction.Commit();
            }

            ClearCache(profileId, principalId);
        }
Beispiel #31
0
        /// <summary>
        /// Deletes the navigation item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        public static void DeleteNavigationItem(string fullId, PrimaryKeyId? profileId, PrimaryKeyId? principalId)
        {
            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(new FilterElement(CustomizationItemEntity.FieldXmlFullId, FilterElementType.Like, fullId + "%"));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)CustomizationStructureType.NavigationMenu));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)ItemCommandType.Add));

            // delete user level only
            if (principalId.HasValue)
            {
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value));
            }
            // delete profile and user level
            else if (profileId.HasValue)
            {
                OrBlockFilterElement block = new OrBlockFilterElement();
                block.ChildElements.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value));
                block.ChildElements.Add(FilterElement.IsNotNullElement(CustomizationItemEntity.FieldPrincipalId));
                filters.Add(block);
            }
            // else delete all - we don't use filter in that case

            using (TransactionScope transaction = DataContext.Current.BeginTransaction())
            {
                foreach (EntityObject item in BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray()))
                {
                    BusinessManager.Delete(item);
                }

                transaction.Commit();
            }

            ClearCache(profileId, principalId);
        }
Beispiel #32
0
        protected void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;
            if (ceo != null)
            {
                CalendarEventRecurrenceEntity cero;
                bool create = false;

                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)EventId).RealEventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                    cero = (CalendarEventRecurrenceEntity)list[0];
                else
                {
                    cero = BusinessManager.InitializeEntity<CalendarEventRecurrenceEntity>(CalendarEventRecurrenceEntity.ClassName);
                    create = true;
                }

                cero.EventId = ((VirtualEventId)EventId).RealEventId;
                cero.RecurrenceType = (int)Pattern;
                switch (Pattern)
                {
                    case 1:	//RecursDaily
                        if (rbRecType11.Checked)
                            cero.Interval = (int)Frequency;
                        else
                        {
                            cero.RecurrenceType = (int)eRecurrenceType.RecursWeekly;
                            cero.DayOfWeekMask = (int)eBitDayOfWeek.Weekdays;
                        }
                        break;
                    case 2:	//RecursWeekly
                        cero.DayOfWeekMask = (int)Weekdays;
                        cero.Interval = (int)Frequency;
                        break;
                    case 3:	//RecursMonthly
                        cero.DayOfMonth = (int)MonthDay;
                        cero.Interval = (int)Frequency;
                        break;
                    case 4:	//RecursMonthNth
                        cero.Instance = (int)WeekNumber;
                        cero.DayOfWeekMask = (int)Weekdays;
                        cero.Interval = (int)Frequency;
                        break;
                    case 5:	//RecursYearly
                        cero.MonthOfYear = (int)MonthNumber;
                        cero.DayOfMonth = (int)MonthDay;
                        break;
                    case 6:	//RecursYearNth
                        cero.Instance = (int)WeekNumber;
                        cero.DayOfWeekMask = (int)Weekdays;
                        cero.MonthOfYear = (int)MonthNumber;
                        break;
                    default:
                        break;
                }

                cero.Title = ceo.Subject;
                if (rbEndBy.Checked)
                {
                    cero.PatternEndDate = dtcDateEnd.SelectedDate.AddDays(1).AddSeconds(-1);
                    cero.Occurrences = 0;
                }
                else
                {
                    cero.Occurrences = int.Parse(tbEndAfter.Text);
                    cero.PatternEndDate = null;
                }

                if (create)
                    BusinessManager.Create(cero);
                else
                    BusinessManager.Update(cero);

                CommandParameters cp = new CommandParameters("CEvent_ReccurenceAdded");
                CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString(), true);
            }
        }
Beispiel #33
0
        /// <summary>
        /// Gets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public static CustomPageEntity GetCustomPage(Guid uid, int? profileId, int? userId)
        {
            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)	// User layer
            {
                if (!profileId.HasValue)
                    profileId = ProfileManager.GetProfileIdByUser(userId.Value);

                // ProfileId is null AND UserId is null
                AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId = value AND UserId is null
                AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId is null AND UserId = value
                AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(andBlock1);
                orBlock.ChildElements.Add(andBlock2);
                orBlock.ChildElements.Add(andBlock3);

                filters.Add(orBlock);
            }
            else if (profileId.HasValue)	// Profile layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(orBlock);
            }
            else // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            EntityObject[] pages = BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray());

            CustomPageEntity retval = null;
            if (pages.Length > 0)
                retval = (CustomPageEntity)pages[0];

            return retval;
        }
Beispiel #34
0
        protected void btnSave_ServerClick(object sender, System.EventArgs e)
        {
            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                CalendarEventRecurrenceEntity cero;
                bool create = false;

                FilterElementCollection fec = new FilterElementCollection();
                FilterElement           fe  = FilterElement.EqualElement("EventId", ((VirtualEventId)EventId).RealEventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    cero = (CalendarEventRecurrenceEntity)list[0];
                }
                else
                {
                    cero   = BusinessManager.InitializeEntity <CalendarEventRecurrenceEntity>(CalendarEventRecurrenceEntity.ClassName);
                    create = true;
                }

                cero.EventId        = ((VirtualEventId)EventId).RealEventId;
                cero.RecurrenceType = (int)Pattern;
                switch (Pattern)
                {
                case 1:                         //RecursDaily
                    if (rbRecType11.Checked)
                    {
                        cero.Interval = (int)Frequency;
                    }
                    else
                    {
                        cero.RecurrenceType = (int)eRecurrenceType.RecursWeekly;
                        cero.DayOfWeekMask  = (int)eBitDayOfWeek.Weekdays;
                    }
                    break;

                case 2:                         //RecursWeekly
                    cero.DayOfWeekMask = (int)Weekdays;
                    cero.Interval      = (int)Frequency;
                    break;

                case 3:                         //RecursMonthly
                    cero.DayOfMonth = (int)MonthDay;
                    cero.Interval   = (int)Frequency;
                    break;

                case 4:                         //RecursMonthNth
                    cero.Instance      = (int)WeekNumber;
                    cero.DayOfWeekMask = (int)Weekdays;
                    cero.Interval      = (int)Frequency;
                    break;

                case 5:                         //RecursYearly
                    cero.MonthOfYear = (int)MonthNumber;
                    cero.DayOfMonth  = (int)MonthDay;
                    break;

                case 6:                         //RecursYearNth
                    cero.Instance      = (int)WeekNumber;
                    cero.DayOfWeekMask = (int)Weekdays;
                    cero.MonthOfYear   = (int)MonthNumber;
                    break;

                default:
                    break;
                }

                cero.Title = ceo.Subject;
                if (rbEndBy.Checked)
                {
                    cero.PatternEndDate = dtcDateEnd.SelectedDate.AddDays(1).AddSeconds(-1);
                    cero.Occurrences    = 0;
                }
                else
                {
                    cero.Occurrences    = int.Parse(tbEndAfter.Text);
                    cero.PatternEndDate = null;
                }

                if (create)
                {
                    BusinessManager.Create(cero);
                }
                else
                {
                    BusinessManager.Update(cero);
                }

                CommandParameters cp = new CommandParameters("CEvent_ReccurenceAdded");
                CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString(), true);
            }
        }
        private void BindTemplates()
        {
            int projectId = CommonHelper.GetProjectIdByObjectIdObjectType(OwnerId, OwnerTypeId);

            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldSupportedIbnObjectTypes, OwnerTypeId));
            if (projectId > 0)
            {
                // O.R. [2010-02-03]: Allow to select non-project templates for a project
                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldProjectId, projectId));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
                filters.Add(orBlock);
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
            }

            if (TeplateGroupList.Items.Count > 0)
            {
                filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldTemplateGroup, int.Parse(TeplateGroupList.SelectedValue)));
            }

            TemplateList.Items.Clear();
            foreach (WorkflowDefinitionEntity entity in BusinessManager.List(WorkflowDefinitionEntity.ClassName, filters.ToArray()))
            {
                TemplateList.Items.Add(new ListItem(entity.Name, entity.PrimaryKeyId.Value.ToString()));
            }
        }
Beispiel #36
0
        private void BindTemplates()
        {
            ddTemplate.Items.Clear();
            ddTemplate.Items.Add(new ListItem(String.Empty, PrimaryKeyId.Empty.ToString()));

            FilterElement           fe  = FilterElement.EqualElement("Name", ddType.SelectedValue);
            FilterElementCollection fec = new FilterElementCollection();

            fec.Add(fe);

            EntityObject[] masTypes = BusinessManager.List(DocumentTypeEntity.GetAssignedMetaClassName(), fec.ToArray());
            if (masTypes.Length > 0)
            {
                FilterElement           fe1  = FilterElement.EqualElement("DocumentTypeId", masTypes[0].PrimaryKeyId.Value);
                FilterElementCollection fec1 = new FilterElementCollection();
                fec1.Add(fe1);
                EntityObject[] mas = BusinessManager.List(DocumentTemplateEntity.GetAssignedMetaClassName(), fec1.ToArray());
                foreach (EntityObject eo in mas)
                {
                    ddTemplate.Items.Add(new ListItem(CHelper.GetResFileString(eo["Name"].ToString()), eo.PrimaryKeyId.Value.ToString()));
                }
            }
        }
        /// <summary>
        /// Preupdates inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreUpdateInsideTransaction(BusinessContext context)
        {
            base.PreUpdateInsideTransaction(context);

            // Check that the value of WorkspacePersonalization property changed from True to False
            CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value);

            if (entity != null &&
                (bool)entity.WorkspacePersonalization &&
                !(bool)context.Request.Target.Properties[CustomizationProfileEntity.FieldWorkspacePersonalization].Value)
            {
                int profileId = (int)context.GetTargetPrimaryKeyId().Value;

                List <string> users = new List <string>();

                if (profileId > 0)
                {
                    // Get users by profile
                    FilterElementCollection fec = new FilterElementCollection();
                    fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                    foreach (CustomizationProfileUserEntity user in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                    {
                        users.Add(user.PrimaryKeyId.Value.ToString());
                    }
                }
                else                 // default profile
                {
                    // 1. Get list all users
                    using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                    {
                        while (reader.Read())
                        {
                            users.Add(reader["UserId"].ToString());
                        }
                    }

                    // 2. Exclude users with non-default profile
                    EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                    foreach (CustomizationProfileUserEntity puEntity in entityList)
                    {
                        users.Remove(puEntity.PrincipalId.ToString());
                    }
                }

                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                {
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                }
                filters.Add(orBlock);

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                {
                    BusinessManager.Delete(page);
                }
            }
        }
Beispiel #38
0
        private IEnumerable <string> GetAssociations()
        {
            // have the "loader" ... also
            bool          GoOldSchool = true;
            List <string> list        = new List <string>(); // to store whatever found

            // _linksRep.Service.get - no listing
            // AssociationGroup g = new AssociationGroup();


            if (GoOldSchool)
            {
                // seems to lack a MC-way to list the associations available
                // it becomes SQL-oriented pretty soon
                // ugly, but works "OldSchool"
                FilterElementCollection col = new FilterElementCollection();
                using (IDataReader reader = Mediachase.BusinessFoundation.Data.DataHelper.List("CatalogAssociation"
                                                                                               , col.ToArray()))
                {
                    // need the FeatureSwitch when going for POs
                    while (reader.Read())
                    {
                        list.Add((string)reader["AssociationName"]);
                    }
                }
            }
            else
            {
                // Gets from DDS
                //var associationDefinitionRepository =
                //    ServiceLocator.Current.GetInstance<GroupDefinitionRepository<AssociationGroupDefinition>>();

                var associationDefinitionRepository        = _AssocGroups.Service;
                IEnumerable <AssociationGroupDefinition> a = associationDefinitionRepository.List();

                foreach (AssociationGroupDefinition item in a)
                {
                    list.Add(item.Name);
                }
            }
            return(list);
        }
        private void BindTemplates()
        {
            int projectId = CommonHelper.GetProjectIdByObjectIdObjectType(OwnerId, OwnerTypeId);

            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldSupportedIbnObjectTypes, OwnerTypeId));
            if (projectId > 0)
            {
                // O.R. [2010-02-03]: Allow to select non-project templates for a project
                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldProjectId, projectId));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
                filters.Add(orBlock);
            }
            else
            {
                filters.Add(FilterElement.IsNullElement(WorkflowDefinitionEntity.FieldProjectId));
            }

            if (TeplateGroupList.Items.Count > 0)
                filters.Add(FilterElement.EqualElement(WorkflowDefinitionEntity.FieldTemplateGroup, int.Parse(TeplateGroupList.SelectedValue)));

            TemplateList.Items.Clear();
            foreach (WorkflowDefinitionEntity entity in BusinessManager.List(WorkflowDefinitionEntity.ClassName, filters.ToArray()))
            {
                TemplateList.Items.Add(new ListItem(entity.Name, entity.PrimaryKeyId.Value.ToString()));
            }
        }
Beispiel #40
0
        protected void btnDelete_Click(object sender, System.EventArgs e)
        {
            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;

            if (ceo != null)
            {
                FilterElementCollection fec     = new FilterElementCollection();
                PrimaryKeyId            realKey = ((VirtualEventId)EventId).RealEventId;
                FilterElement           fe      = FilterElement.EqualElement("EventId", realKey);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];
                    BusinessManager.Delete(cero);

                    Response.Redirect("~/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId=" + realKey.ToString());
                }
            }
        }
        /// <summary>
        /// Preupdates inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PreUpdateInsideTransaction(BusinessContext context)
        {
            base.PreUpdateInsideTransaction(context);

            // Check that the value of WorkspacePersonalization property changed from True to False
            CustomizationProfileEntity entity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
            if (entity != null
                && (bool)entity.WorkspacePersonalization
                && !(bool)context.Request.Target.Properties[CustomizationProfileEntity.FieldWorkspacePersonalization].Value)
            {
                int profileId = (int)context.GetTargetPrimaryKeyId().Value;

                List<string> users = new List<string>();

                if (profileId > 0)
                {
                    // Get users by profile
                    FilterElementCollection fec = new FilterElementCollection();
                    fec.Add(FilterElement.EqualElement(CustomizationProfileUserEntity.FieldProfileId, profileId));

                    foreach (CustomizationProfileUserEntity user in BusinessManager.List(CustomizationProfileUserEntity.ClassName, fec.ToArray()))
                        users.Add(user.PrimaryKeyId.Value.ToString());
                }
                else // default profile
                {
                    // 1. Get list all users
                    using (IDataReader reader = Mediachase.IBN.Business.User.GetListAll())
                    {
                        while (reader.Read())
                            users.Add(reader["UserId"].ToString());
                    }

                    // 2. Exclude users with non-default profile
                    EntityObject[] entityList = BusinessManager.List(CustomizationProfileUserEntity.ClassName, (new FilterElementCollection()).ToArray());
                    foreach (CustomizationProfileUserEntity puEntity in entityList)
                    {
                        users.Remove(puEntity.PrincipalId.ToString());
                    }
                }

                // Remove CustomPages for all users in Profile
                FilterElementCollection filters = new FilterElementCollection();

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                foreach (string userId in users)
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));
                filters.Add(orBlock);

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                    BusinessManager.Delete(page);
            }
        }
Beispiel #42
0
        /// <summary>
        /// Gets the custom page.
        /// </summary>
        /// <param name="uid">The page uid.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public static CustomPageEntity GetCustomPage(Guid uid, int?profileId, int?userId)
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUid, uid));

            if (userId.HasValue)                // User layer
            {
                if (!profileId.HasValue)
                {
                    profileId = ProfileManager.GetProfileIdByUser(userId.Value);
                }

                // ProfileId is null AND UserId is null
                AndBlockFilterElement andBlock1 = new AndBlockFilterElement();
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock1.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId = value AND UserId is null
                AndBlockFilterElement andBlock2 = new AndBlockFilterElement();
                andBlock2.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                andBlock2.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                // ProfileId is null AND UserId = value
                AndBlockFilterElement andBlock3 = new AndBlockFilterElement();
                andBlock3.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                andBlock3.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId.Value));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(andBlock1);
                orBlock.ChildElements.Add(andBlock2);
                orBlock.ChildElements.Add(andBlock3);

                filters.Add(orBlock);
            }
            else if (profileId.HasValue)                // Profile layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));

                OrBlockFilterElement orBlock = new OrBlockFilterElement();
                orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, profileId.Value));
                orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(orBlock);
            }
            else             // Site layer
            {
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                filters.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }

            EntityObject[] pages = BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray());

            CustomPageEntity retval = null;

            if (pages.Length > 0)
            {
                retval = (CustomPageEntity)pages[0];
            }

            return(retval);
        }
Beispiel #43
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(string));
            dt.Columns.Add("Name", typeof(string));

            string sSearch = tbSearchString.Text.Trim();

            FilterElementCollection fec = new FilterElementCollection();

            if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe   = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]);
                FilterElement fe1  = FilterElement.IsNullElement(Request["filterName"]);
                FilterElement feOr = new OrBlockFilterElement();
                feOr.ChildElements.Add(fe);
                feOr.ChildElements.Add(fe1);
                fec.Add(feOr);
            }
            else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe = FilterElement.IsNullElement(Request["filterName"]);
                fec.Add(fe);
            }

            MetaObject[] list = MetaObject.List(mc, fec.ToArray());

            foreach (MetaObject obj in list)
            {
                DataRow row = dt.NewRow();
                row["Id"] = obj.PrimaryKeyId.ToString();
                if (obj.Properties[mc.TitleFieldName].Value != null)
                {
                    row["Name"] = CHelper.GetResFileString(obj.Properties[mc.TitleFieldName].Value.ToString());
                }
                dt.Rows.Add(row);
            }

            if (ViewState["SelectItem_Sort"] == null)
            {
                ViewState["SelectItem_Sort"] = "Name";
            }
            if (ViewState["SelectItem_CurrentPage"] == null)
            {
                ViewState["SelectItem_CurrentPage"] = 0;
            }
            if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize)
            {
                grdMain.AllowPaging = false;
            }
            else
            {
                grdMain.AllowPaging = true;
            }
            DataView dv = dt.DefaultView;

            if (sSearch != String.Empty)
            {
                dv.RowFilter = String.Format(CultureInfo.InvariantCulture, "Name LIKE '%{0}%'", sSearch);
            }
            dv.Sort = ViewState["SelectItem_Sort"].ToString();
            if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging)
            {
                grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"];
            }
            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (DataGridItem dgi in grdMain.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibRelate");
                if (ib != null)
                {
                    string sId     = dgi.Cells[0].Text;
                    string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId));
                    ib.Attributes.Add("onclick", sAction);
                }
            }
        }
Beispiel #44
0
        private EntityObject[] GetEntityObjectListForExport()
        {
            string variant = "0";

            if (Request["variant"] != null)
            {
                variant = Request["variant"];
            }

            SortingElementCollection sec = new SortingElementCollection();

            if (_pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)] != null)
            {
                string             sort = _pc[grdMain.GetPropertyKey(EntityGrid.SortingPropertyKey)];
                SortingElementType set  = SortingElementType.Asc;
                if (sort.IndexOf(" DESC") >= 0)
                {
                    sort = sort.Substring(0, sort.IndexOf(" DESC"));
                    set  = SortingElementType.Desc;
                }

                sec.Add(new SortingElement(sort, set));
            }

            int pageSize = 10;

            if (_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)] != null)
            {
                pageSize = Convert.ToInt32(_pc[grdMain.GetPropertyKey(EntityGrid.PageSizePropertyKey)].ToString());
                if (pageSize == -1)
                {
                    pageSize = 10000;
                }
            }
            int pageIndex = 0;

            if (_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"] != null)
            {
                pageIndex = int.Parse(_pc["EntityList_" + ClassName + "_" + _profileName + "_PageIndex"]);
            }

            ListViewProfile lvp = null;

            switch (variant)
            {
            case "1":                           //OnlyView
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);
                if (sec.Count == 0)
                {
                    sec = lvp.Sorting;
                }
                return(BusinessManager.List(ClassName, lvp.Filters.ToArray(), sec.ToArray()));

            case "2":                           //Only Visible
                lvp = ListViewProfile.Load(ClassName, _profileName, _placeName);

                FilterElementCollection fec = new FilterElementCollection(lvp.Filters.ToArray());

                if (!String.IsNullOrEmpty(txtSearch.Text))
                {
                    FilterElement fe = CHelper.GetSearchFilterElementByKeyword(txtSearch.Text, ClassName);
                    fec.Add(fe);
                }

                EntityObject[]      list    = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray());
                List <EntityObject> newList = new List <EntityObject>();
                int start  = pageIndex * pageSize;
                int finish = start + pageSize;
                for (int i = start; i <= finish && i < list.Length; i++)
                {
                    newList.Add(list[i]);
                }
                return(newList.ToArray());

            case "3":                           //Only Selected
                string              values           = Request["ids"];
                string[]            selectedElements = values.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                List <PrimaryKeyId> listPkey         = new List <PrimaryKeyId>();
                foreach (string elem in selectedElements)
                {
                    string       id  = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    PrimaryKeyId key = PrimaryKeyId.Parse(id);
                    if (key != PrimaryKeyId.Empty)
                    {
                        listPkey.Add(key);
                    }
                }
                FilterElementCollection fecPkey = new FilterElementCollection();
                foreach (PrimaryKeyId id in listPkey)
                {
                    FilterElement fe = FilterElement.EqualElement(FilterElement.PrimaryKeyFieldName, id);
                    fecPkey.Add(fe);
                }
                FilterElement orFilter = new OrBlockFilterElement(fecPkey.ToArray());
                fecPkey.Clear();
                fecPkey.Add(orFilter);

                return(BusinessManager.List(ClassName, fecPkey.ToArray(), sec.ToArray()));

            default:                            //All
                return(BusinessManager.List(ClassName, (new FilterElementCollection()).ToArray(), sec.ToArray()));
            }
        }
Beispiel #45
0
        /// <summary>
        /// Internals the bind.
        /// </summary>
        private void internalBind()
        {
            MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            MainGrid.Columns.Clear();

            MainGrid.AllowPaging = true;

            if (!ShowPaging)
            {
                MainGridExt.BottomHeight = 1;
                SetPageSize(-1);
            }
            else
            {
                MainGridExt.BottomHeight = 30;
                MainGrid.PageSize = GetPageSize();
            }

            int width = 0;

            if (this.ShowCheckboxes)
                width += 22 + 7;

            foreach (EntityGridCustomColumnInfo customColumn in this.CustomColumns)
            {
                MainGrid.Columns.Add(customColumn.Column);
                width += customColumn.Width + 7;
            }

            int counter = 0;
            foreach (EntityFieldInfo field in this.VisibleMetaFields)
            {
                if (PlaceName == String.Empty)
                    MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field.Field));
                else
                    MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetColumn(this.Page, field.Field, PlaceName));

                int cellWidth = GetMetaFieldWidth(counter, field.Width);

                width += cellWidth;

                counter++;
            }

            width += this.VisibleMetaFields.Length * 7;

            MainGrid.Width = width;

            //Adding CssColumn
            MainGrid.Columns.Add((new ListColumnFactory(this.ViewName)).GetCssColumn(this.Page, ClassName));

            internalBindHeader();

            FilterElementCollection fec = new FilterElementCollection();
            fec.AddRange(CurrentProfile.Filters.ToArray());
            if (!String.IsNullOrEmpty(this.SearchKeyword))
            {
                FilterElement fe = CHelper.GetSearchFilterElementByKeyword(this.SearchKeyword, ClassName);
                fec.Add(fe);
            }
            fec.AddRange(AddFilters.ToArray());

            //Sorting
            SortingElementCollection sec = new SortingElementCollection();
            string key = GetPropertyKey(SortingPropertyKey);
            if (_pc[key] != null)
            {
                string sort = _pc[key];
                SortingElementType set = SortingElementType.Asc;
                if (sort.IndexOf(" DESC") >= 0)
                {
                    sort = sort.Substring(0, sort.IndexOf(" DESC"));
                    set = SortingElementType.Desc;
                }

                // O.R. [2009-11-02] check that sorting field exists
                if (mc.Fields.Contains(sort))
                {
                    sec.Add(new SortingElement(sort, set));
                }
                else
                {
                    _pc[key] = null;
                }
            }
            else if (CurrentProfile.Sorting != null)
            {
                // O.R. [2009-11-02] check that sorting fields exist
                foreach (SortingElement sortElement in CurrentProfile.Sorting)
                {
                    if (!mc.Fields.Contains(sortElement.Source))
                    {
                        CurrentProfile.Sorting = null;
                        break;
                    }
                }

                if (CurrentProfile.Sorting != null)
                    sec = CurrentProfile.Sorting;
            }

            if (this.GridFilters.Count > 0)
            {
                fec.AddRange(this.GridFilters);
            }

            if (this.GridSorting.Count > 0)
            {
                sec.AddRange(this.GridSorting);
            }

            if (this.CustomDataSource == null)
            {
                EntityObject[] list;
                try
                {
                    list = BusinessManager.List(ClassName, fec.ToArray(), sec.ToArray());
                }
                catch
                {
                    string sKey = GetPropertyKey(SortingPropertyKey);
                    _pc[sKey] = null;
                    if (this.Parent != null && this.Parent.Parent != null && this.Parent.Parent.Parent != null && this.Parent.Parent.Parent is Mediachase.Ibn.Web.UI.MetaUIEntity.Modules.EntityList)
                        Mediachase.Ibn.Web.UI.MetaUIEntity.Modules.EntityList.SetProfileName(_pc, ClassName, null);
                    throw;
                }

                MainGridExt.IsEmpty = (list.Length == 0);

                if (list.Length == 0)
                {
                    list = new EntityObject[] { new EntityObject(ClassName) };
                    this.Count = 0;
                }
                else
                {
                    this.Count = list.Length;
                }

                MainGrid.DataSource = list;
            }
            else
            {
                MainGrid.DataSource = this.CustomDataSource;
                this.Count = this.CustomDataSource.Length;
            }

            MainGrid.DataBind();

            internalBindPaging();

            #region Appply paging for dashboard
            if (this.DashboardMode)
            {
                MainGridExt.BottomHeight = 16;
                //HtmlControl c = (HtmlControl)MainGrid.BottomPagerRow.FindControl("pagingContainer");
                //c.Style.Add(HtmlTextWriterStyle.Position, "static");
                //c.Style.Add("float", "right");

                //MainGridExt.ServicePath = "debug";
            }
            #endregion

            //if (MainGridExt.IsEmpty)
            //    MainGrid.CssClass = "serverGridBodyEmpty";
        }
Beispiel #46
0
        private void BindValues()
        {
            BindLists();

            SetDefaulValues();

            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;
            if (ceo != null)
            {
                dtcDateStart.SelectedDate = ceo.Start;
                dtcDateEnd.SelectedDate = ceo.End;

                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = FilterElement.EqualElement("EventId", ((VirtualEventId)EventId).RealEventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    int pattern = cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                            cero.DayOfWeekMask.HasValue &&
                            cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                        pattern = 1;

                    Pattern = (byte)pattern;

                    if (cero.Interval.HasValue)
                        Frequency = (byte)cero.Interval.Value;
                    if (cero.DayOfWeekMask.HasValue)
                        Weekdays = (byte)cero.DayOfWeekMask;
                    if (cero.DayOfMonth.HasValue)
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    if (cero.Instance.HasValue)
                        WeekNumber = (byte)cero.Instance.Value;
                    if (cero.MonthOfYear.HasValue)
                        MonthNumber = (byte)cero.MonthOfYear.Value;

                    if (cero.PatternEndDate.HasValue)
                    {
                        rbEndBy.Checked = true;
                        rbEndAfter.Checked = false;
                        dtcDateEnd.SelectedDate = cero.PatternEndDate.Value.Date;
                    }
                    else if (cero.Occurrences.HasValue && cero.Occurrences.Value > 0)
                    {
                        rbEndAfter.Checked = true;
                        tbEndAfter.Text = cero.Occurrences.Value.ToString();
                    }
                }
            }
        }
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;
                string[]          selectedElements = EntityGrid.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                if (selectedElements != null && selectedElements.Length > 0)
                {
                    int          errorCount      = 0;
                    string       bridgeClassName = CHelper.GetFromContext("ReferenceNN_BridgeClassName").ToString();
                    string       field1Name      = CHelper.GetFromContext("ReferenceNN_Field1Name").ToString();
                    string       field2Name      = CHelper.GetFromContext("ReferenceNN_Field2Name").ToString();
                    PrimaryKeyId field1Value     = PrimaryKeyId.Parse(CHelper.GetFromContext("ReferenceNN_Field1Value").ToString());
                    using (TransactionScope tran = DataContext.Current.BeginTransaction())
                    {
                        foreach (string elem in selectedElements)
                        {
                            string[]     parts     = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                            string       id        = parts[0];
                            PrimaryKeyId key       = PrimaryKeyId.Parse(id);
                            string       className = parts[1];

                            FilterElementCollection fec = new FilterElementCollection();
                            fec.Add(FilterElement.EqualElement(field1Name, field1Value));
                            fec.Add(FilterElement.EqualElement(field2Name, key));
                            EntityObject[] list = BusinessManager.List(bridgeClassName, fec.ToArray());
                            if (list.Length > 0)
                            {
                                foreach (EntityObject eo in list)
                                {
                                    try
                                    {
                                        BusinessManager.Delete(bridgeClassName, eo.PrimaryKeyId.Value);
                                    }
                                    catch (Exception ex)
                                    {
                                        CHelper.GenerateErrorReport(ex);
                                        errorCount++;
                                    }
                                }
                            }
                        }

                        tran.Commit();
                    }

                    if (errorCount > 0)
                    {
                        ((CommandManager)Sender).InfoMessage = CHelper.GetResFileString("{IbnFramework.Common:NotAllSelectedItemsWereProcessed}");
                    }
                }
            }
            CHelper.RequireDataBind();
        }
Beispiel #48
0
        /// <summary>
        /// Gets the customization item.
        /// </summary>
        /// <param name="fullId">The full id.</param>
        /// <param name="profileId">The profile id.</param>
        /// <param name="principalId">The principal id.</param>
        /// <returns></returns>
        private static CustomizationItemEntity GetCustomizationItem(string fullId, CustomizationStructureType structureType, ItemCommandType commandType, PrimaryKeyId? profileId, PrimaryKeyId? principalId)
        {
            CustomizationItemEntity result = null;

            FilterElementCollection filters = new FilterElementCollection();
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldXmlFullId, fullId));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldStructureType, (int)structureType));
            filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldCommandType, (int)commandType));

            // Filter by profile
            if (profileId.HasValue)
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldProfileId, profileId.Value));
            else
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldProfileId));

            // Filter by principal
            if (principalId.HasValue)
                filters.Add(FilterElement.EqualElement(CustomizationItemEntity.FieldPrincipalId, principalId.Value));
            else
                filters.Add(FilterElement.IsNullElement(CustomizationItemEntity.FieldPrincipalId));

            EntityObject[] items = BusinessManager.List(CustomizationItemEntity.ClassName, filters.ToArray());

            if (items != null && items.Length > 0)
            {
                result = items[0] as CustomizationItemEntity;
            }

            return result;
        }
Beispiel #49
0
        protected void btnDelete_Click(object sender, System.EventArgs e)
        {
            CalendarEventEntity ceo = BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;
            if (ceo != null)
            {
                FilterElementCollection fec = new FilterElementCollection();
                PrimaryKeyId realKey = ((VirtualEventId)EventId).RealEventId;
                FilterElement fe = FilterElement.EqualElement("EventId", realKey);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];
                    BusinessManager.Delete(cero);

                    Response.Redirect("~/Apps/MetaUIEntity/Pages/EntityView.aspx?ClassName=CalendarEvent&ObjectId=" + realKey.ToString());
                }
            }
        }
        private int BindAssignment()
        {
            int itemsCount = 0;

            if (AssignmentId != PrimaryKeyId.Empty)
            {
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(OwnerType, OwnerId));
                filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID));
                filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active));
                filters.Add(FilterElement.EqualElement("PrimaryKeyId", AssignmentId));

                EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray());
                if (assignments != null && assignments.Length > 0)
                {
                    AssignmentEntity assignment = (AssignmentEntity)assignments[0];

                    SavedPath = AssignmentEntity.GetControlPath(assignment);

                    MCDataBoundControl control = (MCDataBoundControl)LoadAssignment();
                    if (control != null)
                    {
                        control.DataItem = assignment;
                        control.DataBind();
                    }

                    itemsCount = 1;
                }
                else
                {
                    SavedPath = String.Empty;
                    MainPlaceHolder.Controls.Clear();
                    itemsCount = 0;
                }
            }

            return itemsCount;
        }
Beispiel #51
0
        private void BindValues()
        {
            CalendarEventEntity ceo = (CalendarEventEntity)DataItem;//BusinessManager.Load(CalendarEventEntity.ClassName, EventId) as CalendarEventEntity;
            if (ceo != null)
            {
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = FilterElement.EqualElement("EventId", EventId);
                fec.Add(fe);
                EntityObject[] list = BusinessManager.List(CalendarEventRecurrenceEntity.ClassName, fec.ToArray());
                if (list.Length > 0)
                {
                    CalendarEventRecurrenceEntity cero = (CalendarEventRecurrenceEntity)list[0];

                    lblNoRecurrence.Visible = false;
                    ShowRecurrence.Visible = true;
                    txtStartTime.Text = ceo.Start.ToShortTimeString();
                    txtEndTime.Text = ceo.End.ToShortTimeString();
                    Pattern = (byte)cero.RecurrenceType;
                    if (cero.RecurrenceType == (int)eRecurrenceType.RecursWeekly &&
                            cero.DayOfWeekMask.HasValue &&
                            cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays)
                        Pattern = (byte)eRecurrenceType.RecursDaily;

                    if (cero.Interval.HasValue)
                        Frequency = (byte)cero.Interval.Value;
                    if (cero.DayOfWeekMask.HasValue)
                        bWeekdays = (byte)cero.DayOfWeekMask;
                    if (cero.DayOfMonth.HasValue)
                        MonthDay = (byte)cero.DayOfMonth.Value;
                    if (cero.Instance.HasValue)
                        bWeekNumber = (byte)cero.Instance.Value;
                    if (cero.MonthOfYear.HasValue)
                        MonthNumber = (byte)cero.MonthOfYear.Value;

                    if (cero.Occurrences.HasValue)
                        EndAfter = cero.Occurrences.Value;

                    int pattern = Pattern;
                    if (Pattern == 1)
                        pattern = (cero.DayOfWeekMask.HasValue &&
                             cero.DayOfWeekMask.Value == (int)eBitDayOfWeek.Weekdays) ? 12 : 11;

                    Label lblControl = (Label)this.FindControl("txtInfo" + pattern);
                    if (lblControl != null)
                        lblControl.Visible = true;
                    if (EndAfter != 0)
                    {
                        lblEnd.Text = LocRM.GetString("Endafter") + ":";
                        txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences");
                    }
                    else if (cero.PatternEndDate.HasValue)
                    {
                        lblEnd.Text = LocRM.GetString("Endby") + ":";
                        txtEnd.Text = cero.PatternEndDate.Value.ToShortDateString();
                    }
                }
                else
                {
                    lblNoRecurrence.Text = "<br>&nbsp; " + LocRM.GetString("NotSet") + "<br>&nbsp;";
                    lblNoRecurrence.Visible = true;
                    ShowRecurrence.Visible = false;
                }
            }
        }
        /// <summary>
        /// Postcreate inside transaction.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void PostCreateInsideTransaction(BusinessContext context)
        {
            base.PostCreateInsideTransaction(context);

            int userId = (int)(PrimaryKeyId)context.Request.Target.Properties[CustomizationProfileUserEntity.FieldPrincipalId].Value;
            // New profile defines new Left Menu so we should empty cache.
            DataCache.RemoveByUser(userId.ToString());

            // Check WorkspacePersonalization flag in profile and clear user settings for dashboards if the value is False.
            CustomizationProfileUserEntity profileUserEntity = (CustomizationProfileUserEntity)context.Request.Target;
            PrimaryKeyId profileId = profileUserEntity.ProfileId;
            CustomizationProfileEntity profileEntity = (CustomizationProfileEntity)BusinessManager.Load(CustomizationProfileEntity.ClassName, profileId);
            if (!profileEntity.WorkspacePersonalization)
            {
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(CustomPageEntity.FieldUserId, userId));

                foreach (EntityObject page in BusinessManager.List(CustomPageEntity.ClassName, filters.ToArray()))
                    BusinessManager.Delete(page);
            }
        }
Beispiel #53
0
        private void ProcessCollection(DataTable dt, EntityObject[] assignments, WorkflowInstanceEntity wfEntity, int level)
        {
            level++;

            foreach (AssignmentEntity assignment in assignments)
            {
                DataRow row = dt.NewRow();
                row["AssignmentId"] = assignment.PrimaryKeyId.ToString();
                row["Subject"] = assignment.Subject;
                if (assignment.UserId.HasValue)
                    row["User"] = CommonHelper.GetUserStatus(assignment.UserId.Value);
                row["State"] = CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName("AssignmentState"), assignment.State));
                if (assignment.ExecutionResult.HasValue)
                    row["Result"] = assignment.ExecutionResult.Value;
                if (assignment.ActualFinishDate.HasValue)
                    row["FinishDate"] = String.Concat(assignment.ActualFinishDate.Value.ToShortDateString(), " ", assignment.ActualFinishDate.Value.ToShortTimeString());
                row["Comment"] = CHelper.ParseText(assignment.Comment, true, true, false);
                row["Indent"] = (level - 1) * indentSize;
                if (assignment.ClosedBy.HasValue)
                {
                    row["ClosedBy"] = CommonHelper.GetUserStatus(assignment.ClosedBy.Value);
                }
                dt.Rows.Add(row);

                // Filter:
                //	1: WorkflowInstanceId = wfEntity.PrimaryKeyId,
                //	2: ParentAssignmentId = assignment.PrimaryKeyId
                FilterElementCollection fec = new FilterElementCollection();
                fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value));
                fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldParentAssignmentId, assignment.PrimaryKeyId.Value));

                // Sorting
                SortingElementCollection sec = new SortingElementCollection();
                sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc));

                EntityObject[] children = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray());

                ProcessCollection(dt, children, wfEntity, level);
            }
        }
Beispiel #54
0
        private void BindDGContacts(string keyword)
        {
            FilterElement           fe  = CHelper.GetSearchFilterElementByKeyword(keyword, ContactEntity.GetAssignedMetaClassName());
            FilterElementCollection fec = new FilterElementCollection();

            fec.Add(fe);


            dgContacts.DataSource = BusinessManager.List(ContactEntity.GetAssignedMetaClassName(), fec.ToArray());
            dgContacts.DataBind();

            int RowCount = dgContacts.Items.Count;

            if (RowCount == 0)
            {
                Sep12.Visible = false;
                Pan12.Visible = false;
            }
            else
            {
                Sep12.Title = String.Format("{0} ({1})", LocRM.GetString("Contacts"), RowCount);
            }
        }
Beispiel #55
0
        public override void DataBind()
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add("AssignmentId", typeof(string));
            dt.Columns.Add("Subject", typeof(string));
            dt.Columns.Add("User", typeof(string));
            dt.Columns.Add("State", typeof(string));
            dt.Columns.Add("Result", typeof(int));
            dt.Columns.Add("FinishDate", typeof(string));
            dt.Columns.Add("Comment", typeof(string));
            dt.Columns.Add("Indent", typeof(int));
            dt.Columns.Add("ClosedBy", typeof(string));

            WorkflowInstanceEntity wfEntity = (WorkflowInstanceEntity)DataItem;

            // Filter:
            //	1: WorkflowInstanceId = wfEntity.PrimaryKeyId,
            //	2: ParentAssignmentId IS NULL (other elements we'll get via the recursion)
            FilterElementCollection fec = new FilterElementCollection();

            fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value));
            fec.Add(FilterElement.IsNullElement(AssignmentEntity.FieldParentAssignmentId));

            // Sorting
            SortingElementCollection sec = new SortingElementCollection();

            sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc));

            EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray());

            ProcessCollection(dt, assignments, wfEntity, 0);

            AssignmentList.DataSource = dt;
            AssignmentList.DataBind();

            if (dt.Rows.Count > 0)
            {
                AssignmentList.Visible     = true;
                NoAssignmentsLabel.Visible = false;
            }
            else
            {
                AssignmentList.Visible     = false;
                NoAssignmentsLabel.Visible = true;
                NoAssignmentsLabel.Text    = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NoAssignments").ToString();
            }
        }
Beispiel #56
0
        private void ProcessCollection(DataTable dt, EntityObject[] assignments, WorkflowInstanceEntity wfEntity, int level)
        {
            level++;

            foreach (AssignmentEntity assignment in assignments)
            {
                DataRow row = dt.NewRow();
                row["AssignmentId"] = assignment.PrimaryKeyId.ToString();
                row["Subject"]      = assignment.Subject;
                if (assignment.UserId.HasValue)
                {
                    row["User"] = CommonHelper.GetUserStatus(assignment.UserId.Value);
                }
                row["State"] = CHelper.GetResFileString(MetaEnum.GetFriendlyName(MetaDataWrapper.GetEnumByName("AssignmentState"), assignment.State));
                if (assignment.ExecutionResult.HasValue)
                {
                    row["Result"] = assignment.ExecutionResult.Value;
                }
                if (assignment.ActualFinishDate.HasValue)
                {
                    row["FinishDate"] = String.Concat(assignment.ActualFinishDate.Value.ToShortDateString(), " ", assignment.ActualFinishDate.Value.ToShortTimeString());
                }
                row["Comment"] = CHelper.ParseText(assignment.Comment, true, true, false);
                row["Indent"]  = (level - 1) * indentSize;
                if (assignment.ClosedBy.HasValue)
                {
                    row["ClosedBy"] = CommonHelper.GetUserStatus(assignment.ClosedBy.Value);
                }
                dt.Rows.Add(row);

                // Filter:
                //	1: WorkflowInstanceId = wfEntity.PrimaryKeyId,
                //	2: ParentAssignmentId = assignment.PrimaryKeyId
                FilterElementCollection fec = new FilterElementCollection();
                fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldWorkflowInstanceId, wfEntity.PrimaryKeyId.Value));
                fec.Add(FilterElement.EqualElement(AssignmentEntity.FieldParentAssignmentId, assignment.PrimaryKeyId.Value));

                // Sorting
                SortingElementCollection sec = new SortingElementCollection();
                sec.Add(new SortingElement(AssignmentEntity.FieldCreated, SortingElementType.Asc));

                EntityObject[] children = BusinessManager.List(AssignmentEntity.ClassName, fec.ToArray(), sec.ToArray());

                ProcessCollection(dt, children, wfEntity, level);
            }
        }
Beispiel #57
0
        /// <summary>
        /// Возвращает список событий как виртуальных так и реальных.
        /// </summary>
        /// <param name="filterColl">The filter coll.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        private static IEnumerable<CalendarEventEntity> ListEvents(FilterElementCollection filterColl, CalendarEventListRequest request)
        {
            McEvent mcEvent = null;
            //Конструируем стандартный запрос LIST без критериев содержащих дату начала и конца события
            ListRequest moListRequest = (ListRequest)EventHelper.ConstructRequest<ListRequest>(request.Target, true);
            moListRequest.Filters = filterColl.ToArray();
            moListRequest.Sorting = request.Sorting;
            //выполняем стандартный запрос
            ListResponse listResp = (ListResponse)BusinessManager.Execute(moListRequest);

            if (listResp != null && listResp.EntityObjects != null)
            {
                //Пробегаем по реальным events
                foreach (CalendarEventEntity entity in listResp.EntityObjects)
                {
                    mcEvent = EventHelper.LoadCalEvent(entity.PrimaryKeyId.Value);
                    if (mcEvent.IsReccuring)
                    {
                        iCalDateTime dtReccurBase = mcEvent.DTStart;
                        //Пробегаем по виртуальным events
                        foreach (Occurrence occur in mcEvent.GetOccurrences(mcEvent.DTStart, mcEvent.RecurrenceSeriesEndDate))
                        {
                            //Создаем виртуальные события
                            VirtualEventId vEventId = (VirtualEventId)entity.PrimaryKeyId;
                            vEventId.RecurrenceId = EventHelper.iCalDateTime2Recurrence(dtReccurBase, occur.Period.StartTime);
                            //Set virtual id
                            mcEvent.UID = vEventId.ToString();
                            //Set recurrence-ID
                            mcEvent.Recurrence_ID = occur.Period.StartTime;
                            mcEvent.DTStart = occur.Period.StartTime;
                            mcEvent.DTEnd = occur.Period.EndTime;
                            EntityObjectHierarchy recurrenceEntity = EventHelper.ConstructEntityHierarchy(mcEvent);
                            CalendarEventEntity occurEventEntity = recurrenceEntity.InnerEntity as CalendarEventEntity;
                            if (occurEventEntity != null)
                            {
                                yield return occurEventEntity;
                            }
                        }
                    }
                    else
                    {
                        yield return entity;
                    }
                }
            }
        }