first commit
This commit is contained in:
18
PoEco.Net/App.config
Normal file
18
PoEco.Net/App.config
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
|
||||
</startup>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
133
PoEco.Net/DB/ClassGen.cs
Normal file
133
PoEco.Net/DB/ClassGen.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace PoEco.Net.DB
|
||||
{
|
||||
internal class ClassGen
|
||||
{
|
||||
public static MySqlConnection MxPoEDB()
|
||||
{
|
||||
MySqlConnection conn;
|
||||
string myConnectionString;
|
||||
|
||||
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};";
|
||||
conn = new MySqlConnection();
|
||||
conn.ConnectionString = myConnectionString;
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static void AddClass(int id, string name)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"INSERT INTO poeco_classes(cid, name) VALUES ('{id}','{name}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void AddBase(string querycmd)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
//string cmdText = $"INSERT INTO poeco_bases(bid, cid, name) VALUES ('{bid}', '{cid}', '{MySql.Data.MySqlClient.MySqlHelper.EscapeString(name)}')";
|
||||
string cmdText = querycmd;
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void AddImplicit(string querycmd)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
//string cmdText = $"INSERT INTO poeco_implicit(bid, imp) VALUES ('{bid}', '{MySql.Data.MySqlClient.MySqlHelper.EscapeString(imp)}')";
|
||||
string cmdText = querycmd;
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteClass()
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_classes";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteBase()
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_bases";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteImplicit()
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_implicit";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void GenClass()
|
||||
{
|
||||
DeleteClass();
|
||||
DeleteBase();
|
||||
DeleteImplicit();
|
||||
DirectoryInfo dir = new DirectoryInfo("data/lua");
|
||||
int cid = 1;
|
||||
int bid = 1;
|
||||
StringBuilder sCommandBase = new StringBuilder("INSERT INTO poeco_bases(bid, cid, name) VALUES ");
|
||||
List<string> RowsBase = new List<string>();
|
||||
StringBuilder sCommandImp = new StringBuilder("INSERT INTO poeco_implicit(bid, imp) VALUES ");
|
||||
List<string> RowsImp = new List<string>();
|
||||
foreach (var f in dir.GetFiles())
|
||||
{
|
||||
var fnp = Path.GetFileNameWithoutExtension(f.FullName);
|
||||
var fnpUp = char.ToUpper(f.Name[0]) + fnp.Substring(1);
|
||||
AddClass(cid, fnpUp);
|
||||
Utilities.Message.drawProgress(cid, dir.EnumerateFiles().Count());
|
||||
foreach (var l in File.ReadLines(@"data/lua/" + f.Name))
|
||||
{
|
||||
int ll = l.Length;
|
||||
|
||||
if (l.Contains("itemBases["))
|
||||
{
|
||||
RowsBase.Add($"('{bid}','{cid}','{MySql.Data.MySqlClient.MySqlHelper.EscapeString(l.Split('"', '"')[1])}')");
|
||||
}
|
||||
if (l.Contains("\timplicit = \""))
|
||||
{
|
||||
RowsImp.Add($"('{bid}','{MySql.Data.MySqlClient.MySqlHelper.EscapeString(l.Split('"', '"')[1])}')");
|
||||
bid++;
|
||||
}
|
||||
}
|
||||
cid++;
|
||||
}
|
||||
sCommandBase.Append(string.Join(",", RowsBase));
|
||||
sCommandBase.Append(";");
|
||||
AddBase(sCommandBase.ToString());
|
||||
sCommandImp.Append(string.Join(",", RowsImp));
|
||||
sCommandImp.Append(";");
|
||||
AddImplicit(sCommandImp.ToString());
|
||||
sCommandBase.Clear();
|
||||
sCommandImp.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
87
PoEco.Net/DB/Item.cs
Normal file
87
PoEco.Net/DB/Item.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.DB
|
||||
{
|
||||
internal class Item
|
||||
{
|
||||
public static MySqlConnection MxPoEDB()
|
||||
{
|
||||
MySqlConnection conn;
|
||||
string myConnectionString;
|
||||
|
||||
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};";
|
||||
conn = new MySqlConnection();
|
||||
conn.ConnectionString = myConnectionString;
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static bool CheckItemExistsByUIID(string uuid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_items WHERE uiid = '{uuid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows)
|
||||
{
|
||||
con.Close();
|
||||
return true;
|
||||
} else
|
||||
{
|
||||
con.Close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int CountItemByUID(int uid, int tid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT COUNT(*) FROM poeco_items WHERE uid = '{uid}' AND tid = '{tid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
int count = Convert.ToInt32(cmd.ExecuteScalar());
|
||||
return count;
|
||||
}
|
||||
|
||||
public static List<string> EnumerateItemByUID(int uid, int tid)
|
||||
{
|
||||
List<string> i = new List<string>();
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_items WHERE uid = '{uid}' AND tid = '{tid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
MySqlDataReader DR = cmd.ExecuteReader();
|
||||
while (DR.Read())
|
||||
{
|
||||
i.Add(DR.GetString(2));
|
||||
}
|
||||
con.Close();
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void DeleteItemByUIID(int uid, int tid, string uiid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_items WHERE uid = '{uid}' AND tid = '{tid}' AND uiid = '{uiid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteAllItemsByUID(int uid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_items WHERE uid = '{uid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
174
PoEco.Net/DB/Stash.cs
Normal file
174
PoEco.Net/DB/Stash.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.DB
|
||||
{
|
||||
internal class Stash
|
||||
{
|
||||
public static MySqlConnection MxPoEDB()
|
||||
{
|
||||
MySqlConnection conn;
|
||||
string myConnectionString;
|
||||
|
||||
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};;max pool size=200";
|
||||
conn = new MySqlConnection();
|
||||
conn.ConnectionString = myConnectionString;
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static List<int> EnumerateTabByUID(int uid, string type)
|
||||
{
|
||||
List<int> t = new List<int>();
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_tabs WHERE uid = '{uid}' AND type = '{type}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
MySqlDataReader DR = cmd.ExecuteReader();
|
||||
while (DR.Read())
|
||||
{
|
||||
t.Add(DR.GetInt32(1));
|
||||
}
|
||||
con.Close();
|
||||
return t;
|
||||
}
|
||||
|
||||
public static int GetClassIDByBase(string ibase)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_bases WHERE name LIKE '%{MySqlHelper.EscapeString(ibase)}%'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows)
|
||||
{
|
||||
row.Read();
|
||||
int user = row.GetInt32(1);
|
||||
con.Close();
|
||||
return user;
|
||||
}
|
||||
else
|
||||
{
|
||||
con.Close();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetClassByID(int iclass)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_classes WHERE cid = '{iclass}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows)
|
||||
{
|
||||
row.Read();
|
||||
string user = row.GetString(1);
|
||||
con.Close();
|
||||
return user;
|
||||
}
|
||||
else
|
||||
{
|
||||
con.Close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int GetBaseIDByName(string ibase)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_bases WHERE name LIKE '%{MySql.Data.MySqlClient.MySqlHelper.EscapeString(ibase)}%'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return row.GetInt32(0); } else { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddItemTable(int uid, int ti, string uiid, int ilvl, int cid, int bid, string name, string mods, string img, string txt, string b64, double min, double max)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"INSERT INTO poeco_items(uid, tid, uiid, ilvl, cid, bid, name, mods, img, txt, b64, min, max) VALUES ('{uid}','{ti}','{uiid}','{ilvl}','{cid}','{bid}','{name}','{mods}','{img}','{txt}','{b64}','{min}','{max}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void AddProfitTable(int uid, string uiid, string type, string name, int stack, double value)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"INSERT INTO poeco_profits(uid, uiid, type, name, stack, cvalue) VALUES ('{uid}','{uiid}','{type}','{name}','{stack}','{value}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetTabNameByTID(int uid, int tid, string name)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_tabs SET name = '{name}' WHERE uid = '{uid}' AND tid = '{tid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void SetTabRGBByTID(int uid, int tid, string rgb)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_tabs SET rgb = '{rgb}' WHERE uid = '{uid}' AND tid = '{tid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static bool CheckItemExistsDB(string iid)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_items WHERE uiid = '{iid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
return row.HasRows;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteSpecificItem(int userid, string uuid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_items WHERE uid = '{userid}' AND uiid = '{uuid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteItems(int userid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_items WHERE uid = '{userid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
216
PoEco.Net/DB/User.cs
Normal file
216
PoEco.Net/DB/User.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.DB
|
||||
{
|
||||
internal class User
|
||||
{
|
||||
public static MySqlConnection MxPoEDB()
|
||||
{
|
||||
MySqlConnection conn;
|
||||
string myConnectionString;
|
||||
|
||||
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};";
|
||||
conn = new MySqlConnection();
|
||||
conn.ConnectionString = myConnectionString;
|
||||
return conn;
|
||||
}
|
||||
|
||||
public static bool CheckUserExists(string user, string discriminator)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}|{discriminator}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { con.Close(); return true; } else { con.Close(); return false; }
|
||||
}
|
||||
|
||||
public static int GetUserID(string user)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return Convert.ToInt32(row["uid"]); } else { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
public static string[] GetUserNameByID(int uid)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE uid = '{uid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows)
|
||||
{
|
||||
row.Read();
|
||||
string[] user = row["account"].ToString().Split('|');
|
||||
con.Close();
|
||||
return user;
|
||||
} else
|
||||
{
|
||||
con.Close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetUserTokenByID(int uid)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE uid = '{uid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows)
|
||||
{
|
||||
row.Read();
|
||||
string user = row["token"].ToString();
|
||||
con.Close();
|
||||
return user;
|
||||
}
|
||||
else
|
||||
{
|
||||
con.Close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetUserTabIndex(string user)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); con.Close(); return Convert.ToInt32(row["rareindex"]); } else { con.Close(); return 0; }
|
||||
}
|
||||
|
||||
public static int GetUserProfitTabIndex(int uid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_tabs WHERE type = 'profit'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return Convert.ToInt32(row["tid"]); } else { return 0; }
|
||||
}
|
||||
|
||||
public static int GetUserCurrencyIndex(string user, string column)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return Convert.ToInt32(row[column]); } else { return 0; }
|
||||
}
|
||||
|
||||
public static int GetUserItemCount(string user)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return Convert.ToInt32(row["itemcount"]); } else { return 0; }
|
||||
}
|
||||
|
||||
public static string GetUserStashHash(string user)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return row["stashb64"].ToString(); } else { return ""; }
|
||||
}
|
||||
|
||||
public static string GetUserToken(string user)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_user WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (row.HasRows) { row.Read(); return row["token"].ToString(); } else { return ""; }
|
||||
}
|
||||
|
||||
public static int GetTabValueByTID(int uid, int tid)
|
||||
{
|
||||
int tv = 0;
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_items WHERE uid = '{uid}' AND tid = '{tid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
MySqlDataReader DR = cmd.ExecuteReader();
|
||||
while (DR.Read())
|
||||
{
|
||||
tv = tv + DR.GetInt32(12);
|
||||
}
|
||||
return tv;
|
||||
}
|
||||
|
||||
public static int CountTabByUID(int uid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"SELECT COUNT(*) FROM poeco_tabs WHERE uid = '{uid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
int count = Convert.ToInt32(cmd.ExecuteScalar());
|
||||
con.Close();
|
||||
return count;
|
||||
}
|
||||
|
||||
public static void SetUserItemCount(int uid, int count, int index)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_tabs SET count = '{count}' WHERE uid = '{uid}' AND tid = '{index}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void SetUserStashHash(string user, string b64)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_user SET stashb64 = '{b64}' WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void SetUserTabValue(int uid, int ti, double value)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_tabs SET cvalue = '{value}' WHERE uid = '{uid}' AND tid = '{ti}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteProfits(int uid)
|
||||
{
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_profits WHERE uid = '{uid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
80
PoEco.Net/JSON/Classes/Divination.cs
Normal file
80
PoEco.Net/JSON/Classes/Divination.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.JSON.Classes
|
||||
{
|
||||
internal class Divination
|
||||
{
|
||||
public class Sparkline
|
||||
{
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public List<double?> data { get; set; }
|
||||
public double? totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class LowConfidenceSparkline
|
||||
{
|
||||
public List<double?> data { get; set; }
|
||||
public double? totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class ExplicitModifier
|
||||
{
|
||||
public string text { get; set; }
|
||||
public bool? optional { get; set; }
|
||||
}
|
||||
|
||||
public class LineDivination
|
||||
{
|
||||
public int? id { get; set; }
|
||||
public string name { get; set; }
|
||||
public string icon { get; set; }
|
||||
public int? mapTier { get; set; }
|
||||
public int? levelRequired { get; set; }
|
||||
public string baseType { get; set; }
|
||||
public int? stackSize { get; set; }
|
||||
public object variant { get; set; }
|
||||
public object prophecyText { get; set; }
|
||||
public object artFilename { get; set; }
|
||||
public int? links { get; set; }
|
||||
public int? itemClass { get; set; }
|
||||
public Sparkline sparkline { get; set; }
|
||||
public LowConfidenceSparkline lowConfidenceSparkline { get; set; }
|
||||
public List<object> implicitModifiers { get; set; }
|
||||
public List<ExplicitModifier> explicitModifiers { get; set; }
|
||||
public string flavourText { get; set; }
|
||||
public bool? corrupted { get; set; }
|
||||
public int? gemLevel { get; set; }
|
||||
public int? gemQuality { get; set; }
|
||||
public string itemType { get; set; }
|
||||
public double chaosValue { get; set; }
|
||||
public double exaltedValue { get; set; }
|
||||
public double divineValue { get; set; }
|
||||
public int count { get; set; }
|
||||
public string detailsId { get; set; }
|
||||
public object tradeInfo { get; set; }
|
||||
public object mapRegion { get; set; }
|
||||
public int? listingCount { get; set; }
|
||||
}
|
||||
|
||||
public class Translations
|
||||
{
|
||||
}
|
||||
|
||||
public class Language
|
||||
{
|
||||
public string name { get; set; }
|
||||
public Translations translations { get; set; }
|
||||
}
|
||||
|
||||
public class RootDivination
|
||||
{
|
||||
public List<LineDivination> lines { get; set; }
|
||||
public Language language { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
76
PoEco.Net/JSON/Currency.cs
Normal file
76
PoEco.Net/JSON/Currency.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using PoEco.Net.DB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using static PoEco.Net.JSON.Stash;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace PoEco.Net.JSON
|
||||
{
|
||||
internal class Currency
|
||||
{
|
||||
public static MySqlConnection MxPoEDB()
|
||||
{
|
||||
MySqlConnection conn;
|
||||
string myConnectionString;
|
||||
|
||||
myConnectionString = $"server={JSON.Settings.GetdbHost()};port={JSON.Settings.GetdbPort()};uid={JSON.Settings.GetdbUser()};pwd={JSON.Settings.GetdbPass()};database={JSON.Settings.GetdbName()};";
|
||||
conn = new MySqlConnection();
|
||||
conn.ConnectionString = myConnectionString;
|
||||
return conn;
|
||||
}
|
||||
public static void GenCurrencyTab(string user, int tab, string columnname, string table)
|
||||
{
|
||||
int uid = DB.User.GetUserID(user);
|
||||
double chaosValue = 0;
|
||||
string curName = "";
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.tab.{tab}.json"));
|
||||
foreach (Stash.Item i in stash.items)
|
||||
{
|
||||
if (columnname == "divvalue")
|
||||
{
|
||||
//Console.WriteLine(MySqlHelper.EscapeString(i.typeLine)+" "+GetCurrencyValueByName(MySqlHelper.EscapeString(curName), table));
|
||||
MySqlConnection cond = MxPoEDB();
|
||||
string cmdTextd = $"INSERT INTO poeco_tab_div(uid, uiid, name, stack, cvalue) VALUES ('{uid}','{i.id}','{MySqlHelper.EscapeString(i.typeLine)}','{i.stackSize}','{GetCurrencyValueByName(MySqlHelper.EscapeString(curName), table)}')";
|
||||
MySqlCommand cmdd = new MySqlCommand(cmdTextd, cond);
|
||||
cond.Open();
|
||||
cmdd.ExecuteNonQuery();
|
||||
cond.Close();
|
||||
}
|
||||
curName = i.typeLine;
|
||||
chaosValue = chaosValue + (GetCurrencyValueByName(MySqlHelper.EscapeString(curName), table) * i.stackSize);
|
||||
}
|
||||
MySqlConnection con = MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_user SET {columnname} = '{chaosValue}' WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
public static double GetCurrencyValueByName(string name, string table)
|
||||
{
|
||||
using (var con = MxPoEDB())
|
||||
{
|
||||
string cmdText = $"SELECT * FROM {table} WHERE name = '{name}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
var row = cmd.ExecuteReader();
|
||||
if (name == "Chaos Orb")
|
||||
{
|
||||
return 1.0;
|
||||
} else
|
||||
{
|
||||
if (row.HasRows) { row.Read(); return Convert.ToDouble(row["vchaos"]); } else { return 0; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
49
PoEco.Net/JSON/Settings.cs
Normal file
49
PoEco.Net/JSON/Settings.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.JSON
|
||||
{
|
||||
internal class Settings
|
||||
{
|
||||
public class SETTINGS
|
||||
{
|
||||
public string dbHost { get; set; }
|
||||
public string dbPort { get; set; }
|
||||
public string dbName { get; set; }
|
||||
public string dbUser { get; set; }
|
||||
public string dbPass { get; set; }
|
||||
public string league { get; set; }
|
||||
public bool web { get; set; }
|
||||
public string webpath { get; set; }
|
||||
}
|
||||
|
||||
public static string GetdbHost() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).dbHost;
|
||||
public static string GetdbPort() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).dbPort;
|
||||
public static string GetdbName() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).dbName;
|
||||
public static string GetdbUser() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).dbUser;
|
||||
public static string GetdbPass() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).dbPass;
|
||||
public static string GetLeague() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).league;
|
||||
public static bool GetWeb() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).web;
|
||||
public static string GetWebPath() => JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/settings.json")).webpath;
|
||||
|
||||
public static void WriteSection(string section)
|
||||
{
|
||||
SETTINGS settings = JsonConvert.DeserializeObject<SETTINGS>(File.ReadAllText("data/gui.settings.json"));
|
||||
File.WriteAllText("data/gui.settings.json", JsonConvert.SerializeObject((object)new SETTINGS()
|
||||
{
|
||||
dbHost = settings.dbHost,
|
||||
dbPort = settings.dbPort,
|
||||
dbName = settings.dbName,
|
||||
dbUser = settings.dbUser,
|
||||
dbPass = settings.dbPass,
|
||||
league = settings.league
|
||||
}, Formatting.Indented));
|
||||
}
|
||||
}
|
||||
}
|
||||
476
PoEco.Net/JSON/Stash.cs
Normal file
476
PoEco.Net/JSON/Stash.cs
Normal file
@@ -0,0 +1,476 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
using Newtonsoft.Json;
|
||||
using PoEco.Net.DB;
|
||||
using PoEco.Net.Web;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.JSON
|
||||
{
|
||||
internal class Stash
|
||||
{
|
||||
public static void GenStashHash(string user)
|
||||
{
|
||||
List<string> itemsID = new List<string>();
|
||||
StringBuilder stashHash = new StringBuilder();
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.json"));
|
||||
foreach (var i in stash.items)
|
||||
{
|
||||
itemsID.Add(i.id);
|
||||
}
|
||||
stashHash.Append(string.Join(":", itemsID));
|
||||
string sb64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(stashHash.ToString()));
|
||||
DB.User.SetUserStashHash(user, sb64);
|
||||
}
|
||||
public static string GetStashHash(string user)
|
||||
{
|
||||
List<string> itemsID = new List<string>();
|
||||
StringBuilder stashHash = new StringBuilder();
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.json"));
|
||||
foreach (var i in stash.items)
|
||||
{
|
||||
itemsID.Add(i.id);
|
||||
}
|
||||
stashHash.Append(string.Join(":", itemsID));
|
||||
string sb64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(stashHash.ToString()));
|
||||
return sb64;
|
||||
}
|
||||
public static int GetUserItemCount(string user, int tid)
|
||||
{
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.rare.{tid}.json"));
|
||||
return stash.items.Count;
|
||||
}
|
||||
public static int GetUserProfitCount(string user, int tid)
|
||||
{
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.profit.{tid}.json"));
|
||||
return stash.items.Count;
|
||||
}
|
||||
public static void UpdateUserTabRGB(string user, int tabindex)
|
||||
{
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.json"));
|
||||
MySqlConnection con = DB.Stash.MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_user SET tabrgb = '{stash.tabs[tabindex].colour.r}:{stash.tabs[tabindex].colour.g}:{stash.tabs[tabindex].colour.b}' WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
public static void UpdateUserTabName(string user, int tabindex)
|
||||
{
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($"data/stash/{user}.tab{tabindex}.json"));
|
||||
MySqlConnection con = DB.Stash.MxPoEDB();
|
||||
string cmdText = $"UPDATE poeco_user SET tabname = '{stash.tabs[tabindex].n}' WHERE account = '{user}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
public static void CleanDB(string user, int userid)
|
||||
{
|
||||
MySqlConnection con = DB.Stash.MxPoEDB();
|
||||
string cmdText = $"SELECT * FROM poeco_items WHERE uid = '{userid}'";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
MySqlDataReader mdata = cmd.ExecuteReader();
|
||||
while (mdata.Read())
|
||||
{
|
||||
//if (!CheckItemExistsStash(user, mdata.GetString(6)))
|
||||
//{
|
||||
// DB.Stash.DeleteSpecificItem(userid, mdata.GetString(6));
|
||||
//}
|
||||
}
|
||||
}
|
||||
public static bool CheckItemExistsStash(string user, int tid, string uuid)
|
||||
{
|
||||
bool exists = false;
|
||||
List<string> items = new List<string>();
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($"data/stash/{user}.rare.{tid}.json"));
|
||||
foreach (var s in stash.items)
|
||||
{
|
||||
items.Add(s.id);
|
||||
}
|
||||
if (items.Contains(uuid))
|
||||
{
|
||||
exists = true;
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
public static void GenItemTable(string user)
|
||||
{
|
||||
List<string> stringItemTxt = new List<string>();
|
||||
List<string> stringItemMod = new List<string>();
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.json"));
|
||||
int curitem = 1;
|
||||
double chaosValue = 0;
|
||||
int guid = 0;
|
||||
//DB.Stash.DeleteItems(DB.User.GetUserID(user));
|
||||
var tmpfiles = Directory.GetFiles("tmp");
|
||||
StringBuilder sCommand = new StringBuilder("INSERT INTO poeco_items(uid, tabindex, tabname, tabrgb, cid, bid, uiid, imod, var, img, txt, b64, ctype, min, max) VALUES ");
|
||||
List<string> Rows = new List<string>();
|
||||
int itemcount = stash.items.Count();
|
||||
foreach ( var file in tmpfiles ) { File.Delete(file); }
|
||||
foreach (Item obj in stash.items)
|
||||
{
|
||||
if (!DB.Stash.CheckItemExistsDB(obj.id))
|
||||
{
|
||||
itemcount--;
|
||||
}
|
||||
if (obj.typeLine != "" && obj.frameType == 2 && obj.identified && !DB.Stash.CheckItemExistsDB(obj.id))
|
||||
{
|
||||
//Message.drawProgress(curitem, itemcount);
|
||||
int icid = DB.Stash.GetClassIDByBase(obj.typeLine);
|
||||
string itemclass = DB.Stash.GetClassByID(icid);
|
||||
stringItemTxt.Add($"Item Class: {char.ToUpper(itemclass[0]) + itemclass.Substring(1)}");
|
||||
stringItemTxt.Add("Rarity: Rare");
|
||||
stringItemTxt.Add(obj.name ?? "");
|
||||
stringItemTxt.Add(obj.typeLine ?? "");
|
||||
stringItemTxt.Add("--------");
|
||||
if (obj.properties != null && obj.properties.Count<Property>() > 0)
|
||||
{
|
||||
foreach (Property property in obj.properties)
|
||||
{
|
||||
if (property.name == "Quality")
|
||||
stringItemTxt.Add(string.Format("Quality: {0}", property.values[0][0]));
|
||||
if (property.name == "Armour")
|
||||
stringItemTxt.Add(string.Format("Armour: {0}", property.values[0][0]));
|
||||
if (property.name == "Energy Shield")
|
||||
stringItemTxt.Add(string.Format("Energy Shield: {0}", property.values[0][0]));
|
||||
if (property.name == "Evasion Rating")
|
||||
stringItemTxt.Add(string.Format("Evasion Rating: {0}", property.values[0][0]));
|
||||
if (property.values.Count<List<object>>() == 0)
|
||||
stringItemTxt.Add(property.name ?? "");
|
||||
if (property.name == "Physical Damage")
|
||||
stringItemTxt.Add(string.Format("Physical Damage: {0}", property.values[0][0]));
|
||||
if (property.name == "Elemental Damage")
|
||||
stringItemTxt.Add(string.Format("Elemental Damage: {0}", property.values[0][0]));
|
||||
if (property.name == "Critical Strike Chance")
|
||||
stringItemTxt.Add(string.Format("Critical Strike Chance: {0}", property.values[0][0]));
|
||||
if (property.name == "Attacks per Second")
|
||||
stringItemTxt.Add(string.Format("Attacks per Second: {0}", property.values[0][0]));
|
||||
if (property.name == "Weapon Range")
|
||||
stringItemTxt.Add(string.Format("Weapon Range: {0}", property.values[0][0]));
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
}
|
||||
stringItemTxt.Add("Requirements:");
|
||||
if (obj.requirements != null)
|
||||
{
|
||||
foreach (Requirement requirement in obj.requirements)
|
||||
{
|
||||
if (requirement.name == "Level")
|
||||
stringItemTxt.Add(string.Format("Level: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Str")
|
||||
stringItemTxt.Add(string.Format("Str: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Dex")
|
||||
stringItemTxt.Add(string.Format("Dex: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Int")
|
||||
stringItemTxt.Add(string.Format("Int: {0}", requirement.values[0][0]));
|
||||
}
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
if (obj.sockets != null)
|
||||
{
|
||||
List<string> stringList2 = new List<string>();
|
||||
List<string> stringList3 = new List<string>();
|
||||
List<string> stringList4 = new List<string>();
|
||||
List<string> stringList5 = new List<string>();
|
||||
List<string> stringList6 = new List<string>();
|
||||
List<string> stringList7 = new List<string>();
|
||||
foreach (Socket socket in obj.sockets)
|
||||
{
|
||||
if (socket.group == 0)
|
||||
stringList2.Add(socket.sColour.ToString());
|
||||
if (socket.group == 1)
|
||||
stringList3.Add(socket.sColour.ToString());
|
||||
if (socket.group == 2)
|
||||
stringList4.Add(socket.sColour.ToString());
|
||||
if (socket.group == 3)
|
||||
stringList5.Add(socket.sColour.ToString());
|
||||
if (socket.group == 4)
|
||||
stringList6.Add(socket.sColour.ToString());
|
||||
if (socket.group == 5)
|
||||
stringList7.Add(socket.sColour.ToString());
|
||||
}
|
||||
string str1 = string.Join("-", (IEnumerable<string>)stringList2);
|
||||
string str2 = string.Join("-", (IEnumerable<string>)stringList3);
|
||||
string str3 = string.Join("-", (IEnumerable<string>)stringList4);
|
||||
string str4 = string.Join("-", (IEnumerable<string>)stringList5);
|
||||
string str5 = string.Join("-", (IEnumerable<string>)stringList6);
|
||||
string str6 = string.Join("-", (IEnumerable<string>)stringList7);
|
||||
stringItemTxt.Add("Sockets: " + str1 + " " + str2 + " " + str3 + " " + str4 + " " + str5 + " " + str6);
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
stringItemTxt.Add(string.Format("Item Level: {0}", (object)obj.ilvl));
|
||||
stringItemTxt.Add("--------");
|
||||
if (obj.implicitMods != null)
|
||||
{
|
||||
foreach (string implicitMod in obj.implicitMods)
|
||||
{
|
||||
stringItemTxt.Add(implicitMod ?? "");
|
||||
stringItemMod.Add(implicitMod + "/n");
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
stringItemMod.Add("--------/n");
|
||||
}
|
||||
if (obj.explicitMods != null)
|
||||
{
|
||||
foreach (string explicitMod in obj.explicitMods)
|
||||
{
|
||||
stringItemTxt.Add(explicitMod ?? "");
|
||||
stringItemMod.Add(explicitMod + "/n");
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllLines("tmp/" + obj.id + ".txt", (IEnumerable<string>)stringItemTxt);
|
||||
File.WriteAllLines("tmp/" + obj.id + ".mod.txt", (IEnumerable<string>)stringItemMod);
|
||||
string ib64 = Convert.ToBase64String(File.ReadAllBytes("tmp/" + obj.id + ".txt"));
|
||||
Web.PoEPrices.GetItemJson(obj.id, ib64);
|
||||
int tabindex = DB.User.GetUserTabIndex(user);
|
||||
Rows.Add(
|
||||
$"(" +
|
||||
$"'{DB.User.GetUserID(user)}'," +
|
||||
$"'{stash.tabs[tabindex].i}'," +
|
||||
$"'{stash.tabs[tabindex].n}'," +
|
||||
$"'{stash.tabs[tabindex].colour.r}:{stash.tabs[tabindex].colour.g}:{stash.tabs[tabindex].colour.b}'," +
|
||||
$"'{icid}'," +
|
||||
$"'{DB.Stash.GetBaseIDByName(obj.typeLine)}'," +
|
||||
$"'{obj.id}'," +
|
||||
$"'{MySql.Data.MySqlClient.MySqlHelper.EscapeString(File.ReadAllText("tmp/" + obj.id + ".mod.txt"))}'," +
|
||||
$"'{DB.Stash.GetClassByID(icid)}:{MySql.Data.MySqlClient.MySqlHelper.EscapeString(obj.typeLine)}:{MySql.Data.MySqlClient.MySqlHelper.EscapeString(obj.name)}:{obj.ilvl}'," +
|
||||
$"'{obj.icon}'," +
|
||||
$"'{MySql.Data.MySqlClient.MySqlHelper.EscapeString(File.ReadAllText("tmp/" + obj.id + ".txt"))}'," +
|
||||
$"'{ib64}'," +
|
||||
$"'{Web.PoEPrices.GetCurType(obj.id)}'," +
|
||||
$"'{Web.PoEPrices.GetMin(obj.id)}'," +
|
||||
$"'{Web.PoEPrices.GetMax(obj.id)}'" +
|
||||
$")");
|
||||
stringItemTxt.Clear();
|
||||
stringItemMod.Clear();
|
||||
curitem++;
|
||||
Utilities.Message.CMW(chaosValue.ToString(),true,1);
|
||||
}
|
||||
}
|
||||
sCommand.Append(string.Join(",", Rows));
|
||||
//Message.CMW(sCommand.ToString(),true,3);
|
||||
sCommand.Append(";");
|
||||
if (sCommand.ToString() != "INSERT INTO poeco_items(uid, tabindex, tabname, tabrgb, cid, bid, uiid, imod, var, img, txt, b64, ctype, min, max) VALUES ;")
|
||||
{
|
||||
//DB.Stash.AddItemTable(sCommand.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class Colour
|
||||
{
|
||||
public int r { get; set; }
|
||||
|
||||
public int g { get; set; }
|
||||
|
||||
public int b { get; set; }
|
||||
}
|
||||
|
||||
public class Tab
|
||||
{
|
||||
public string n { get; set; }
|
||||
|
||||
public int i { get; set; }
|
||||
|
||||
public string id { get; set; }
|
||||
|
||||
public string type { get; set; }
|
||||
|
||||
public bool selected { get; set; }
|
||||
|
||||
public Colour colour { get; set; }
|
||||
|
||||
public string srcL { get; set; }
|
||||
|
||||
public string srcC { get; set; }
|
||||
|
||||
public string srcR { get; set; }
|
||||
}
|
||||
|
||||
public class Socket
|
||||
{
|
||||
public int group { get; set; }
|
||||
|
||||
public string attr { get; set; }
|
||||
|
||||
public string sColour { get; set; }
|
||||
}
|
||||
|
||||
public class Property
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public List<List<object>> values { get; set; }
|
||||
|
||||
public int displayMode { get; set; }
|
||||
|
||||
public int? type { get; set; }
|
||||
}
|
||||
|
||||
public class Requirement
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public List<List<object>> values { get; set; }
|
||||
|
||||
public int displayMode { get; set; }
|
||||
|
||||
public string suffix { get; set; }
|
||||
}
|
||||
|
||||
public class AdditionalProperty
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public List<List<object>> values { get; set; }
|
||||
|
||||
public int displayMode { get; set; }
|
||||
|
||||
public double progress { get; set; }
|
||||
|
||||
public int type { get; set; }
|
||||
}
|
||||
|
||||
public class NextLevelRequirement
|
||||
{
|
||||
public string name { get; set; }
|
||||
|
||||
public List<List<object>> values { get; set; }
|
||||
|
||||
public int displayMode { get; set; }
|
||||
}
|
||||
|
||||
public class SocketedItem
|
||||
{
|
||||
public bool verified { get; set; }
|
||||
|
||||
public int w { get; set; }
|
||||
|
||||
public int h { get; set; }
|
||||
|
||||
public string icon { get; set; }
|
||||
|
||||
public bool support { get; set; }
|
||||
|
||||
public string id { get; set; }
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
public string typeLine { get; set; }
|
||||
|
||||
public bool identified { get; set; }
|
||||
|
||||
public int ilvl { get; set; }
|
||||
|
||||
public List<Property> properties { get; set; }
|
||||
|
||||
public List<Requirement> requirements { get; set; }
|
||||
|
||||
public List<AdditionalProperty> additionalProperties { get; set; }
|
||||
|
||||
public List<NextLevelRequirement> nextLevelRequirements { get; set; }
|
||||
|
||||
public string secDescrText { get; set; }
|
||||
|
||||
public List<string> explicitMods { get; set; }
|
||||
|
||||
public string descrText { get; set; }
|
||||
|
||||
public int frameType { get; set; }
|
||||
|
||||
public int socket { get; set; }
|
||||
|
||||
public string colour { get; set; }
|
||||
}
|
||||
|
||||
public class Item
|
||||
{
|
||||
public bool verified { get; set; }
|
||||
|
||||
public int w { get; set; }
|
||||
|
||||
public int h { get; set; }
|
||||
|
||||
public string icon { get; set; }
|
||||
|
||||
public int stackSize { get; set; }
|
||||
|
||||
public int maxStackSize { get; set; }
|
||||
|
||||
public string league { get; set; }
|
||||
|
||||
public string id { get; set; }
|
||||
|
||||
public List<Socket> sockets { get; set; }
|
||||
|
||||
public string name { get; set; }
|
||||
|
||||
public string typeLine { get; set; }
|
||||
|
||||
public bool identified { get; set; }
|
||||
|
||||
public int ilvl { get; set; }
|
||||
|
||||
public bool corrupted { get; set; }
|
||||
|
||||
public int frameType { get; set; }
|
||||
|
||||
public int x { get; set; }
|
||||
|
||||
public int y { get; set; }
|
||||
|
||||
public string inventoryId { get; set; }
|
||||
|
||||
public List<SocketedItem> socketedItems { get; set; }
|
||||
|
||||
public List<Property> properties { get; set; }
|
||||
|
||||
public List<Requirement> requirements { get; set; }
|
||||
|
||||
public List<string> implicitMods { get; set; }
|
||||
|
||||
public List<string> explicitMods { get; set; }
|
||||
|
||||
public List<string> craftedMods { get; set; }
|
||||
|
||||
public bool? support { get; set; }
|
||||
|
||||
public List<AdditionalProperty> additionalProperties { get; set; }
|
||||
|
||||
public string secDescrText { get; set; }
|
||||
|
||||
public string descrText { get; set; }
|
||||
|
||||
public List<string> flavourText { get; set; }
|
||||
|
||||
public bool? fractured { get; set; }
|
||||
|
||||
public List<string> fracturedMods { get; set; }
|
||||
|
||||
public List<string> enchantMods { get; set; }
|
||||
|
||||
public int? talismanTier { get; set; }
|
||||
}
|
||||
|
||||
public class StashRoot
|
||||
{
|
||||
public int numTabs { get; set; }
|
||||
|
||||
public List<Tab> tabs { get; set; }
|
||||
|
||||
public bool quadLayout { get; set; }
|
||||
|
||||
public List<Item> items { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
125
PoEco.Net/PoEco.Net.csproj
Normal file
125
PoEco.Net/PoEco.Net.csproj
Normal file
@@ -0,0 +1,125 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{EB540AAD-F925-4C2E-913E-2891408DB5A3}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PoEco.Net</RootNamespace>
|
||||
<AssemblyName>PoEco</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BouncyCastle.Cryptography.2.2.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Protobuf, Version=3.21.9.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.21.9\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.3.5\lib\net462\K4os.Compression.LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.3.5.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.3.5\lib\net462\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.8.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.8\lib\net462\K4os.Hash.xxHash.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=8.2.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MySql.Data.8.2.0\lib\net48\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.ConfigurationManager, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Configuration.ConfigurationManager.4.4.1\lib\net461\System.Configuration.ConfigurationManager.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Diagnostics.DiagnosticSource, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.7.0.2\lib\net462\System.Diagnostics.DiagnosticSource.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.IO.Pipelines, Version=5.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Pipelines.5.0.2\lib\net461\System.IO.Pipelines.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="ZstdSharp, Version=0.7.1.0, Culture=neutral, PublicKeyToken=8d151af33a4ad5cf, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\ZstdSharp.Port.0.7.1\lib\net461\ZstdSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DB\ClassGen.cs" />
|
||||
<Compile Include="DB\Item.cs" />
|
||||
<Compile Include="DB\Stash.cs" />
|
||||
<Compile Include="DB\User.cs" />
|
||||
<Compile Include="JSON\Currency.cs" />
|
||||
<Compile Include="JSON\Classes\Divination.cs" />
|
||||
<Compile Include="JSON\Settings.cs" />
|
||||
<Compile Include="JSON\Stash.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Utilities\Draw.cs" />
|
||||
<Compile Include="Utilities\Message.cs" />
|
||||
<Compile Include="Web\PoBLua.cs" />
|
||||
<Compile Include="Web\PoENinja.cs" />
|
||||
<Compile Include="Web\PoEPrices.cs" />
|
||||
<Compile Include="Web\Stash.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
421
PoEco.Net/Program.cs
Normal file
421
PoEco.Net/Program.cs
Normal file
@@ -0,0 +1,421 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
using Newtonsoft.Json;
|
||||
using PoEco.Net.DB;
|
||||
using PoEco.Net.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static PoEco.Net.JSON.Stash;
|
||||
using static PoEco.Net.Web.PoEPrices;
|
||||
|
||||
namespace PoEco.Net
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
public static string version = "1.0.0";
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (!args.Contains("--gui")) { Utilities.Message.Splash("PoEco.Net", "mikx"); }
|
||||
int a = args.Length;
|
||||
if (a < 1)
|
||||
{
|
||||
Utilities.Message.CMW("Usage: poeco.exe <args>", true, 1);
|
||||
Utilities.Message.CMW("--debug Skip parts of the logics for debuging.", true, 1);
|
||||
Utilities.Message.CMW("--lua Generate up to date classes and bases.", true, 1);
|
||||
Utilities.Message.CMW("--gen Generate up to date currencies value.", true, 1);
|
||||
Utilities.Message.CMW("--usergen-rare <userid> Generate up to date user rare tab.", true, 1);
|
||||
Utilities.Message.CMW("--usergen-tab <userid> Generate up to date user tabs.", true, 1);
|
||||
} else
|
||||
{
|
||||
if (args.Contains("--lua"))
|
||||
{
|
||||
Message.CMW("Generating the latest Classes and Bases from PoB Lua...", true, 1);
|
||||
Web.PoBLua.GetLatestLUA();
|
||||
DB.ClassGen.GenClass();
|
||||
Message.CMW("Generation done.", true, 2);
|
||||
}
|
||||
if (args.Contains("--gen"))
|
||||
{
|
||||
Message.CMW("Getting the latest PoE.Ninja Currency Data...", true, 1);
|
||||
if (File.Exists("data/ninja/currency.json")) { File.Delete("data/ninja/currency.json"); }
|
||||
Web.PoENinja.SaveData("https://poe.ninja/api/data/" + "currencyoverview?league=" + JSON.Settings.GetLeague() + "&type=Currency&language=en", "data/ninja/currency.json");
|
||||
Web.PoENinja.GenCurrency();
|
||||
Message.CMW("Getting the latest PoE.Ninja Divination Data...", true, 1);
|
||||
if (File.Exists("data/ninja/divination.json")) { File.Delete("data/ninja/divination.json"); }
|
||||
Web.PoENinja.SaveData("https://poe.ninja/api/data/" + "itemoverview?league=" + JSON.Settings.GetLeague() + "&type=DivinationCard&language=en", "data/ninja/divination.json");
|
||||
Web.PoENinja.GenDivination();
|
||||
Message.CMW("Getting the latest PoE.Ninja Essence Data...", true, 1);
|
||||
if (File.Exists("data/ninja/essence.json")) { File.Delete("data/ninja/essence.json"); }
|
||||
Web.PoENinja.SaveData("https://poe.ninja/api/data/" + "itemoverview?league=" + JSON.Settings.GetLeague() + "&type=Essence&language=en", "data/ninja/essence.json");
|
||||
Web.PoENinja.GenEssence();
|
||||
Message.CMW("Getting the latest PoE.Ninja Scarab Data...", true, 1);
|
||||
if (File.Exists("data/ninja/scarab.json")) { File.Delete("data/ninja/scarab.json"); }
|
||||
Web.PoENinja.SaveData("https://poe.ninja/api/data/" + "itemoverview?league=" + JSON.Settings.GetLeague() + "&type=Scarab&language=en", "data/ninja/scarab.json");
|
||||
Web.PoENinja.GenFragment();
|
||||
Message.CMW("Getting the latest PoE.Ninja Fossil Data...", true, 1);
|
||||
if (File.Exists("data/ninja/fossil.json")) { File.Delete("data/ninja/fossil.json"); }
|
||||
Web.PoENinja.SaveData("https://poe.ninja/api/data/" + "itemoverview?league=" + JSON.Settings.GetLeague() + "&type=Fossil&language=en", "data/ninja/fossil.json");
|
||||
Web.PoENinja.GenFossil();
|
||||
return;
|
||||
}
|
||||
if (args.Contains("--usergen-rare"))
|
||||
{
|
||||
if (args.Length > 1)
|
||||
{
|
||||
int uid = Convert.ToInt16(args[1]);
|
||||
string user = DB.User.GetUserNameByID(uid)[0];
|
||||
string discriminator = DB.User.GetUserNameByID(uid)[1];
|
||||
Message.CMW($"User \"{user}\" processing...", true, 1);
|
||||
Message.CMW($"Checking the database for user \"{user}\"...", true, 1);
|
||||
if (DB.User.CheckUserExists(user, discriminator))
|
||||
{
|
||||
Message.CMW($"User \"{user}\" exists with ID \"{uid}\".", true, 2);
|
||||
foreach (var png in Directory.GetFiles("data/tabmap")) { File.Delete(png); }
|
||||
File.Copy(@"data/StashTab_Quad.png", $@"data/tabmap/{user}#{discriminator}.png");
|
||||
if (args.Contains("--clean")) { DB.Item.DeleteAllItemsByUID(uid); }
|
||||
int uct = DB.User.CountTabByUID(uid);
|
||||
foreach (int ti in DB.Stash.EnumerateTabByUID(uid, "rare"))
|
||||
{
|
||||
Message.CMW($"Processing tab \"{ti}\" from user \"{user}\".", true, 2);
|
||||
string token = DB.User.GetUserTokenByID(uid);
|
||||
if (!args.Contains("--debug"))
|
||||
{
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={ti}&accountName={user}%23{discriminator}", $"data/stash/{user}.rare.{ti}.json");
|
||||
}
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.rare.{ti}.json"));
|
||||
int stashitemcount = JSON.Stash.GetUserItemCount(user, ti);
|
||||
int stashitemleft = stashitemcount;
|
||||
List<string> stringItemTxt = new List<string>();
|
||||
List<string> stringItemMod = new List<string>();
|
||||
List<string> Rows = new List<string>();
|
||||
StringBuilder sCommand = new StringBuilder("INSERT INTO poeco_items(uid, tabindex, tabname, tabrgb, cid, bid, uiid, imod, var, img, txt, b64, ctype, min, max) VALUES ");
|
||||
double chaosValue = 0;
|
||||
while (stashitemleft > 0)
|
||||
{
|
||||
int idel = 0;
|
||||
foreach (string i in DB.Item.EnumerateItemByUID(uid, ti))
|
||||
{
|
||||
if (!JSON.Stash.CheckItemExistsStash(user, ti, i))
|
||||
{
|
||||
DB.Item.DeleteItemByUIID(uid, ti, i);
|
||||
idel++;
|
||||
}
|
||||
}
|
||||
if (idel > 0) { Message.CMW($"Cleaned Item(s) Database. Deleted {idel} Item(s).", true, 2); }
|
||||
idel = 0;
|
||||
foreach (var i in stash.items)
|
||||
{
|
||||
if (!DB.Item.CheckItemExistsByUIID(i.id))
|
||||
{
|
||||
if (i.frameType == 2)
|
||||
{
|
||||
Message.CMW($"[{stashitemleft}][{i.id.Substring(0,5)}] Processing {i.name} {i.typeLine}.", true, 2);
|
||||
int icid = DB.Stash.GetClassIDByBase(i.typeLine);
|
||||
string itemclass = DB.Stash.GetClassByID(icid);
|
||||
stringItemTxt.Add($"Item Class: {char.ToUpper(itemclass[0]) + itemclass.Substring(1)}");
|
||||
stringItemTxt.Add("Rarity: Rare");
|
||||
stringItemTxt.Add(i.name ?? "");
|
||||
stringItemTxt.Add(i.typeLine ?? "");
|
||||
stringItemTxt.Add("--------");
|
||||
if (i.properties != null && i.properties.Count<Property>() > 0)
|
||||
{
|
||||
foreach (Property property in i.properties)
|
||||
{
|
||||
if (property.name == "Quality")
|
||||
stringItemTxt.Add(string.Format("Quality: {0}", property.values[0][0]));
|
||||
if (property.name == "Armour")
|
||||
stringItemTxt.Add(string.Format("Armour: {0}", property.values[0][0]));
|
||||
if (property.name == "Energy Shield")
|
||||
stringItemTxt.Add(string.Format("Energy Shield: {0}", property.values[0][0]));
|
||||
if (property.name == "Evasion Rating")
|
||||
stringItemTxt.Add(string.Format("Evasion Rating: {0}", property.values[0][0]));
|
||||
if (property.values.Count<List<object>>() == 0)
|
||||
stringItemTxt.Add(property.name ?? "");
|
||||
if (property.name == "Physical Damage")
|
||||
stringItemTxt.Add(string.Format("Physical Damage: {0}", property.values[0][0]));
|
||||
if (property.name == "Elemental Damage")
|
||||
stringItemTxt.Add(string.Format("Elemental Damage: {0}", property.values[0][0]));
|
||||
if (property.name == "Critical Strike Chance")
|
||||
stringItemTxt.Add(string.Format("Critical Strike Chance: {0}", property.values[0][0]));
|
||||
if (property.name == "Attacks per Second")
|
||||
stringItemTxt.Add(string.Format("Attacks per Second: {0}", property.values[0][0]));
|
||||
if (property.name == "Weapon Range")
|
||||
stringItemTxt.Add(string.Format("Weapon Range: {0}", property.values[0][0]));
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
}
|
||||
stringItemTxt.Add("Requirements:");
|
||||
if (i.requirements != null)
|
||||
{
|
||||
foreach (Requirement requirement in i.requirements)
|
||||
{
|
||||
if (requirement.name == "Level")
|
||||
stringItemTxt.Add(string.Format("Level: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Str")
|
||||
stringItemTxt.Add(string.Format("Str: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Dex")
|
||||
stringItemTxt.Add(string.Format("Dex: {0}", requirement.values[0][0]));
|
||||
if (requirement.name == "Int")
|
||||
stringItemTxt.Add(string.Format("Int: {0}", requirement.values[0][0]));
|
||||
}
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
if (i.sockets != null)
|
||||
{
|
||||
List<string> stringList2 = new List<string>();
|
||||
List<string> stringList3 = new List<string>();
|
||||
List<string> stringList4 = new List<string>();
|
||||
List<string> stringList5 = new List<string>();
|
||||
List<string> stringList6 = new List<string>();
|
||||
List<string> stringList7 = new List<string>();
|
||||
foreach (Socket socket in i.sockets)
|
||||
{
|
||||
if (socket.group == 0)
|
||||
stringList2.Add(socket.sColour.ToString());
|
||||
if (socket.group == 1)
|
||||
stringList3.Add(socket.sColour.ToString());
|
||||
if (socket.group == 2)
|
||||
stringList4.Add(socket.sColour.ToString());
|
||||
if (socket.group == 3)
|
||||
stringList5.Add(socket.sColour.ToString());
|
||||
if (socket.group == 4)
|
||||
stringList6.Add(socket.sColour.ToString());
|
||||
if (socket.group == 5)
|
||||
stringList7.Add(socket.sColour.ToString());
|
||||
}
|
||||
string str1 = string.Join("-", (IEnumerable<string>)stringList2);
|
||||
string str2 = string.Join("-", (IEnumerable<string>)stringList3);
|
||||
string str3 = string.Join("-", (IEnumerable<string>)stringList4);
|
||||
string str4 = string.Join("-", (IEnumerable<string>)stringList5);
|
||||
string str5 = string.Join("-", (IEnumerable<string>)stringList6);
|
||||
string str6 = string.Join("-", (IEnumerable<string>)stringList7);
|
||||
stringItemTxt.Add("Sockets: " + str1 + " " + str2 + " " + str3 + " " + str4 + " " + str5 + " " + str6);
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
stringItemTxt.Add(string.Format("Item Level: {0}", (object)i.ilvl));
|
||||
stringItemTxt.Add("--------");
|
||||
if (i.implicitMods != null)
|
||||
{
|
||||
foreach (string implicitMod in i.implicitMods)
|
||||
{
|
||||
stringItemTxt.Add(implicitMod ?? "");
|
||||
stringItemMod.Add(implicitMod + "/n");
|
||||
}
|
||||
stringItemTxt.Add("--------");
|
||||
stringItemMod.Add("--------/n");
|
||||
}
|
||||
if (i.explicitMods != null)
|
||||
{
|
||||
foreach (string explicitMod in i.explicitMods)
|
||||
{
|
||||
stringItemTxt.Add(explicitMod ?? "");
|
||||
stringItemMod.Add(explicitMod + "/n");
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllLines("tmp/" + i.id + ".txt", (IEnumerable<string>)stringItemTxt);
|
||||
File.WriteAllLines("tmp/" + i.id + ".mod.txt", (IEnumerable<string>)stringItemMod);
|
||||
string ib64 = Convert.ToBase64String(File.ReadAllBytes("tmp/" + i.id + ".txt"));
|
||||
if (!args.Contains("--debug")) { Web.PoEPrices.GetItemJson(i.id, ib64); }
|
||||
if (File.Exists($"tmp/" + i.id + ".json"))
|
||||
{
|
||||
string type = "";
|
||||
int tabindex = DB.User.GetUserTabIndex(user);
|
||||
double min = Web.PoEPrices.GetMin(i.id);
|
||||
double max = Web.PoEPrices.GetMax(i.id);
|
||||
type = "c";
|
||||
if (JsonConvert.DeserializeObject<PoEPricesRoot>(File.ReadAllText("tmp/" + i.id + ".json")).currency == "divine")
|
||||
{
|
||||
//min = min * JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString("Divine Orb"), "poeco_currency");
|
||||
//max = max * JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString("Divine Orb"), "poeco_currency");
|
||||
type = "d";
|
||||
}
|
||||
Draw.GenQuad(i.w, i.h, i.x, i.y, i.icon, Math.Round(min, 1), Math.Round(max, 1), type, user, discriminator);
|
||||
DB.Stash.AddItemTable(uid, ti, i.id, i.ilvl, icid, DB.Stash.GetBaseIDByName(i.typeLine), i.name, MySqlHelper.EscapeString(File.ReadAllText("tmp/" + i.id + ".mod.txt")), i.icon, MySqlHelper.EscapeString(File.ReadAllText("tmp/" + i.id + ".txt")), ib64, min, max);
|
||||
chaosValue = chaosValue + max;
|
||||
stringItemTxt.Clear();
|
||||
stringItemMod.Clear();
|
||||
stashitemleft--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Message.CMW($"[{i.id}] Skipping {i.name} {i.typeLine}.", true, 3);
|
||||
stashitemleft--;
|
||||
}
|
||||
stringItemTxt.Clear();
|
||||
stringItemMod.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
stashitemleft--;
|
||||
}
|
||||
}
|
||||
int uic = DB.Item.CountItemByUID(uid, ti);
|
||||
DB.User.SetUserItemCount(uid, uic, ti);
|
||||
chaosValue = chaosValue + DB.User.GetTabValueByTID(uid, ti);
|
||||
DB.User.SetUserTabValue(uid, ti, chaosValue);
|
||||
DB.Stash.SetTabNameByTID(uid,ti, stash.tabs[ti].n);
|
||||
DB.Stash.SetTabRGBByTID(uid, ti, $"{stash.tabs[ti].colour.r}:{stash.tabs[ti].colour.g}:{stash.tabs[ti].colour.b}");
|
||||
}
|
||||
Message.CMW($"Processed all item(s) in the rare tab.", true, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.Contains("--usergen-pro"))
|
||||
{
|
||||
int uid = Convert.ToInt16(args[1]);
|
||||
string user = DB.User.GetUserNameByID(uid)[0];
|
||||
string discriminator = DB.User.GetUserNameByID(uid)[1];
|
||||
int proindex = DB.User.GetUserProfitTabIndex(uid);
|
||||
string token = DB.User.GetUserToken(user);
|
||||
DB.User.DeleteProfits(uid);
|
||||
if (!args.Contains("--debug"))
|
||||
{
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={proindex}&accountName={user}%23{discriminator}", $"data/stash/{user}.profit.{proindex}.json");
|
||||
}
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($"data/stash/{user}.profit.{proindex}.json"));
|
||||
|
||||
int currencyIndex = 0;
|
||||
int divIndex = 0;
|
||||
int essenceIndex = 0;
|
||||
int fragIndex = 0;
|
||||
int fossilIndex = 0;
|
||||
|
||||
foreach (var t in stash.tabs)
|
||||
{
|
||||
switch (t.type)
|
||||
{
|
||||
case "CurrencyStash":
|
||||
if (t.n.Length == 1)
|
||||
{
|
||||
currencyIndex = t.i;
|
||||
}
|
||||
break;
|
||||
case "DivinationCardStash":
|
||||
divIndex = t.i;
|
||||
break;
|
||||
case "EssenceStash":
|
||||
essenceIndex = t.i;
|
||||
break;
|
||||
case "FragmentStash":
|
||||
fragIndex = t.i;
|
||||
break;
|
||||
case "DelveStash":
|
||||
fossilIndex = t.i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
double pvalue = 0;
|
||||
int pcount = JSON.Stash.GetUserProfitCount(user, proindex);
|
||||
DB.Stash.SetTabRGBByTID(uid, proindex, $"{stash.tabs[proindex].colour.r}:{stash.tabs[proindex].colour.g}:{stash.tabs[proindex].colour.b}");
|
||||
DB.Stash.SetTabNameByTID(uid, proindex, stash.tabs[proindex].n);
|
||||
Message.CMW($"Processing {pcount} items in Profit tab...", true, 2);
|
||||
foreach (var i in stash.items)
|
||||
{
|
||||
if (i.frameType == 5) // Currency
|
||||
{
|
||||
pvalue = pvalue + (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_currency")*i.stackSize);
|
||||
DB.Stash.AddProfitTable(uid, i.id, "currency", MySqlHelper.EscapeString(i.typeLine), i.stackSize, (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_currency") * i.stackSize));
|
||||
}
|
||||
if (i.frameType == 0) // Fragment
|
||||
{
|
||||
pvalue = pvalue + (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_fragment") * i.stackSize);
|
||||
DB.Stash.AddProfitTable(uid, i.id, "fragment", MySqlHelper.EscapeString(i.typeLine), i.stackSize, (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_fragment") * i.stackSize));
|
||||
}
|
||||
if (i.frameType == 6) // Div
|
||||
{
|
||||
pvalue = pvalue + (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_divination") * i.stackSize);
|
||||
DB.Stash.AddProfitTable(uid, i.id, "divination", MySqlHelper.EscapeString(i.typeLine), i.stackSize, (JSON.Currency.GetCurrencyValueByName(MySqlHelper.EscapeString(i.typeLine), "poeco_divination") * i.stackSize));
|
||||
}
|
||||
}
|
||||
DB.User.SetUserItemCount(uid, pcount, proindex);
|
||||
DB.User.SetUserTabValue(uid, proindex, pvalue);
|
||||
}
|
||||
|
||||
if (args.Contains("--usergen-tab"))
|
||||
{
|
||||
int uid = Convert.ToInt16(args[1]);
|
||||
string user = DB.User.GetUserNameByID(uid)[0];
|
||||
string discriminator = DB.User.GetUserNameByID(uid)[1];
|
||||
int rareindex = DB.User.GetUserTabIndex(user);
|
||||
string token = DB.User.GetUserToken(user);
|
||||
if (!args.Contains("--debug"))
|
||||
{
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={rareindex}&accountName={user}%23{discriminator}", $"data/stash/{user}.json");
|
||||
}
|
||||
StashRoot stash = JsonConvert.DeserializeObject<StashRoot>(File.ReadAllText($@"data/stash/{user}.json"));
|
||||
int currencyIndex = 0;
|
||||
int divIndex = 0;
|
||||
int essenceIndex = 0;
|
||||
int fragIndex = 0;
|
||||
int fossilIndex = 0;
|
||||
|
||||
foreach (var t in stash.tabs)
|
||||
{
|
||||
switch (t.type)
|
||||
{
|
||||
case "CurrencyStash":
|
||||
if (t.n.Length == 1)
|
||||
{
|
||||
currencyIndex = t.i;
|
||||
}
|
||||
break;
|
||||
case "DivinationCardStash":
|
||||
divIndex = t.i;
|
||||
break;
|
||||
case "EssenceStash":
|
||||
essenceIndex = t.i;
|
||||
break;
|
||||
case "FragmentStash":
|
||||
fragIndex = t.i;
|
||||
break;
|
||||
case "DelveStash":
|
||||
fossilIndex = t.i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (DB.User.GetUserCurrencyIndex(user, "curindex") != -1)
|
||||
{
|
||||
Message.CMW($"Processing Currency tab...", true, 2);
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={currencyIndex}&accountName={user}%23{discriminator}", $"data/stash/{user}.tab.{currencyIndex}.json");
|
||||
JSON.Currency.GenCurrencyTab(user, currencyIndex, "curvalue", "poeco_currency");
|
||||
}
|
||||
if (DB.User.GetUserCurrencyIndex(user, "divindex") != -1)
|
||||
{
|
||||
Message.CMW($"Processing Divination tab...", true, 2);
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={divIndex}&accountName={user}%23{discriminator}", $"data/stash/{user}.tab.{divIndex}.json");
|
||||
JSON.Currency.GenCurrencyTab(user, divIndex, "divvalue", "poeco_divination");
|
||||
}
|
||||
if (DB.User.GetUserCurrencyIndex(user, "essindex") != -1)
|
||||
{
|
||||
Message.CMW($"Processing Essence tab...", true, 2);
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={essenceIndex}&accountName={user}%23{discriminator}", $"data/stash/{user}.tab.{essenceIndex}.json");
|
||||
JSON.Currency.GenCurrencyTab(user, essenceIndex, "essvalue", "poeco_essence");
|
||||
}
|
||||
if (DB.User.GetUserCurrencyIndex(user, "fraindex") != -1)
|
||||
{
|
||||
Message.CMW($"Processing Fragment tab...", true, 2);
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={fragIndex}&accountName={user}%23{discriminator}", $"data/stash/{user}.tab.{fragIndex}.json");
|
||||
JSON.Currency.GenCurrencyTab(user, fragIndex, "fravalue", "poeco_fragment");
|
||||
}
|
||||
if (DB.User.GetUserCurrencyIndex(user, "fosindex") != -1)
|
||||
{
|
||||
Message.CMW($"Processing Fossil tab...", true, 2);
|
||||
Web.Stash.DownloadStash(token, $"https://www.pathofexile.com/character-window/get-stash-items?league={JSON.Settings.GetLeague()}&tabs=1&tabIndex={fossilIndex}&accountName={user}%23{discriminator}", $"data/stash/{user}.tab.{fossilIndex}.json");
|
||||
JSON.Currency.GenCurrencyTab(user, fossilIndex, "fosvalue", "poeco_fossil");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
PoEco.Net/Properties/AssemblyInfo.cs
Normal file
36
PoEco.Net/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PoEco.Net")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("PoEco.Net")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("eb540aad-f925-4c2e-913e-2891408db5a3")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
112
PoEco.Net/Utilities/Draw.cs
Normal file
112
PoEco.Net/Utilities/Draw.cs
Normal file
@@ -0,0 +1,112 @@
|
||||
using Org.BouncyCastle.Asn1.Cms;
|
||||
using PoEco.Net.JSON;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using Image = System.Drawing.Image;
|
||||
|
||||
namespace PoEco.Net.Utilities
|
||||
{
|
||||
internal class Draw
|
||||
{
|
||||
public static void GenQuad(int w, int h, int x, int y, string imgUrl, double min, double max, string type, string user, string discriminator)
|
||||
{
|
||||
int fontsize = 16;
|
||||
|
||||
int calculatedW = w * 47;
|
||||
int calculatedH = h * 47;
|
||||
|
||||
int calculatedX = x * 47;
|
||||
int calculatedY = y * 47;
|
||||
|
||||
Color cborder = Color.FromArgb(61,235,52);
|
||||
|
||||
// Adjust font size by item size
|
||||
// w == item width
|
||||
// h == item height
|
||||
switch (w)
|
||||
{
|
||||
case 1:
|
||||
switch (h)
|
||||
{
|
||||
case 1:
|
||||
fontsize = 12;
|
||||
break;
|
||||
case 3:
|
||||
fontsize = 12;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ColorConverter cc = new ColorConverter();
|
||||
Color fontc = (Color)cc.ConvertFromString("#3d3d3b");
|
||||
switch (type)
|
||||
{
|
||||
case "c":
|
||||
if (min < 10) { fontc = (Color)cc.ConvertFromString("#fc0303"); }
|
||||
if (min >= 10 && min < 20) { fontc = (Color)cc.ConvertFromString("#fc5e03"); }
|
||||
if (min >= 20 && min < 50) { fontc = (Color)cc.ConvertFromString("#fcce03"); }
|
||||
if (min >= 50) { fontc = (Color)cc.ConvertFromString("#29f705"); }
|
||||
break;
|
||||
case "d":
|
||||
fontc = (Color)cc.ConvertFromString("#29f705");
|
||||
break;
|
||||
}
|
||||
|
||||
var fontFamily = new FontFamily("Verdana");
|
||||
var vfont = new Font(fontFamily, fontsize, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
Image imageFile = Image.FromFile($@"data/tabmap/{user}#{discriminator}.png");
|
||||
Graphics newGraphics = Graphics.FromImage(imageFile);
|
||||
|
||||
Pen border = new Pen(cborder, 2);
|
||||
Pen backPen = new Pen(cborder, 0);
|
||||
SolidBrush back = new SolidBrush((Color)cc.ConvertFromString("#3d3d3b"));
|
||||
SolidBrush font = new SolidBrush(fontc);
|
||||
|
||||
Rectangle rect = new Rectangle(calculatedX, calculatedY, calculatedW, calculatedH);
|
||||
Rectangle backgroundRect = new Rectangle(calculatedX, calculatedY, calculatedW-5, calculatedH-5);
|
||||
|
||||
newGraphics.DrawRectangle(border, rect);
|
||||
newGraphics.FillRectangle(back, rect);
|
||||
newGraphics.DrawRectangle(border, rect);
|
||||
|
||||
WebClient wc = new WebClient();
|
||||
byte[] bytes = wc.DownloadData(imgUrl);
|
||||
MemoryStream ms = new MemoryStream(bytes);
|
||||
Image itemIcon = Image.FromStream(ms);
|
||||
|
||||
Bitmap bmp = new Bitmap(itemIcon.Width, itemIcon.Height);
|
||||
ColorMatrix matrix = new ColorMatrix();
|
||||
|
||||
matrix.Matrix33 = 0.3f;
|
||||
|
||||
ImageAttributes attributes = new ImageAttributes();
|
||||
|
||||
attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
|
||||
newGraphics.DrawImage(itemIcon, new Rectangle(x * 47, y * 47, bmp.Width, bmp.Height), 0 , 0, itemIcon.Width, itemIcon.Height, GraphicsUnit.Pixel, attributes);
|
||||
|
||||
StringFormat stringFormatMin = new StringFormat();
|
||||
stringFormatMin.Alignment = StringAlignment.Center;
|
||||
stringFormatMin.LineAlignment = StringAlignment.Near;
|
||||
newGraphics.DrawString(min.ToString() + type, vfont, font, rect, stringFormatMin);
|
||||
|
||||
StringFormat stringFormatMax = new StringFormat();
|
||||
stringFormatMax.Alignment = StringAlignment.Center;
|
||||
stringFormatMax.LineAlignment = StringAlignment.Far;
|
||||
newGraphics.DrawString(max.ToString() + type, vfont, font, rect, stringFormatMax);
|
||||
|
||||
imageFile.Save($@"data/tabmap/{user}#{discriminator}.png", ImageFormat.Bmp);
|
||||
if (Settings.GetWeb()) { File.Copy($@"data/tabmap/{user}#{discriminator}.png", $@"{Settings.GetWebPath()}/{user}#{discriminator}.png", true); }
|
||||
}
|
||||
}
|
||||
}
|
||||
151
PoEco.Net/Utilities/Message.cs
Normal file
151
PoEco.Net/Utilities/Message.cs
Normal file
@@ -0,0 +1,151 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.Utilities
|
||||
{
|
||||
internal class Message
|
||||
{
|
||||
public static void CMW(string msg, bool time, int color)
|
||||
{
|
||||
DateTime now;
|
||||
string str1;
|
||||
int num;
|
||||
if (DateTime.Now.Second < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str1 = string.Format("0{0}", (object)now.Second);
|
||||
}
|
||||
else
|
||||
{
|
||||
num = DateTime.Now.Second;
|
||||
str1 = num.ToString();
|
||||
}
|
||||
now = DateTime.Now;
|
||||
string str2;
|
||||
if (now.Minute < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str2 = string.Format("0{0}", (object)now.Minute);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = DateTime.Now;
|
||||
num = now.Minute;
|
||||
str2 = num.ToString();
|
||||
}
|
||||
now = DateTime.Now;
|
||||
string str3;
|
||||
if (now.Hour < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str3 = string.Format("0{0}", (object)now.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = DateTime.Now;
|
||||
num = now.Hour;
|
||||
str3 = num.ToString();
|
||||
}
|
||||
string str4 = string.Format("{0}:{1}:{2}", (object)str3, (object)str2, (object)str1);
|
||||
File.AppendAllText("mxfiltergen.logs", string.Format("[{0}] {1}", (object)str4, (object)msg) + Environment.NewLine);
|
||||
ConsoleColor consoleColor = ConsoleColor.White;
|
||||
switch (color)
|
||||
{
|
||||
case 1:
|
||||
consoleColor = ConsoleColor.Cyan;
|
||||
break;
|
||||
case 2:
|
||||
consoleColor = ConsoleColor.Green;
|
||||
break;
|
||||
case 3:
|
||||
consoleColor = ConsoleColor.Red;
|
||||
break;
|
||||
}
|
||||
if (time)
|
||||
{
|
||||
Console.ForegroundColor = consoleColor;
|
||||
Console.WriteLine(string.Format("[{0}] {1}", (object)str4, (object)msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = consoleColor;
|
||||
Console.WriteLine(string.Format(""));
|
||||
}
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
}
|
||||
|
||||
public static void drawProgress(int progress, int total)
|
||||
{
|
||||
DateTime now;
|
||||
string str1;
|
||||
int num;
|
||||
if (DateTime.Now.Second < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str1 = string.Format("0{0}", (object)now.Second);
|
||||
}
|
||||
else
|
||||
{
|
||||
num = DateTime.Now.Second;
|
||||
str1 = num.ToString();
|
||||
}
|
||||
now = DateTime.Now;
|
||||
string str2;
|
||||
if (now.Minute < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str2 = string.Format("0{0}", (object)now.Minute);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = DateTime.Now;
|
||||
num = now.Minute;
|
||||
str2 = num.ToString();
|
||||
}
|
||||
now = DateTime.Now;
|
||||
string str3;
|
||||
if (now.Hour < 10)
|
||||
{
|
||||
now = DateTime.Now;
|
||||
str3 = string.Format("0{0}", (object)now.Hour);
|
||||
}
|
||||
else
|
||||
{
|
||||
now = DateTime.Now;
|
||||
num = now.Hour;
|
||||
str3 = num.ToString();
|
||||
}
|
||||
string str4 = string.Format("[{0}] [", (object)string.Format("{0}:{1}:{2}", (object)str3, (object)str2, (object)str1));
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
if (progress == 1)
|
||||
{
|
||||
Console.Write(str4);
|
||||
Console.CursorLeft = total + str4.Length;
|
||||
Console.Write("]");
|
||||
}
|
||||
Console.CursorLeft = progress + str4.Length - 1;
|
||||
Console.Write("#");
|
||||
Console.CursorLeft = str4.Length + total + 2;
|
||||
Console.Write(string.Format("{0}/{1}", (object)progress, (object)total));
|
||||
if (progress != total)
|
||||
return;
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
public static void Splash(string progname, string dev)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine($"#### {progname}");
|
||||
Console.WriteLine(string.Format("#### VERSION: {0}", (object)Program.version));
|
||||
Console.WriteLine($"#### DEV: {dev}");
|
||||
Console.WriteLine("#### POWERED BY: poe.ninja / poeprices.info");
|
||||
Console.WriteLine("");
|
||||
Console.ForegroundColor = ConsoleColor.White;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
PoEco.Net/Web/PoBLua.cs
Normal file
30
PoEco.Net/Web/PoBLua.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.Web
|
||||
{
|
||||
internal class PoBLua
|
||||
{
|
||||
public class LuaRoot
|
||||
{
|
||||
public List<string> lua { get; set; }
|
||||
}
|
||||
public static void GetLatestLUA()
|
||||
{
|
||||
if (!Directory.Exists(@"data\lua")) { Directory.CreateDirectory(@"data\lua"); }
|
||||
WebClient wc = new WebClient();
|
||||
LuaRoot lr = JsonConvert.DeserializeObject<LuaRoot>(File.ReadAllText(@"data\lua.json"));
|
||||
foreach (var l in lr.lua)
|
||||
{
|
||||
if(File.Exists($@"data\lua\{l}.lua")) { File.Delete($@"data\lua\{l}.lua"); }
|
||||
wc.DownloadFile($"https://github.com/PathOfBuildingCommunity/PathOfBuilding/raw/dev/src/Data/Bases/{l}.lua", $@"data\lua\{l}.lua");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
283
PoEco.Net/Web/PoENinja.cs
Normal file
283
PoEco.Net/Web/PoENinja.cs
Normal file
@@ -0,0 +1,283 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using PoEco.Net.DB;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static PoEco.Net.JSON.Classes.Divination;
|
||||
|
||||
namespace PoEco.Net.Web
|
||||
{
|
||||
internal class PoENinja
|
||||
{
|
||||
public static void SaveData(string url, string path)
|
||||
{
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.Encoding = Encoding.UTF8;
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
try
|
||||
{
|
||||
Uri address = new Uri(url);
|
||||
string contents = webClient.DownloadString(address);
|
||||
System.IO.File.AppendAllText(path, contents, Encoding.UTF8);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
Utilities.Message.CMW("URL: " + url, true, 3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenCurrency()
|
||||
{
|
||||
DeleteCurrencies();
|
||||
int curID = 1;
|
||||
double divineValue = 0;
|
||||
string cmdText = "";
|
||||
RootCurrency rcur = JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/currency.json", Encoding.UTF8));
|
||||
foreach (var c in rcur.lines)
|
||||
{
|
||||
if (c.currencyTypeName == "Divine Orb") { divineValue = Convert.ToInt32(Math.Round(c.chaosEquivalent)); }
|
||||
}
|
||||
foreach (LineCurrency line in JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/currency.json", Encoding.UTF8)).lines)
|
||||
{
|
||||
string curType = line.currencyTypeName;
|
||||
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
cmdText = $"INSERT INTO poeco_currency(curid,name,vchaos,vdivine) VALUES ('{curID}','{MySql.Data.MySqlClient.MySqlHelper.EscapeString(line.currencyTypeName)}','{Math.Round(line.chaosEquivalent,10)}','{Math.Round(line.chaosEquivalent / divineValue, 2, MidpointRounding.AwayFromZero)}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
curID++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenDivination()
|
||||
{
|
||||
DeleteDivinations();
|
||||
int divID = 1;
|
||||
string cmdText = "";
|
||||
RootCurrency rcur = JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/divination.json", Encoding.UTF8));
|
||||
foreach (LineDivination line in JsonConvert.DeserializeObject<RootDivination>(File.ReadAllText("data/ninja/divination.json", Encoding.UTF8)).lines)
|
||||
{
|
||||
string curType = line.name;
|
||||
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
cmdText = $"INSERT INTO poeco_divination(divid,name,vchaos,vdivine) VALUES ('{divID}','{MySqlHelper.EscapeString(line.name)}','{Math.Round(line.chaosValue,2)}','{line.divineValue}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
divID++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenEssence()
|
||||
{
|
||||
DeleteEssences();
|
||||
int divID = 1;
|
||||
string cmdText = "";
|
||||
RootCurrency rcur = JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/essence.json", Encoding.UTF8));
|
||||
foreach (LineDivination line in JsonConvert.DeserializeObject<RootDivination>(File.ReadAllText("data/ninja/essence.json", Encoding.UTF8)).lines)
|
||||
{
|
||||
string curType = line.name;
|
||||
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
cmdText = $"INSERT INTO poeco_essence(essid,name,vchaos,vdivine) VALUES ('{divID}','{MySqlHelper.EscapeString(line.name)}','{Math.Round(line.chaosValue)}','{line.divineValue}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
divID++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenFragment()
|
||||
{
|
||||
DeleteFragments();
|
||||
int divID = 1;
|
||||
string cmdText = "";
|
||||
RootCurrency rcur = JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/scarab.json", Encoding.UTF8));
|
||||
foreach (LineDivination line in JsonConvert.DeserializeObject<RootDivination>(File.ReadAllText("data/ninja/scarab.json", Encoding.UTF8)).lines)
|
||||
{
|
||||
string curType = line.name;
|
||||
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
cmdText = $"INSERT INTO poeco_fragment(fraid,name,vchaos,vdivine) VALUES ('{divID}','{MySqlHelper.EscapeString(line.name)}','{Math.Round(line.chaosValue)}','{line.divineValue}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
divID++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenFossil()
|
||||
{
|
||||
DeleteFossils();
|
||||
int divID = 1;
|
||||
string cmdText = "";
|
||||
RootCurrency rcur = JsonConvert.DeserializeObject<RootCurrency>(File.ReadAllText("data/ninja/fossil.json", Encoding.UTF8));
|
||||
foreach (LineDivination line in JsonConvert.DeserializeObject<RootDivination>(File.ReadAllText("data/ninja/fossil.json", Encoding.UTF8)).lines)
|
||||
{
|
||||
string curType = line.name;
|
||||
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
cmdText = $"INSERT INTO poeco_fossil(fosid,name,vchaos,vdivine) VALUES ('{divID}','{MySqlHelper.EscapeString(line.name)}','{Math.Round(line.chaosValue)}','{line.divineValue}')";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
divID++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteCurrencies()
|
||||
{
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_currency";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteDivinations()
|
||||
{
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_divination";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteEssences()
|
||||
{
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_essence";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteFragments()
|
||||
{
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_fragment";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
|
||||
public static void DeleteFossils()
|
||||
{
|
||||
MySqlConnection con = DB.User.MxPoEDB();
|
||||
string cmdText = $"DELETE FROM poeco_fossil";
|
||||
MySqlCommand cmd = new MySqlCommand(cmdText, con);
|
||||
con.Open();
|
||||
cmd.ExecuteNonQuery();
|
||||
con.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class CurrencyDetail
|
||||
{
|
||||
public int id { get; set; }
|
||||
public string icon { get; set; }
|
||||
public string name { get; set; }
|
||||
public string tradeId { get; set; }
|
||||
}
|
||||
|
||||
public class LanguageCurrency
|
||||
{
|
||||
public string name { get; set; }
|
||||
public TranslationsCurrency translations { get; set; }
|
||||
}
|
||||
|
||||
public class LineCurrency
|
||||
{
|
||||
public string currencyTypeName { get; set; }
|
||||
public Pay pay { get; set; }
|
||||
public Receive receive { get; set; }
|
||||
public double chaosEquivalent { get; set; }
|
||||
public LowConfidencePaySparkLine lowConfidencePaySparkLine { get; set; }
|
||||
public LowConfidenceReceiveSparkLine lowConfidenceReceiveSparkLine { get; set; }
|
||||
public string detailsId { get; set; }
|
||||
}
|
||||
|
||||
public class LowConfidencePaySparkLine
|
||||
{
|
||||
public List<object> data { get; set; }
|
||||
public double totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class LowConfidenceReceiveSparkLine
|
||||
{
|
||||
public List<double?> data { get; set; }
|
||||
public double totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class Pay
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int league_id { get; set; }
|
||||
public int pay_currency_id { get; set; }
|
||||
public int get_currency_id { get; set; }
|
||||
public DateTime sample_time_utc { get; set; }
|
||||
public int count { get; set; }
|
||||
public double value { get; set; }
|
||||
public int data_point_count { get; set; }
|
||||
public bool includes_secondary { get; set; }
|
||||
public int listing_count { get; set; }
|
||||
}
|
||||
|
||||
public class PaySparkLine
|
||||
{
|
||||
public List<object> data { get; set; }
|
||||
public double totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class Receive
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int league_id { get; set; }
|
||||
public int pay_currency_id { get; set; }
|
||||
public int get_currency_id { get; set; }
|
||||
public DateTime sample_time_utc { get; set; }
|
||||
public int count { get; set; }
|
||||
public double value { get; set; }
|
||||
public int data_point_count { get; set; }
|
||||
public bool includes_secondary { get; set; }
|
||||
public int listing_count { get; set; }
|
||||
}
|
||||
|
||||
public class ReceiveSparkLine
|
||||
{
|
||||
public List<double> data { get; set; }
|
||||
public double totalChange { get; set; }
|
||||
}
|
||||
|
||||
public class RootCurrency
|
||||
{
|
||||
public List<LineCurrency> lines { get; set; }
|
||||
public List<CurrencyDetail> currencyDetails { get; set; }
|
||||
public LanguageCurrency language { get; set; }
|
||||
}
|
||||
|
||||
public class TranslationsCurrency
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
65
PoEco.Net/Web/PoEPrices.cs
Normal file
65
PoEco.Net/Web/PoEPrices.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Security.Policy;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.Web
|
||||
{
|
||||
internal class PoEPrices
|
||||
{
|
||||
public static void GetItemJson(string iid, string b64)
|
||||
{
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
string url = $"https://www.poeprices.info/api?l={JSON.Settings.GetLeague()}&i={b64}";
|
||||
WebClient webClient = new WebClient();
|
||||
try
|
||||
{
|
||||
webClient.DownloadFile(url, "tmp/" + iid + ".json");
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
if (ex.Message.Contains("The remote server returned an error: (504) Gateway Time-out."))
|
||||
{
|
||||
Utilities.Message.CMW("Failed. Retrying...", true, 3);
|
||||
GetItemJson(iid, b64);
|
||||
}
|
||||
//Utilities.Message.CMW(ex.Message, true, 3);
|
||||
//Utilities.Message.CMW("URL: " + url, true, 3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public static double GetMin(string iid)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<PoEPricesRoot>(File.ReadAllText("tmp/" + iid + ".json")).min;
|
||||
}
|
||||
|
||||
public static double GetMax(string iid)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<PoEPricesRoot>(File.ReadAllText("tmp/" + iid + ".json")).max;
|
||||
}
|
||||
|
||||
public static string GetCurType(string iid)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<PoEPricesRoot>(File.ReadAllText("tmp/" + iid + ".json")).currency;
|
||||
}
|
||||
|
||||
public class PoEPricesRoot
|
||||
{
|
||||
public double min { get; set; }
|
||||
|
||||
public double max { get; set; }
|
||||
|
||||
public string currency { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
57
PoEco.Net/Web/Stash.cs
Normal file
57
PoEco.Net/Web/Stash.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PoEco.Net.Web
|
||||
{
|
||||
internal class Stash
|
||||
{
|
||||
public static void DownloadStash(string token, string url, string path)
|
||||
{
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.Encoding = Encoding.UTF8;
|
||||
webClient.Headers.Add(HttpRequestHeader.Cookie, "POESESSID=" + token);
|
||||
webClient.Headers.Add("user-agent", $"PoEcoDB/{Program.version} (poeco@mxpoe.ovh)");
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
|
||||
try
|
||||
{
|
||||
Uri address = new Uri(url);
|
||||
webClient.DownloadFile(address, path);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
Utilities.Message.CMW("URL: " + url, true, 3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message,true,3);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetStash(string token, string url, string path)
|
||||
{
|
||||
WebClient webClient = new WebClient();
|
||||
webClient.Encoding = Encoding.UTF8;
|
||||
webClient.Headers.Add("Authorization", "Bearer " + token);
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
try
|
||||
{
|
||||
Uri address = new Uri(url);
|
||||
webClient.DownloadFile(address, path);
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
Utilities.Message.CMW("URL: " + url, true, 3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Utilities.Message.CMW(ex.Message, true, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
20
PoEco.Net/packages.config
Normal file
20
PoEco.Net/packages.config
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle.Cryptography" version="2.2.1" targetFramework="net481" />
|
||||
<package id="Google.Protobuf" version="3.21.9" targetFramework="net481" />
|
||||
<package id="K4os.Compression.LZ4" version="1.3.5" targetFramework="net481" />
|
||||
<package id="K4os.Compression.LZ4.Streams" version="1.3.5" targetFramework="net481" />
|
||||
<package id="K4os.Hash.xxHash" version="1.0.8" targetFramework="net481" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net481" />
|
||||
<package id="MySql.Data" version="8.2.0" targetFramework="net481" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net481" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net481" />
|
||||
<package id="System.Configuration.ConfigurationManager" version="4.4.1" targetFramework="net481" />
|
||||
<package id="System.Diagnostics.DiagnosticSource" version="7.0.2" targetFramework="net481" />
|
||||
<package id="System.IO.Pipelines" version="5.0.2" targetFramework="net481" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net481" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net481" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net481" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net481" />
|
||||
<package id="ZstdSharp.Port" version="0.7.1" targetFramework="net481" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user