Пример #1
0
        /**
         * Init
         */
        public void Init()
        {
            int    number   = 1;
            string basePath = ApplicationPaths.GetApplicationPath();

            for (;;)
            {
                controlPath = basePath + "\\fmps_config_" + number;
                FileInfo control = new FileInfo(controlPath);
                if (control.Exists == false)
                {
                    control.Create().Close();
                    break;
                }
                number++;
            }

            configPath = basePath + "\\fmps_config_" + number + ".xml";
            FileInfo config = new FileInfo(configPath);

            if (config.Exists == true)
            {
                StreamReader  reader     = new StreamReader(configPath, new UTF8Encoding(false));
                XmlSerializer serializer = new XmlSerializer(typeof(WindowConfigValues));
                values = (WindowConfigValues)serializer.Deserialize(reader);
                reader.Close();
            }
        }
Пример #2
0
        /**
         * HandleException
         */
        private void HandleException(Exception e)
        {
            List <Exception> list = new List <Exception>();
            Exception        ex   = e;

            for (;;)
            {
                if (ex == null)
                {
                    break;
                }
                list.Add(ex);
                ex = ex.InnerException;
            }

            StringBuilder message = new StringBuilder();

            foreach (Exception item in list)
            {
                message.Append(item.Message + "\r\n");
                message.Append(item.StackTrace + "\r\n");
                message.Append("\r\n");
            }

            string basePath = ApplicationPaths.GetApplicationPath();
            string path     = basePath + "\\fmps_error_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".log";

            File.WriteAllText(path, message.ToString(), new UTF8Encoding(false));
            Debug.WriteLine(message.ToString());
            Console.WriteLine(message.ToString());

            MessageBox.Show("エラーが発生しました", "エラー", MessageBoxButton.OK, MessageBoxImage.Error);

            Shutdown(1);
        }
Пример #3
0
        /**
         * Init
         */
        public void Init()
        {
            string basePath = ApplicationPaths.GetApplicationPath();

            configPath = basePath + "\\fmps_settings.xml";
            FileInfo config = new FileInfo(configPath);

            if (config.Exists == true)
            {
                StreamReader  reader     = new StreamReader(configPath, new UTF8Encoding(false));
                XmlSerializer serializer = new XmlSerializer(typeof(ApplicationConfigValues));
                values = (ApplicationConfigValues)serializer.Deserialize(reader);
                reader.Close();
            }
        }