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.º 2
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);
                }
            }
        }
Ejemplo n.º 3
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.º 4
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.º 5
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.º 6
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());
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the public root.
        /// </summary>
        /// <returns></returns>
        public static CalendarFolder GetPublicRoot()
        {
            CalendarFolder[] nodes = CalendarFolder.List(FilterElement.IsNullElement(TreeService.ParentIdFieldName),
                                                         FilterElement.IsNullElement("ProjectId"));

            if (nodes.Length > 0)
            {
                return(nodes[0]);
            }

            // Create Public Root
            return(CreateRootNode("Public", null, null));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Gets the private root.
        /// </summary>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        public static CalendarFolder GetPrivateRoot(int ownerId)
        {
            CalendarFolder[] nodes = CalendarFolder.List(FilterElement.IsNullElement(TreeService.ParentIdFieldName),
                                                         FilterElement.EqualElement("Owner", ownerId),
                                                         FilterElement.IsNullElement("ProjectId"));

            if (nodes.Length > 0)
            {
                return(nodes[0]);
            }

            // Create Private Root
            return(CreateRootNode(string.Format(CultureInfo.InvariantCulture, "Private_{0}", ownerId), null, ownerId));
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Finds the config row.
        /// </summary>
        /// <param name="serviceType">Type of the service.</param>
        /// <param name="key">The key.</param>
        /// <returns></returns>
        private static OutgoingEmailServiceConfigRow FindConfigRow(OutgoingEmailServiceType serviceType, int?key)
        {
            OutgoingEmailServiceConfigRow[] configs = OutgoingEmailServiceConfigRow.List(
                FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceType, serviceType),
                key.HasValue ?
                FilterElement.EqualElement(OutgoingEmailServiceConfigRow.ColumnServiceKey, key):
                FilterElement.IsNullElement(OutgoingEmailServiceConfigRow.ColumnServiceKey));

            if (configs.Length > 0)
            {
                return(configs[0]);
            }

            return(null);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
0
        internal void Load(MetaView metaView)
        {
            _metaClassName       = metaView.MetaClassName;
            _availableFieldNames = metaView.AvailableFieldNames;

            List <string> fieldNames = new List <string>(_availableFieldNames);

            mcweb_MetaViewPreferenceRow[] preferenceRows = mcweb_MetaViewPreferenceRow.List(FilterElement.EqualElement("MetaViewName", metaView.Name), FilterElement.IsNullElement("PrincipalId"));
            if (preferenceRows.Length == 0)
            {
                preferenceRows = new mcweb_MetaViewPreferenceRow[] { null };
            }

            foreach (mcweb_MetaViewPreferenceRow preferenceRow in preferenceRows)
            {
                MetaViewPreferenceInfo preferenceInfo = new MetaViewPreferenceInfo();
                preferenceInfo.Load(preferenceRow, fieldNames);
                _preferences.Add(preferenceInfo);
            }
        }
Ejemplo n.º 15
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);
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Processes this instance.
        /// </summary>
        public static void Process()
        {
            // Step 1. Process WorkflowInstanceEntity
            // Step 1-1. Set Overdue
            foreach (WorkflowInstanceEntity entity in BusinessManager.List(WorkflowInstanceEntity.ClassName,
                                                                           new FilterElement[] {
                FilterElement.EqualElement(WorkflowInstanceEntity.FieldState, (int)BusinessProcessState.Active),
                FilterElement.IsNullElement(WorkflowInstanceEntity.FieldTimeStatus),
                new FilterElement(WorkflowInstanceEntity.FieldPlanFinishDate, FilterElementType.LessOrEqual, DateTime.UtcNow)
            }))
            {
                BusinessManager.Update(entity);
            }

            // Step 1-2. Reset Overdue
            foreach (WorkflowInstanceEntity entity in BusinessManager.List(WorkflowInstanceEntity.ClassName,
                                                                           new FilterElement[] {
                FilterElement.EqualElement(WorkflowInstanceEntity.FieldState, (int)BusinessProcessState.Active),
                FilterElement.EqualElement(WorkflowInstanceEntity.FieldTimeStatus, (int)WorkflowInstanceTimeStatus.OverDue),
                new FilterElement(WorkflowInstanceEntity.FieldPlanFinishDate, FilterElementType.Greater, DateTime.UtcNow)
            }))
            {
                BusinessManager.Update(entity);
            }

            // Step 2. Process AssignmentEntity
            // Step 2-1. Set Overdue
            foreach (AssignmentEntity entity in BusinessManager.List(AssignmentEntity.ClassName,
                                                                     new FilterElement[] {
                FilterElement.EqualElement(AssignmentEntity.FieldState, (int)AssignmentState.Active),
                FilterElement.IsNullElement(AssignmentEntity.FieldTimeStatus),
                new FilterElement(AssignmentEntity.FieldPlanFinishDate, FilterElementType.LessOrEqual, DateTime.UtcNow)
            }))
            {
                // Process Auto Complete
                if (entity.WorkflowInstanceId.HasValue)
                {
                    WorkflowInstanceEntity wfInstance = (WorkflowInstanceEntity)BusinessManager.Load(WorkflowInstanceEntity.ClassName, entity.WorkflowInstanceId.Value);

                    switch (WorkflowParameters.GetAssignmentOverdueAction(wfInstance))
                    {
                    case AssignmentOverdueAction.NoAction:
                        BusinessManager.Update(entity);
                        break;

                    case AssignmentOverdueAction.AutoCompleteWithDecline:
                        CloseAssignmentRequest declineRequet = new CloseAssignmentRequest(entity.PrimaryKeyId.Value, (int)AssignmentExecutionResult.Declined);

                        declineRequet.Comment = WorkflowParameters.GetAutoCompleteComment(wfInstance);
                        if (string.IsNullOrEmpty(declineRequet.Comment))
                        {
                            declineRequet.Comment = GetAutoCompleteDefaultComment();
                        }

                        BusinessManager.Execute(declineRequet);
                        break;

                    case AssignmentOverdueAction.AutoCompleteWithAccept:
                        CloseAssignmentRequest acceptRequet = new CloseAssignmentRequest(entity.PrimaryKeyId.Value, (int)AssignmentExecutionResult.Accepted);

                        acceptRequet.Comment = WorkflowParameters.GetAutoCompleteComment(wfInstance);
                        if (string.IsNullOrEmpty(acceptRequet.Comment))
                        {
                            acceptRequet.Comment = GetAutoCompleteDefaultComment();
                        }

                        BusinessManager.Execute(acceptRequet);
                        break;
                    }
                }
                else
                {
                    BusinessManager.Update(entity);
                }
            }

            // Step 2-1. Reset Overdue
            foreach (AssignmentEntity entity in BusinessManager.List(AssignmentEntity.ClassName,
                                                                     new FilterElement[] {
                FilterElement.EqualElement(AssignmentEntity.FieldState, (int)AssignmentState.Active),
                FilterElement.EqualElement(AssignmentEntity.FieldTimeStatus, (int)AssignmentTimeStatus.OverDue),
                new FilterElement(AssignmentEntity.FieldPlanFinishDate, FilterElementType.Greater, DateTime.UtcNow)
            }))
            {
                BusinessManager.Update(entity);
            }
        }