Ejemplo n.º 1
0
        public FilterElement Add(object value, FilterOperation operation)
        {
            FilterElement element = new FilterElement(value, operation);

            elements.Add(element);
            return(element);
        }
Ejemplo n.º 2
0
		protected override void PreListInsideTransaction(BusinessContext context)
		{
			base.PreListInsideTransaction(context);

			// OZ 2008-11-11 Fix Contact view for ibn partners
			ListRequest request = (ListRequest)context.Request;

			Guid orgUid, contactUid;

			// Check  

			if (PartnerUtil.GetClientInfo((int)DataContext.Current.CurrentUserId, out orgUid, out contactUid))
			{
				List<FilterElement> filters = new List<FilterElement>(request.Filters);

				// if (OrgUid!=null)   -> View all Contacts with OrgUid only 
				if (orgUid != Guid.Empty)
				{
					filters.Add(FilterElement.EqualElement("OrganizationId", orgUid));
				}
				// if (ContactUid!=null)   -> View Contact with ContactUid only 
				else if (contactUid != Guid.Empty)
				{
					filters.Add(FilterElement.EqualElement("PrimaryKeyId", contactUid));
				}
				// Nothing show
				else
				{
					filters.Add(FilterElement.IsNullElement("PrimaryKeyId"));
				}

				request.Filters = filters.ToArray();
			}
			//
		}
Ejemplo n.º 3
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            DateTime startDate     = DateTime.Parse(Request["uid"], CultureInfo.InvariantCulture);
            DateTime destStartDate = CHelper.GetWeekStartByDate(DTCWeek.SelectedDate);

            if (startDate.Date != destStartDate.Date)
            {
                TimeTrackingEntry[] mas      = TimeTrackingEntry.List(FilterElement.EqualElement("OwnerId", Mediachase.IBN.Business.Security.CurrentUser.UserID), FilterElement.EqualElement("StartDate", startDate));
                List <int>          entryIds = new List <int>();
                foreach (TimeTrackingEntry tte in mas)
                {
                    entryIds.Add((int)tte.PrimaryKeyId.Value);
                }
                if (entryIds.Count > 0)
                {
                    TimeTrackingManager.AddEntries(destStartDate, Mediachase.IBN.Business.Security.CurrentUser.UserID, entryIds);
                }
            }


            // Refresh parent window
            CommandParameters cp = new CommandParameters("MC_TT_CloneWeek");

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
        }
Ejemplo n.º 4
0
        private void BindDataGrid(bool dataBind)
        {
            _isFilterSet = false;
            _filterText  = String.Empty;

            //добавляем к фильтру выбраное значение из левой панели, если включена группировка
            #region GroupItem
            if (_isGroupSet)
            {
                string groupCurrent = lvp.GroupByFieldName;
                if (!String.IsNullOrEmpty(groupCurrent) && mc.Fields.Contains(groupCurrent) && groupList.Items.Count > 0 && groupList.SelectedValue != null)
                {
                    FilterElementCollection fec = new FilterElementCollection();
                    fec.Add(FilterElement.EqualElement(groupCurrent, groupList.SelectedValue));
                    grdMain.AddFilters = fec;
                }
            }
            #endregion

            grdMain.SearchKeyword = txtSearch.Text;

            if (dataBind)
            {
                grdMain.DataBind();
            }
        }
Ejemplo n.º 5
0
        private Closeness ComputeCloseness(FilterElement filterElement, DecodedEventWrapper etwEvent)
        {
            if (null == filterElement.TaskName)
            {
                // If the task name for this filter is a wildcard, the event name
                // should also be a wildcard because we don't support filters of
                // the format '*.<eventType>'. This means we have a wildcard match.
                System.Fabric.Interop.Utility.ReleaseAssert(null == filterElement.EventType, StringResources.DCAError_EventNameNotAWildcard);
                return(Closeness.TaskWildcardEventWildcardMatch);
            }

            if (false == filterElement.TaskName.Equals(etwEvent.TaskName))
            {
                // If the task name for this filter does not match the event's
                // task name, then we have no match.
                return(Closeness.NoMatch);
            }

            if (null == filterElement.EventType)
            {
                // If the event name for this filter is a wildcard, we have a
                // task name, event wildcard match.
                return(Closeness.TaskNameEventWildcardMatch);
            }

            if (false == filterElement.EventType.Equals(etwEvent.EventType))
            {
                // If the event name for this filter does not match the event's
                // event name, then we have no match.
                return(Closeness.NoMatch);
            }

            // If we get here, it means that both task name and event name match
            return(Closeness.TaskNameEventTypeMatch);
        }
Ejemplo n.º 6
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();
        }
Ejemplo n.º 7
0
 public static EntityObject[] GetCustomerGiftCards(PrimaryKeyId contactId)
 {
     return(BusinessManager.List(GiftCardMetaClass, new[]
     {
         FilterElement.EqualElement(ContactIdField, contactId)
     }));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Adds a filter to the group.
        /// </summary>
        /// <param name="filterType">Type of filter.</param>
        /// <param name="expression">Filter expression.</param>
        public void Filter(FilterType filterType, LambdaExpression expression)
        {
            IEnumerable <Declaration> references = expression.Parameters.Select <ParameterExpression, Declaration>(p => Scope.Lookup(p.Name, p.Type));
            var filter = new FilterElement(filterType, Scope.VisibleDeclarations, references, expression);

            _filters.Add(filter);
        }
Ejemplo n.º 9
0
        public void TestFilter()
        {
            string        filter  = "Šokolado";
            FilterElement element = new FilterElement(driver).Open().AcceptCookies().ChooseFilter(filter).ChooseProduct(0);

            Assert.IsTrue(element.SelectIncludes(filter));
        }
Ejemplo n.º 10
0
        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()));
            }
        }
Ejemplo n.º 11
0
        static void CleanUpProvider(KnowledgeSyncProvider provider)
        {
            AppointmentSyncProvider   outlookProvider = provider as AppointmentSyncProvider;
            CalendarEventSyncProvider ibnProvider     = provider as CalendarEventSyncProvider;

            if (outlookProvider != null)
            {
                // Remove the data store file
                string metafile = outlookProvider.CurrentSetting.CurrentSyncAppSetting.metaDataFileName;
                if (System.IO.File.Exists(metafile))
                {
                    System.IO.File.Delete(metafile);
                }
            }
            else if (ibnProvider != null)
            {
                FilterElement filterEl = new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal, ibnProvider.ReplicaId.GetGuidId());
                foreach (SynchronizationMetadataRow row in SynchronizationMetadataRow.List(filterEl))
                {
                    BusinessManager.Delete(new CalendarEventEntity((PrimaryKeyId)row.Uri));

                    row.Delete();
                }
                SynchronizationReplicaRow.Delete(ibnProvider.ReplicaId.GetGuidId());
            }
        }
Ejemplo n.º 12
0
        internal void SaveTo(FiltersSection section)
        {
            FilterCollection filterCollection = section.Filters;

            filterCollection.Clear();
            foreach (IFilter filter in list)
            {
                Type          filterType    = filter.GetType();
                FilterElement filterElement = new FilterElement();
                filterElement.Name = filterType.Name;
                filterElement.Type = filterType;
                filterCollection.Add(filterElement);

                foreach (PropertyInfo propertyInfo in filterType.GetProperties())
                {
                    if (propertyInfo.Name != "LastResult")
                    {
                        FilterParameterElement parameter = new FilterParameterElement();
                        parameter.Name = propertyInfo.Name;

                        object propertyValue = propertyInfo.GetValue(filter, null);
                        parameter.Type = propertyValue.GetType();

                        TypeConverter converter = TypeDescriptor.GetConverter(propertyValue);
                        parameter.Value = converter.ConvertToString(propertyValue);

                        filterElement.Parameters.Add(parameter);
                    }
                }
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the week items for user.
        /// </summary>
        /// <param name="from">From.</param>
        /// <param name="to">To.</param>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public static WeekItemInfo[] GetWeekItemsForUser(DateTime from, DateTime to, int userId)
        {
            List <WeekItemInfo> retVal = new List <WeekItemInfo>();

            // Load User TT blocks
            TimeTrackingBlock[] userBlocks = TimeTrackingBlock.List(FilterElement.EqualElement("OwnerId", userId),
                                                                    new IntervalFilterElement("StartDate", from, to));

            // Sort Block By Start Date
            Array.Sort <TimeTrackingBlock>(userBlocks, CompareTimeTrackingBlockByStartDate);

            // Create Week Item Info list
            DateTime currentWeekStart = GetRealWeekStart(from);

            // TODO: Current
            while (currentWeekStart < to)
            {
                // Calculate aggregated status of all blocks
                WeekItemStatus status = CalculateWeekStatusByBlocks(currentWeekStart, userBlocks);

                WeekItemInfo item = new WeekItemInfo(currentWeekStart,
                                                     Iso8601WeekNumber.GetWeekNumber(currentWeekStart.AddDays(3)),
                                                     status);

                CalculateDayTotal(currentWeekStart, item, userBlocks);

                retVal.Add(item);

                // Go to next week
                currentWeekStart = currentWeekStart.AddDays(7);
            }

            return(retVal.ToArray());
        }
Ejemplo n.º 14
0
        private void BindDataGrid(bool dataBind)
        {
            grdMain.SearchKeyword = tbSearchString.Text.Trim();

            DataTable dt = ((DataTable)ViewState["Resources"]).Copy();
            FilterElementCollection fec = new FilterElementCollection();

            foreach (DataRow dr in dt.Rows)
            {
                string[] elem = dr["Id"].ToString().Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
                if (elem[1] != "0")
                {
                    MetaClass mcEl = MetaDataWrapper.GetMetaClassByName(elem[1]);
                    if (mcEl.IsCard)
                    {
                        elem[1] = mcEl.CardOwner.Name;
                    }
                }
                if (elem[1] == ddFilter.SelectedValue)
                {
                    MetaClass     mc = MetaDataWrapper.GetMetaClassByName(ddFilter.SelectedValue);
                    FilterElement fe = FilterElement.NotEqualElement(
                        SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name,
                        PrimaryKeyId.Parse(elem[0]));
                    fec.Add(fe);
                }
            }
            grdMain.AddFilters = fec;

            if (dataBind)
            {
                grdMain.DataBind();
            }
        }
Ejemplo n.º 15
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters   cp        = (CommandParameters)Element;
                DateTime            startDate = DateTime.Parse(cp.CommandArguments["primaryKeyId"], CultureInfo.InvariantCulture);
                TimeTrackingBlock[] mas       = TimeTrackingBlock.List(FilterElement.EqualElement("OwnerId", Mediachase.IBN.Business.Security.CurrentUser.UserID), FilterElement.EqualElement("StartDate", startDate));

                using (TransactionScope tran = DataContext.Current.BeginTransaction())
                {
                    foreach (TimeTrackingBlock ttb in mas)
                    {
                        StateMachineService sms = ((BusinessObject)ttb).GetService <StateMachineService>();

                        // process only initial state
                        if (sms.StateMachine.GetStateIndex(sms.CurrentState.Name) == 0)
                        {
                            StateTransition[] availableTransitions = sms.GetNextAvailableTransitions(true);
                            if (availableTransitions.Length > 0)
                            {
                                sms.MakeTransition(availableTransitions[0].Uid);
                                ttb.Save();
                            }
                        }
                    }
                    tran.Commit();
                }

                CHelper.RequireBindGrid();
            }
        }
        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);
        }
Ejemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_classes.Count <= 0)
            {
                throw new Exception("Classes is required!");
            }

            ddFilter.SelectedIndexChanged += new EventHandler(ddFilter_SelectedIndexChanged);

            if (!IsPostBack)
            {
                BindDropDowns();

                btnNew.Visible    = _isCanCreate;
                tblSelect.Visible = true;
                tblNew.Visible    = false;
            }

            grdMain.ClassName      = ddFilter.SelectedValue;
            grdMain.ViewName       = "";
            grdMain.PlaceName      = _placeName;
            grdMain.ProfileName    = ProfileName;
            grdMain.ShowCheckboxes = _isMultipleSelect;

            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);
            }

            if (TreeServiceTargetObjectId != PrimaryKeyId.Empty)
            {
                FilterElement fe = new FilterElement(Mediachase.Ibn.Data.Services.TreeService.OutlineNumberFieldName, FilterElementType.NotContains, TreeServiceTargetObjectId.ToString().ToLower());
                fec.Add(fe);
            }
            grdMain.AddFilters = fec;

            ctrlGridEventUpdater.ClassName      = ddFilter.SelectedValue;
            ctrlGridEventUpdater.ViewName       = "";
            ctrlGridEventUpdater.PlaceName      = _placeName;
            ctrlGridEventUpdater.GridId         = grdMain.GridClientContainerId;
            ctrlGridEventUpdater.GridActionMode = Mediachase.UI.Web.Apps.MetaUI.Grid.MetaGridServerEventAction.Mode.ListViewUI;

            //ddFilter.Visible = (_classes.Count > 1);

            BindDataGrid(!Page.IsPostBack);

            BindButtons();
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the email delivery provider filters.
        /// </summary>
        /// <returns></returns>
        internal static FilterElement[] CreateIbnClientMessageDeliveryProviderFilters()
        {
            List <FilterElement> retVal = new List <FilterElement>();

            retVal.Add(FilterElement.IsNotNullElement(OutgoingMessageQueueEntity.FieldIbnClientMessageId));
            retVal.Add(FilterElement.EqualElement(OutgoingMessageQueueEntity.FieldIsDelivered, false));

            retVal.Add(new FilterElement("", FilterElementType.Custom,
                                         "[t01].[Modified] < (DATEADD(mi,-(CASE WHEN [t01].[DeliveryAttempts]>5 THEN 30 ELSE [t01].[DeliveryAttempts]*5 END),getutcdate()))"));

            // Check Delivery Constrains Max Delivery Attempts
            if (PortalConfig.MdsMaxDeliveryAttempts > 0)
            {
                retVal.Add(new FilterElement(OutgoingMessageQueueEntity.FieldDeliveryAttempts,
                                             FilterElementType.LessOrEqual,
                                             PortalConfig.MdsMaxDeliveryAttempts));
            }

            // Check Delivery Constrains Delivery Timeout
            if (PortalConfig.MdsDeliveryTimeout > 0)
            {
                retVal.Add(new FilterElement(OutgoingMessageQueueEntity.FieldCreated,
                                             FilterElementType.GreaterOrEqual,
                                             DateTime.UtcNow.AddMinutes(-1 * PortalConfig.MdsDeliveryTimeout)));
            }

            return(retVal.ToArray());
        }
Ejemplo n.º 20
0
        public static bool DebitGiftCard(string giftCardMetaClass, PrimaryKeyId contactId, string redemtionCode, decimal debitAmount)
        {
            var cards = BusinessManager.List(giftCardMetaClass,
                                             new FilterElement[]
            {
                FilterElement.EqualElement("ContactId", contactId),
                FilterElement.EqualElement("IsActive", true),
                FilterElement.EqualElement("RedemtionCode", redemtionCode)
            });

            if (cards == null || cards.Count() == 0)
            {
                return(false);
            }
            var card = cards[0];

            if ((decimal)card["Balance"] < debitAmount)
            {
                return(false);
            }
            decimal newBalance = (decimal)card["Balance"] - debitAmount;

            card["Balance"] = newBalance;
            if (newBalance == 0)
            {
                card["IsActive"] = false;
            }
            BusinessManager.Update(card);

            return(true);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Gets the element by path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        public static FolderElement[] GetElementsByPath(string path)
        {
            FolderElement[] retVal = null;
            char            delim  = '/';

            string[] folderParts = path.Split(new char[] { delim });

            //Incorrect path
            if (folderParts.Length == 0)
            {
                return(retVal);
            }

            string rootFolderName = folderParts[0];

            FilterElement filter =
                new FilterElement("Name", FilterElementType.Equal, rootFolderName);

            Folder[] folders = Folder.List(filter);
            if (folders.Length != 0)
            {
                Folder rootFolder = folders[0];
                rootFolder = FindFolderByPattern(rootFolder, rootFolder.Name, delim,
                                                 String.Join(delim.ToString(), folderParts));
                if (rootFolder != null)
                {
                    FilterElement filterElem =
                        new FilterElement("ParentId", FilterElementType.Equal,
                                          rootFolder.PrimaryKeyId.Value);
                    retVal = FolderElement.List(filterElem);
                }
            }

            return(retVal);
        }
Ejemplo n.º 22
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);
                }
            }
        }
 private static IList <string> CreateDocumentTypeList(FilterElement filterElement)
 {
     return(filterElement.DocumentTypes
            .OfType <DocumentTypeElement>()
            .Select(configDocumentType => configDocumentType.Alias)
            .ToList());
 }
Ejemplo n.º 24
0
        public static IEnumerable <ItemMetadataAdaptor> GetAllMetadataItems(SyncId replicaId)
        {
            FilterElement filterEl = new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal,
                                                       replicaId.GetGuidId());

            return(SynchronizationMetadataRow.List(filterEl).Select(x => new ItemMetadataAdaptor(x)));
        }
Ejemplo n.º 25
0
 internal FilterData(LocationData parent, FilterElement element)
     : this(parent)
 {
     Property        = element.Property;
     MatchExpression = element.MatchExpression;
     Enabled         = element.Enabled;
 }
Ejemplo n.º 26
0
        /// <summary>
        /// Add a new filter element to the filter
        /// </summary>
        /// <param name="filterText"></param>
        public void Add(string filterText)
        {
            // First, make sure the new filter is not redundant
            foreach (var filter in _filters)
            {
                if (filter.Text == filterText)
                {
                    return;
                }

                if (filterText.StartsWith(filter.Text + "."))
                {
                    return;
                }
            }

            var newFilter = new FilterElement(filterText);

            // Check to see if it makes any of the existing
            // filter elements redundant.
            for (int index = _filters.Count - 1; index >= 0; index--)
            {
                if (_filters[index].Text.StartsWith(filterText + "."))
                {
                    _filters.RemoveAt(index);
                }
            }

            _filters.Add(new FilterElement(filterText));
        }
Ejemplo n.º 27
0
        private FilterElementCollection GetFilters()
        {
            FilterElementCollection coll = new FilterElementCollection();

            if (!String.IsNullOrEmpty(ClassName))
            {
                if (ObjectId == null)
                {
                    throw new ArgumentNullException("QueryString:ObjectId");
                }

                //Profile level
                if (String.Compare(ClassName, CustomizationProfileEntity.ClassName, true) == 0)
                {
                    // ProfileId is null OR ProfileId = value
                    OrBlockFilterElement orBlock = new OrBlockFilterElement();
                    orBlock.ChildElements.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                    orBlock.ChildElements.Add(FilterElement.EqualElement(CustomPageEntity.FieldProfileId, ObjectId));

                    coll.Add(orBlock);
                    coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
                }

                //User level
                if (String.Compare(ClassName, "Principal", true) == 0)
                {
                    int profileId = ProfileManager.GetProfileIdByUser();

                    // 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));
                    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, ObjectId));

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

                    coll.Add(orBlock);
                }
            }
            else
            {
                //Site level
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldProfileId));
                coll.Add(FilterElement.IsNullElement(CustomPageEntity.FieldUserId));
            }
            return(coll);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates the security filter element, that check security from TimeTrackingBlock
        /// </summary>
        /// <returns></returns>
        public static FilterElement CreateSecurityFilterElement()
        {
            FilterElement retVal = new FilterElement("ParentBlockId", FilterElementType.In, "{TimeTrackingSecurity:CanRead}", true);

            retVal.Uid = new Guid(SecurityFilterId);

            return retVal;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Removes all workflow participants.
 /// </summary>
 /// <param name="workflowInstanceId">The workflow instance id.</param>
 private void RemoveAllWorkflowParticipants(Guid workflowInstanceId)
 {
     WorkflowParticipantRow[] oldParticipants = WorkflowParticipantRow.List(FilterElement.EqualElement(WorkflowParticipantRow.ColumnWorkflowInstanceId, workflowInstanceId));
     foreach (WorkflowParticipantRow oldParticipant in oldParticipants)
     {
         oldParticipant.Delete();
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Creates the security filter element, that check security from TimeTrackingBlock
        /// </summary>
        /// <returns></returns>
        public static FilterElement CreateSecurityFilterElement()
        {
            FilterElement retVal = new FilterElement("ParentBlockId", FilterElementType.In, "{TimeTrackingSecurity:CanRead}", true);

            retVal.Uid = new Guid(SecurityFilterId);

            return(retVal);
        }
Ejemplo n.º 31
0
        public List <StavEntityView> GetListNaslStavEntity(int idStavEntity)
        {
            var filter = new Filter("C_StavEntity_Id_Parent", idStavEntity);
            List <NasledovnyStavEntity> naslStavy = this.GetList <NasledovnyStavEntity>(filter);

            filter = new Filter(FilterElement.In("C_StavEntity_Id", naslStavy.Select(nav => nav.C_StavEntity_Id_Child)));
            return(this.GetList <StavEntityView>(filter));
        }
Ejemplo n.º 32
0
        /// <summary>
        /// Lists the specified folder id.
        /// </summary>
        /// <param name="folderId">The folder id.</param>
        /// <returns></returns>
        public static ListInfo[] List(int folderId)
        {
            FilterElement listSequrityFilterElement = new FilterElement(
                "ListInfoId",
                FilterElementType.In,
                new SelectCommandBuilderParameter("SELECT ListId FROM LISTINFO_SECURITY_ALL WHERE PrincipalId = @UserId AND AllowLevel >= 1", SqlHelper.SqlParameter("@UserId", SqlDbType.Int, Security.CurrentUserId)));

            return List(FilterElement.EqualElement("FolderId", folderId), listSequrityFilterElement);
        }
        public override void DataBind()
        {
            CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName);
            CHelper.AddToContext(_httpContextClassNameKey, ClassName);
            CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName);
            CHelper.AddToContext(_httpContextFilter1FieldValueKey, ObjectId);
            CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName);

            MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            grdMain.ClassName = ClassName;
            grdMain.ViewName = ViewName;
            grdMain.PlaceName = PlaceName;
            grdMain.ProfileName = ProfileName;
            grdMain.ShowCheckboxes = (ObjectId > 0);

            MetaClass bridgeClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName);
            string pkName = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name;
            string bridgeTableName = bridgeClass.DataSource.PrimaryTable;
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement fe;

            if (ObjectId < 0)	// default profile
            {
                fe = new FilterElement(pkName, FilterElementType.In,
                    String.Format("(SELECT [{0}] FROM cls_Principal WHERE Card = 'User' AND Activity = 3 AND [{0}] NOT IN (SELECT [{0}] FROM [{1}]))",
                        Filter2FieldName, bridgeTableName));
            }
            else
            {
                fe = new FilterElement(pkName, FilterElementType.In,
                    String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]={3})",
                        Filter2FieldName, bridgeTableName, Filter1FieldName, ObjectId));
            }
            fec.Add(fe);
            grdMain.AddFilters = fec;
            grdMain.DataBind();

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName = ViewName;
            ctrlGridEventUpdater.PlaceName = PlaceName;
            ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId;

            MainMetaToolbar.ClassName = ClassName;
            MainMetaToolbar.ViewName = ViewName;
            MainMetaToolbar.PlaceName = PlaceName;
            MainMetaToolbar.DataBind();
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Evals the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="elements">The elements.</param>
        /// <returns></returns>
        public static bool Eval(EntityObject source, FilterElement[] elements)
        {
            if (source == null)
                throw new ArgumentNullException("source");

            if (elements == null)
                return true;

            foreach (FilterElement element in elements)
            {
                if (!Eval(source, element))
                    return false;
            }

            return true;
        }
Ejemplo n.º 35
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");
                    }
                }

            }
        }
Ejemplo n.º 36
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();
        }
Ejemplo n.º 37
0
 private void AddGridFilterAttributes(FilterElement filterElement, Transaction trn, TransactionLevel level)
 {
     // Currently only the description attribute is added.
     if (level.DescriptionAttribute != null)
         AddFilterAttribute(filterElement, trn.Model, level.DescriptionAttribute.Name, BuildCaption(settings.Labels.FilterCaption,level.DescriptionAttribute,level.DescriptionAttribute.Attribute.ContextualTitleProperty), null, String.Empty);
 }
Ejemplo n.º 38
0
        static void CleanUpProvider(KnowledgeSyncProvider provider)
        {
            AppointmentSyncProvider outlookProvider = provider as AppointmentSyncProvider;
            CalendarEventSyncProvider ibnProvider = provider as CalendarEventSyncProvider;
            if (outlookProvider != null)
            {
                // Remove the data store file
                string metafile = outlookProvider.CurrentSetting.CurrentSyncAppSetting.metaDataFileName;
                if (System.IO.File.Exists(metafile))
                {
                    System.IO.File.Delete(metafile);
                }
            }
            else if (ibnProvider != null)
            {
                FilterElement filterEl = new FilterElement(SynchronizationMetadataRow.ColumnReplicaId, FilterElementType.Equal, ibnProvider.ReplicaId.GetGuidId());
                foreach (SynchronizationMetadataRow row in SynchronizationMetadataRow.List(filterEl))
                {
                    BusinessManager.Delete(new CalendarEventEntity((PrimaryKeyId)row.Uri));

                    row.Delete();
                }
                SynchronizationReplicaRow.Delete(ibnProvider.ReplicaId.GetGuidId());
            }
        }
Ejemplo n.º 39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (_classes.Count <= 0)
                throw new Exception("Classes is required!");

            ddFilter.SelectedIndexChanged += new EventHandler(ddFilter_SelectedIndexChanged);

            if (!IsPostBack)
            {
                BindDropDowns();

                btnNew.Visible = _isCanCreate;
                tblSelect.Visible = true;
                tblNew.Visible = false;
            }

            grdMain.ClassName = ddFilter.SelectedValue;
            grdMain.ViewName = "";
            grdMain.PlaceName = _placeName;
            grdMain.ProfileName = ProfileName;
            grdMain.ShowCheckboxes = _isMultipleSelect;

            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);
            }

            if (TreeServiceTargetObjectId != PrimaryKeyId.Empty)
            {
                FilterElement fe = new FilterElement(Mediachase.Ibn.Data.Services.TreeService.OutlineNumberFieldName, FilterElementType.NotContains, TreeServiceTargetObjectId.ToString().ToLower());
                fec.Add(fe);
            }
            grdMain.AddFilters = fec;

            ctrlGridEventUpdater.ClassName = ddFilter.SelectedValue;
            ctrlGridEventUpdater.ViewName = "";
            ctrlGridEventUpdater.PlaceName = _placeName;
            ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId;
            ctrlGridEventUpdater.GridActionMode = Mediachase.UI.Web.Apps.MetaUI.Grid.MetaGridServerEventAction.Mode.ListViewUI;

            //ddFilter.Visible = (_classes.Count > 1);

            BindDataGrid(!Page.IsPostBack);

            BindButtons();
        }
Ejemplo n.º 40
0
 public CalendarEventListRequest(EntityObject target, FilterElement[] filters)
     : base(CalendarEventListMethod.METHOD_NAME, target)
 {
     this.Filters = filters;
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Evals the specified source.
        /// </summary>
        /// <param name="source">The source.</param>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public static bool Eval(EntityObject source, FilterElement element)
        {
            if (source == null)
                throw new ArgumentNullException("source");
            if (element == null)
                throw new ArgumentNullException("element");

            switch (element.Type)
            {
                case FilterElementType.Abstract:
                    throw new NotSupportedException();

                case FilterElementType.Exists:
                    throw new NotSupportedException();
                case FilterElementType.NotExists:
                    throw new NotSupportedException();
                case FilterElementType.In:
                    throw new NotSupportedException();
                case FilterElementType.NotIn:
                    throw new NotSupportedException();

                case FilterElementType.AndBlock:
                    {
                        foreach (FilterElement childElement in element.ChildElements)
                        {
                            if (!Eval(source, childElement))
                                return false;
                        }
                        return true;
                    }
                case FilterElementType.OrBlock:
                    {
                        foreach (FilterElement childElement in element.ChildElements)
                        {
                            if (Eval(source, childElement))
                                return true;
                        }
                        return false;
                    }
                case FilterElementType.Between:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);

                        object start = element.ChildElements[0].Value;
                        object end = element.ChildElements[1].Value;

                        int result1 = Compare(start, propertyValue);
                        int result2 = Compare(propertyValue, end);

                        return result1 <= 0 && result2<= 0;
                    }
                case FilterElementType.Contains:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask==null)
                            return false;

                        return propertyValue.IndexOf(mask, StringComparison.OrdinalIgnoreCase)!=-1;
                    }
                case FilterElementType.NotContains:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        return !(propertyValue.IndexOf(mask, StringComparison.OrdinalIgnoreCase) != -1);
                    }
                case FilterElementType.Custom:
                    throw new NotSupportedException();
                case FilterElementType.EndsWith:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        return propertyValue.EndsWith(mask, StringComparison.OrdinalIgnoreCase);
                    }
                case FilterElementType.NotEndsWith:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        return !propertyValue.EndsWith(mask, StringComparison.OrdinalIgnoreCase);
                    }
                case FilterElementType.StartsWith:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        return propertyValue.StartsWith(mask, StringComparison.OrdinalIgnoreCase);
                    }
                case FilterElementType.NotStartsWith:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        return !propertyValue.StartsWith(mask, StringComparison.OrdinalIgnoreCase);
                    }

                case FilterElementType.Equal:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) == 0;
                    }
                case FilterElementType.NotEqual:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) != 0;
                    }
                case FilterElementType.Greater:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) > 0;
                    }
                case FilterElementType.GreaterOrEqual:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) >= 0;
                    }
                case FilterElementType.IsNotNull:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        return propertyValue!=null;
                    }
                case FilterElementType.IsNull:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        return propertyValue == null;
                    }
                case FilterElementType.Less:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) < 0;
                    }
                case FilterElementType.LessOrEqual:
                    {
                        object propertyValue = GetPropertyValue(source, element.Source);
                        object srcValue = element.Value;

                        return Compare(propertyValue, srcValue) <= 0;
                    }
                case FilterElementType.Like:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        // TODO: Support % Only
                        mask = mask.Replace('%', '*');

                        return WildcardUtil.PatternMatch(propertyValue, mask);
                    }
                case FilterElementType.NotLike:
                    {
                        string propertyValue = (string)GetPropertyValue(source, element.Source);
                        string mask = (string)element.Value;

                        if (propertyValue == null || mask == null)
                            return false;

                        // TODO: Support % Only
                        mask = mask.Replace('%', '*');

                        return !WildcardUtil.PatternMatch(propertyValue, mask);
                    }
            }

            throw new NotSupportedException();
        }
Ejemplo n.º 42
0
        /// <summary>
        /// Loads the entity objects from disk.
        /// </summary>
        /// <param name="metaClass">The meta class.</param>
        /// <returns></returns>
        private EntityObject[] LoadEntityObjects(string metaClass, FilterElement[] filters)
        {
            if (metaClass == null)
                throw new ArgumentNullException("metaClass");

            List<EntityObject> retVal = new List<EntityObject>();

            foreach (EntityObject item in LoadEntityObjects(metaClass))
            {
                if (InMemoryFilterElementEvaluator.Eval(item, filters))
                {
                    retVal.Add(item);
                }
            }

            return retVal.ToArray();
        }
Ejemplo n.º 43
0
 public CalendarEventListRequest(EntityObject target, FilterElement[] filters, SortingElement[] sorting)
     : base(CalendarEventListMethod.METHOD_NAME, target)
 {
     this.Filters = filters;
     this.Sorting = sorting;
 }
Ejemplo n.º 44
0
        public override void DataBind()
        {
            CHelper.AddToContext(_httpContextBridgeClassNameKey, BridgeClassName);
            CHelper.AddToContext(_httpContextClassNameKey, ClassName);
            CHelper.AddToContext(_httpContextFilter1FieldNameKey, Filter1FieldName);
            CHelper.AddToContext(_httpContextFilter1FieldValueKey, Request["ObjectId"]);
            CHelper.AddToContext(_httpContextFilter2FieldNameKey, Filter2FieldName);

            MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(ClassName);

            if (String.IsNullOrEmpty(ProfileName))
            {
                ListViewProfile[] list = ListViewProfile.GetSystemProfiles(ClassName, PlaceName);
                if (list.Length == 0)
                {
                    list = ListViewProfile.GetSystemProfiles(ClassName, "EntityList");
                    if (list.Length == 0)
                    {
                        list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        if (list.Length == 0)
                        {
                            ListViewProfile lvp = new ListViewProfile();
                            lvp.Id = Guid.NewGuid().ToString();
                            lvp.IsPublic = true;
                            lvp.IsSystem = true;
                            lvp.Name = CHelper.GetResFileString(mc.FriendlyName);
                            lvp.ColumnsUI.Add(new ColumnProperties(mc.TitleFieldName, "150px", String.Empty));
                            lvp.FieldSet.Add(mc.TitleFieldName);
                            lvp.Filters = new FilterElementCollection();
                            ListViewProfile.SaveSystemProfile(ClassName, PlaceName, Mediachase.Ibn.Data.Services.Security.CurrentUserId, lvp);
                            list = ListViewProfile.GetSystemProfiles(ClassName, String.Empty);
                        }
                    }
                }
                ProfileName = list[0].Id;
            }
            grdMain.ClassName = ClassName;
            grdMain.ViewName = ViewName;
            grdMain.PlaceName = PlaceName;
            grdMain.ProfileName = ProfileName;
            grdMain.ShowCheckboxes = ShowCheckBoxes;

            MetaClass bridgeClass = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(BridgeClassName);
            string pkName = SqlContext.Current.Database.Tables[mc.DataSource.PrimaryTable].PrimaryKey.Name;
            string bridgeTableName = bridgeClass.DataSource.PrimaryTable;
            FilterElementCollection fec = new FilterElementCollection();
            FilterElement fe = new FilterElement(pkName, FilterElementType.In,
                String.Format("(SELECT [{0}] FROM [{1}] WHERE [{2}]='{3}')",
                            Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));
            //FilterElement fe = new FilterElement(String.Empty, FilterElementType.Custom,
            //    String.Format("[t01].[{0}] IN (SELECT [{1}] FROM [{2}] WHERE [{3}]='{4}')",
            //                pkName, Filter2FieldName, bridgeTableName, Filter1FieldName, Request["ObjectId"]));
            fec.Add(fe);
            grdMain.AddFilters = fec;
            grdMain.DataBind();

            ctrlGridEventUpdater.ClassName = ClassName;
            ctrlGridEventUpdater.ViewName = ViewName;
            ctrlGridEventUpdater.PlaceName = PlaceName;
            ctrlGridEventUpdater.GridId = grdMain.GridClientContainerId;

            MainMetaToolbar.ClassName = ClassName;
            MainMetaToolbar.ViewName = ViewName;
            MainMetaToolbar.PlaceName = PlaceName;
            MainMetaToolbar.DataBind();
        }
Ejemplo n.º 45
0
        private WebDavStorageElementPropertiesRow GetWebDavStoragePropertyRow(ObjectTypes storageType, int objectId)
        {
            WebDavStorageElementPropertiesRow retVal = null;

            FilterElement filterEl1 = new FilterElement("ObjectTypeId", FilterElementType.Equal, (int)storageType);
            FilterElement filterEl2 = new FilterElement("ObjectId", FilterElementType.Equal, objectId);

            WebDavStorageElementPropertiesRow[] propertyRow = WebDavStorageElementPropertiesRow.List(filterEl1, filterEl2);

            if (propertyRow.Length > 0)
            {
                retVal = propertyRow[0];
            }

            return retVal;
        }
Ejemplo n.º 46
0
        public static string GetHistorySystemListViewProfile(string historyClassName, string placeName)
        {
            ListViewProfile[] mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName);
            if (mas.Length == 0)
            {
                ListViewProfile profile = new ListViewProfile();
                profile.Id = Guid.NewGuid().ToString();
                profile.IsPublic = true;
                profile.IsSystem = true;
                MetaClass mc = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(historyClassName);
                profile.Name = CHelper.GetResFileString(mc.PluralName);
                profile.FieldSetName = mc.Name;

                MetaClass mc2 = Mediachase.Ibn.Core.MetaDataWrapper.GetMetaClassByName(HistoryManager.GetOriginalMetaClassName(historyClassName));
                HistoryMetaClassInfo historyInfo = HistoryManager.GetInfo(mc2);
                Collection<string> selectedFields = historyInfo.SelectedFields;

                profile.FieldSet = new List<string>();
                profile.ColumnsUI = new ColumnPropertiesCollection();
                profile.FieldSet.Add(ChangeDetectionService.ModifiedFieldName);
                profile.FieldSet.Add(mc2.TitleFieldName);
                profile.ColumnsUI.Add(new ColumnProperties(ChangeDetectionService.ModifiedFieldName, "200px", String.Empty));
                profile.ColumnsUI.Add(new ColumnProperties(mc2.TitleFieldName, "200px", String.Empty));
                foreach (string fieldName in selectedFields)
                {
                    if (fieldName == mc2.TitleFieldName || fieldName == ChangeDetectionService.ModifiedFieldName)
                        continue;
                    profile.FieldSet.Add(fieldName);
                    profile.ColumnsUI.Add(new ColumnProperties(fieldName, "200px", String.Empty));
                }
                profile.GroupByFieldName = String.Empty;
                FilterElementCollection fec = new FilterElementCollection();
                FilterElement fe = new FilterElement();
                fe.ValueIsTemplate = true;
                fe.Source = "ObjectId";
                fe.Value = "{QueryString:ObjectId}";
                fec.Add(fe);
                profile.Filters = fec;
                profile.Sorting = new SortingElementCollection();

                ListViewProfile.SaveSystemProfile(historyClassName, placeName, Mediachase.IBN.Business.Security.CurrentUser.UserID, profile);
                mas = ListViewProfile.GetSystemProfiles(historyClassName, placeName);
                if (mas.Length == 0)
                    throw new Exception("ListViewProfiles are not exist!");
            }
            return mas[0].Id;
        }
Ejemplo n.º 47
0
        private void AddGridFilterConditions(FilterElement filterElement, Transaction trn, TransactionLevel level)
        {
            // Currently only the description attribute is added.
            if (level.DescriptionAttribute != null)
                AddFilterCondition(filterElement, level.DescriptionAttribute.Attribute);

            foreach (SettingsDefaultFilterElement filter in settings.DefaultFilters.DefaultFilters)
            {
                bool roda = false;
                if (filter.Selection)
                {
                    if (filterElement.Parent is SelectionElement)
                    {
                        roda = true;
                    }
                }
                if (filter.Prompt)
                {
                    if (filterElement.Parent is PromptElement)
                    {
                        roda = true;
                    }
                }

                if (roda)
                {
                    if (filter.Attribute != null)
                    {
                        if (trn.Structure.Root.ContainsAttribute(filter.Attribute, false))
                        {
                            if (!String.IsNullOrEmpty(filter.Value))
                            {
                                filterElement.AddCondition(filter.Value);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 48
0
 private void AddGridFilterDynamicFilters(FilterElement filterElement, Transaction trn, TransactionLevel level)
 {
     try
     {
         if (settings.DynamicFilters.GenerateDynaicFilters)
         {
             int max = settings.DynamicFilters.MaxAttributes;
             int c = 0;
             foreach (TransactionAttribute ta in level.Attributes)
             {
                 if (ta.Attribute.Type == eDBType.CHARACTER || ta.Attribute.Type == eDBType.VARCHAR || ta.Attribute.Type == eDBType.NUMERIC || ta.Attribute.Type == eDBType.DATE)
                 {
                     AttributeElement at = new AttributeElement(ta.Attribute);
                     at.Description = ta.Attribute.Description;
                     filterElement.Dynamicfilters.Add(at);
                     c++;
                     if (c >= max) break;
                 }
             }
         }
     }
     catch (System.Exception e) {
         System.Windows.Forms.MessageBox.Show("Erro: " + e.Message + Environment.NewLine + e.StackTrace);
     }
 }
Ejemplo n.º 49
0
        private static IEnumerable<FilterElement> FindFilterElementBySource(string[] source, FilterElement[] filters, bool recursive)
        {
            foreach (FilterElement filter in filters)
            {
                //Рекурсивно ищем в дочерних элементах
                if (recursive && filter.HasChildElements)
                {
                    foreach (FilterElement childFilter in FindFilterElementBySource(source, filter.ChildElements.ToArray(), recursive))
                    {
                        yield return childFilter;
                    }
                }

                if (Array.Find<string>(source, delegate(string other) { return filter.Source == other; }) != null)
                {
                    yield return filter;
                }
            }
        }
Ejemplo n.º 50
0
 private void AddFilterCondition(FilterElement filterElement, Gx.Attribute att)
 {
     string conditionText = getCondition(att, filterElement.Instance.Settings);
     ConditionElement conditionElement = filterElement.AddCondition(conditionText);
 }
Ejemplo n.º 51
0
 private static void DeepRemoveFilter(FilterElementCollection filterColl, FilterElement toRemoveFilter)
 {
     if (filterColl.Contains(toRemoveFilter))
     {
         filterColl.Remove(toRemoveFilter);
     }
     foreach (FilterElement filterEl in filterColl)
     {
         if (filterEl.HasChildElements)
         {
             DeepRemoveFilter(filterEl.ChildElements, toRemoveFilter);
         }
     }
 }
Ejemplo n.º 52
0
        private void AddFilterAttribute(FilterElement filterElement, KBModel model, string name, string description, Domain domain, string defaultValue)
        {
            FilterAttributeElement filterAttElement = filterElement.AddFilterAttribute(name);
            filterAttElement.Description = description;
            filterAttElement.Domain = domain;
            filterAttElement.Default = defaultValue;

            PropertiesObject underlying = (domain != null ? (PropertiesObject)domain : (PropertiesObject)Gx.Attribute.Get(model, name));
            if (underlying != null && underlying.GetPropertyValue<int>(Properties.ATT.ControlType) == Properties.ATT.ControlType_Values.ComboBox)
                filterAttElement.AllValue = true;
        }
Ejemplo n.º 53
0
 public EntityObject[] List(string metaClassName, FilterElement[] filters)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 54
0
 public CalendarEventListRequest(string metaClassName, FilterElement[] filters, SortingElement[] sorting)
     : base(CalendarEventListMethod.METHOD_NAME, new EntityObject(metaClassName))
 {
     this.Filters = filters;
     this.Sorting = sorting;
 }