Пример #1
0
        public bool SaveAccount(ushort conn)
        {
            int Idx = GetIndex(conn);

            try
            {
                string CorrectPatch = Functions.getCorrectPath(AccountList[Idx].Account.Info.AccountName);
                string indented     = "";
                using (StreamWriter file = File.CreateText(CorrectPatch + ".json"))
                {
                    indented = JsonConvert.SerializeObject(AccountList[Idx].Account, Formatting.Indented);
                    file.Write(indented);
                }

                W2Log.Write(String.Format("save account sucess: {0}/{1}", Idx, AccountList[Idx].Account.Info.AccountName), ELogType.GAME_EVENT);


                indented.Replace(AccountList[Idx].Account.Info.AccountPass, "null");
                int update = MySQL.nQuery(string.Format("INSERT INTO `accounts_json` (`login`, `conteudo`) VALUES ('{0}', '{1}') ON DUPLICATE KEY UPDATE `login` = '{2}' ", AccountList[Idx].Account.Info.AccountName.ToLower(), indented, AccountList[Idx].Account.Info.AccountName.ToLower()));
                if (update != 0)
                {
                    W2Log.Write(string.Format("Sucess DBSaveAccount update json: {0} - {1}", Idx, AccountList[Idx].Account.Info.AccountName));
                }


                return(true);
            }
            catch (Exception e)
            {
                W2Log.Write(String.Format("save account fail: {0}/{1}", AccountList[Idx].Account.Info.AccountName, e.Message), ELogType.GAME_EVENT);
                return(false);
            }
        }