예제 #1
0
        private bool FilterDataUpdate(string path)
        {
            bool success = false;

            string[] urls = { "https://poe.game.daum.net/api/trade/data/stats", "https://www.pathofexile.com/api/trade/data/stats" };

            // 마우스 훜시 프로그램에 딜레이가 생겨 쓰레드 처리
            Thread thread = new Thread(() =>
            {
                bool isKR = false;
                foreach (string u in urls)
                {
                    isKR = !isKR;

                    string sResult = SendHTTP(null, u, 5);
                    if ((sResult ?? "") != "")
                    {
                        FilterData rootClass = Json.Deserialize <FilterData>(sResult);

                        for (int i = 0; i < rootClass.Result.Length; i++)
                        {
                            if (
                                rootClass.Result[i].Entries.Length > 0 &&
                                RS.lFilterType.ContainsKey(rootClass.Result[i].Entries[0].Type)
                                )
                            {
                                rootClass.Result[i].Label = RS.lFilterType[rootClass.Result[i].Entries[0].Type];
                            }

                            if (rootClass.Result[i].Entries[0].Type == "monster")
                            {
                                for (int j = 0; j < rootClass.Result[i].Entries.Length; j++)
                                {
                                    rootClass.Result[i].Entries[j].Text = rootClass.Result[i].Entries[j].Text.Replace(" (×#)", "");
                                }
                            }
                        }

                        string local = mParser.Local.Text[isKR ? 0 : 1];
                        foreach (ParserDictItem itm in mParser.Local.Entries)
                        {
                            for (int i = 0; i < rootClass.Result.Length; i++)
                            {
                                int index = Array.FindIndex(rootClass.Result[i].Entries, x => x.Id.Substring(x.Id.IndexOf(".") + 1) == itm.Id);
                                if (index > -1)
                                {
                                    rootClass.Result[i].Entries[index].Text = rootClass.Result[i].Entries[index].Text.Replace("(" + local + ")", "").Trim();
                                    rootClass.Result[i].Entries[index].Part = itm.Key;
                                }
                            }
                        }

                        rootClass.Upddate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
                        using (StreamWriter writer = new StreamWriter(path + (isKR ? "FiltersKO.txt" : "FiltersEN.txt"), false, Encoding.UTF8))
                        {
                            writer.Write(Json.Serialize <FilterData>(rootClass));
                            writer.Close();
                        }

                        success = true;
                    }
                }
            });

            thread.Start();
            thread.Join();

            return(success);
        }
예제 #2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string sEntity;

            string[] exchange = null;

            if (bdExchange.Visibility == Visibility.Visible && (cbOrbs.SelectedIndex > 0 || cbSplinters.SelectedIndex > 0))
            {
                exchange = new string[2];

                ParserDictionary exchange_item1 = GetExchangeItem(0, mItemBaseName.TypeKR);
                ParserDictionary exchange_item2 = GetExchangeItem(0, (string)(cbOrbs.SelectedIndex > 0 ? cbOrbs.SelectedValue : cbSplinters.SelectedValue));

                if (exchange_item1 == null || exchange_item2 == null)
                {
                    ForegroundMessage("선택한 교환 아이템 코드가 잘못되었습니다.", "에러", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                exchange[0] = exchange_item1.ID;
                exchange[1] = exchange_item2.ID;

                Process.Start(
                    RS.ExchangeApi[RS.ServerLang] + RS.ServerType + "/?redirect&source="
                    + Uri.EscapeDataString(
                        "{\"exchange\":{\"status\":{\"option\":\"online\"},\"have\":[\"" + exchange[0] + "\"],\"want\":[\"" + exchange[1] + "\"]}}"
                        )
                    );
            }
            else
            {
                sEntity = CreateJson(GetItemOptions(), false);

                if (sEntity == null || sEntity == "")
                {
                    ForegroundMessage("Json 생성을 실패했습니다.", "에러", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (mConfigData.Options.ServerRedirect)
                {
                    Process.Start(RS.TradeApi[RS.ServerLang] + RS.ServerType + "/?redirect&source=" + Uri.EscapeDataString(sEntity));
                }
                else
                {
                    string request_result = null;

                    // 마우스 훜시 프로그램에 딜레이가 생겨 쓰레드 처리
                    Thread thread = new Thread(() =>
                    {
                        request_result = SendHTTP(sEntity, RS.TradeApi[RS.ServerLang] + RS.ServerType, mConfigData.Options.ServerTimeout);
                        if ((request_result ?? "") != "")
                        {
                            try
                            {
                                ResultData resultData = Json.Deserialize <ResultData>(request_result);
                                Process.Start(RS.TradeUrl[RS.ServerLang] + RS.ServerType + "/" + resultData.ID);
                            }
                            catch { }
                        }
                    });

                    thread.Start();
                    thread.Join();

                    if ((request_result ?? "") == "")
                    {
                        ForegroundMessage(
                            "현재 거래소 접속이 원활하지 않을 수 있습니다." + '\n'
                            + "한/영 서버의 거래소 접속을 확인 하신후 다시 시도하세요.",
                            "검색 실패",
                            MessageBoxButton.OK, MessageBoxImage.Information
                            );
                        return;
                    }
                }
            }

            Close();
        }
예제 #3
0
        // 데이터 CSV 파일은 POE 클라이언트를 VisualGGPK.exe (libggpk) 를 통해 추출할 수 있다.
        private bool BaseDataUpdates(string path)
        {
            bool success = false;

            if (File.Exists(path + "csv/ko/BaseItemTypes.dat.csv") && File.Exists(path + "csv/ko/Words.dat.csv"))
            {
                try
                {
                    List <string[]> oCsvEnList = new List <string[]>();
                    List <string[]> oCsvKoList = new List <string[]>();

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/en/BaseItemTypes.dat.csv")))
                    {
                        string   sEnContents = oStreamReader.ReadToEnd();
                        string[] sEnLines    = sEnContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sEnLines)
                        {
                            //oCsvEnList.Add(sLine.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                            oCsvEnList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/ko/BaseItemTypes.dat.csv")))
                    {
                        string   sKoContents = oStreamReader.ReadToEnd();
                        string[] sKoLines    = sKoContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sKoLines)
                        {
                            //oCsvKoList.Add(sLine.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));
                            oCsvKoList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    List <BaseResultData> datas = new List <BaseResultData>();

                    for (int i = 1; i < oCsvEnList.Count; i++)
                    {
                        if (
                            oCsvEnList[i][6] == "Metadata/Items/Currency/AbstractMicrotransaction" ||
                            oCsvEnList[i][6] == "Metadata/Items/HideoutDoodads/AbstractHideoutDoodad"
                            )
                        {
                            continue;
                        }

                        BaseResultData baseResultData = new BaseResultData();
                        baseResultData.ID           = oCsvEnList[i][1].Replace("Metadata/Items/", "");
                        baseResultData.InheritsFrom = oCsvEnList[i][6].Replace("Metadata/Items/", "");
                        baseResultData.NameEn       = Regex.Replace(oCsvEnList[i][5], "^\"(.+)\"$", "$1");
                        baseResultData.NameKo       = Regex.Replace(oCsvKoList[i][5], "^\"(.+)\"$", "$1");
                        baseResultData.Detail       = "";

                        if (datas.Find(x => x.NameEn == baseResultData.NameEn) == null)
                        {
                            datas.Add(baseResultData);
                        }
                    }

                    BaseData rootClass = Json.Deserialize <BaseData>("{\"result\":[{\"data\":[]}]}");
                    rootClass.Result[0].Data = datas.ToArray();

                    using (StreamWriter writer = new StreamWriter(path + "Bases.txt", false, Encoding.UTF8))
                    {
                        writer.Write(Json.Serialize <BaseData>(rootClass));
                    }

                    //-----------------------------

                    oCsvEnList = new List <string[]>();
                    oCsvKoList = new List <string[]>();

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/en/Words.dat.csv")))
                    {
                        string   sEnContents = oStreamReader.ReadToEnd();
                        string[] sEnLines    = sEnContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sEnLines)
                        {
                            oCsvEnList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/ko/Words.dat.csv")))
                    {
                        string   sKoContents = oStreamReader.ReadToEnd();
                        string[] sKoLines    = sKoContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sKoLines)
                        {
                            oCsvKoList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    List <WordeResultData> wdatas = new List <WordeResultData>();

                    for (int i = 1; i < oCsvEnList.Count; i++)
                    {
                        WordeResultData wordeResultData = new WordeResultData();
                        wordeResultData.Key    = oCsvEnList[i][1];
                        wordeResultData.NameEn = Regex.Replace(oCsvEnList[i][6], "^\"(.+)\"$", "$1");
                        wordeResultData.NameKo = Regex.Replace(oCsvKoList[i][6], "^\"(.+)\"$", "$1");
                        wdatas.Add(wordeResultData);
                    }

                    WordData wordClass = Json.Deserialize <WordData>("{\"result\":[{\"data\":[]}]}");
                    wordClass.Result[0].Data = wdatas.ToArray();

                    using (StreamWriter writer = new StreamWriter(path + "Words.txt", false, Encoding.UTF8))
                    {
                        writer.Write(Json.Serialize <WordData>(wordClass));
                    }

                    //-----------------------------

                    oCsvEnList = new List <string[]>();
                    oCsvKoList = new List <string[]>();

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/en/Prophecies.dat.csv")))
                    {
                        string   sEnContents = oStreamReader.ReadToEnd();
                        string[] sEnLines    = sEnContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sEnLines)
                        {
                            oCsvEnList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/ko/Prophecies.dat.csv")))
                    {
                        string   sKoContents = oStreamReader.ReadToEnd();
                        string[] sKoLines    = sKoContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sKoLines)
                        {
                            oCsvKoList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    datas = new List <BaseResultData>();

                    for (int i = 1; i < oCsvEnList.Count; i++)
                    {
                        BaseResultData baseResultData = new BaseResultData();
                        baseResultData.ID           = "Prophecies/" + oCsvEnList[i][1];
                        baseResultData.InheritsFrom = "Prophecies/Prophecy";
                        baseResultData.NameEn       = Regex.Replace(oCsvEnList[i][4], "^\"(.+)\"$", "$1");
                        baseResultData.NameKo       = Regex.Replace(oCsvKoList[i][4], "^\"(.+)\"$", "$1");
                        baseResultData.Detail       = "";

                        datas.Add(baseResultData);
                    }

                    rootClass = Json.Deserialize <BaseData>("{\"result\":[{\"data\":[]}]}");
                    rootClass.Result[0].Data = datas.ToArray();

                    using (StreamWriter writer = new StreamWriter(path + "Prophecies.txt", false, Encoding.UTF8))
                    {
                        writer.Write(Json.Serialize <BaseData>(rootClass));
                    }

                    //-----------------------------

                    oCsvEnList = new List <string[]>();
                    oCsvKoList = new List <string[]>();

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/en/MonsterVarieties.dat.csv")))
                    {
                        string   sEnContents = oStreamReader.ReadToEnd();
                        string[] sEnLines    = sEnContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sEnLines)
                        {
                            oCsvEnList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    using (StreamReader oStreamReader = new StreamReader(File.OpenRead(path + "csv/ko/MonsterVarieties.dat.csv")))
                    {
                        string   sKoContents = oStreamReader.ReadToEnd();
                        string[] sKoLines    = sKoContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        foreach (string sLine in sKoLines)
                        {
                            oCsvKoList.Add(Regex.Split(sLine, ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)"));
                        }
                    }

                    datas = new List <BaseResultData>();

                    for (int i = 1; i < oCsvEnList.Count; i++)
                    {
                        BaseResultData baseResultData = new BaseResultData();
                        baseResultData.ID           = oCsvEnList[i][1].Replace("Metadata/Monsters/", "");
                        baseResultData.InheritsFrom = oCsvEnList[i][9].Replace("Metadata/Monsters/", "");
                        baseResultData.NameEn       = Regex.Replace(oCsvEnList[i][33], "^\"(.+)\"$", "$1");
                        baseResultData.NameKo       = Regex.Replace(oCsvKoList[i][33], "^\"(.+)\"$", "$1");
                        baseResultData.Detail       = "";

                        if (datas.Find(x => x.NameEn == baseResultData.NameEn) == null)
                        {
                            datas.Add(baseResultData);
                        }
                    }

                    rootClass = Json.Deserialize <BaseData>("{\"result\":[{\"data\":[]}]}");
                    rootClass.Result[0].Data = datas.ToArray();

                    using (StreamWriter writer = new StreamWriter(path + "Monsters.txt", false, Encoding.UTF8))
                    {
                        writer.Write(Json.Serialize <BaseData>(rootClass));
                    }

                    success = true;
                }
                catch { }
            }

            return(success);
        }
예제 #4
0
        private bool FilterDataUpdates(string path)
        {
            bool success = false;

            // 마우스 훜시 프로그램에 딜레이가 생겨 쓰레드 처리
            Thread thread = new Thread(() =>
            {
                bool isKR     = false;
                string[] urls = { "https://poe.game.daum.net/api/trade/data/stats", "https://www.pathofexile.com/api/trade/data/stats" };
                foreach (string u in urls)
                {
                    isKR           = !isKR;
                    string sResult = SendHTTP(null, u, 5);
                    if ((sResult ?? "") != "")
                    {
                        FilterData rootClass = Json.Deserialize <FilterData>(sResult);

                        for (int i = 0; i < rootClass.Result.Length; i++)
                        {
                            if (
                                rootClass.Result[i].Entries.Length > 0 &&
                                RS.lFilterType.ContainsKey(rootClass.Result[i].Entries[0].Type)
                                )
                            {
                                rootClass.Result[i].Label = RS.lFilterType[rootClass.Result[i].Entries[0].Type];
                            }

                            if (rootClass.Result[i].Entries[0].Type == "monster")
                            {
                                for (int j = 0; j < rootClass.Result[i].Entries.Length; j++)
                                {
                                    rootClass.Result[i].Entries[j].Text = rootClass.Result[i].Entries[j].Text.Replace(" (×#)", "");
                                }
                            }
                        }

                        string local = isKR ? "(특정)" : " (Local)";

                        foreach (KeyValuePair <string, byte> itm in RS.lParticular)
                        {
                            for (int i = 0; i < rootClass.Result.Length; i++)
                            {
                                int index = Array.FindIndex(rootClass.Result[i].Entries, x => x.ID.Substring(x.ID.IndexOf(".") + 1) == itm.Key);
                                if (index > -1)
                                {
                                    rootClass.Result[i].Entries[index].Text = rootClass.Result[i].Entries[index].Text.Replace(local, "");
                                    rootClass.Result[i].Entries[index].Part = itm.Value == 1 ? "Weapons" : "Armours";
                                }
                            }
                        }

                        foreach (KeyValuePair <string, bool> itm in RS.lDisable)
                        {
                            for (int i = 0; i < rootClass.Result.Length; i++)
                            {
                                int index = Array.FindIndex(rootClass.Result[i].Entries, x => x.ID.Substring(x.ID.IndexOf(".") + 1) == itm.Key);
                                if (index > -1)
                                {
                                    rootClass.Result[i].Entries[index].Text = "__DISABLE__";
                                    rootClass.Result[i].Entries[index].Part = "Disable";
                                }
                            }
                        }

                        using (StreamWriter writer = new StreamWriter(path + (isKR ? "FiltersKO.txt" : "FiltersEN.txt"), false, Encoding.UTF8))
                        {
                            writer.Write(Json.Serialize <FilterData>(rootClass));
                        }

                        success = true;
                    }
                }
            });

            thread.Start();
            thread.Join();

            return(success);
        }
예제 #5
0
        private bool LoadData(out string outString)
        {
#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;
            string     s  = "";
            try
            {
                if (mCreateDatabase)
                {
                    string[] items = { "Bases", "Words", "Prophecies", "Monsters", "FiltersKO", "FiltersEN" };
                    foreach (string item in items)
                    {
                        File.Delete(path + item + ".txt");
                    }

                    if (!BaseDataUpdates(path) || !FilterDataUpdates(path))
                    {
                        s = "생성 실패";
                        throw new UnauthorizedAccessException("failed to create database");
                    }
                }

                s  = "Bases.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string   json = reader.ReadToEnd();
                    BaseData data = Json.Deserialize <BaseData>(json);
                    mBaseDatas = new List <BaseResultData>();
                    mBaseDatas.AddRange(data.Result[0].Data);
                }

                s  = "Words.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string   json = reader.ReadToEnd();
                    WordData data = Json.Deserialize <WordData>(json);
                    mWordDatas = new List <WordeResultData>();
                    mWordDatas.AddRange(data.Result[0].Data);
                }

                s  = "Prophecies.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string   json = reader.ReadToEnd();
                    BaseData data = Json.Deserialize <BaseData>(json);
                    mProphecyDatas = new List <BaseResultData>();
                    mProphecyDatas.AddRange(data.Result[0].Data);
                }

                s  = "Monsters.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string   json = reader.ReadToEnd();
                    BaseData data = Json.Deserialize <BaseData>(json);
                    mMonsterDatas = new List <BaseResultData>();
                    mMonsterDatas.AddRange(data.Result[0].Data);
                }

                s  = "FiltersKO.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mFilterData[0] = Json.Deserialize <FilterData>(json);
                }

                s  = "FiltersEN.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mFilterData[1] = Json.Deserialize <FilterData>(json);
                }
            }
            catch (Exception ex)
            {
                outString = s;
                MessageBox.Show(Application.Current.MainWindow, ex.Message, "에러");
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            outString = s;
            return(true);
        }
예제 #6
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);
        }
예제 #7
0
        /*
         * [DataContract]
         * public class MODS
         * {
         *  [DataMember(Name = "FIELD1")]
         *  public string FIELD1;
         *  [DataMember(Name = "FIELD2")]
         *  public string FIELD2;
         *  [DataMember(Name = "FIELD3")]
         *  public int FIELD3;
         *  [DataMember(Name = "FIELD4")]
         *  public string FIELD4;
         *  [DataMember(Name = "FIELD5")]
         *  public string FIELD5;
         * }
         *
         * private bool MergeModData()
         * {
         *  string path = (string)Application.Current.Properties["DataPath"];
         *  FileStream fs = null;
         *  string s = "";
         *  try
         *  {
         *      List<MODS>[] modsData = new List<MODS>[2];
         *
         *      s = "_POE_EXE/mods_ko.txt";
         *      fs = new FileStream(path + s, FileMode.Open);
         *      using (StreamReader reader = new StreamReader(fs))
         *      {
         *          fs = null;
         *          string json = reader.ReadToEnd();
         *          modsData[0] = Json.Deserialize<List<MODS>>(json);
         *          reader.Close();
         *      }
         *
         *      s = "_POE_EXE/mods_en.txt";
         *      fs = new FileStream(path + s, FileMode.Open);
         *      using (StreamReader reader = new StreamReader(fs))
         *      {
         *          fs = null;
         *          string json = reader.ReadToEnd();
         *          modsData[1] = Json.Deserialize<List<MODS>>(json);
         *          reader.Close();
         *      }
         *
         *      ModsDict modsDict = new ModsDict();
         *      modsDict.Entries = new List<ModsDictItem>();
         *
         *      int i = -1;
         *
         *      foreach (var item in modsData[1])
         *      {
         *          i++;
         *          string[] split = item.FIELD4.Replace("\u000a", "\n").Split(new string[] { "\n" }, StringSplitOptions.None);
         *
         *          string[] sa = new string[2] { "Eternal Iron Hook", "Totemic Wood Lure" };
         *          if (split[0].WithIn(sa)) continue;
         *
         *          for (int k = 0; k < split.Length; k++)
         *          {
         *              FilterDictItem filter = null;
         *              string[] matches = { null, null };
         *
         *              foreach (var re in mFilter[1].Result)
         *              {
         *                  split[k] = split[k].RepEx(@" an additional (Arrow|Target|Curse)", " 1 additional $1s");
         *
         *                  string tmp = split[k].RepEx(@"\([0-9\-\.]+\)", "#");
         *                  filter = Array.Find(re.Entries, x => x.Text == tmp);
         *                  if (filter == null)
         *                  {
         *                      tmp = tmp.RepEx(@"[0-9]+ to #|# to [0-9]+|[0-9]+ to [0-9]+", "# to #");
         *                      filter = Array.Find(re.Entries, x => x.Text == tmp);
         *                  }
         *                  if (filter == null)
         *                  {
         *                      tmp = tmp.RepEx(@"[+-]?[0-9]+\.[0-9]+|[+-]?[0-9]+", "#").Escape()
         *                              .RepEx(@"\\#", "[+-]?([0-9]+\\.[0-9]+|[0-9]+|\\#)")
         *                              .Replace("Attacks\\ have\\ ", "(Melee )?Attacks\\ have\\ ");
         *                      Regex rgx = new Regex("^" + tmp + "$", RegexOptions.IgnoreCase);
         *                      filter = Array.Find(re.Entries, x => rgx.IsMatch(x.Text));
         *                  }
         *                  if (filter != null)
         *                  {
         *                      tmp = filter.Text.Replace("#", @"(\([0-9\.-]+\)|[0-9]+|[0-9]+\.[0-9]+)");
         *                      matches = split[k].RepEx(tmp, "$1,$2").Split(',')
         *                                      .Select(x => x[0] == '$' ? null : x.RepEx(@"\(|\)|\+", "")).ToArray();
         *                      if(matches.Length == 1) matches = new string[] { null, null };
         *                      break;
         *                  }
         *              }
         *
         *              if (filter != null)
         *              {
         *                  ModsDictItem modsDictItem = new ModsDictItem();
         *                  modsDictItem.Id = filter != null ? filter.Id.Split('.')[1] : split[k];
         *                  modsDictItem.Level = item.FIELD3;
         *                  modsDictItem.Fix = item.FIELD1;
         *                  modsDictItem.Tags = item.FIELD5;
         *                  modsDictItem.Name = new string[2] { item.FIELD2, modsData[0][i].FIELD2 };
         *                  modsDictItem.Min = matches[0]?.RepEx("([0-9])-", "$1~");
         *                  modsDictItem.Max = matches[1]?.RepEx("([0-9])-", "$1~");
         *                  modsDict.Entries.Add(modsDictItem);
         *              }
         *          }
         *      }
         *
         *      File.Delete(path + "Mods.txt");
         *      using (StreamWriter writer = new StreamWriter(path + "Mods.txt", false, Encoding.UTF8))
         *      {
         *          writer.Write(Json.Serialize<ModsDict>(modsDict, true));
         *          writer.Close();
         *      }
         *  }
         *  catch (Exception ex)
         *  {
         *      MessageBox.Show(Application.Current.MainWindow, ex.Message, "에러");
         *      return false;
         *  }
         *  finally
         *  {
         *      if (fs != null) fs.Dispose();
         *  }
         *
         *  return true;
         * }
         */

        private bool LoadData(out string outString)
        {
            string     path = (string)Application.Current.Properties["DataPath"];
            FileStream fs   = null;
            string     s    = "";

            try
            {
                if (!File.Exists(path + "FiltersKO.txt") || !File.Exists(path + "FiltersEN.txt"))
                {
                    mTrayIcon.BalloonTipText = "데이터를 업데이트 하는중...";
                    mTrayIcon.BalloonTipIcon = System.Windows.Forms.ToolTipIcon.Info;
                    mTrayIcon.ShowBalloonTip(5000);

                    string[] items = { "FiltersKO", "FiltersEN", "ItemsKO", "ItemsEN", "StaticKO", "StaticEN" };
                    foreach (string item in items)
                    {
                        File.Delete(path + item + ".txt");
                    }

                    if (!FilterDataUpdate(path) || !ItemDataUpdate(path) || !StaticDataUpdate(path))
                    {
                        s = "생성 실패";
                        throw new UnauthorizedAccessException("Database 파일 생성 실패");
                    }
                }

                s  = "FiltersKO.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mFilter[0] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                s  = "FiltersEN.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mFilter[1] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                s  = "ItemsKO.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mItems[0] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                s  = "ItemsEN.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mItems[1] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                s  = "StaticKO.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mStatic[0] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                s  = "StaticEN.txt";
                fs = new FileStream(path + s, FileMode.Open);
                using (StreamReader reader = new StreamReader(fs))
                {
                    fs = null;
                    string json = reader.ReadToEnd();
                    mStatic[1] = Json.Deserialize <FilterData>(json);
                    reader.Close();
                }

                /*
                 * s = "Mods.txt";
                 * fs = new FileStream(path + s, FileMode.Open);
                 * using (StreamReader reader = new StreamReader(fs))
                 * {
                 *  fs = null;
                 *  string json = reader.ReadToEnd();
                 *  mMods = Json.Deserialize<ModsDict>(json);
                 *  reader.Close();
                 * }
                 */

                //MergeModData();
            }
            catch (Exception ex)
            {
                outString = s;
                MessageBox.Show(Application.Current.MainWindow, ex.Message, "에러");
                return(false);
            }
            finally
            {
                if (fs != null)
                {
                    fs.Dispose();
                }
            }

            outString = s;
            return(true);
        }
예제 #8
0
파일: Updates.cs 프로젝트: dennistlt/test
        private bool FilterDataUpdates(string path)
        {
            bool success = false;

            // 마우스 훜시 프로그램에 딜레이가 생겨 쓰레드 처리
            Thread thread = new Thread(() =>
            {
                string u       = "https://pathofexile.com/api/trade/data/stats";
                string sResult = SendHTTP(null, u, 5);
                if ((sResult ?? "") != "")
                {
                    FilterData rootClass = Json.Deserialize <FilterData>(sResult);

                    for (int i = 0; i < rootClass.Result.Length; i++)
                    {
                        if (
                            rootClass.Result[i].Entries.Length > 0 &&
                            Restr.lFilterTypeName.ContainsKey(rootClass.Result[i].Entries[0].Type)
                            )
                        {
                            rootClass.Result[i].Label = Restr.lFilterTypeName[rootClass.Result[i].Entries[0].Type];
                        }
                    }

                    foreach (KeyValuePair <string, byte> itm in Restr.lParticular)
                    {
                        for (int i = 0; i < rootClass.Result.Length; i++)
                        {
                            int index = Array.FindIndex(rootClass.Result[i].Entries, x => x.ID.Substring(x.ID.IndexOf(".") + 1) == itm.Key);
                            if (index > -1 && rootClass.Result[i].Entries[index].Text.IndexOf("(" + Restr.Local + ")") > 0)
                            {
                                rootClass.Result[i].Entries[index].Text = rootClass.Result[i].Entries[index].Text.Replace(" (" + Restr.Local + ")", "");
                                rootClass.Result[i].Entries[index].Part = itm.Value == 1 ? "Weapons" : "Armours";
                            }
                        }
                    }

                    foreach (KeyValuePair <string, bool> itm in Restr.lDisable)
                    {
                        for (int i = 0; i < rootClass.Result.Length; i++)
                        {
                            int index = Array.FindIndex(rootClass.Result[i].Entries, x => x.ID.Substring(x.ID.IndexOf(".") + 1) == itm.Key);
                            if (index > -1)
                            {
                                rootClass.Result[i].Entries[index].Text = "__DISABLE__";
                                rootClass.Result[i].Entries[index].Part = "Disable";
                            }
                        }
                    }

                    using (StreamWriter writer = new StreamWriter(path + "Filters.txt", false, Encoding.UTF8))
                    {
                        writer.Write(Json.Serialize <FilterData>(rootClass));
                    }

                    success = true;
                }
            });

            thread.Start();
            thread.Join();

            return(success);
        }
예제 #9
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string sEntity;
            string url = "";

            string[] exchange     = null;
            string   accountState = (string)cbAccountState.SelectedValue;

            if (bdExchange.Visibility == Visibility.Visible && (cbOrbs.SelectedIndex > 0 || cbSplinters.SelectedIndex > 0))
            {
                exchange    = new string[2];
                exchange[0] = Restr.lExchangeCurrency[mItemBaseName.TypeEN];
                exchange[1] = Restr.lExchangeCurrency[(string)(cbOrbs.SelectedIndex > 0 ? cbOrbs.SelectedValue : cbSplinters.SelectedValue)];
                int minimumStock = int.Parse(tbPriceMinStock.Text);
                url  = Restr.ExchangeApi[Restr.ServerLang] + Restr.ServerType + "/?redirect&source=";
                url += Uri.EscapeDataString("{\"exchange\":{\"status\":{\"option\":\"" + accountState + "\"},\"have\":[\"" + exchange[0] + "\"],\"want\":[\"" + exchange[1] + "\"],\"minimum\":" + minimumStock + "}}");
                Process.Start(url);
            }
            else
            {
                sEntity = CreateJson(GetItemOptions(), false, accountState);

                if (sEntity == null || sEntity == "")
                {
                    ForegroundMessage("Json 생성을 실패했습니다.", "에러", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (mConfigData.Options.ServerRedirect)
                {
                    url  = Restr.TradeApi[Restr.ServerLang] + Restr.ServerType + "/?redirect&source=";
                    url += Uri.EscapeDataString(sEntity);
                    Process.Start(url);
                }
                else
                {
                    string sResult = null;

                    // 마우스 훜시 프로그램에 딜레이가 생겨 쓰레드 처리
                    Thread thread = new Thread(() =>
                    {
                        sResult = SendHTTP(sEntity, Restr.TradeApi[Restr.ServerLang] + Restr.ServerType, mConfigData.Options.ServerTimeout);
                        if ((sResult ?? "") != "")
                        {
                            try
                            {
                                ResultData resultData = Json.Deserialize <ResultData>(sResult);
                                url = Restr.TradeUrl[Restr.ServerLang] + Restr.ServerType + "/" + resultData.ID;
                                Process.Start(url);
                            }
                            catch { }
                        }
                    });

                    thread.Start();
                    thread.Join();

                    if ((sResult ?? "") == "")
                    {
                        ForegroundMessage(
                            "Server cannot be connected right now.",
                            "Search failed",
                            MessageBoxButton.OK, MessageBoxImage.Information
                            );
                        return;
                    }
                }
            }

            Hide();
        }