Ejemplo n.º 1
0
        public static void Start()
        {
            //bind manufacturer comboxbox
            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(SupportCatalog));

            _supportCatalog = new SupportCatalog();

            //if no material catalog is found then save default items
            try
            {
                if (File.Exists(Settings.RoamingSupportConeProfilesPath))
                {
                    using (var streamReader = new StreamReader(Settings.RoamingSupportConeProfilesPath))
                    {
                        try
                        {
                            _supportCatalog = (SupportCatalog)serializer.Deserialize(streamReader);
                        }
                        catch
                        {
                        }
                    }
                }
                else if (File.Exists(Settings.SupportConeProfilesPath))
                {
                    using (var streamReader = new StreamReader(Settings.SupportConeProfilesPath))
                    {
                        try
                        {
                            _supportCatalog = (SupportCatalog)serializer.Deserialize(streamReader);
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    _supportCatalog.Add(new SupportCatalogItem()
                    {
                        TopHeight    = 1,
                        TopRadius    = 0.35f,
                        MiddleRadius = 1f,
                        BottomRadius = 6f,
                        BottomHeight = 1f,
                        IsDefault    = true
                    });
                    Save();
                }
            }
            catch (Exception exc) {
                MessageBox.Show(exc.StackTrace);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Checks if the User with ID provided has equal or higher permission than the permission provided
        /// </summary>
        /// <param name="userId">ID of User to check permission for</param>
        /// <param name="permission">Permission to check that User has</param>
        /// <returns></returns>
        private bool UserCanAccessSupportCatalog(int userId, SupportCatalog permission)
        {
            var userRoles = GetUserRoles(userId);

            return(userRoles.Any(role => role.SupportCatalogAccess >= permission));
        }