/// <summary> /// 读取 /// </summary> /// <typeparam name="T">配置类型</typeparam> /// <param name="file">文件</param> /// <returns>配置列表</returns> public static List <T> Load <T>(string file = "") where T : class, global::ProtoBuf.IExtensible { Type type = typeof(T); string Path = ""; if (string.IsNullOrEmpty(file)) { string[] name; if (!TableManager.tableNameDictionary.TryGetValue(type, out name)) { Log.AddLog(string.Format("错误表格的类型:", type.FullName)); return(null); } Path = HttpRuntime.AppDomainAppPath + "protodatas/" + name[0]; } else { Path = HttpRuntime.AppDomainAppPath + file; } if (File.Exists(Path)) { using (FileStream stream = File.OpenRead(Path)) { byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); return(TableManager.Unserialize <T>(buffer)); } } else { Log.AddLog(string.Format("表格不存在:", type.FullName)); return(null); } }
/// <summary> /// 上传按钮点击响应 /// </summary> protected void uploadButton_Click(object sender, EventArgs e) { if (this.noticeFileUpload.HasFile) { NoticeEditData.NoticeList = TableManager.Unserialize <mw.SysNtfConfig>(this.noticeFileUpload.FileBytes); NoticeEditData.DoLoad(); this.noticeListBox.Items.Clear(); foreach (var config in NoticeEditData.NoticeList) { if (config.id < NoticeEditData.CommonIdStart) { this.noticeListBox.Items.Add(new ListItem(this.GetNoticeText(config), config.title_id.ToString())); } } this.errorLabel.Text = TableManager.GMTDescTable[655].desc; TableManager.Save(NoticeEditData.NoticeList); } else { this.errorLabel.Text = TableManager.GMTDescTable[656].desc; } }