Esempio n. 1
0
        /// <summary>
        /// Clears stored information and removes the provider screens.
        /// </summary>
        public override void Clear()
        {
            if (TheBllDatabase != null)
            {
                TheBllDatabase = null;
            }
            TheBllDatabase = new BLL.Database();
            TablePrefixes.Clear();
            ViewPrefixes.Clear();
            StoredProcedurePrefixes.Clear();

            foreach (ContentItem contentIten in Screens)
            {
                contentIten.Clear();
            }
            if (Screens != null && Screens.Length >= 2)
            {
                Screens[0] = null;
                Screens[1] = null;
                Screens    = null;
            }
        }
Esempio n. 2
0
        private static void GetXmlSettings(string xmlFile)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(xmlFile);

            string[] prefixes = doc.SelectSingleNode("database_provider_settings/table_prefixes").InnerText.Split('|');

            foreach (string prefix in prefixes)
            {
                if (!string.IsNullOrEmpty(prefix))
                {
                    TablePrefixes.Add(prefix);
                }
            }
            prefixes = doc.SelectSingleNode("database_provider_settings/view_prefixes").InnerText.Split('|');

            foreach (string prefix in prefixes)
            {
                if (!string.IsNullOrEmpty(prefix))
                {
                    ViewPrefixes.Add(prefix);
                }
            }
            prefixes = doc.SelectSingleNode("database_provider_settings/stored_procedure_prefixes").InnerText.Split('|');

            foreach (string prefix in prefixes)
            {
                if (!string.IsNullOrEmpty(prefix))
                {
                    StoredProcedurePrefixes.Add(prefix);
                }
            }
            Model.Table.TablePrefixes = TablePrefixes;
            Model.View.ViewPrefixes   = ViewPrefixes;
            Model.StoredProcedure.StoredProcedurePrefixes = StoredProcedurePrefixes;
        }
Esempio n. 3
0
        private object RolePrivileges(SecurityRole selectedRole)
        {
            EntityCollection returnCollection;
            var privileges = new List <PrivilegeSet>();

            MisPrivilegeSets = new List <MisPrivilegeSet>();
            int    fetchCount   = 5000; // Initialize the page number.
            int    pageNumber   = 1;    // Initialize the number of records.
            string pagingCookie = null;
            string fetchXML     = "<fetch returntotalrecordcount='true' >" +
                                  "  <entity name='roleprivileges' >" +
                                  "    <attribute name='privilegedepthmask' />" +
                                  "    <link-entity name='role' from='roleid' to='roleid' alias='role' >" +
                                  "      <attribute name='name' />" +
                                  "      <filter>" +
                                  "        <condition attribute='name' operator='eq' value='" +
                                  selectedRole.Name.Replace("&", "&amp;").Replace("\"", "&quot;").Replace("'", "&apos;").Replace("<", "&lt;").Replace(">", "&gt;") +
                                  "' />" +
                                  "      </filter>" +
                                  "    </link-entity>" +
                                  "    <link-entity name='privilegeobjecttypecodes' from='privilegeid' to='privilegeid' alias='objecttype' >" +
                                  "      <attribute name='objecttypecode' />" +
                                  "    </link-entity>" +
                                  "    <link-entity name='privilege' from='privilegeid' to='privilegeid'  alias='privilege' >" +
                                  "      <attribute name='accessright' alias='AccessRight' />" +
                                  "      <attribute name='name' />" +
                                  "<attribute name = 'canbeentityreference' />" +
                                  "    </link-entity>" +
                                  "  </entity>" +
                                  "</fetch>";

            while (true)
            {
                // Build fetchXml string with the placeholders.
                string xml = CreateXml(fetchXML, pagingCookie, pageNumber, fetchCount);

                // Execute the fetch query and get the xml result.
                RetrieveMultipleRequest fetchRequest1 = new RetrieveMultipleRequest
                {
                    Query = new FetchExpression(xml)
                };

                returnCollection = ((RetrieveMultipleResponse)Service.Execute(fetchRequest1)).EntityCollection;

                // Check for morerecords, if it returns 1.
                if (returnCollection.MoreRecords)
                {
                    // Increment the page number to retrieve the next page.
                    pageNumber++;

                    // Set the paging cookie to the paging cookie returned from current results.
                    pagingCookie = returnCollection.PagingCookie;
                }
                else
                {
                    // If no more records in the result nodes, exit the loop.
                    break;
                }
            }

            foreach (Entity ent in returnCollection.Entities)
            {
                var logicalName = ((AliasedValue)ent.Attributes["objecttype.objecttypecode"]).Value.ToString();
                var isEntity    = true;
                if (ent.Attributes.Contains("privilege.canbeentityreference"))
                {
                    isEntity = (bool)((AliasedValue)ent.Attributes["privilege.canbeentityreference"]).Value;
                }

                var priName = ((AliasedValue)ent.Attributes["privilege.name"]).Value.ToString();
                if (logicalName == "activitypointer")
                {
                    AddPermission(ent, privileges);
                }
                else if (TableExlusionList.Contains(logicalName))
                {
                }

                //   else if (CustomisationList.Contains(logicalName)) AddPermission(ent, "Customization");
                else if (PrvExclusionList.Contains(priName))
                {
                }
                else if (TablePrefixes.Any(tp => priName.Contains(tp)))
                {
                    AddPermission(ent, privileges);
                }
                else if (!isEntity) // not an entity
                {
                    AddMiscPriv(ent);
                }
                else
                {
                    AddPermission(ent, privileges);
                }
            }
            privileges.Sort(new PrivilegeComparer(SortOrder.Ascending));
            return(privileges);
        }