Exemplo n.º 1
0
        private string[] createSeriesListWithNiceNames()
        {
            string[] series = new string[_xrommFileSys.Trials.Length + 1]; // +1 for CT position
            series[0] = "CT Scan";

            for (int i = 0; i < _xrommFileSys.Trials.Length; i++)
            {
                series[i + 1] = _xrommFileSys.Trials[i].TrialName;
            }

            //now try and replace ugly names with nice ones :)
            string configFile = _xrommFileSys.SeriesNamesFilename;

            if (System.IO.File.Exists(configFile))
            {
                Dictionary <string, string> lookupTable = IniFileParser.GetIniFileStrings(configFile, "SeriesNames");
                for (int i = 0; i < series.Length; i++)
                {
                    if (lookupTable.ContainsKey(series[i]))
                    {
                        series[i] = lookupTable[series[i]];
                    }
                }
            }
            return(series);
        }
Exemplo n.º 2
0
        public static string GetWorkGroupName()
        {
            string result = String.Empty;
            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                //OS X
                string configFilePath = @"/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist";
                PlistParser parser = new PlistParser(configFilePath);
                result = parser["Workgroup"].ToString();
            }
            else if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
            {
                //Linux
                string configFilePath = @"/etc/samba/smb.conf";
                IniFileParser parser = new IniFileParser(configFilePath);
                result = parser.GetValue("Global", "Workgroup");
            }
            else
            {
                //Windows
                using (ManagementObject managementObject = new ManagementObject(String.Format("Win32_ComputerSystem.Name='{0}'", Environment.MachineName)))
                {
                    object workgroup;
                    //Workgroup is NULL under XP
                    if (OSVersionPlatform.IsWindowsVistaOrHigher())
                        workgroup = managementObject["Workgroup"];
                    else
                        workgroup = managementObject["Domain"];

                    result = workgroup.ToString();
                }
            }
            return result;
        }
Exemplo n.º 3
0
        public void Init()
        {
            // Set default values
            IsNotBusy      = true;
            Connect        = "Connect";
            ErrorIsVisible = Visibility.Collapsed;
            ErrorString    = "";

            // Get Login / Password from cache (i.e. INI FILE)
            Login    = CurrentApplication.RbApplication.GetUserLoginFromCache();
            Password = CurrentApplication.RbApplication.GetUserPasswordFromCache();

            // Get AutoLogin value (specific value from INI FILE)
            iniFileParser = CurrentApplication.RbApplication.GetIniFileParser();
            String autoLoginString = iniFileParser.GetValue("AutoLogin", "Application", "False");

            AutoLogin = autoLoginString.ToLower() == "true";

            if (AutoLogin)
            {
                RBLogin(Login, Password);
            }

            // FOR TEST:
            //ErrorIsVisible = Visibility.Visible;
            //ErrorString = "Lorem ipsum dolor sit amet, libero amet, aliquam sed quis nam a, interdum massa est, pede aenean. Luctus felis. Nam accumsan consectetuer dui enim nostra et, amet odio consequatur, quis lacinia ipsum vel diam. Pellentesque rem fermentum felis, orci risus vel augue amet odio quam, sit eu quis donec scelerisque urna, urna dictum. Felis cursus lorem eget sagittis sed ante, ultrices varius non pulvinar elit in justo, lectus consectetuer tempus ornare tempor libero, per suspendisse mauris vel nec. Per lorem ante etiam aliquet cursus nec, ac lobortis. Eget metus. Mus urna in habitant ut tincidunt libero, et sit, urna interdum eget purus nec odio a, id sodales in. Tincidunt sit amet mattis aliquam sed risus, orci mollis lacus ullamcorper vel.";
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            IniFileParser iniParser = new IniFileParser("config.ini");
            string        user      = iniParser.Read("username");
            string        pass      = iniParser.Read("password");

            Console.WriteLine(user + " - " + pass);

            HttpService.LoginAsync(user, pass, JWTService.GetComputerSid().Value, (response) => {
                Debug.WriteLine(response);

                var token = response.Split(':').Last();

                Console.WriteLine("Login Successful");


                var generatedToken = JWTService.GenerateToken(token, JWTService.GetComputerSid().Value);
                Console.WriteLine(generatedToken);

                Console.WriteLine("jwt token created");
                Constants.AccessToken = generatedToken;

                RunMethodInSeparateThread(StartServer);

                Console.WriteLine("Press Ctrl + C to Exit");
            }).Wait();
        }
Exemplo n.º 5
0
        private string[] createSeriesListWithNiceNames()
        {
            string[] series = _wrist.series;

            //make niceSeries a complete list of all the current "not-nice" names
            string[] niceSeries = new string[series.Length + 1];
            niceSeries[0] = _wrist.neutralSeries;
            Array.ConstrainedCopy(series, 0, niceSeries, 1, series.Length); //copy the existing value

            //now try and replace ugly names with nice ones :)
            string configFile = _wrist.SeriesNamesFilename;

            if (File.Exists(configFile))
            {
                Dictionary <string, string> lookupTable = IniFileParser.GetIniFileStrings(configFile, "SeriesNames");
                for (int i = 0; i < niceSeries.Length; i++)
                {
                    if (lookupTable.ContainsKey(niceSeries[i]))
                    {
                        niceSeries[i] = lookupTable[niceSeries[i]];
                    }
                }
            }
            return(niceSeries);
        }
Exemplo n.º 6
0
    private ConfigProperties()
    {
        IniFileParser parser = new IniFileParser();

        parser.Open(FILE_NAME);
        isServer = parser.ReadValue(GENERAL_SECTION, IS_SERVER, false);
        parser.Close();
    }
Exemplo n.º 7
0
        public static string GetWorkGroupName()
        {
            string result = String.Empty;

            if (OSVersionPlatform.GetConcretePlatform() == PlatformID.MacOSX)
            {
                //OS X
                string      configFilePath = @"/Library/Preferences/SystemConfiguration/com.apple.smb.server.plist";
                PlistParser parser         = new PlistParser(configFilePath);

                const string workgroupKey = "Workgroup";
                if (parser.ContainsKey(workgroupKey))
                {
                    result = parser[workgroupKey].ToString();
                }
                else
                {
                    const string defaultWorkgroup = "WORKGROUP";
                    result = defaultWorkgroup;
                }
            }
            else if (OSVersionPlatform.GetGenericPlatform() == PlatformID.Unix)
            {
                //Linux
                string        configFilePath = @"/etc/samba/smb.conf";
                IniFileParser parser         = new IniFileParser(configFilePath);
                result = parser.GetValue("Global", "Workgroup");
            }
            else
            {
                //Windows
                using (ManagementObject managementObject = new ManagementObject(String.Format("Win32_ComputerSystem.Name='{0}'", Environment.MachineName)))
                {
                    object workgroup = managementObject["Workgroup"];

                    //Workgroup is NULL under XP and Server OS
                    //instead read Domain
                    if (workgroup == null)
                    {
                        workgroup = managementObject["Domain"];
                        const string LocalSuffix = ".local";
                        if (workgroup != null)
                        {
                            string domain = (string)workgroup;
                            if (domain.EndsWith(LocalSuffix))
                            {
                                domain = Path.GetFileNameWithoutExtension(domain);
                            }
                            workgroup = domain;
                        }
                    }

                    result = workgroup.ToString();
                }
            }
            return(result);
        }
Exemplo n.º 8
0
        public ConfigEditor(string filePath)
        {
            PathToUserIni = Path.Combine(filePath, "User.ini");
            PathTo2k4Ini  = Path.Combine(filePath, "UT2004.ini");

            configParser = new();
            GetCleanUT2k4IniFileContents();

            userConfigData   = configParser.ReadFile(PathToUserIni);
            ut2004ConfigData = configParser.ReadFile(PathTo2k4Ini);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 拡張編集オブジェクトファイルを読み取る。
        /// </summary>
        /// <param name="fileInfo">ファイル情報。</param>
        /// <param name="strict">厳格な形式チェックを行うならば true 。</param>
        /// <returns>拡張編集オブジェクト。</returns>
        public static ExEditObject Read(FileInfo fileInfo, bool strict = false)
        {
            if (fileInfo == null)
            {
                throw new ArgumentNullException(nameof(fileInfo));
            }

            var sections = IniFileParser.FromFile(fileInfo, strict);

            return(ExEditObject.FromExoFileSections(sections));
        }
Exemplo n.º 10
0
        public void IniFileParser_ParsesFile()
        {
            //arrange
            string executingPath = Path.GetFullPath("App_Data");
            const string fileName = "system.ini";
            string iniFilePath = Path.Combine(executingPath, fileName);

            //act
            IniFileParser parser = new IniFileParser(iniFilePath);

            //assert
            Assert.IsTrue(parser.GetValue("drivers", "wave").Equals("mmdrv.dll"));
            Assert.IsTrue(parser.GetValue("drivers", "timer").Equals("timer.drv"));
        }
        public void IniFileParser_ParsesFile()
        {
            //arrange
            string       executingPath = Path.GetFullPath("App_Data");
            const string fileName      = "system.ini";
            string       iniFilePath   = Path.Combine(executingPath, fileName);

            //act
            IniFileParser parser = new IniFileParser(iniFilePath);

            //assert
            Assert.IsTrue(parser.GetValue("drivers", "wave").Equals("mmdrv.dll"));
            Assert.IsTrue(parser.GetValue("drivers", "timer").Equals("timer.drv"));
        }
Exemplo n.º 12
0
        public static void Test(string testName, string filepath)
        {
            Console.WriteLine("===== " + testName + " =====");
            IniFileParser parserIni = null;

            try
            {
                parserIni = new IniFileParser(filepath);
            }
            catch (ParserINI.Exceptions.WrongFileFormatException)
            {
                Console.Error.WriteLine("Wrong file format, filepath: " + filepath);
                return;
            }
            catch (ParserINI.Exceptions.FileReadingException)
            {
                Console.Error.WriteLine("Couldn't read file, filepath: " + filepath);
                return;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(e);
                return;
            }

            try
            {
                Console.WriteLine("Int val: " + parserIni.GetIntValue("SOME_SECTION", "SomeInt"));
                Console.WriteLine("Long val: " + parserIni.GetLongValue("SOME_SECTION", "SomeLong"));
                Console.WriteLine("Double val: " + parserIni.GetDoubleValue("SOME_SECTION", "SomeDouble"));
                Console.WriteLine("String val: " + parserIni.GetStringValue("SOME_SECTION", "SomeString"));
            }
            catch (ParserINI.Exceptions.SectionNotFoundException e)
            {
                Console.Error.WriteLine("Section not found: " + e.GetSectionName());
            }
            catch (ParserINI.Exceptions.KeyNotFoundException e)
            {
                Console.Error.WriteLine("Key not found: " + e.GetKeyName());
            }
            catch (ParserINI.Exceptions.ValueCastException)
            {
                Console.Error.WriteLine("Cast exception handled");
            }
        }
Exemplo n.º 13
0
        private void InitializeRainbowSDK()
        {
            rainbowApplication = new Rainbow.Application();;

            // Set Application Id, Secret Key and Host Name
            rainbowApplication.SetApplicationInfo(APP_ID, APP_SECRET_KEY);
            rainbowApplication.SetHostInfo(HOST_NAME);

            // Get Rainbow main objects
            rainbowContacts         = rainbowApplication.GetContacts();
            rainbowConversations    = rainbowApplication.GetConversations();
            rainbowInstantMessaging = rainbowApplication.GetInstantMessaging();

            // EVENTS WE WANT TO MANAGE
            rainbowApplication.ConnectionStateChanged += RainbowApplication_ConnectionStateChanged;

            rainbowContacts.RosterPeerAdded   += RainbowContacts_RosterPeerAdded;
            rainbowContacts.RosterPeerRemoved += RainbowContacts_RosterPeerRemoved;

            rainbowContacts.ContactPresenceChanged += RainbowContacts_ContactPresenceChanged;

            rainbowConversations.ConversationCreated += RainbowConversations_ConversationCreated;
            rainbowConversations.ConversationRemoved += RainbowConversations_ConversationRemoved;

            rainbowInstantMessaging.MessageReceived   += RainbowInstantMessaging_MessageReceived;
            rainbowInstantMessaging.ReceiptReceived   += RainbowInstantMessaging_ReceiptReceived;
            rainbowInstantMessaging.UserTypingChanged += RainbowInstantMessaging_UserTypingChanged;

            rainbowContactsList = new List <Contact>();


            // Get Login/password used successfully in last connexion
            String login = rainbowApplication.GetUserLoginFromCache();

            if (!String.IsNullOrEmpty(login))
            {
                tbLogin.Text = login;
            }

            String pwd = rainbowApplication.GetUserPasswordFromCache();

            if (!String.IsNullOrEmpty(pwd))
            {
                tbPassword.Text = pwd;
            }

            // Get INI File Parser
            rainbowIniFileParser = rainbowApplication.GetIniFileParser();

            // Get AutoLogon settings and launch login process automatically if set
            String autoLogon = rainbowIniFileParser.GetValue("AutoLogon", "Settings", "false");

            if (autoLogon != "true")
            {
                cbAutoLogon.Checked = false;
            }
            else
            {
                cbAutoLogon.Checked = true;

                btnLoginLogout_Click(null, null);
            }
        }