コード例 #1
0
 internal static int GetLastPlayed(int accountID) // get last played finds the last player saved on an account
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             int i = 0;
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Player_Select_By_Account", conn);
             sp.AddParameter("@accountID", SqlDbType.Int, 4, ParameterDirection.Input, accountID);
             DataTable dtPlayerItem = sp.ExecuteDataTable();
             if (dtPlayerItem == null || dtPlayerItem.Rows.Count < 1)
             {
                 return(-1);
             }
             DateTime db = DateTime.MinValue;
             DateTime dt = DateTime.MinValue;
             foreach (DataRow dr in dtPlayerItem.Rows)
             {
                 dt = Convert.ToDateTime(dr["lastOnline"]);
                 if (DateTime.Compare(dt, db) > 0)  // In Compare, > 0 means param 1 > param 2
                 {
                     db = dt;
                     i  = Convert.ToInt32(dr["playerID"]);
                 }
             }
             return(i);
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #2
0
        internal static ArrayList p_getScores()
        {
            ArrayList scoresList = new ArrayList();

            using (var conn = DataAccess.GetSQLConnection())
            {
                try
                {
                    PC score = new PC();
                    SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Scores_Select", conn);
                    sp.AddParameter("@devRequest", SqlDbType.Bit, 1, ParameterDirection.Input, true);
                    sp.AddParameter("@classType", SqlDbType.Int, 4, ParameterDirection.Input, 0);
                    DataTable dtScores = sp.ExecuteDataTable();
                    int       max      = ProtocolYuusha.MAX_SCORES;
                    foreach (DataRow dr in dtScores.Rows)
                    {
                        if (max <= 0)
                        {
                            return(scoresList);
                        }
                        score             = new PC();
                        score             = ConvertRowToScore(score, dr, true);
                        score.UniqueID    = Convert.ToInt32(dr["playerID"]);
                        score.IsAnonymous = (bool)PC.GetField(score.UniqueID, "anonymous", score.IsAnonymous, null);
                        scoresList.Add(score);
                        max--;
                    }
                }
                catch (Exception e)
                {
                    Utils.LogException(e);
                }
            }
            return(scoresList);
        }
コード例 #3
0
ファイル: DBEditor.cs プロジェクト: mdcohen/dragonsspine
        internal static int UpdateCellInfo(bool newCellInfo, int cellID, string notes, string mapName, int xCord, int yCord, int zCord, string segue, string description, string cellLock, bool portal, bool pvpEnabled, bool singleCustomer, bool teleport, bool mailbox)
        {
            try
            {
                string sptouse = "prApp_CellsInfo_Update";
                if (newCellInfo)
                {
                    sptouse = "prApp_CellsInfo_Insert";
                }

                SqlStoredProcedure sp = new SqlStoredProcedure(sptouse, DataAccess.GetSQLConnection());
                sp.AddParameter("@mapName", SqlDbType.VarChar, 50, ParameterDirection.Input, mapName);
                sp.AddParameter("@xCord", SqlDbType.Int, 4, ParameterDirection.Input, xCord);
                sp.AddParameter("@yCord", SqlDbType.Int, 4, ParameterDirection.Input, yCord);
                sp.AddParameter("@description", SqlDbType.NVarChar, 510, ParameterDirection.Input, description);
                sp.AddParameter("@lock", SqlDbType.NVarChar, 510, ParameterDirection.Input, cellLock);
                sp.AddParameter("@notes", SqlDbType.VarChar, 255, ParameterDirection.Input, notes);
                sp.AddParameter("@portal", SqlDbType.Bit, 1, ParameterDirection.Input, portal);
                sp.AddParameter("@zCord", SqlDbType.Int, 4, ParameterDirection.Input, zCord);
                sp.AddParameter("@segue", SqlDbType.VarChar, 50, ParameterDirection.Input, segue);
                sp.AddParameter("@pvpEnabled", SqlDbType.Bit, 1, ParameterDirection.Input, pvpEnabled);
                sp.AddParameter("@singleCustomer", SqlDbType.Bit, 1, ParameterDirection.Input, singleCustomer);
                sp.AddParameter("@teleport", SqlDbType.Bit, 1, ParameterDirection.Input, teleport);
                sp.AddParameter("@mailbox", SqlDbType.Bit, 1, ParameterDirection.Input, mailbox);
                sp.AddParameter("@cellID", SqlDbType.Int, 4, ParameterDirection.Input, cellID);
                return(sp.ExecuteNonQuery());
            }
            catch (Exception e)
            {
                Utils.LogException(e);
                return(-1);
            }
        }
コード例 #4
0
 internal static int InsertStoreItem(int spawnZoneID, StoreItem storeItem)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Stores_Insert", conn);
             sp.AddParameter("@spawnZoneID", SqlDbType.Int, 4, ParameterDirection.Input, spawnZoneID);
             sp.AddParameter("@notes", SqlDbType.NVarChar, 255, ParameterDirection.Input, storeItem.notes);
             sp.AddParameter("@original", SqlDbType.Bit, 1, ParameterDirection.Input, storeItem.original);
             sp.AddParameter("@itemID", SqlDbType.Int, 4, ParameterDirection.Input, storeItem.itemID);
             sp.AddParameter("@sellPrice", SqlDbType.Int, 4, ParameterDirection.Input, storeItem.sellPrice);
             sp.AddParameter("@stocked", SqlDbType.SmallInt, 2, ParameterDirection.Input, storeItem.stocked);
             sp.AddParameter("@charges", SqlDbType.SmallInt, 2, ParameterDirection.Input, storeItem.charges);
             sp.AddParameter("@figExp", SqlDbType.BigInt, 8, ParameterDirection.Input, storeItem.figExp);
             sp.AddParameter("@seller", SqlDbType.VarChar, 20, ParameterDirection.Input, storeItem.seller);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #5
0
 internal static int UpdateStoreItem(int stockID, int stocked) // set a new stocked amount for this stockID
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Stores_Update", conn);
             sp.AddParameter("@stockID", SqlDbType.Int, 4, ParameterDirection.Input, stockID);
             sp.AddParameter("@stocked", SqlDbType.Int, 4, ParameterDirection.Input, stocked);
             DataTable dtStockItem = sp.ExecuteDataTable();
             if (dtStockItem == null)
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #6
0
 internal static int SaveLottery(Land land)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Land_Update_Lottery", conn);
             sp.AddParameter("@landID", SqlDbType.Int, 4, ParameterDirection.Input, land.LandID);
             sp.AddParameter("@lottery", SqlDbType.BigInt, 8, ParameterDirection.Input, land.Lottery);
             sp.AddParameter("@lotteryParticipants", SqlDbType.VarChar, 255, ParameterDirection.Input, Utils.ConvertListToString(land.LotteryParticipants).Trim());
             DataTable dtLand = sp.ExecuteDataTable();
             if (dtLand == null)
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #7
0
 internal static int GetAccountID(string account) // get an account ID (generated by db) using account name
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             int i = 0;
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Select", conn);
             sp.AddParameter("@account", SqlDbType.NVarChar, 20, ParameterDirection.Input, account);
             DataTable dtAccountItem = sp.ExecuteDataTable();
             if (dtAccountItem == null || dtAccountItem.Rows.Count < 1)
             {
                 return(-1);
             }
             foreach (DataRow dr in dtAccountItem.Rows)
             {
                 i = Convert.ToInt16(dr["AccountID"]);
                 return(i);
             }
             return(-1);
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #8
0
 internal static bool AccountExists(string account) // searches DB to see if account exists
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Check", conn);
             sp.AddParameter("@account", SqlDbType.NVarChar, 20, ParameterDirection.Input, account);
             DataTable dtAccountItem = sp.ExecuteDataTable();
             if (dtAccountItem == null || dtAccountItem.Rows.Count < 1)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(false);
         }
     }
 }
コード例 #9
0
        internal static bool ItemIDExists(int itemID)
        {
            if (!Item.ItemDictionary.ContainsKey(itemID))
            {
                using (var conn = DataAccess.GetSQLConnection())
                {
                    try
                    {
                        var       sp            = new SqlStoredProcedure("prApp_CatalogItem_Select_All", conn);
                        DataTable dtCatalogItem = sp.ExecuteDataTable();
                        foreach (DataRow dr in dtCatalogItem.Rows)
                        {
                            if (itemID == Convert.ToInt32(dr["itemID"]))
                            {
                                return(true);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Utils.LogException(e);
                        return(true);
                    }
                }

                return(false);
            }

            return(true);
        }
コード例 #10
0
 internal static List <Cell> GetCellList(string name)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             List <Cell>        cellsList = new List <Cell>();
             SqlStoredProcedure sp        = new SqlStoredProcedure("prApp_Cell_Select_By_Map", conn);
             sp.AddParameter("@mapName", SqlDbType.NVarChar, 50, ParameterDirection.Input, name);
             DataTable dtCellsInfo = sp.ExecuteDataTable();
             if (dtCellsInfo != null)
             {
                 foreach (DataRow dr in dtCellsInfo.Rows)
                 {
                     cellsList.Add(new Cell(dr));
                 }
                 Utils.Log("Loaded Cells: " + name, Utils.LogType.SystemGo);
                 return(cellsList);
             }
             else
             {
                 Utils.Log("DBWorld.GetCellsList returned null for map " + name, Utils.LogType.SystemFailure);
                 return(null);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(null);
         }
     }
 }
コード例 #11
0
ファイル: DBNPC.cs プロジェクト: mdcohen/dragonsspine
        internal static bool LoadNPCDictionary()
        {
            using (var conn = DataAccess.GetSQLConnection())
            {
                try
                {
                    SqlStoredProcedure sp     = new SqlStoredProcedure("prApp_NPC_Select_All", conn);
                    DataTable          dtNPCs = sp.ExecuteDataTable();
                    foreach (DataRow dr in dtNPCs.Rows)
                    {
                        int npcID = Convert.ToInt32(dr["npcID"]);

                        if (!NPC.NPCDictionary.ContainsKey(npcID))
                        {
                            NPC.NPCDictionary.Add(npcID, dr);
                        }
                        else
                        {
                            Utils.Log("DAL.DBNPC.LoadNPCDictionary attempted to add an NPC ID that already exists. NPCID: " + npcID, Utils.LogType.SystemWarning);
                        }
                    }
                    Utils.Log("Loaded NPCs (" + NPC.NPCDictionary.Count.ToString() + ")", Utils.LogType.SystemGo);
                    return(true);
                }
                catch (Exception e)
                {
                    Utils.LogException(e);
                    return(false);
                }
            }
        }
コード例 #12
0
 internal static bool LoadMaps(Land land)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Map_Select", conn);
             sp.AddParameter("@landID", SqlDbType.SmallInt, 2, ParameterDirection.Input, land.LandID);
             DataTable dtMaps = sp.ExecuteDataTable();
             foreach (DataRow dr in dtMaps.Rows)
             {
                 //if (dr["name"].ToString() != "Innkadi")
                 //{
                 land.Add(new Map(land.FacetID, dr));
                 Utils.Log("Loaded Map: " + dr["name"].ToString(), Utils.LogType.SystemGo);
                 //}
             }
             return(true);
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(false);
         }
     }
 }
コード例 #13
0
ファイル: DBMail.cs プロジェクト: mdcohen/dragonsspine
 internal static GameMailAttachment GetMailAttachment(long mailID)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_MailAttachment_Select_By_MailID", conn);
             sp.AddParameter("@mailID", SqlDbType.BigInt, 8, ParameterDirection.Input, mailID);
             DataTable dtMailAtt = sp.ExecuteDataTable();
             if (dtMailAtt.Rows.Count > 0)
             {
                 return(new GameMailAttachment(dtMailAtt.Rows[0]));
             }
             else
             {
                 return(null);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(null);
         }
     }
 }
コード例 #14
0
ファイル: DBMail.cs プロジェクト: mdcohen/dragonsspine
 internal static int UpdateMailMessage(GameMailMessage mail)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Mail_Update", conn);
             sp.AddParameter("@mailID", SqlDbType.BigInt, 8, ParameterDirection.Input, mail.MailID);
             sp.AddParameter("@attachment", SqlDbType.Int, 4, ParameterDirection.Input, mail.HasAttachment);
             sp.AddParameter("@readByReceiver", SqlDbType.Int, 4, ParameterDirection.Input, mail.HasBeenReadByReceiver);
             DataTable dtMail = sp.ExecuteDataTable();
             if (dtMail == null)
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #15
0
 internal static int SaveAccount(Account account)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Update", conn);
             sp.AddParameter("@accountID", SqlDbType.Int, 4, ParameterDirection.Input, account.accountID);
             sp.AddParameter("@notes", SqlDbType.Text, System.Int32.MaxValue, ParameterDirection.Input, account.notes);
             sp.AddParameter("@account", SqlDbType.NVarChar, 20, ParameterDirection.Input, account.accountName);
             sp.AddParameter("@password", SqlDbType.NVarChar, 100, ParameterDirection.Input, account.password);
             sp.AddParameter("@currentMarks", SqlDbType.Int, 4, ParameterDirection.Input, account.currentMarks);
             sp.AddParameter("@email", SqlDbType.NVarChar, 50, ParameterDirection.Input, account.email);
             DataTable dtPlayerStats = sp.ExecuteDataTable();
             if (dtPlayerStats == null)
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #16
0
ファイル: DBMail.cs プロジェクト: mdcohen/dragonsspine
 internal static int InsertMailAttachment(GameMailAttachment attachment)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_MailAttachment_Insert", conn);
             sp.AddParameter("@mailID", SqlDbType.BigInt, 8, ParameterDirection.Input, attachment.MailID);
             sp.AddParameter("@itemID", SqlDbType.Int, 4, ParameterDirection.Input, attachment.ItemID);
             sp.AddParameter("@attunedID", SqlDbType.Int, 4, ParameterDirection.Input, attachment.AttunedID);
             sp.AddParameter("@special", SqlDbType.VarChar, 255, ParameterDirection.Input, attachment.Special);
             sp.AddParameter("@coinValue", SqlDbType.Float, 8, ParameterDirection.Input, attachment.CoinValue);
             sp.AddParameter("@charges", SqlDbType.Int, 4, ParameterDirection.Input, attachment.Charges);
             sp.AddParameter("@attuneType", SqlDbType.Int, 4, ParameterDirection.Input, (int)attachment.AttuneType);
             sp.AddParameter("@figExp", SqlDbType.BigInt, 8, ParameterDirection.Input, attachment.FigExp);
             sp.AddParameter("@timeCreated", SqlDbType.DateTime, 8, ParameterDirection.Input, attachment.TimeCreated);
             sp.AddParameter("@whoCreated", SqlDbType.NVarChar, 100, ParameterDirection.Input, attachment.WhoCreated);
             sp.AddParameter("@paymentRequested", SqlDbType.Float, 8, ParameterDirection.Input, attachment.PaymentRequested);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #17
0
 internal static int DeleteAccount(int accountID)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Delete", conn);
         sp.AddParameter("@accountID", SqlDbType.Int, 4, ParameterDirection.Input, accountID);
         return(sp.ExecuteNonQuery());
     }
 }
コード例 #18
0
        internal static int SaveAccountField(int accountID, String field, Object var)
        {
            using (var conn = DataAccess.GetSQLConnection())
            {
                try
                {
                    SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Update_Field", conn);
                    sp.AddParameter("@AccountID", SqlDbType.Int, 4, ParameterDirection.Input, accountID);
                    sp.AddParameter("@field", SqlDbType.NVarChar, 50, ParameterDirection.Input, field);
                    sp.AddParameter("@type", SqlDbType.NVarChar, 50, ParameterDirection.Input, var.GetType().ToString());
                    if (var.GetType().Equals(Type.GetType("System.Int32")))
                    {
                        sp.AddParameter("@int", SqlDbType.Int, 4, ParameterDirection.Input, var);
                    }
                    else if (var.GetType().Equals(Type.GetType("System.String")))
                    {
                        sp.AddParameter("@string", SqlDbType.NVarChar, 4000, ParameterDirection.Input, var);
                    }
                    else if (var.GetType().Equals(Type.GetType("System.Boolean")))
                    {
                        sp.AddParameter("@bit", SqlDbType.Bit, 1, ParameterDirection.Input, var);
                    }
                    else if (var.GetType().Equals(Type.GetType("System.Char")))
                    {
                        sp.AddParameter("@int", SqlDbType.Char, 1, ParameterDirection.Input, var);
                    }
                    else if (var.GetType().Equals(Type.GetType("System.DateTime")))
                    {
                        sp.AddParameter("@dateTime", SqlDbType.DateTime, 8, ParameterDirection.Input, var);
                    }
                    else
                    {
                        Utils.Log("DBAccount.saveAccountProperty(" + accountID + ", " + field + ", " + var.GetType().ToString() + ") *Type Not Recognized*, " + var.GetType().ToString(), Utils.LogType.SystemFailure);
                        return(-1);
                    }

                    DataTable dtAccount = sp.ExecuteDataTable();
                    if (dtAccount == null)
                    {
                        return(-1);
                    }
                    else
                    {
                        return(1);
                    }
                }
                catch (Exception e)
                {
                    Utils.LogException(e);
                    return(-1);
                }
            }
        }
コード例 #19
0
ファイル: DBEditor.cs プロジェクト: mdcohen/dragonsspine
 internal static int DeleteSpawnZone(int spawnZoneID)
 {
     try
     {
         SqlStoredProcedure sp = new SqlStoredProcedure("prApp_SpawnZone_Delete", DataAccess.GetSQLConnection());
         sp.AddParameter("@zoneID", SqlDbType.Int, 4, ParameterDirection.Input, spawnZoneID);
         return(sp.ExecuteNonQuery());
     }
     catch (Exception e)
     {
         Utils.LogException(e);
         return(-1);
     }
 }
コード例 #20
0
 internal static List <Account> GetAllAccounts()
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         List <Account>     accounts = new List <Account>();
         SqlStoredProcedure sp       = new SqlStoredProcedure("prApp_Account_Select_All", conn);
         DataTable          dt       = sp.ExecuteDataTable();
         foreach (DataRow dr in dt.Rows)
         {
             accounts.Add(new Account(dr));
         }
         return(accounts);
     }
 }
コード例 #21
0
 internal static Account GetAccountByName(string name)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Select", conn);
         sp.AddParameter("@account", SqlDbType.NVarChar, 20, ParameterDirection.Input, name);
         DataTable dt = sp.ExecuteDataTable();
         if (dt.Rows.Count > 0)
         {
             DataRow dr = dt.Rows[0];
             return(new Account(dr));
         }
         return(null);
     }
 }
コード例 #22
0
ファイル: DBEditor.cs プロジェクト: mdcohen/dragonsspine
 internal static int DeleteCellInfo(string MapName, int XCord, int YCord)
 {
     try
     {
         SqlStoredProcedure sp = new SqlStoredProcedure("prApp_CellsInfo_Delete", DataAccess.GetSQLConnection());
         sp.AddParameter("@MapName", SqlDbType.NVarChar, 50, ParameterDirection.Input, MapName);
         sp.AddParameter("@XCord", SqlDbType.Int, 4, ParameterDirection.Input, XCord);
         sp.AddParameter("@YCord", SqlDbType.Int, 4, ParameterDirection.Input, YCord);
         return(sp.ExecuteNonQuery());
     }
     catch (Exception e)
     {
         Utils.LogException(e);
         return(-1);
     }
 }
コード例 #23
0
 internal static int ClearStoreItems()
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Stores_Clear", conn);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #24
0
        internal static ArrayList GetSpawnLinksByMap(int map)
        {
            ArrayList zones = new ArrayList();

            using (var conn = DataAccess.GetSQLConnection())
            {
                SqlStoredProcedure sp = new SqlStoredProcedure("prApp_SpawnZone_Select_By_Map", conn);
                sp.AddParameter("@map", SqlDbType.Int, 4, ParameterDirection.Input, map);
                DataTable szTable = sp.ExecuteDataTable();
                foreach (DataRow dr in szTable.Rows)
                {
                    zones.Add(new SpawnZone(dr));
                }
            }
            return(zones);
        }
コード例 #25
0
ファイル: DBMail.cs プロジェクト: mdcohen/dragonsspine
 // Currently only one attachment per message.
 internal static int DeleteMailAttachment(long mailID)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_MailAttachment_Delete", conn);
             sp.AddParameter("@mailID", SqlDbType.BigInt, 4, ParameterDirection.Input, mailID);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #26
0
 internal static int DeleteStoreItem(int stockID) // delete this stockID from a store
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Stores_Delete", conn);
             sp.AddParameter("@stockID", SqlDbType.Int, 4, ParameterDirection.Input, stockID);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #27
0
ファイル: DBNPC.cs プロジェクト: mdcohen/dragonsspine
 internal static NPC GetNPCByID(int NpcID)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_NPC_Select", conn);
             sp.AddParameter("@npcID", SqlDbType.Int, 4, ParameterDirection.Input, NpcID);
             DataTable dtNPCs = sp.ExecuteDataTable();
             return(new NPC(dtNPCs.Rows[0]));
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(null);
         }
     }
 }
コード例 #28
0
        internal static Object GetAccountField(int accountID, String field, Type objectType)
        {
            // objectTypes: "System.Int32", "System.String", "System.Boolean", "System.Char", "System.DateTme"
            using (var conn = DataAccess.GetSQLConnection())
            {
                try
                {
                    SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Select_Field", conn);
                    sp.AddParameter("@accountID", SqlDbType.Int, 4, ParameterDirection.Input, accountID);
                    sp.AddParameter("@field", SqlDbType.NVarChar, 50, ParameterDirection.Input, field);
                    DataTable dtAccount = sp.ExecuteDataTable();
                    if (dtAccount == null || dtAccount.Rows.Count < 1)
                    {
                        return(null);
                    }
                    foreach (DataRow dr in dtAccount.Rows)
                    {
                        switch (objectType.ToString())
                        {
                        case "System.Int32":
                            return(Convert.ToInt32(dr[field]));

                        case "System.String":
                            return(dr[field].ToString());

                        case "System.Boolean":
                            return(Convert.ToBoolean(dr[field]));

                        case "System.Char":
                            return(Convert.ToChar(dr[field]));

                        case "System.DateTime":
                            return(Convert.ToDateTime(dr[field]));
                        }
                    }
                    return(null);
                }
                catch (Exception e)
                {
                    Utils.LogException(e);
                    return(null);
                }
            }
        }
コード例 #29
0
 internal static int InsertAccount(string account, string password, string ipAddress, string email) // insert a new account
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Account_Insert", conn);
             sp.AddParameter("@account", SqlDbType.NVarChar, 20, ParameterDirection.Input, account);
             sp.AddParameter("@password", SqlDbType.NVarChar, 100, ParameterDirection.Input, password);
             sp.AddParameter("@ipAddress", SqlDbType.NVarChar, 16, ParameterDirection.Input, ipAddress);
             sp.AddParameter("@ipAddressList", SqlDbType.NVarChar, 16, ParameterDirection.Input, ipAddress); // initial IPAddressList is current IPAddress only
             sp.AddParameter("@email", SqlDbType.NVarChar, 50, ParameterDirection.Input, email);
             return(sp.ExecuteNonQuery());
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(-1);
         }
     }
 }
コード例 #30
0
 internal static void SetupNewCharacter(Character ch)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_CharGen_Select", conn);
             sp.AddParameter("@race", SqlDbType.VarChar, 20, ParameterDirection.Input, ch.race);
             sp.AddParameter("@classType", SqlDbType.Int, 4, ParameterDirection.Input, (int)ch.BaseProfession);
             DataTable dtSetupNewChar = sp.ExecuteDataTable();
             foreach (DataRow dr in dtSetupNewChar.Rows)
             {
                 ConvertRowToNewCharacter(ch, dr);
             }
         }
         catch (Exception e)
         {
             Utils.LogException(e);
         }
     }
 }