//Type 1????,2?????
        public bool AddAndUpdateConsortiaEuqipControl(ConsortiaEquipControlInfo info, int userID, ref string msg)
        {
            bool result = false;
            try
            {
                SqlParameter[] para = new SqlParameter[6];
                para[0] = new SqlParameter("@ConsortiaID", info.ConsortiaID);
                para[1] = new SqlParameter("@Level", info.Level);
                para[2] = new SqlParameter("@Type", info.Type);
                para[3] = new SqlParameter("@Riches", info.Riches);
                para[4] = new SqlParameter("@UserID", userID);
                para[5] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
                para[5].Direction = ParameterDirection.ReturnValue;

                result = db.RunProcedure("SP_Consortia_Equip_Control_Add", para);
                int returnValue = (int)para[2].Value;
                result = returnValue == 0;

                switch (returnValue)
                {
                    case 2:
                        msg = "ConsortiaBussiness.AddAndUpdateConsortiaEuqipControl.Msg2";
                        break;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }
            return result;
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.ConsortiaID == 0)
                return 0;
            //Type 1表示商城,2表示铁匠铺

            bool result = false;
            string msg = "ConsortiaEquipControlHandler.Fail";
            ConsortiaEquipControlInfo info = new ConsortiaEquipControlInfo();
            info.ConsortiaID = client.Player.PlayerCharacter.ConsortiaID;
            using (ConsortiaBussiness db = new ConsortiaBussiness())
            {
                for (int i = 0; i < 5; i++)
                {

                    info.Riches = packet.ReadInt();
                    info.Type = 1;
                    info.Level = i + 1;

                    db.AddAndUpdateConsortiaEuqipControl(info, client.Player.PlayerCharacter.ID, ref msg);
                }
                info.Riches = packet.ReadInt();
                info.Type = 2;
                info.Level = 0;
                db.AddAndUpdateConsortiaEuqipControl(info, client.Player.PlayerCharacter.ID, ref msg);
                msg = "ConsortiaEquipControlHandler.Success";
                result = true;
            }
            packet.WriteBoolean(result);
            packet.WriteString(LanguageMgr.GetTranslation(msg));
            client.Out.SendTCP(packet);

            return 0;
        }
        public ConsortiaEquipControlInfo GetConsortiaEuqipRiches(int consortiaID, int Level, int type)
        {
            ConsortiaEquipControlInfo info = null;
            SqlDataReader reader = null;
            try
            {
                SqlParameter[] para = new SqlParameter[3];
                para[0] = new SqlParameter("@ConsortiaID", consortiaID);
                para[1] = new SqlParameter("@Level", Level);
                para[2] = new SqlParameter("@Type", type);

                db.GetReader(ref reader, "SP_Consortia_Equip_Control_Single", para);

                while (reader.Read())
                {
                    info = new ConsortiaEquipControlInfo();
                    info.ConsortiaID = (int)reader["ConsortiaID"];
                    info.Level = (int)reader["Level"];
                    info.Riches = (int)reader["Riches"];
                    info.Type = (int)reader["Type"];
                    return info;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("GetAllConsortiaLevel", e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
            if (info == null)
            {
                info = new ConsortiaEquipControlInfo();
                info.ConsortiaID = consortiaID;
                info.Level = Level;
                info.Riches = 100;
                info.Type = type;
            }
            return info;
        }
        public ConsortiaEquipControlInfo[] GetConsortiaEquipControlPage(int page, int size, ref int total, int order, int consortiaID, int level, int type)
        {
            List<ConsortiaEquipControlInfo> infos = new List<ConsortiaEquipControlInfo>();
            try
            {
                string sWhere = " IsExist=1 ";
                if (consortiaID != -1)
                {
                    sWhere += " and ConsortiaID =" + consortiaID + " ";
                }
                if (level != -1)
                {
                    sWhere += " and Level =" + level + " ";
                }
                if (type != -1)
                {
                    sWhere += " and Type =" + type + " ";
                }

                string sOrder = "ConsortiaID ";

                DataTable dt = GetPage("Consortia_Equip_Control", sWhere, page, size, "*", sOrder, "ConsortiaID", ref total);
                foreach (DataRow dr in dt.Rows)
                {
                    ConsortiaEquipControlInfo info = new ConsortiaEquipControlInfo();
                    info.ConsortiaID = (int)dr["ConsortiaID"];
                    info.Level = (int)dr["Level"];
                    info.Riches = (int)dr["Riches"];
                    info.Type = (int)dr["Type"];

                    infos.Add(info);
                }

            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
            }

            return infos.ToArray();
        }
示例#5
0
 public static XElement CreateConsortiaEquipControlInfo(ConsortiaEquipControlInfo info)
 {
     return new XElement("Item", new XAttribute("ConsortiaID", info.ConsortiaID),
         new XAttribute("Level", info.Level),
         new XAttribute("Riches", info.Riches),
         new XAttribute("Type", info.Type));
 }