123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.IO;
- namespace Server
- {
- class G
- {
- public static NLog.Logger logger = null;
- static public uint Random()
- {
- byte[] buff = Guid.NewGuid().ToByteArray();
- int size = buff.Length;
- return System.BitConverter.ToUInt32(buff, size - 8);
- }
- static void Main()
- {
- long d = DateTime.Now.Ticks;
- Console.WriteLine(d);
- d = DateTime.Now.AddDays(-1).Ticks;
- Console.WriteLine(d);
- JObject a = new JObject();
- a["last"] = d;
- File.WriteAllText("d:\\test.json", a.ToString());
- JObject b = JObject.Parse(File.ReadAllText("d:\\test.json"));
- Console.WriteLine(b["last"].Value<long>());
- Console.ReadLine();
- }
- public static Settings settings;
- static G()
- {
- try
- {
- string text = File.ReadAllText("init-cs.json");
- G.settings = JsonConvert.DeserializeObject<Settings>(text);
- }
- catch
- {
- G.settings = new Settings();
- }
- var appBasePath = System.IO.Directory.GetCurrentDirectory();
- NLog.GlobalDiagnosticsContext.Set("basedir", appBasePath);
- logger = NLog.LogManager.GetLogger("G");
- }
- }
- public class Settings
- {
- public ushort Port;
- public string ServerID, ServerName, MessageIP;
- public ushort MessagePort;
- public string DBURL;
- }
- }
|