Ejemplo n.º 1
0
        private bool Setting()
        {
#if DEBUG
            string path = System.IO.Path.GetFullPath(@"..\..\") + "_POE_Data\\";
#else
            string path = System.Reflection.Assembly.GetExecutingAssembly().Location;
            path = path.Remove(path.Length - 4) + "Data\\";
#endif
            FileStream fs = null;
            try
            {
                fs = new FileStream(path + "Config.txt", FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mConfigData = Json.Deserialize <ConfigData>(json);
                }

                if (mConfigData.Options.SearchPriceCount > 80)
                {
                    mConfigData.Options.SearchPriceCount = 80;
                }

                // 업데이트 오류시 Parser.txt가 지워질수 있어 존재여부 체크
                if (File.Exists(path + "Parser.txt"))
                {
                    fs = new FileStream(path + "Parser.txt", FileMode.Open);
                    using (StreamReader reader = new StreamReader(fs))
                    {
                        fs = null;
                        string json = reader.ReadToEnd();
                        mParserData = Json.Deserialize <ParserData>(json);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.MainWindow, ex.Message, "에러");
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        internal bool Setting()
        {
            string     path = (string)Application.Current.Properties["DataPath"];
            FileStream fs   = null;

            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                if (!File.Exists(path + "Config.txt"))
                {
                    if (!BasicDataUpdate(path, "Config.txt"))
                    {
                        throw new UnauthorizedAccessException("Config 파일 생성 실패");
                    }
                }
                fs = new FileStream(path + "Config.txt", FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mConfig = Json.Deserialize <ConfigData>(json);
                }

                if (mConfig.Options.SearchListCount > 80)
                {
                    mConfig.Options.SearchListCount = 80;
                }

                if (!File.Exists(path + "Parser.txt"))
                {
                    if (!BasicDataUpdate(path, "Parser.txt"))
                    {
                        throw new UnauthorizedAccessException("Parser 파일 생성 실패");
                    }
                }
                fs = new FileStream(path + "Parser.txt", FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mParser = Json.Deserialize <ParserData>(json);
                }

                if (!File.Exists(path + "Checked.txt"))
                {
                    if (!BasicDataUpdate(path, "Checked.txt"))
                    {
                        throw new UnauthorizedAccessException("checked 파일 생성 실패");
                    }
                }

                fs = new FileStream(path + "Checked.txt", FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mChecked = Json.Deserialize <CheckedDict>(json);
                }

                if (mChecked.Entries == null)
                {
                    mChecked.Entries = new List <CheckedDictItem>();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(Application.Current.MainWindow, ex.Message, "에러");
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            return(true);
        }