private static STActivityInfo ConvertToSTActivity(mw.ActivityConfig config) { STActivityInfo act = new STActivityInfo(); act.id = config.id; List <mw.AchieveConfig> listAchieve = GMTActivityMananger.GetAchieveConfigsByActivityId(act.id); if (listAchieve.Count == 0) { return(null); } int titleTextId = listAchieve[0].name; act.title = TextManager.GetText(titleTextId); int descTextId = listAchieve[0].txt; act.desc = TextManager.GetText(descTextId); act.firstmark = (config.NeedFlag == 1); act.order = config.sortvalue; act.quests = new List <STQuestInfo>(); foreach (var AchieveConfig in listAchieve) { STQuestInfo quest = ConvertToSTQuest(AchieveConfig); act.quests.Add(quest); } return(act); }
/// <summary> /// 应用程序启动 /// </summary> protected void Application_Start(object sender, EventArgs e) { System.Net.ServicePointManager.DefaultConnectionLimit = 100; Init(); UserManager.Init(); gmt.Server.Load(); gmt.Server.newLoad(); Log.Start(); Network.Start(); FTPManager.Load(); TableManager.Start(); TextManager.Load(); RevolvingManager.Start(); NoticeManager.Load(); ActivityManger.Start(); ServerListConfig.Load(); GMTActivityMananger.start(); GiftTable.Start(); TimedMailSender.Init(); RevolvingManager.UpdateService(); PayType.LoadPayType(); }
private static bool MakeRewardConfigWithRewardInfos(List <STRewardInfo> listRewards, out mw.RewardConfig configReward) { configReward = GMTActivityMananger.GetNewConfigReward(); if (null == configReward) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_ID_MAX); return(false); } // 最大4个 不然客户端排版会出问题 for (int i = 0; i < listRewards.Count; i++) { if (listRewards[i].count > 9999) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_ITEM_COUNT); return(false); } if (i == 0) { configReward.reward_idx_1 = (mw.Enums.RewardType)listRewards[0].type; configReward.reward_type_1 = listRewards[0].item; configReward.reward_count_1 = listRewards[0].count; configReward.max_rand_1 = 10000; configReward.min_rand_1 = 1; } else if (i == 1) { configReward.reward_idx_2 = (mw.Enums.RewardType)listRewards[1].type; configReward.reward_type_2 = listRewards[1].item; configReward.reward_count_2 = listRewards[1].count; configReward.max_rand_2 = 10000; configReward.min_rand_2 = 1; } else if (i == 2) { configReward.reward_idx_3 = (mw.Enums.RewardType)listRewards[2].type; configReward.reward_type_3 = listRewards[2].item; configReward.reward_count_3 = listRewards[2].count; configReward.max_rand_3 = 10000; configReward.min_rand_3 = 1; } else if (i == 3) { configReward.reward_idx_4 = (mw.Enums.RewardType)listRewards[3].type; configReward.reward_type_4 = listRewards[3].item; configReward.reward_count_4 = listRewards[3].count; configReward.max_rand_4 = 10000; configReward.min_rand_4 = 1; } } return(true); }
public static bool LoadAcitvity4Client() { m_listActivity4Client.Clear(); Dictionary <int, mw.ActivityConfig> dic = GMTActivityMananger.GetTableActivity(); foreach (var config in dic.Values) { STActivityInfo act = ConvertToSTActivity(config); if (null != act) { m_listActivity4Client.Add(act); } } return(true); }
public static string RemoveActivity(List <int> ids) { List <int> removedIds = new List <int>(); foreach (var id in ids) { if (GMTActivityMananger.RemoveActivityNode(id)) { removedIds.Add(id); } } GMTActivityMananger.SaveTable(); m_listActivity4Client.RemoveAll(o => removedIds.Contains(o.id)); string res = JsonConvert.SerializeObject(removedIds); return(res); }
protected override void OnGmPageLoad() { if (Request.Files.Count != 0) { string strMsg = ""; EErrType errcode = EErrType.ERR_SUCCESS; for (int i = 0; i < Request.Files.Count; ++i) { bool suc = true; HttpPostedFile file = Request.Files[i]; string savePath = Global.ProtoDataPath + file.FileName; try { file.SaveAs(savePath); } catch (Exception e) { Log.AddLog(e.ToString()); suc = false; } if (suc) { strMsg += file.FileName + "\\n"; } } if (strMsg == "") { errcode = EErrType.ERR_TABLE_DATA_SAVE_FAILED; } if (errcode == EErrType.ERR_SUCCESS) { TextManager.Load(); GMTActivityMananger.start(); } Response.Write("{\"error\":" + (int)errcode + ",\"msg\":\"" + strMsg + "\"}"); Response.End(); } }
private static STQuestInfo ConvertToSTQuest(mw.AchieveConfig config) { STQuestInfo quest = new STQuestInfo(); quest.type = (int)config.type; quest.typename = GetQuestTypeName(quest.type); quest.desc = TextManager.GetText(config.desc); quest.overlap = (config.taskFlag == 1); quest.request = config.opt_type_1; quest.requestname = GetRequestName(quest.request); quest.count_a = config.opt_val_1_a; quest.count_b = config.opt_val_1_b; quest.count_c = config.opt_val_1_c; mw.RewardConfig configReward = GMTActivityMananger.GetRewardConfigsById(config.reward); if (null != configReward) { ConvertToSTReward(configReward, out quest.rewards); } return(quest); }
/// <summary> /// 打包表格 /// </summary> /// <param name="version">版本</param> /// <returns>Zip包缓冲区</returns> public static byte[] PackTable(string version) { using (MemoryStream memory = new MemoryStream()) { using (ZipOutputStream stream = new ZipOutputStream(memory)) { byte[] buffer = null; // 服务器列表 if (!string.IsNullOrEmpty(version) && version[version.Length - 1] != '/') { version = version + '/'; } foreach (var data in ServerListConfig.DataList) { string md5Path = version + "updateex/" + data.Name + "/"; string tablePath = md5Path + TableManager.Directory; TableManager.ClearMD5Record(); // 活动 List <mw.ActivityConfig> Updateactivitytable = GMTActivityMananger.GetTableActivity().Values.ToList(); if (null != Updateactivitytable) { buffer = TableManager.Serialize(Updateactivitytable); TableManager.UpdateMD5(buffer, TableManager.Directory + "ActivityExConfig.protodata.bytes"); stream.PutNextEntry(new ZipEntry(tablePath + "ActivityExConfig.protodata.bytes")); stream.Write(buffer, 0, buffer.Length); } List <mw.AchieveConfig> Updateachievetable = GMTActivityMananger.GetTableAchieve().Values.ToList(); if (null != Updateachievetable) { buffer = TableManager.Serialize(Updateachievetable); TableManager.UpdateMD5(buffer, TableManager.Directory + "AchieveExConfig.protodata.bytes"); stream.PutNextEntry(new ZipEntry(tablePath + "AchieveExConfig.protodata.bytes")); stream.Write(buffer, 0, buffer.Length); } List <mw.RewardConfig> Updaterewardtable = GMTActivityMananger.GetTableReward().Values.ToList(); if (null != Updaterewardtable) { buffer = TableManager.Serialize(Updaterewardtable); TableManager.UpdateMD5(buffer, TableManager.Directory + "RewardExConfig.protodata.bytes"); stream.PutNextEntry(new ZipEntry(tablePath + "RewardExConfig.protodata.bytes")); stream.Write(buffer, 0, buffer.Length); } // 文本 buffer = TableManager.Serialize(TextManager.GetConfigList()); TableManager.UpdateMD5(buffer, TableManager.Directory + "UIDescExConfig.protodata.bytes"); stream.PutNextEntry(new ZipEntry(tablePath + "UIDescExConfig.protodata.bytes")); stream.Write(buffer, 0, buffer.Length); buffer = Encoding.UTF8.GetBytes(TableManager.GetMD5Text()); stream.PutNextEntry(new ZipEntry(md5Path + "md5.txt")); stream.Write(buffer, 0, buffer.Length); } stream.CloseEntry(); stream.Finish(); byte[] zipBuffer = new byte[memory.Length]; Array.Copy(memory.GetBuffer(), zipBuffer, zipBuffer.Length); return(zipBuffer); } } }
/// <summary> /// 发送表格 /// </summary> /// <param name="version">版本号</param> /// <returns>是否成功</returns> public static bool SendTable(string version) { byte[] buffer = null; errorText = ""; foreach (var data in ServerListConfig.DataList) { string md5Path = version + "/updateex/" + data.Name + "/"; string tablePath = md5Path + TableManager.Directory; FTPManager.MakeDirectory(version + "/"); FTPManager.MakeDirectory(version + "/updateex/"); FTPManager.MakeDirectory(version + "/updateex/" + data.Name); FTPManager.MakeDirectory(tablePath); TableManager.ClearMD5Record(); // 活动 List <mw.ActivityConfig> Updateactivitytable = GMTActivityMananger.GetTableActivity().Values.ToList(); buffer = TableManager.Serialize(Updateactivitytable); TableManager.UpdateMD5(buffer, TableManager.Directory + tableNameDictionary[typeof(mw.ActivityConfig)][0]); if (!FTPManager.Upload(tablePath + tableNameDictionary[typeof(mw.ActivityConfig)][0], buffer)) { errorText += FTPManager.GetLastError(); } List <mw.AchieveConfig> Updateachievetable = GMTActivityMananger.GetTableAchieve().Values.ToList(); buffer = TableManager.Serialize(Updateachievetable); TableManager.UpdateMD5(buffer, TableManager.Directory + tableNameDictionary[typeof(mw.AchieveConfig)][0]); if (!FTPManager.Upload(tablePath + tableNameDictionary[typeof(mw.AchieveConfig)][0], buffer)) { errorText += FTPManager.GetLastError(); } List <mw.RewardConfig> Updaterewardtable = GMTActivityMananger.GetTableReward().Values.ToList(); buffer = TableManager.Serialize(Updaterewardtable); TableManager.UpdateMD5(buffer, TableManager.Directory + tableNameDictionary[typeof(mw.RewardConfig)][0]); if (!FTPManager.Upload(tablePath + tableNameDictionary[typeof(mw.RewardConfig)][0], buffer)) { errorText += FTPManager.GetLastError(); } //编辑礼包 List <mw.GiftConfig> UpdatereGiftTable = new List <mw.GiftConfig>(); UpdatereGiftTable = GiftManager.addgiftconfig; buffer = TableManager.Serialize(UpdatereGiftTable); TableManager.UpdateMD5(buffer, TableManager.Directory + tableNameDictionary[typeof(mw.GiftConfig)][0]); if (!FTPManager.Upload(tablePath + tableNameDictionary[typeof(mw.GiftConfig)][0], buffer)) { errorText += FTPManager.GetLastError(); } // 文本 buffer = TableManager.Serialize(TextManager.GetConfigList()); TableManager.UpdateMD5(buffer, TableManager.Directory + tableNameDictionary[typeof(mw.UIDescConfig)][0]); if (!FTPManager.Upload(tablePath + tableNameDictionary[typeof(mw.UIDescConfig)][0], buffer)) { errorText += FTPManager.GetLastError(); } buffer = Encoding.UTF8.GetBytes(TableManager.GetMD5Text()); if (!FTPManager.Upload(md5Path + "md5.txt", buffer)) { errorText += FTPManager.GetLastError(); } } if (string.IsNullOrEmpty(errorText)) { return(true); } return(false); }
private static bool DoAddQuest(int activiytId, List <STQuestInfo> quests, ref List <mw.AchieveConfig> listAchieve, ref List <mw.RewardConfig> listReward) { for (int i = 0; i < quests.Count; ++i) { mw.Enums.TaskType taskType = (mw.Enums.TaskType)quests[i].type; mw.AchieveConfig configAchieve = GMTActivityMananger.GetNewConfigAchieve(taskType); if (null == configAchieve) { return(false); } configAchieve.activity = activiytId; configAchieve.taskFlag = (quests[i].overlap) ? 1 : 0; configAchieve.opt_type_1 = quests[i].type; configAchieve.opt_val_1_a = quests[i].count_a; configAchieve.opt_val_1_b = quests[i].count_b; configAchieve.opt_val_1_c = quests[i].count_c; if (quests[i].count_a < 1 || quests[i].count_a > 9999 || quests[i].count_b < 0 || quests[i].count_b > 9999 || quests[i].count_c < 0 || quests[i].count_c > 9999 ) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ACHIEVE_REQUEST_COUNT); return(false); } if (quests[i].rewards.Count == 0 || quests[i].rewards.Count > 4) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_REWARD_COUNT); return(false); } mw.RewardConfig configReward = null; bool ret = MakeRewardConfigWithRewardInfos(quests[i].rewards, out configReward); if (null != configReward) { listReward.Add(configReward); } if (!ret) { return(false); } configAchieve.reward = configReward.id; int taskDescTextId = 0; if (!string.IsNullOrEmpty(quests[i].desc)) { taskDescTextId = TextManager.CreateText(); TextManager.SetText(taskDescTextId, quests[i].desc); } // 这里贼乱, name 是活动标题, txt是活动内容, desc 是活动任务描述 configAchieve.desc = taskDescTextId; listAchieve.Add(configAchieve); } return(true); }
public static string AddNewActivity(string title, string desc, bool firstmark, int order, List <STQuestInfo> quests) { mw.ActivityConfig configActivity = null; if (quests.Count == 0) { CErrMgr.SetLastErrMsg(EErrType.ERR_ACTIVITY_ACHIEVE_ZERO); goto err; } configActivity = GMTActivityMananger.GetNewConfigActivity(); if (null == configActivity) { goto err; } configActivity.NeedFlag = (firstmark)?1:0; configActivity.sortvalue = order; List <mw.AchieveConfig> listAchieve = new List <mw.AchieveConfig>(); List <mw.RewardConfig> listReward = new List <mw.RewardConfig>(); if (!DoAddQuest(configActivity.id, quests, ref listAchieve, ref listReward)) { goto err; } int titleTextId = 0; if (!string.IsNullOrEmpty(title)) { titleTextId = TextManager.CreateText(); TextManager.SetText(titleTextId, title); } int descTextId = 0; if (!string.IsNullOrEmpty(desc)) { descTextId = TextManager.CreateText(); TextManager.SetText(descTextId, desc); } foreach (var ach in listAchieve) { ach.name = titleTextId; ach.txt = descTextId; } // 创建条件满足 STActivityInfo stActivity = ConvertToSTActivity(configActivity); m_listActivity4Client.Add(stActivity); GMTActivityMananger.SaveTable(); string res = JsonConvert.SerializeObject(stActivity); return("{\"error\":0, \"data\":" + res + "}"); // 创建条件不满足, 上方textid 创建还没销毁, 后面补充 err: // 销毁 (还没写) if (null != configActivity) { GMTActivityMananger.RemoveActivityNode(configActivity.id); } return(CErrMgr.GetLastErrMsg()); }