special class
This commit is contained in:
parent
01f733823b
commit
a65b8d9040
|
@ -48,7 +48,7 @@ namespace MxWs.JSON
|
|||
int itemid = 0;
|
||||
foreach (var e in ind)
|
||||
{
|
||||
RootObject j = JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(string.Format("index_{0}.json",e)));
|
||||
RootObject j = JsonConvert.DeserializeObject<RootObject>(File.ReadAllText(string.Format("json/index_{0}.json",e)));
|
||||
if(j.Misc.Count > 0)
|
||||
{
|
||||
foreach (var d in j.Misc)
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
using MySql.Data.MySqlClient;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MxWs.JSON
|
||||
{
|
||||
public class Special
|
||||
{
|
||||
public List<string> special { get; set; }
|
||||
}
|
||||
|
||||
public class SpecialObject
|
||||
{
|
||||
public List<object> Data { get; set; }
|
||||
}
|
||||
|
||||
class SpecialGen
|
||||
{
|
||||
internal static void GenSpecial(string dumpid, string special)
|
||||
{
|
||||
string did = string.Format("dumpid='{0}'", dumpid);
|
||||
StringBuilder sb = new StringBuilder("INSERT INTO ah_special_data (dumpid,itemid,specialid,value) VALUES ");
|
||||
List<string> Rows = new List<string>();
|
||||
List<string> ind = new List<string>();
|
||||
|
||||
Special ji = JsonConvert.DeserializeObject<Special>(File.ReadAllText(special));
|
||||
|
||||
foreach (var i in ji.special)
|
||||
{
|
||||
ind.Add(i);
|
||||
}
|
||||
|
||||
string duid = Server.dumpID;
|
||||
int sid = 1;
|
||||
int itemid = 0;
|
||||
foreach (var e in ind)
|
||||
{
|
||||
SpecialObject j = JsonConvert.DeserializeObject<SpecialObject>(File.ReadAllText(string.Format("json/special_{0}.json", e)));
|
||||
|
||||
if (j.Data.Count > 0)
|
||||
{
|
||||
foreach (var d in j.Data)
|
||||
{
|
||||
itemid = Convert.ToInt32(d);
|
||||
Rows.Add(string.Format("('{0}','{1}','{2}','{3}')", duid, itemid, sid, GetItemValue(itemid)));
|
||||
}
|
||||
}
|
||||
sid = sid + 1;
|
||||
}
|
||||
sb.Append(string.Join(",", Rows));
|
||||
sb.Append(";");
|
||||
InsertIndex(sb.ToString());
|
||||
}
|
||||
|
||||
public static int GetItemValue(int id)
|
||||
{
|
||||
string d = Server.dumpID;
|
||||
//string d = "nB3qJHOVPH";
|
||||
int v = 0;
|
||||
|
||||
string stm = string.Format("SELECT * FROM ah_items WHERE dumpid='{0}' AND itemid='{1}'", d, id);
|
||||
MySqlConnection mc = Utilities.DB.ItemDB();
|
||||
MySqlCommand cmd = new MySqlCommand(stm, mc);
|
||||
mc.Open();
|
||||
|
||||
MySqlDataReader result = cmd.ExecuteReader();
|
||||
|
||||
if (result.Read())
|
||||
{
|
||||
v = Convert.ToInt32(result["minimum"]);
|
||||
}
|
||||
|
||||
mc.Close();
|
||||
return v;
|
||||
}
|
||||
|
||||
private static void InsertIndex(string cmd)
|
||||
{
|
||||
MySqlConnection mc = Utilities.DB.ItemDB();
|
||||
MySqlCommand command = mc.CreateCommand();
|
||||
command.CommandText = cmd;
|
||||
mc.Open();
|
||||
command.ExecuteNonQuery();
|
||||
mc.Close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -64,6 +64,7 @@
|
|||
<Compile Include="JSON\AHUrl.cs" />
|
||||
<Compile Include="JSON\IndexGen.cs" />
|
||||
<Compile Include="JSON\Settings.cs" />
|
||||
<Compile Include="JSON\SpecialGen.cs" />
|
||||
<Compile Include="Utilities\DB.cs" />
|
||||
<Compile Include="Utilities\IO.cs" />
|
||||
<Compile Include="Utilities\MSG.cs" />
|
||||
|
|
|
@ -19,10 +19,12 @@ namespace MxWs
|
|||
public static bool debug = false;
|
||||
public static bool serverLoop = true;
|
||||
public static bool indexBool = false;
|
||||
public static bool specialBool = false;
|
||||
|
||||
public static string st = "init";
|
||||
public static string dumpID = "";
|
||||
public static string indexString = "";
|
||||
public static string specialString = "";
|
||||
|
||||
// Settings Variables
|
||||
// Values are set by ReadSettings() during "init" state.
|
||||
|
@ -62,6 +64,14 @@ namespace MxWs
|
|||
int ini = Array.IndexOf(args, "--index");
|
||||
indexString = args[ini + 1];
|
||||
|
||||
}
|
||||
// Special Arg Logic
|
||||
if (args.Contains("--special"))
|
||||
{
|
||||
specialBool = true;
|
||||
int ini = Array.IndexOf(args, "--special");
|
||||
specialString = args[ini + 1];
|
||||
|
||||
}
|
||||
// SkipDump Arg Logic
|
||||
if (args.Contains("--skipdump"))
|
||||
|
@ -123,6 +133,18 @@ namespace MxWs
|
|||
case "gen_index":
|
||||
Utilities.MSG.CMW("Generating the index table...", true, 1);
|
||||
JSON.IndexGen.GenIndex(dumpID, indexString);
|
||||
if (specialBool)
|
||||
{
|
||||
st = "gen_special";
|
||||
}
|
||||
else
|
||||
{
|
||||
st = "clean";
|
||||
}
|
||||
break;
|
||||
case "gen_special":
|
||||
Utilities.MSG.CMW("Generating the special table...", true, 1);
|
||||
JSON.SpecialGen.GenSpecial(dumpID, specialString);
|
||||
st = "clean";
|
||||
break;
|
||||
case "clean":
|
||||
|
|
Loading…
Reference in New Issue