Exemplo n.º 1
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());
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Recalculates the project and objects TotalMinutes and TotalApproved.
        /// </summary>
        /// <param name="block">The block.</param>
        private static void RecalculateProjectAndObjects(TimeTrackingBlock block)
        {
            int projectId = GetProjectIdByTimeTrackingBlock(block);

            if (projectId > 0)
            {
                TimeTrackingEntry[] entryList = TimeTrackingEntry.List(
                    FilterElement.EqualElement("ParentBlockId", block.PrimaryKeyId.Value),
                    FilterElement.IsNotNullElement("ObjectId"),
                    FilterElement.IsNotNullElement("ObjectTypeId"));
                foreach (TimeTrackingEntry entry in entryList)
                {
                    DbTimeTracking.RecalculateObject((int)entry.Properties["ObjectId"].Value, (int)entry.Properties["ObjectTypeId"].Value, block.ProjectId.Value);
                }

                DbTimeTracking.RecalculateProject(projectId);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Determines whether [is workflow instance closed] [the specified instance id].
        /// </summary>
        /// <param name="instanceId">The instance id.</param>
        /// <returns>
        ///     <c>true</c> if [is workflow instance closed] [the specified instance id]; otherwise, <c>false</c>.
        /// </returns>
        private static bool IsWorkflowInstanceClosed(Guid instanceId)
        {
            // Use HttpContext Optimization
            string key = "IsWorkflowInstanceClosed_" + instanceId.ToString("N", CultureInfo.InvariantCulture);

            if (HttpContext.Current.Items.Contains(key))
            {
                return((bool)HttpContext.Current.Items[key]);
            }

            bool bRetVal = BusinessManager.List(WorkflowInstanceEntity.ClassName,
                                                new FilterElement[] {
                FilterElement.EqualElement("PrimaryKeyId", instanceId),
                FilterElement.IsNotNullElement(WorkflowInstanceEntity.FieldExecutionResult),
            }).Length > 0;

            HttpContext.Current.Items[key] = bRetVal;

            return(bRetVal);
        }
Exemplo n.º 5
0
        private void BindAllProjectsGrid(DateTime startDate, int userId)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("ObjectId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectTypeId", typeof(int)));
            dt.Columns.Add(new DataColumn("ObjectName", typeof(string)));
            dt.Columns.Add(new DataColumn("BlockTypeInstanceId", typeof(int)));
            DataRow dr;

            #region 1. Make the list of all BlockTypeInstances
            Dictionary <int, string> allList = new Dictionary <int, string>();
            bool isProject = false;
            foreach (ListItem li in BlockInstanceList.Items)
            {
                if (!isProject)
                {
                    // Check that we have reached the [ All Projects ]
                    if (li.Value == "0")
                    {
                        isProject = true;
                    }
                    continue;
                }
                allList.Add(int.Parse(li.Value, CultureInfo.InvariantCulture), li.Text);
            }
            #endregion

            #region 2. Get the list of the existing blocks by StartDate and OwnerId
            List <int> idList = new List <int>();
            Dictionary <int, TimeTrackingBlock> existingBlocks = new Dictionary <int, TimeTrackingBlock>();
            foreach (TimeTrackingBlock block in TimeTrackingBlock.List(FilterElement.EqualElement("StartDate", startDate), FilterElement.EqualElement("OwnerId", userId), FilterElement.IsNotNullElement("ProjectId")))
            {
                idList.Add(block.PrimaryKeyId.Value);
                existingBlocks.Add(block.PrimaryKeyId.Value, block);
            }
            #endregion

            #region 3. Get the security info by existing blocks and remove the forbidden items from allList
            SerializableDictionary <int, Collection <string> > objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlock.GetAssignedMetaClass(), idList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                TimeTrackingBlock block = existingBlocks[id];
                if (!allowedRights.Contains(Mediachase.Ibn.Data.Services.Security.RightWrite))
                {
                    allList.Remove(block.BlockTypeInstanceId);
                }
            }
            #endregion

            #region 4. Fill in the DataTable
            foreach (KeyValuePair <int, string> item in allList)
            {
                bool   isHeaderAdded = false;
                int    instanceId    = item.Key;
                string instanceName  = item.Value;
                using (IDataReader reader = Mediachase.IBN.Business.TimeTracking.GetListTimeTrackingItemsForAdd(instanceId, startDate, userId))
                {
                    while (reader.Read())
                    {
                        if (!isHeaderAdded)
                        {
                            dr                        = dt.NewRow();
                            dr["ObjectId"]            = instanceId;
                            dr["ObjectTypeId"]        = ProjectObjectType;
                            dr["ObjectName"]          = instanceName;
                            dr["BlockTypeInstanceId"] = instanceId;
                            dt.Rows.Add(dr);

                            isHeaderAdded = true;
                        }

                        dr                        = dt.NewRow();
                        dr["ObjectId"]            = reader["ObjectId"];
                        dr["ObjectTypeId"]        = reader["ObjectTypeId"];
                        dr["ObjectName"]          = reader["ObjectName"];
                        dr["BlockTypeInstanceId"] = reader["BlockTypeInstanceId"];
                        dt.Rows.Add(dr);
                    }
                }
            }
            #endregion

            MainGrid.DataSource = dt.DefaultView;
            MainGrid.DataBind();
        }