注册 登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

一车,一房,一个温暖家

10万左右的车,80平方的房子,这是我奋斗的暖暖的家

 
 
 

日志

 
 

【转载】拼接JSON字符串  

2015-05-30 13:03:10|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
本文转载自顽强的小草《拼接JSON字符串》
void brief_of_geteventcountCompleted(object sender, of_geteventcountCompletedEventArgs e)
        {
 
                StringBuilder sb = new StringBuilder();
                string conInfo = e.UserState + "";
                if (!string.IsNullOrWhiteSpace(conInfo))
                {
                    //string[] cons = conInfo.Split('﹋');
                    // if (cons != null && cons.Length == 2)
                    {
                        try
                        {
                            if (e.Result != null && e.Result >= 0)
                            {
                                byte[] blobdata = e.blobdata;
                                string echotext = e.echotext;
                                UnCompress(ref blobdata, ref echotext);
                                if (blobdata != null)
                                {
                                    DataStore dsDb = new DataStore();
                                    dsDb.SetFullState(DataWindowFullState.FromByteArray(blobdata));
                                    blobdata = null;
                                    decimal ecount = 0;
         
                                    dsDb.SetFilter("servtype='" + filterTy + "'"); //按业务类型过滤
                                    dsDb.Filter();
                                    if (dsDb.RowCount > 0)
                                    {                                        
                                        if (sb.Length > 0)
                                        {
                                            sb.Append(",");
                                        }
                                        sb.Append("{st:\"" + filterTy + "\",sts:[");
                                        ecount = 0;
                                        bool isDel = false, isHas = false, isAHas = false,isFilter = false;
                                        string property = "", servicetype = "";
                                        for (int i = 1; i <= dsDb.RowCount; i++)
                                        {
                                            isDel = false;
                                            isHas = false;
                                            isFilter = false;
                                            if (!dsDb.IsItemNull(i, "property") && !dsDb.IsItemNull(i, "servicetype"))
                                            {
                                                property = dsDb.GetItemString(i, "property");
                                                servicetype = dsDb.GetItemString(i, "servicetype");
                                                if (!string.IsNullOrWhiteSpace(property) && !string.IsNullOrWhiteSpace(servicetype))
                                                {
                                                    if (isAHas)
                                                    {
                                                        sb.Append(",");
                                                    }
                                                    sb.Append("{pro:\"" + property + "\",proname:\"" + servicetype + "\",sts:[");

                                                    isAHas = true;                                                   
                                                    foreach (string ste in states.Keys)
                                                    {
                                                        dsDb.SetFilter("servtype='" + filterTy + "' and property='" + property + "' and state='" + ste + "'"); //按业务类型过滤
                                                        dsDb.Filter();
                                                        isFilter = true;
                                                        ecount = 0;
                                                        for (int j = 1; j <= dsDb.RowCount; j++)
                                                        {
                                                            if (!dsDb.IsItemNull(j, "ecount"))
                                                            {
                                                                ecount += dsDb.GetItemDecimal(j, "ecount");
                                                                //aecount += dsDb.GetItemDecimal(j, "ecount");
                                                
                                                            }
                                                            dsDb.DeleteRow(j);
                                                            j = 0;
                                                            isDel = true;
                                                        }
                                                        if (isHas)
                                                        {
                                                            sb.Append(",");
                                                        }
                                                        isHas = true;
                                                        sb.Append("{st:\"" + ste + "\",c:" + ecount + "}");
                                                        isHas = true;

                                                    }
                                                    sb.Append("]}");
                                                }                                               
                                            }
                                            if (!isDel)
                                            {
                                                dsDb.DeleteRow(i);
                                                i = 0;
                                            }                                           
                                            if (isFilter)
                                            {                                               
                                                dsDb.SetFilter("servtype='" + filterTy + "'"); //按业务类型过滤
                                                dsDb.Filter();
                                                i = 0;
                                            }
                                        }
                                        sb.Append("]}");
                                    }
                                    dsDb.Reset();
                                    dsDb = null;
                                    if (sb.Length > 0)
                                    {
                                        sb.Insert(0, "{idbuild:\"" + conInfo + "\",data:[");
                                        sb.Append("],s:\"ok\"}");
                                    }
                                }
                            }
                        }
                        catch (Exception)
                        {
                            sb.Append("{idbuild:\"" + conInfo + "\",s:\"error\"}");
                        }
                        if (sb.Length <= 0)
                        {
                            sb.Append("{idbuild:\"" + conInfo + "\",s:\"nodata\"}");
                        }

                    }
                    //cons = null;
                }
                HttpContext.Current.Response.Write("<script type='text/javascript'>SetHtml(" + sb.ToString() + ");</script>");
                sb.Clear();
                sb = null;

                if (runWs == finishWs)
                {
                    SetProcTimeInfo();
                }
                else
                {
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.Clear();

            }
        }
  评论这张
 
阅读(0)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018