public void EnterAccessGroup(string AccessGroupValue)
        {
            AccessGroupValue = AccessGroupValue.Split('[')[1];
            int index = 1;

            for (; index < AccessGroupList.Options.Count; index++)
            {
                if (AccessGroupList.Options[index].Text.Split('[')[1] == AccessGroupValue)
                {
                    break;
                }
            }
            AccessGroupList.SelectByIndex(index);
            //AccessGroupList.SelectByText(AccessGroupValue);
        }
Пример #2
0
 public RESTAccessGroupAttribute()
 {
     this.group = AccessGroupList.Nobody;
 }
Пример #3
0
 public RESTAccessGroupAttribute(AccessGroupList group)
 {
     this.group = group;
 }
Пример #4
0
        private static void WriteUserDatabase()
        {
            lock (lockObject)
            {
                writeUserDB = true;
                try
                {
                    // First get the name of the inifile
                    string iniFilename = UserDatabaseFilename;

                    // First read the ini-file settings
                    if (File.Exists(iniFilename))
                    {
                        File.Delete(iniFilename);
                    }

                    // Add first some informative info to the ini file
                    using (TextWriter tw = new StreamWriter(iniFilename))
                    {
                        tw.WriteLine("# Make sure when adding a new user that the section names are consecutive");
                        tw.WriteLine("# if they are not user info will not be read.");
                        tw.WriteLine("#");
                        tw.WriteLine("# The user '________' is special because this user is used by the website and a few");
                        tw.WriteLine("# maintance programs like this one it's self and XML2MySQL.");
                        tw.WriteLine("# Don't change this username and password before you make appropiate changes in those programs.");
                        tw.WriteLine("#");
                        tw.WriteLine("# The following entries must be set in a section for a [User#]if they are not user info will not be read.");
                        tw.WriteLine("# Username=username");
                        tw.WriteLine("# Password=password");
                        tw.WriteLine("# NumberOfDifferentIPsPerHour=0");
                        tw.WriteLine("# NumberOfRequestsPerHour=0");
                        tw.WriteLine("# AccessGroup=group list");
                        tw.WriteLine("#");
                        tw.WriteLine("#");
                        tw.WriteLine("# AccessGroup can have none, one or more of the following items separated by a ,");
                        tw.Write("# AccessGroup=");
                        int countGroups = 0;
                        foreach (object v in Enum.GetValues(typeof(AccessGroupList)))
                        {
                            AccessGroupList group = (AccessGroupList)v;
                            if (!(group == AccessGroupList.Everybody || group == AccessGroupList.Nobody))
                            {
                                if (countGroups > 0)
                                {
                                    tw.Write(",");
                                }
                                tw.Write(group.ToString());
                                countGroups++;
                            }
                        } //foreach
                        tw.WriteLine();

                        tw.WriteLine("#");
                        tw.WriteLine();
                    } //using

                    IniFile ini = new IniFile(iniFilename);

                    int count = 0;
                    foreach (UserAccount ua in userDatabase.Values)
                    {
                        count++;
                        string section = String.Format("User{0}", count);

                        ini.IniWriteValue(section, "Username", ua.Username);
                        ini.IniWriteValue(section, "Password", ua.Password);
                        ini.IniWriteValue(section, "NumberOfDifferentIPsPerHour", ua.NumberOfDifferentIPsPerHour.ToString());
                        ini.IniWriteValue(section, "NumberOfRequestsPerHour", ua.NumberOfRequestsPerHour.ToString());

                        string groupList = string.Empty;
                        foreach (AccessGroupList group in ua.AccessGroupList)
                        {
                            // Everbody is present by default
                            if (group != RadioChannelWebService.AccessGroupList.Everybody)
                            {
                                if (groupList.Length > 0)
                                {
                                    groupList += ",";
                                }
                                groupList += group.ToString();
                            }
                        } //foreach

                        ini.IniWriteValue(section, "AccessGroup", groupList);
                    } //foreach
                }
                finally
                {
                    writeUserDB = false;
                }
            } //lock
        }