Example #1
0
        public static RunTimeConfig ReadRunTimeConfig(string runTimePath, string publicKey)
        {
            RunTimeConfig rtc = new RunTimeConfig();

            try
            {
                var          fi      = new FileInfo(runTimePath);
                StreamReader sr      = fi.OpenText();
                string       content = sr.ReadToEnd();
                if (!string.IsNullOrEmpty(publicKey))
                {
                    content = EncrypterHelper.DecryptRASString(content, publicKey);
                }
                string[] temps = content.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                sr.Close();
                string group = "";
                foreach (string str in temps)
                {
                    if (str.Contains("[") && str.Contains("]"))
                    {
                        group = str.Replace("[", "").Replace("]", "");
                        continue;
                    }
                    int index = str.IndexOf('=');
                    if (index >= 1)
                    {
                        try
                        {
                            string key   = str.Substring(0, index);
                            string value = str.Substring(index + 1, str.Length - index - 1).Trim();
                            if (group.ToLower().Equals(group.ToLower()))
                            {
                                switch (key.ToLower())
                                {
                                case FramePluginKey:
                                    rtc.FramePluginKey = value;
                                    break;

                                case FunctionPluginKey:
                                    rtc.FunctionPluginKey = value;
                                    break;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LogHelper.Error(ex);
                            Environment.Exit(0);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
            return(rtc);
        }
Example #2
0
        private static void ErrorReport(string message)
        {
            try
            {
                string str = EncrypterHelper.DecryptRASString(pwd, pubulicKey);

                DateTime dt          = DateTime.Now;
                string   date        = string.Format("_{0:0000}{1:00}{2:00}.log", dt.Year, dt.Month, dt.Day);
                var      errorReport = "logs\\" + appName + date;

                Process.Start("MDT.Tools.ErrorReport.exe", string.Format("-i {0} -n {1}", str, errorReport));
                Application.Exit();
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }