当前位置: 首页>>代码示例>>C#>>正文


C# MessageStructure.RecordEnd方法代码示例

本文整理汇总了C#中ZyGames.Framework.RPC.IO.MessageStructure.RecordEnd方法的典型用法代码示例。如果您正苦于以下问题:C# MessageStructure.RecordEnd方法的具体用法?C# MessageStructure.RecordEnd怎么用?C# MessageStructure.RecordEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZyGames.Framework.RPC.IO.MessageStructure的用法示例。


在下文中一共展示了MessageStructure.RecordEnd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SuccessCallback

 protected override void SuccessCallback(MessageStructure writer, MessageHead head)
 {
     int type = writer.ReadInt();
     if (type == 1)
     {
         int recordCount = writer.ReadInt();
         JsonObject jsonContainer = new JsonObject();
         List<JsonObject> jsonList = new List<JsonObject>();
         for (int i = 0; i < recordCount; i++)
         {
             writer.RecordStart();
             var item = new JsonObject();
             item.Add("NoticeID", writer.ReadString());
             item.Add("Title",  writer.ReadString());
             item.Add("Content", writer.ReadString());
             item.Add("IsBroadcast", writer.ReadInt());
             item.Add("IsTop", writer.ReadInt());
             item.Add("Creater", writer.ReadString());
             item.Add("CreateDate", writer.ReadString());
             item.Add("ExpiryDate", writer.ReadString());
             jsonList.Add(item);
             writer.RecordEnd();
         }
         jsonContainer.Add("total", recordCount);
         jsonContainer.Add("rows", jsonList.ToArray());
         WriteTableJson(jsonContainer);
     }
 }
开发者ID:0jpq0,项目名称:Scut,代码行数:28,代码来源:NoticeRemote.cs

示例2: ProcessLoopRocord


//.........这里部分代码省略.........
            if (recordCount == 0)
            {
                builderContent.Append("<tr><td align=\"center\">空数据</td></tr>");
            }

            for (int i = 0; i < recordCount; i++)
            {
                try
                {
                    reader.RecordStart();
                    MessageStructure msgReader = reader;
                    int loopDepth = 0; //循环深度
                    List<ParamInfoModel> recordQueue = new List<ParamInfoModel>();

                    headContent.Append("<tr><!--头开始tr-->");
                    builderContent.Append("<tr><!--内容开始tr-->");
                    int columnNum = 0;

                    #region

                    for (int r = 1; r < queue.Count - 1; r++)
                    {
                        var record = queue[r];
                        string fieldName = record.Field;
                        FieldType fieldType = record.FieldType;
                        string fieldValue = "";
                        try
                        {
                            if (loopDepth > 0 && fieldType == FieldType.End)
                            {
                                loopDepth--;
                                recordQueue.Add(record);
                            }
                            if (loopDepth == 0 && recordQueue.Count > 0)
                            {
                                builderContent.Append("</tr><tr>");
                                builderContent.AppendFormat("<td colspan=\"{0}\" align=\"right\">", columnNum);
                                builderContent.Append(
                                    "<!--子表开始--><table style=\"width:95%; border-color:#999\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\">");
                                //处理循环记录
                                ProcessLoopRocord(builderContent, recordQueue, msgReader);

                                builderContent.Append("</table><!--子表结束-->");
                                builderContent.Append("</td>");
                                recordQueue.Clear();
                            }

                            if (loopDepth == 0)
                            {
                                if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
                                {
                                    if (i == 0)
                                        headContent.AppendFormat("<td align=\"center\"><strong>{0}</strong>({1})</td>",
                                                                 fieldName, fieldType);
                                    builderContent.AppendFormat("<td align=\"center\">&nbsp;{0}</td>", fieldValue);
                                    columnNum++;
                                }
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                    recordQueue.Add(record);
                                }
                            }
                            else if (fieldType != FieldType.End)
                            {
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                }
                                recordQueue.Add(record);
                            }
                        }
                        catch (Exception ex)
                        {
                            builderContent.AppendFormat("<td align=\"center\">{0}列出错{1}</td>", fieldName, ex.Message);
                        }

                    }

                    #endregion

                    headContent.Append("</tr><!--头结束tr-->");
                    builderContent.Append("</tr><!--内容结束tr-->");
                    //读取行结束
                    reader.RecordEnd();
                }
                catch (Exception ex)
                {
                    builderContent.AppendFormat("<tr><td align=\"left\">{0}行出错{1}</td></tr>", (i + 1), ex.Message);
                }
            }

            respContent.Append(headContent.ToString());
            respContent.Append(builderContent.ToString());
            respContent.Append("</table><!--子表结束-->");
            respContent.Append("</td></tr>");
            respContent.Append("<tr>");
            respContent.Append("<td colspan=\"3\" align=\"left\">End</td>");
            respContent.Append("</tr>");
        }
开发者ID:0jpq0,项目名称:Scut,代码行数:101,代码来源:UnitTest.aspx.cs

示例3: ParseRecordEnd

        private static void ParseRecordEnd(StringBuilder itemBuilder, MessageStructure msgReader, List<ParamInfoModel> queue, int depth, int recordNum, string[] keyNames)
        {
            string keyValue = string.Empty;
            string keyName = keyNames.Length > depth ? keyNames[depth] : string.Empty;
            List<LuaConfig> builderList = new List<LuaConfig>();
            int recordCount = 0;
            try
            {
                recordCount = msgReader.ReadInt();
            }
            catch { }
            for (int i = 0; i < recordCount; i++)
            {
                try
                {
                    msgReader.RecordStart();
                    int loopDepth = 0; //循环深度
                    StringBuilder recordBuilder = new StringBuilder();
                    List<ParamInfoModel> recordQueue = new List<ParamInfoModel>();

                    int columnNum = 0;
                    int childNum = 0;

                    #region 遍历列取数据
                    for (int r = 1; r < queue.Count - 1; r++)
                    {
                        var record = queue[r];
                        string fieldName = record.Field;
                        FieldType fieldType = record.FieldType;
                        string fieldValue = "";
                        try
                        {
                            if (loopDepth > 0 && fieldType == FieldType.End)
                            {
                                loopDepth--;
                                recordQueue.Add(record);
                            }
                            if (loopDepth == 0 && recordQueue.Count > 0)
                            {
                                //处理循环记录
                                childNum++;
                                var childBuilder = new StringBuilder();
                                ParseRecordEnd(childBuilder, msgReader, recordQueue, depth + 1, childNum, keyNames);
                                //
                                recordQueue.Clear();
                                //选择输出格式
                                FormatChildToLua(recordBuilder, childBuilder, columnNum);
                            }

                            if (loopDepth == 0)
                            {
                                if (NetHelper.GetFieldValue(msgReader, fieldType, ref fieldValue))
                                {
                                    if (columnNum > 0)
                                    {
                                        recordBuilder.Append(",");
                                    }
                                    if (fieldName.Trim().ToLower() == keyName.Trim().ToLower())
                                    {
                                        keyValue = fieldValue;
                                    }
                                    if (fieldType == FieldType.Byte || fieldType == FieldType.Short || fieldType == FieldType.Int)
                                    {
                                        recordBuilder.AppendFormat("{0}={1}", fieldName, fieldValue);
                                    }
                                    else
                                    {
                                        recordBuilder.AppendFormat("{0}=\"{1}\"", fieldName, fieldValue);
                                    }
                                    columnNum++;
                                }
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                    recordQueue.Add(record);
                                }
                            }
                            else if (fieldType != FieldType.End)
                            {
                                if (fieldType == FieldType.Record)
                                {
                                    loopDepth++;
                                }
                                recordQueue.Add(record);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(string.Format("recordindex:{0},fieldName:{1} error:", i, fieldName), ex);
                        }
                    }

                    #endregion
                    //读取行结束
                    msgReader.RecordEnd();
                    builderList.Add(new LuaConfig { Key = keyValue, Builder = recordBuilder });
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("recordindex:{0}error:", i), ex);
//.........这里部分代码省略.........
开发者ID:87170360,项目名称:Maximus,代码行数:101,代码来源:ClientConfigInfo.aspx.cs


注:本文中的ZyGames.Framework.RPC.IO.MessageStructure.RecordEnd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。