Пример #1
0
        /// <summary>
        /// Creates new group with specified details in specified organization.
        /// </summary>
        /// <param name="name">The name of the group.</param>
        /// <param name="description">The group description.</param>
        /// <param name="organizationId">The identifier of the organization.</param>
        /// <param name="builtIn">Whether the group is built-in.</param>
        /// <returns>The System.Guid that represents the identifier of the newly created group.</returns>
        internal static Guid InsertGroup(string name, string description, Guid organizationId, bool builtIn)
        {
            ClientDataSet.GroupDataTable table = new ClientDataSet.GroupDataTable();
            ClientDataSet.GroupRow       row   = table.NewGroupRow();

            row.GroupId        = Guid.NewGuid();
            row.Name           = name;
            row.Description    = description;
            row.OrganizationId = organizationId;
            row.BuiltIn        = builtIn;

            try
            {
                table.AddGroupRow(row);
            }
            catch (ConstraintException ex)
            {
                throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
            }

            using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            Guid groupId = row.GroupId;

            return(groupId);
        }
Пример #2
0
 public static ClientDataSet.EntityFieldDataTable GetEntityField(Guid entityFieldId, Guid organizationId)
 {
     using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         return(adapter.GetEntityField(entityFieldId));
     }
 }
Пример #3
0
 public static ClientDataSet.MessageDataTable GetMessages(string localObjectType, string localObjectId)
 {
     using (MessageTableAdapter adapter = new MessageTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
     {
         return(adapter.GetMessages(localObjectType, localObjectId));
     }
 }
Пример #4
0
 /// <summary>
 /// Gets the groups for the specified organization, excluding marked as deleted.
 /// </summary>
 /// <param name="organizationId">The identifier of the organization.</param>
 /// <returns>The table object that contains groups.</returns>
 public static ClientDataSet.GroupDataTable GetGroups(Guid organizationId)
 {
     using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         return(adapter.GetGroups(organizationId));
     }
 }
Пример #5
0
        public static Guid InsertEntityNode(Guid organizationId, Guid?instanceId, string name, Guid entityNodeTypeId, Guid entityId, Guid parentEntityNodeId, EntityLevel level)
        {
            ClientDataSet.EntityNodeDataTable table = new ClientDataSet.EntityNodeDataTable();
            ClientDataSet.EntityNodeRow       row   = table.NewEntityNodeRow();

            row.EntityNodeId = Guid.NewGuid();
            row.Name         = name;
            if (level == EntityLevel.Instance)
            {
                if (instanceId.HasValue)
                {
                    row.InstanceId = instanceId.Value;
                }
            }
            row.OrganizationId   = organizationId;
            row.EntityNodeTypeId = entityNodeTypeId;
            row.EntityId         = entityId;
            row.FullPath         = string.Empty;
            if (parentEntityNodeId != Guid.Empty)
            {
                row.ParentEntityNodeId = parentEntityNodeId;
            }
            row.OrderNumber = 0;
            table.AddEntityNodeRow(row);

            using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            return(row.EntityNodeId);
        }
Пример #6
0
 public static ClientDataSet.RuleDataTable GetRules(Guid ruleEngineId, Guid organizationId, Guid?instanceId)
 {
     using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         return(adapter.GetRules(ruleEngineId, organizationId, instanceId));
     }
 }
Пример #7
0
 public static ClientDataSet.EntityNodeDataTable GetEntityNodes(Guid organizationId, Guid nodeTypeId)
 {
     using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         return(adapter.GetEntityNodesByType(nodeTypeId));
     }
 }
Пример #8
0
 public static ClientDataSet.GroupRow GetGroupRow(Guid groupId)
 {
     using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
     {
         ClientDataSet.GroupDataTable table = adapter.GetGroup(groupId);
         return((table.Count > 0) ? table[0] : null);
     }
 }
Пример #9
0
 private static ClientDataSet.EntityNodeRow GetEntityNode(Guid entityNodeId, Guid organizationId)
 {
     using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         ClientDataSet.EntityNodeDataTable table = adapter.GetEntityNode(entityNodeId);
         return((table.Count > 0) ? table[0] : null);
     }
 }
Пример #10
0
 public static ClientDataSet.RuleRow GetRuleRow(string ruleName, Guid organizationId)
 {
     using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         ClientDataSet.RuleDataTable table = adapter.GetRuleByName(ruleName, organizationId);
         return((table.Count > 0) ? table[0] : null);
     }
 }
Пример #11
0
        public static void DeleteEntityField(Guid entityFieldId, Guid organizationId)
        {
            using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Delete(entityFieldId);
            }

            RemoveFromCache();
        }
Пример #12
0
        public static Guid InsertMessage(Guid?parentMessageId, string localObjectType, string localObjectId, Guid fromUserId, Guid?toUserId, string subject, string text)
        {
            Guid messageId = Guid.NewGuid();

            using (MessageTableAdapter adapter = new MessageTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
            {
                adapter.Insert(messageId, parentMessageId, localObjectType, localObjectId, fromUserId, toUserId, subject, text, DateTime.UtcNow);
            }
            return(messageId);
        }
Пример #13
0
        public static void DeleteRule(Guid ruleId, Guid organizationId)
        {
            if (ruleId.Equals(Guid.Empty))
            {
                throw new ArgumentNullException("ruleId", Properties.Resources.ExceptionMessage_ArgumentsIsEmpty);
            }

            using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Delete(ruleId);
            }
        }
Пример #14
0
        public static void UpdateEntityField(Guid entityFieldId, int entityFieldTypeId, string name, string description, int dataTypeId, string defaultValue
                                             , bool allowDBNull, bool unique, int maxLength, string minValue, string maxValue, int decimalDigits, int orderNumber
                                             , Guid entityId, Guid organizationId, Guid?instanceId, bool active)
        {
            using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(entityFieldId, entityFieldTypeId, name, description, dataTypeId, (((EntityFieldType)entityFieldTypeId == EntityFieldType.Value) ? defaultValue : null)
                               , allowDBNull, unique, maxLength, minValue, maxValue, decimalDigits, orderNumber, entityId, organizationId, instanceId, active);
            }

            RemoveFromCache();
        }
Пример #15
0
        public static void DeleteGroup(Guid groupId)
        {
            ClientDataSet.GroupRow row = GetGroupRow(groupId);
            if (row != null)
            {
                row.Deleted = true;

                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(UserContext.Current.OrganizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Пример #16
0
        public static int UpdateOrderNumber(Guid organizationId, Guid ruleId, int orderNumber)
        {
            if (organizationId.Equals(Guid.Empty) ||
                ruleId.Equals(Guid.Empty))
            {
                throw new ArgumentNullException("ruleId", Properties.Resources.ExceptionMessage_ArgumentsIsEmpty);
            }

            using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                return(adapter.UpdateRuleOrder(ruleId, orderNumber));
            }
        }
Пример #17
0
        public static int UpdateRuleUses(Guid organizationId, Guid ruleId, Guid lastUsedUser, DateTime lastUsedDate)
        {
            if (ruleId.Equals(Guid.Empty) ||
                organizationId.Equals(Guid.Empty))
            {
                throw new ArgumentNullException("ruleId", Properties.Resources.ExceptionMessage_ArgumentsIsEmpty);
            }

            using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                return(adapter.UpdateRuleUses(ruleId, lastUsedUser, lastUsedDate));
            }
        }
Пример #18
0
        public static void UpdateRule(Guid ruleId, Guid ruleEngineId, Guid organizationId, Guid?instanceId, string name, string displayName, int orderNumber, bool active)
        {
            if (ruleId.Equals(Guid.Empty) || ruleEngineId.Equals(Guid.Empty) || string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("ruleId", Properties.Resources.ExceptionMessage_ArgumentsIsEmpty);
            }

            ClientDataSet.RuleDataTable table = new ClientDataSet.RuleDataTable();

            using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                table = adapter.GetRule(ruleId);

                ClientDataSet.RuleRow row = ((table.Count > 0) ? table[0] : null);

                if (row == null)
                {
                    row                = table.NewRuleRow();
                    row.RuleId         = ruleId;
                    row.RuleEngineId   = ruleEngineId;
                    row.OrganizationId = organizationId;
                    if (instanceId.HasValue)
                    {
                        row.InstanceId = instanceId.Value;
                    }
                    else
                    {
                        row.SetInstanceIdNull();
                    }
                    row.UsedQty = 0;
                    row.SetLastUsedUserNull();
                    row.SetLastUsedDateNull();
                    row.CreatedBy   = UserContext.Current != null ? UserContext.Current.UserId : Guid.Empty;
                    row.CreatedDate = DateTime.UtcNow;
                }

                row.Name        = name;
                row.DisplayName = displayName;
                row.Active      = active;
                row.OrderNumber = orderNumber;

                if (row.RowState == DataRowState.Detached)
                {
                    table.AddRuleRow(row);
                }

                adapter.Update(row);
            }
        }
Пример #19
0
        public static void UpdateEntityNodePath(Guid entityNodeId, string fullPath)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow row = GetEntityNode(entityNodeId, organizationId);
            if (row != null)
            {
                row.FullPath = fullPath;

                using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Пример #20
0
        public static Guid InsertEntityField(int entityFieldTypeId, string name, string description, int dataTypeId, string defaultValue
                                             , bool allowDBNull, bool unique, int maxLength, string minValue, string maxValue, int decimalDigits, int orderNumber
                                             , Guid entityId, Guid organizationId, Guid?instanceId, bool active)
        {
            ClientDataSet.EntityFieldDataTable table = new ClientDataSet.EntityFieldDataTable();
            ClientDataSet.EntityFieldRow       row   = table.NewEntityFieldRow();

            row.EntityFieldId     = Guid.NewGuid();
            row.EntityFieldTypeId = entityFieldTypeId;
            row.Name        = name;
            row.Description = description;
            row.DataTypeId  = dataTypeId;
            if ((EntityFieldType)entityFieldTypeId == EntityFieldType.Value)
            {
                row.DefaultValue = defaultValue;
            }
            row.AllowDBNull = allowDBNull;
            row.Unique      = unique;
            row.MaxLength   = maxLength;
            if (minValue != null)
            {
                row.MinValue = minValue;
            }
            if (maxValue != null)
            {
                row.MaxValue = maxValue;
            }
            row.DecimalDigits  = decimalDigits;
            row.OrderNumber    = orderNumber;
            row.EntityId       = entityId;
            row.OrganizationId = organizationId;
            if (instanceId.HasValue)
            {
                row.InstanceId = instanceId.Value;
            }
            row.Active = active;

            table.AddEntityFieldRow(row);

            using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            RemoveFromCache();

            return(row.EntityFieldId);
        }
Пример #21
0
        private static void DeleteChildEntityNodes(ClientDataSet.EntityNodeRow parentRow, Guid organizationId)
        {
            parentRow.Deleted = true;

            ClientDataSet.EntityNodeDataTable table = null;
            using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(parentRow);

                table = adapter.GetEntityNodesByParentEntityNodeId(parentRow.EntityNodeId);
            }

            foreach (ClientDataSet.EntityNodeRow row in table)
            {
                DeleteChildEntityNodes(row, organizationId);
            }
        }
Пример #22
0
        /// <summary>
        /// Returns the identifier of the group with specified name in the specified organization.
        /// </summary>
        /// <param name="name">The name of the group.</param>
        /// <param name="organizationId">The identifier of the organization which the group belong to.</param>
        /// <returns>The identifier of the group with specified name.</returns>
        public static Guid GetGroupIdByName(string name, Guid organizationId)
        {
            Guid groupId = Guid.Empty;

            if (!string.IsNullOrEmpty(name))
            {
                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    ClientDataSet.GroupDataTable table = adapter.GetGroupByName(name);
                    if (table.Count > 0)
                    {
                        groupId = table[0].GroupId;
                    }
                }
            }
            return(groupId);
        }
Пример #23
0
        public static ClientDataSet.EntityFieldDataTable GetEntityFields(Guid entityId, Guid organizationId, Guid?instanceId, bool?active)
        {
            ClientDataSet.EntityFieldDataTable table = null;
            using (EntityFieldTableAdapter adapter = new EntityFieldTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                table = adapter.GetEntityFields(entityId, organizationId, instanceId, active);
            }

            if (!FrameworkConfiguration.Current.WebApplication.EnableMultipleInstances)
            {
                foreach (ClientDataSet.EntityFieldRow row in table.Select(string.Format(CultureInfo.InvariantCulture, "{0} IS NOT NULL", table.InstanceIdColumn.ColumnName)))
                {
                    table.RemoveEntityFieldRow(table.FindByEntityFieldId(row.EntityFieldId));
                }
                table.AcceptChanges();
            }

            return(table);
        }
Пример #24
0
        public static void MergeEntityNode(Guid sourceId, Guid targetId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow sourceRow = GetEntityNode(sourceId, organizationId);
            ClientDataSet.EntityNodeRow destRow   = GetEntityNode(targetId, organizationId);

            if (sourceRow != null && destRow != null)
            {
                destRow.Name = sourceRow.Name;

                sourceRow.Deleted = true;

                using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(destRow);
                    adapter.Update(sourceRow);
                }
            }
        }
Пример #25
0
        public static ClientDataSet.EntityNodeDataTable GetEntityNodesTree(Guid organizationId, Guid?instanceId, Guid entityId, string entityName)
        {
            ClientDataSet.EntityNodeDataTable table = null;
            using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                table = adapter.GetEntityNodesByEntityId(entityId, organizationId, instanceId);
            }

            string customRootNodeText = EntityFieldProvider.Entities[entityId.ToString()].CustomRootNodeText;

            ClientDataSet.EntityNodeRow rootRow = table.NewEntityNodeRow();
            rootRow.EntityNodeId = Guid.Empty;
            if (!string.IsNullOrEmpty(customRootNodeText))
            {
                rootRow.Name = customRootNodeText.Replace("#organizationName#", UserContext.Current.Organization.Name);
            }
            else
            {
                rootRow.Name = entityName;
            }
            rootRow.EntityId       = entityId;
            rootRow.OrganizationId = organizationId;
            rootRow.SetParentEntityNodeIdNull();
            table.AddEntityNodeRow(rootRow);

            foreach (ClientDataSet.EntityNodeRow row in table)
            {
                if (row.EntityNodeId != Guid.Empty)
                {
                    if (row.IsParentEntityNodeIdNull())
                    {
                        row.ParentEntityNodeId = Guid.Empty;
                    }
                }
            }

            table.AcceptChanges();

            return(table);
        }
Пример #26
0
        /// <summary>
        /// Updates the details of specified group in the specified organization.
        /// </summary>
        /// <param name="groupId">The identifier of the group.</param>
        /// <param name="name">The name of the group.</param>
        /// <param name="description">The group description.</param>
        /// <param name="organizationId">The identifier of the organization.</param>
        public static void UpdateGroup(Guid groupId, string name, string description, Guid organizationId)
        {
            ClientDataSet.GroupRow row = GetGroupRow(groupId);
            if (row != null)
            {
                try
                {
                    row.Name = name;
                }
                catch (ConstraintException ex)
                {
                    throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
                }

                row.Description = ((description == null) ? string.Empty : description);

                using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Returns the list of the groups wich have the specified roles in the specified instance.
        /// </summary>
        /// <param name="organizationId">The organizations' identifier.</param>
        /// <param name="instanceId">The instance's identifier.</param>
        /// <param name="roleIdList">An array containing the unique identifiers of the roles.</param>
        /// <returns>The list of the groups.</returns>
        public static ArrayList GetGroupIdList(Guid organizationId, Guid instanceId, ArrayList roleIdList)
        {
            ArrayList groupIdList = new ArrayList();

            if (roleIdList != null)
            {
                if (roleIdList.Count > 0)
                {
                    using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                    {
                        foreach (ClientDataSet.GroupRow row in adapter.GetGroupsByRoles(organizationId, ((instanceId == Guid.Empty) ? null : new Guid?(instanceId)), Support.ConvertListToString(roleIdList).ToUpperInvariant()))
                        {
                            if (!groupIdList.Contains(row.GroupId))
                            {
                                groupIdList.Add(row.GroupId);
                            }
                        }
                    }
                }
            }
            return(groupIdList);
        }
Пример #28
0
        /// <summary>
        /// Changes the parent of the specified entity node.
        /// </summary>
        /// <param name="entityNodeId">The identifier of the entity node.</param>
        /// <param name="parentEntityNodeId">The identifier of new parent of the entity node.</param>
        public static void ChangeParentEntityNode(Guid entityNodeId, Guid?parentEntityNodeId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow row = GetEntityNode(entityNodeId, organizationId);
            if (row != null)
            {
                if (parentEntityNodeId.HasValue && (parentEntityNodeId.Value != Guid.Empty))
                {
                    row.ParentEntityNodeId = parentEntityNodeId.Value;
                }
                else
                {
                    row.SetParentEntityNodeIdNull();
                }

                using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Пример #29
0
        /// <summary>
        /// Updates the name of the built-in group that is associated to the specified instance.
        /// </summary>
        /// <param name="ds">The data sourceRow.</param>
        /// <param name="instanceId">The unique identifier of the instance.</param>
        /// <param name="name">The name of the instance.</param>
        internal static void UpdateInstanceAdministratorGroup(Guid organizationId, Guid instanceId, string name)
        {
            using (GroupTableAdapter adapter = new GroupTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                ClientDataSet.GroupDataTable table = adapter.GetGroupsByRoles(organizationId, ((instanceId == Guid.Empty) ? null : new Guid?(instanceId)), RoleProvider.InstanceAdministratorRoleId.ToString().ToUpperInvariant());
                if (table.Count > 0)
                {
                    ClientDataSet.GroupRow row = table[0];

                    try
                    {
                        row.Name = string.Format(CultureInfo.InvariantCulture, Resources.GroupProvider_InstanceAdministratorGroup_Name, name);
                    }
                    catch (ConstraintException ex)
                    {
                        throw new ConstraintException(string.Format(CultureInfo.CurrentCulture, Resources.GroupProvider_ErrorMessage_GroupAlreadyExists, name), ex);
                    }

                    row.Description = Resources.GroupProvider_InstanceAdministratorGroup_Description;

                    adapter.Update(row);
                }
            }
        }
Пример #30
0
        public static void UpdateEntityNodesRelatedEntityNodes(Guid entityNodesRelatedEntityNodesId, Guid entityNodeId, Guid relatedEntityNodeId, Guid entityId, RelationType relationType, Guid organizationId)
        {
            using (EntityNodesRelatedEntityNodesTableAdapter adapter = new EntityNodesRelatedEntityNodesTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                ClientDataSet.EntityNodesRelatedEntityNodesDataTable table = adapter.GetEntityNodesRelatedEntityNodes(entityNodesRelatedEntityNodesId);
                ClientDataSet.EntityNodesRelatedEntityNodesRow       row   = null;
                if (table.Count > 0)
                {
                    row = table[0];
                }

                if (row == null)
                {
                    row = table.NewEntityNodesRelatedEntityNodesRow();
                    row.EntityNodesRelatedEntityNodesId = entityNodesRelatedEntityNodesId;
                }
                row.EntityNodeId        = entityNodeId;
                row.RelatedEntityNodeId = relatedEntityNodeId;
                row.EntityId            = entityId;
                row.RelationType        = (int)relationType;

                if (row.RowState == DataRowState.Detached)
                {
                    table.AddEntityNodesRelatedEntityNodesRow(row);
                }

                adapter.Update(row);
            }
        }