Пример #1
0
        public static bool AddConsortia(int consortiaID)
        {
            bool result = false;
            m_lock.AcquireWriterLock(Timeout.Infinite);
            try
            {
                if (!_consortia.ContainsKey(consortiaID))
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.BuildDate = DateTime.Now;
                    info.Level = 1;
                    info.IsExist = true;
                    info.ConsortiaName = "";
                    info.ConsortiaID = consortiaID;
                    _consortia.Add(consortiaID, info);
                }
            }
            catch (Exception ex)
            {
                log.Error("ConsortiaUpGrade", ex);
            }
            finally
            {
                m_lock.ReleaseWriterLock();
            }

            return result;
        }
Пример #2
0
 public ConsortiaInfo[] GetConsortiaAll()
 {
     List<ConsortiaInfo> infos = new List<ConsortiaInfo>();
     SqlDataReader reader = null;
     try
     {
         db.GetReader(ref reader, "SP_Consortia_All");
         while (reader.Read())
         {
             ConsortiaInfo info = new ConsortiaInfo();
             info.ConsortiaID = (int)reader["ConsortiaID"];
             info.Honor = (int)reader["Honor"];
             info.Level = (int)reader["Level"];
             info.Riches = (int)reader["Riches"];
             info.MaxCount = (int)reader["MaxCount"];
             info.BuildDate = (DateTime)reader["BuildDate"];
             info.IsExist = (bool)reader["IsExist"];
             info.DeductDate = (DateTime)reader["DeductDate"];
             info.StoreLevel = (int)reader["StoreLevel"];
             info.SmithLevel = (int)reader["SmithLevel"];
             info.ShopLevel = (int)reader["ShopLevel"];
             info.SkillLevel = (int)reader["SkillLevel"];
             info.ConsortiaName = reader["ConsortiaName"] == null ? "" : reader["ConsortiaName"].ToString();
             info.IsDirty = false;
             infos.Add(info);
         }
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
             log.Error("Init", e);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
     }
     return infos.ToArray();
 }
Пример #3
0
 public bool AddConsortia(ConsortiaInfo info, ref string msg, ref ConsortiaDutyInfo dutyInfo)
 {
     bool result = false;
     try
     {
         SqlParameter[] para = new SqlParameter[23];
         para[0] = new SqlParameter("@ConsortiaID", info.ConsortiaID);
         para[0].Direction = ParameterDirection.InputOutput;
         para[1] = new SqlParameter("@BuildDate", info.BuildDate);
         para[2] = new SqlParameter("@CelebCount", info.CelebCount);
         para[3] = new SqlParameter("@ChairmanID", info.ChairmanID);
         para[4] = new SqlParameter("@ChairmanName", info.ChairmanName == null ? "" : info.ChairmanName);
         para[5] = new SqlParameter("@ConsortiaName", info.ConsortiaName == null ? "" : info.ConsortiaName);
         para[6] = new SqlParameter("@CreatorID", info.CreatorID);
         para[7] = new SqlParameter("@CreatorName", info.CreatorName == null ? "" : info.CreatorName);
         para[8] = new SqlParameter("@Description", info.Description);
         para[9] = new SqlParameter("@Honor", info.Honor);
         para[10] = new SqlParameter("@IP", info.IP);
         para[11] = new SqlParameter("@IsExist", info.IsExist);
         para[12] = new SqlParameter("@Level", info.Level);
         para[13] = new SqlParameter("@MaxCount", info.MaxCount);
         para[14] = new SqlParameter("@Placard", info.Placard);
         para[15] = new SqlParameter("@Port", info.Port);
         para[16] = new SqlParameter("@Repute", info.Repute);
         para[17] = new SqlParameter("@Count", info.Count);
         para[18] = new SqlParameter("@Riches", info.Riches);
         para[19] = new SqlParameter("@Result", System.Data.SqlDbType.Int);
         para[19].Direction = ParameterDirection.ReturnValue;
         para[20] = new SqlParameter("@tempDutyLevel", System.Data.SqlDbType.Int);
         para[20].Direction = ParameterDirection.InputOutput;
         para[20].Value = dutyInfo.Level;
         para[21] = new SqlParameter("@tempDutyName", System.Data.SqlDbType.VarChar, 100);
         para[21].Direction = ParameterDirection.InputOutput;
         para[21].Value = "";
         para[22] = new SqlParameter("@tempRight", System.Data.SqlDbType.Int);
         para[22].Direction = ParameterDirection.InputOutput;
         para[22].Value = dutyInfo.Right;
         result = db.RunProcedure("SP_Consortia_Add", para);
         int returnValue = (int)para[19].Value;
         result = returnValue == 0;
         if (result)
         {
             info.ConsortiaID = (int)para[0].Value;
             dutyInfo.Level = (int)para[20].Value;
             dutyInfo.DutyName = para[21].Value.ToString();
             dutyInfo.Right = (int)para[22].Value;
         }
         switch (returnValue)
         {
             case 2:
                 msg = "ConsortiaBussiness.AddConsortia.Msg2";
                 break;
         }
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
             log.Error("Init", e);
     }
     finally
     {
     }
     return result;
 }
Пример #4
0
        //SP_Consortia_CheckByName
        public ConsortiaInfo GetConsortiaSingleByName(string ConsortiaName)
        {
            SqlDataReader reader = null;
            try
            {
                SqlParameter[] para = new SqlParameter[1];
                para[0] = new SqlParameter("@ConsortiaName", SqlDbType.VarChar, 200);
                para[0].Value = ConsortiaName;
                db.GetReader(ref reader, "SP_Consortia_CheckByName", para);
                while (reader.Read())
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.ConsortiaID = (int)reader["ConsortiaID"];
                    info.BuildDate = (DateTime)reader["BuildDate"];
                    info.CelebCount = (int)reader["CelebCount"];
                    info.ChairmanID = (int)reader["ChairmanID"];
                    info.ChairmanName = reader["ChairmanName"].ToString();
                    //info.ChairmanTypeVIP = (byte)reader["typeVIP"];
                    //info.ChairmanVIPLevel = (int)reader["VIPLevel"];
                    info.ConsortiaName = reader["ConsortiaName"].ToString();
                    info.CreatorID = (int)reader["CreatorID"];
                    info.CreatorName = reader["CreatorName"].ToString();
                    info.Description = reader["Description"].ToString();
                    info.Honor = (int)reader["Honor"];
                    info.IsExist = (bool)reader["IsExist"];
                    info.Level = (int)reader["Level"];
                    info.MaxCount = (int)reader["MaxCount"];
                    info.Placard = reader["Placard"].ToString();
                    info.IP = reader["IP"].ToString();
                    info.Port = (int)reader["Port"];
                    info.Repute = (int)reader["Repute"];
                    info.Count = (int)reader["Count"];
                    info.Riches = (int)reader["Riches"];
                    info.DeductDate = (DateTime)reader["DeductDate"];
                    info.StoreLevel = (int)reader["StoreLevel"];
                    info.SmithLevel = (int)reader["SmithLevel"];
                    info.ShopLevel = (int)reader["ShopLevel"];
                    info.SkillLevel = (int)reader["SkillLevel"];
                    return info;
                }
            }
            catch
            {
                throw (new Exception());
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }

            return null;
        }
Пример #5
0
        public ConsortiaInfo GetConsortiaSingle(int id)
        {
            SqlDataReader reader = null;
            try
            {
                SqlParameter[] para = new SqlParameter[1];
                para[0] = new SqlParameter("@ID", id);
                db.GetReader(ref reader, "SP_Consortia_Single", para);
                while (reader.Read())
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.ConsortiaID = (int)reader["ConsortiaID"];
                    info.BuildDate = (DateTime)reader["BuildDate"];
                    info.CelebCount = (int)reader["CelebCount"];
                    info.ChairmanID = (int)reader["ChairmanID"];
                    info.ChairmanName = reader["ChairmanName"].ToString();
                    info.ChairmanTypeVIP = Convert.ToByte(reader["typeVIP"]);
                    info.ChairmanVIPLevel = (int)reader["VIPLevel"];
                    info.ConsortiaName = reader["ConsortiaName"].ToString();
                    info.CreatorID = (int)reader["CreatorID"];
                    info.CreatorName = reader["CreatorName"].ToString();
                    info.Description = reader["Description"].ToString();
                    info.Honor = (int)reader["Honor"];
                    info.IsExist = (bool)reader["IsExist"];
                    info.Level = (int)reader["Level"];
                    info.MaxCount = (int)reader["MaxCount"];
                    info.Placard = reader["Placard"].ToString();
                    info.IP = reader["IP"].ToString();
                    info.Port = (int)reader["Port"];
                    info.Repute = (int)reader["Repute"];
                    info.Count = (int)reader["Count"];
                    info.Riches = (int)reader["Riches"];
                    info.DeductDate = (DateTime)reader["DeductDate"];
                    info.StoreLevel = (int)reader["StoreLevel"];
                    info.SmithLevel = (int)reader["SmithLevel"];
                    info.ShopLevel = (int)reader["ShopLevel"];
                    info.SkillLevel = (int)reader["SkillLevel"];

                    return info;
                }
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                    log.Error("Init", e);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();
            }
            return null;
        }
Пример #6
0
        public ConsortiaInfo[] GetConsortiaPage(int page, int size, ref int total, int order, string name, int consortiaID, int level, int openApply)
        {
            List<ConsortiaInfo> infos = new List<ConsortiaInfo>();
            try
            {
                string sWhere = " IsExist=1 ";
                if (!string.IsNullOrEmpty(name))
                {
                    sWhere += " and ConsortiaName like '%" + name + "%' ";
                }
                if (consortiaID != -1)
                {
                    sWhere += " and ConsortiaID =" + consortiaID + " ";
                }
                if (level != -1)
                {
                    sWhere += " and Level =" + level + " ";
                }
                if (openApply != -1)
                {
                    sWhere += " and OpenApply =" + openApply + " ";
                }
                string sOrder = "ConsortiaName";
                switch (order)
                {
                    case 1:
                        sOrder = "ReputeSort";
                        break;
                    case 2:
                        sOrder = "ChairmanName";
                        break;
                    case 3:
                        sOrder = "Count desc";
                        break;
                    case 4:
                        sOrder = "Level desc";
                        break;
                    case 5:
                        sOrder = "Honor desc";
                        break;
                    case 10:
                        sOrder = "LastDayRiches desc";
                        break;
                    case 11:
                        sOrder = "AddDayRiches desc";
                        break;
                    case 12:
                        sOrder = "AddWeekRiches desc";
                        break;
                    case 13:
                        sOrder = "LastDayHonor desc";
                        break;
                    case 14:
                        sOrder = "AddDayHonor desc";
                        break;
                    case 15:
                        sOrder = "AddWeekHonor desc";
                        break;
                    case 16:
                        sOrder = "level desc,LastDayRiches desc";
                        break;
                }

                sOrder += ",ConsortiaID ";

                DataTable dt = GetPage("V_Consortia", sWhere, page, size, "*", sOrder, "ConsortiaID", ref total);
                foreach (DataRow dr in dt.Rows)
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.ConsortiaID = (int)dr["ConsortiaID"];
                    info.BuildDate = (DateTime)dr["BuildDate"];
                    info.CelebCount = (int)dr["CelebCount"];
                    info.ChairmanID = (int)dr["ChairmanID"];
                    info.ChairmanName = dr["ChairmanName"].ToString();
                    info.ChairmanTypeVIP =Convert.ToByte(dr["typeVIP"]);
                    info.ChairmanVIPLevel = (int)dr["VIPLevel"];
                    info.ConsortiaName = dr["ConsortiaName"].ToString();
                    info.CreatorID = (int)dr["CreatorID"];
                    info.CreatorName = dr["CreatorName"].ToString();
                    info.Description = dr["Description"].ToString();
                    info.Honor = (int)dr["Honor"];
                    info.IsExist = (bool)dr["IsExist"];
                    info.Level = (int)dr["Level"];
                    info.MaxCount = (int)dr["MaxCount"];
                    info.Placard = dr["Placard"].ToString();
                    info.IP = dr["IP"].ToString();
                    info.Port = (int)dr["Port"];
                    info.Repute = (int)dr["Repute"];
                    info.Count = (int)dr["Count"];
                    info.Riches = (int)dr["Riches"];
                    info.DeductDate = (DateTime)dr["DeductDate"];
                    info.AddDayHonor = (int)dr["AddDayHonor"];
                    info.AddDayRiches = (int)dr["AddDayRiches"];
                    info.AddWeekHonor = (int)dr["AddWeekHonor"];
                    info.AddWeekRiches = (int)dr["AddWeekRiches"];
                    info.LastDayRiches = (int)dr["LastDayRiches"];
                    info.OpenApply = (bool)dr["OpenApply"];
                    info.StoreLevel = (int)dr["StoreLevel"];
                    info.SmithLevel = (int)dr["SmithLevel"];
                    info.ShopLevel = (int)dr["ShopLevel"];
                    info.SkillLevel = (int)dr["SkillLevel"];
                    infos.Add(info);
                }

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

            return infos.ToArray();
        }
Пример #7
0
        public void SendConsortiaUpGrade(ConsortiaInfo info)
        {
            GSPacketIn pkg = new GSPacketIn((byte)eChatServerPacket.CONSORTIA_RESPONSE);
            pkg.WriteByte(6);
            pkg.WriteInt(info.ConsortiaID);
            pkg.WriteString(info.ConsortiaName);
            pkg.WriteInt(info.Level);

            SendTCP(pkg);
        }
Пример #8
0
        public static bool ConsortiaUpGrade(int consortiaID, int consortiaLevel)
        {
            bool result = false;
            m_lock.AcquireWriterLock(Timeout.Infinite);
            try
            {
                if (_consortia.ContainsKey(consortiaID) && _consortia[consortiaID].IsExist)
                {
                    _consortia[consortiaID].Level = consortiaLevel;
                }
                else
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.BuildDate = DateTime.Now;
                    info.Level = consortiaLevel;
                    info.IsExist = true;
                    _consortia.Add(consortiaID, info);
                }
            }
            catch (Exception ex)
            {
                log.Error("ConsortiaUpGrade", ex);
            }
            finally
            {
                m_lock.ReleaseWriterLock();
            }

            return result;
        }
Пример #9
0
 public static XElement CreateConsortiaInfo(ConsortiaInfo info)
 {
     return new XElement("Item", new XAttribute("ConsortiaID", info.ConsortiaID),
         new XAttribute("BuildDate", info.BuildDate.ToString("yyyy-MM-dd HH:mm:ss")),
         new XAttribute("CelebCount", info.CelebCount),
         new XAttribute("ChairmanID", info.ChairmanID),
         new XAttribute("ChairmanName", info.ChairmanName == null ? "" : info.ChairmanName),
         new XAttribute("ChairmanTypeVIP", info.ChairmanTypeVIP),//ChairmanTypeVIP="0"
         new XAttribute("ChairmanVIPLevel", info.ChairmanVIPLevel),//ChairmanVIPLevel="1"
         new XAttribute("ConsortiaName", info.ConsortiaName == null ? "" : info.ConsortiaName),
         new XAttribute("CreatorID", info.CreatorID),
         new XAttribute("CreatorName", info.CreatorName == null ? "" : info.CreatorName),
         new XAttribute("Description", info.Description == null ? "" : info.Description),
         new XAttribute("Honor", info.Honor),
         new XAttribute("IP", info.IP),
         new XAttribute("Level", info.Level),
         new XAttribute("MaxCount", info.MaxCount),
         new XAttribute("Placard", info.Placard == null ? "" : info.Placard),
         new XAttribute("Repute", info.Repute),
         new XAttribute("Count", info.Count),
         new XAttribute("Riches", info.Riches),
         new XAttribute("FightPower", info.FightPower),//FightPower="981928"
         new XAttribute("DeductDate", info.DeductDate.ToString("yyyy-MM-dd HH:mm:ss")),
         new XAttribute("AddDayHonor", info.AddDayHonor),
         new XAttribute("AddDayRiches", info.AddDayRiches),
         new XAttribute("AddWeekHonor", info.AddWeekHonor),
         new XAttribute("AddWeekRiches", info.AddWeekRiches),
         new XAttribute("LastDayRiches", info.LastDayRiches),
         new XAttribute("OpenApply", info.OpenApply),
         new XAttribute("StoreLevel", info.StoreLevel),
         new XAttribute("SmithLevel", info.SmithLevel),
         new XAttribute("ShopLevel", info.ShopLevel),
         new XAttribute("BufferLevel", info.SkillLevel),//info.SkillLevel
         new XAttribute("ConsortiaGiftGp", 940),//ConsortiaGiftGp="940"
         new XAttribute("ConsortiaAddDayGiftGp", 0),//ConsortiaAddDayGiftGp="0"
         new XAttribute("ConsortiaAddWeekGiftGp", 8),//ConsortiaAddWeekGiftGp="8"
         new XAttribute("Port", info.Port),//);
         new XAttribute("IsVoting", false),//IsVoting="false"
         new XAttribute("VoteRemainDay", 3),//VoteRemainDay="3"
         new XAttribute("CharmGP", 940),//CharmGP="940"
         new XAttribute("BadgeID", 0),//BadgeID="0"
         new XAttribute("BadgeBuyTime", DateTime.Now.AddDays(-5).ToString("yyyy-MM-dd HH:mm:ss")),//BadgeBuyTime="2012-08-16 16:30:30"
         new XAttribute("ValidDate", 0));//ValidDate="0"
 }
Пример #10
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            var consortiaCmd = packet.ReadInt();

            bool result = false;
            string msg = "Packet Error!";
            ConsortiaLevelInfo levelInfo = null;
            GamePlayer[] players = WorldMgr.GetAllPlayers();

            switch (consortiaCmd)
            {
                case (int)ConsortiaPackageType.CONSORTIA_TRYIN:
                    HandleCONSORTIA_TRYIN(packet);
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_CREATE:
                    //Create Guild
                    {
                        if (client.Player.PlayerCharacter.ConsortiaID != 0)
                            return 0;
                        levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1);
                        string name = packet.ReadString();
                        //if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12)
                        //{
                        //    client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long"));
                        //    return 1;
                        //}
                        //result = false;
                        int id = 0;
                        int mustGold = levelInfo.NeedGold;
                        int mustLevel = 5;
                        msg = "ConsortiaCreateHandler.Failed";
                        ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo();

                        if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel)
                        {
                            using (ConsortiaBussiness db = new ConsortiaBussiness())
                            {
                                ConsortiaInfo info = new ConsortiaInfo();
                                info.BuildDate = DateTime.Now;
                                info.CelebCount = 0;
                                info.ChairmanID = client.Player.PlayerCharacter.ID;
                                info.ChairmanName = client.Player.PlayerCharacter.NickName;
                                info.ConsortiaName = name;
                                info.CreatorID = info.ChairmanID;
                                info.CreatorName = info.ChairmanName;
                                info.Description = "";
                                info.Honor = 0;
                                info.IP = "";
                                info.IsExist = true;
                                info.Level = levelInfo.Level;
                                info.MaxCount = levelInfo.Count;
                                info.Riches = levelInfo.Riches;
                                info.Placard = "";
                                info.Port = 0;
                                info.Repute = 0;
                                info.Count = 1;

                                if (db.AddConsortia(info, ref msg, ref dutyInfo))
                                {
                                    client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID;
                                    client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName;
                                    client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level;
                                    client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName;
                                    client.Player.PlayerCharacter.Right = dutyInfo.Right;
                                    client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level;
                                    client.Player.RemoveGold(mustGold);
                                    msg = "ConsortiaCreateHandler.Success";
                                    result = true;
                                    id = info.ConsortiaID;
                                    GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer, info.ConsortiaName);
                                }
                                else
                                {
                                    client.Player.SendMessage("db.AddConsortia Error ");
                                }
                            }

                        }
                        //Send package create Guild
                        client.Out.SendConsortiaCreate(name, result, id, name, LanguageMgr.GetTranslation(msg), dutyInfo.Level, dutyInfo.DutyName, dutyInfo.Right, client.Player.PlayerCharacter.ID);
                    }
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_DISBAND:
                    HandleCONSORTIA_DISBAND(packet);
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_RENEGADE:
                    HandleCONSORTIA_RENEGADE(packet);
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_TRYIN_PASS:
                    HandleCONSORTIA_TRYIN_PASS(packet);
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_TRYIN_DEL:
                    HandleCONSORTIA_TRYIN_DEL(packet);
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_RICHES_OFFER:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_APPLY_STATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_DUTY_DELETE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_DUTY_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_INVITE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_INVITE_PASS:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_INVITE_DELETE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_DESCRIPTION_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_PLACARD_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_BANCHAT_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_USER_REMARK_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_USER_GRADE_UPDATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_CHAIRMAN_CHAHGE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_CHAT:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_LEVEL_UP:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_TASK_RELEASE:
                    break;
                case (int)ConsortiaPackageType.DONATE:
                    break;
                case (int)ConsortiaPackageType.CONSORTIA_EQUIP_CONTROL:
                    break;
                case (int)ConsortiaPackageType.POLL_CANDIDATE:
                    break;
                case (int)ConsortiaPackageType.SKILL_SOCKET:
                    break;
                case (int)ConsortiaPackageType.CONSORTION_MAIL:
                    break;
                case (int)ConsortiaPackageType.BUY_BADGE:
                    break;
            }

            return 0;
        }
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            if (client.Player.PlayerCharacter.ConsortiaID != 0)
                return 0;

            ConsortiaLevelInfo levelInfo = ConsortiaLevelMgr.FindConsortiaLevelInfo(1);
            string name = packet.ReadString();
            if (string.IsNullOrEmpty(name) || System.Text.Encoding.Default.GetByteCount(name) > 12)
            {
                client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ConsortiaCreateHandler.Long"));
                return 1;
            }

            bool result = false;
            int id = 0;
            int mustGold = levelInfo.NeedGold;
            int mustLevel = 5;
            string msg = "ConsortiaCreateHandler.Failed";
            ConsortiaDutyInfo dutyInfo = new ConsortiaDutyInfo();

            if (!string.IsNullOrEmpty(name) && client.Player.PlayerCharacter.Gold >= mustGold && client.Player.PlayerCharacter.Grade >= mustLevel)
            {
                using (ConsortiaBussiness db = new ConsortiaBussiness())
                {
                    ConsortiaInfo info = new ConsortiaInfo();
                    info.BuildDate = DateTime.Now;
                    info.CelebCount = 0;
                    info.ChairmanID = client.Player.PlayerCharacter.ID;
                    info.ChairmanName = client.Player.PlayerCharacter.NickName;
                    info.ConsortiaName = name;
                    info.CreatorID = info.ChairmanID;
                    info.CreatorName = info.ChairmanName;
                    info.Description = "";
                    info.Honor = 0;
                    info.IP = "";
                    info.IsExist = true;
                    info.Level = levelInfo.Level;
                    info.MaxCount = levelInfo.Count;
                    info.Riches = levelInfo.Riches;
                    info.Placard = "";
                    info.Port = 0;
                    info.Repute = 0;
                    info.Count = 1;
                    if (db.AddConsortia(info, ref msg, ref dutyInfo))
                    {
                        client.Player.PlayerCharacter.ConsortiaID = info.ConsortiaID;
                        client.Player.PlayerCharacter.ConsortiaName = info.ConsortiaName;
                        client.Player.PlayerCharacter.DutyLevel = dutyInfo.Level;
                        client.Player.PlayerCharacter.DutyName = dutyInfo.DutyName;
                        client.Player.PlayerCharacter.Right = dutyInfo.Right;
                        client.Player.PlayerCharacter.ConsortiaLevel = levelInfo.Level;
                        client.Player.RemoveGold(mustGold);
                        msg = "ConsortiaCreateHandler.Success";
                        result = true;
                        id = info.ConsortiaID;
                        GameServer.Instance.LoginServer.SendConsortiaCreate(id, client.Player.PlayerCharacter.Offer,info.ConsortiaName);
                    }
                }

            }
            packet.WriteBoolean(result);
            packet.WriteInt(id);
            packet.WriteString(name);
            packet.WriteString(LanguageMgr.GetTranslation(msg));
            packet.WriteInt(dutyInfo.Level);
            packet.WriteString(dutyInfo.DutyName == null ? "" : dutyInfo.DutyName);
            packet.WriteInt(dutyInfo.Right);
            client.Out.SendTCP(packet);

            //client.Out.SendMessage(eMessageType.Normal, msg);

            return 0;
        }