Beispiel #1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="item"></param>
        public void Save(object item, string file)
        {
            string json = I3JsonConvert.ToJson(item);

            using (FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write))
            {
                byte[] data = Encoding.UTF8.GetBytes(json);
                fs.Write(data, 0, data.Length);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 转换为图片单元格,复制所有属性(目的是为了在ReportData经过json转换后,找回Cell中丢失的单元格类型信息,要求I3ReportImageCell代码中的属性,全部写在I3ReportCell中)
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns></returns>
        public I3ReportImageCell ConvertToImageItem(int row, int col)
        {
            I3ReportCell old = GetCellItem(row, col);

            if (old != null && old is I3ReportImageCell)
            {
                return(old as I3ReportImageCell);
            }

            I3ReportImageCell item = null;

            if (old == null)
            {
                item = new I3ReportImageCell(row, col);
            }
            else
            {
                string json = I3JsonConvert.ToJson(old);
                item = (I3ReportImageCell)I3JsonConvert.FromJson(json, typeof(I3ReportImageCell));
            }
            this[row][col] = item;

            return(item);
        }
Beispiel #3
0
        /// <summary>
        /// 处理请求
        /// </summary>
        /// <param name="context">Http上下文</param>
        virtual public void ProcessRequest(HttpContext context)
        {
            this.context = context;

            HttpResponse response = context.Response;

            response.Clear();
            response.ContentType = "application/json";
            //response.ContentType = "text/plain";
            response.ContentEncoding        = Encoding.UTF8;
            context.Request.ContentEncoding = Encoding.UTF8;

            bool   packageResult = GetPackageResultParam(context.Request);
            string json          = null;

            try
            {
                BeforeProcessRequest();
                if (packageResult)
                {
                    ServiceResult result = new ServiceResult();
                    //调用方法
                    result.data  = ProcessMethod(context.Request);
                    result.state = (int)ServiceResultState.Success;
                    json         = I3JsonConvert.ToJson(result);
                }
                else
                {
                    json = I3JsonConvert.ToJson(ProcessMethod(context.Request));
                }
                AfterProcessRequest();
            }
            catch (JsonServiceException ex)
            {
                //I3LocalLogUtil.Current.LogDir = "locallog";
                I3LocalLogUtil.Current.WriteExceptionLog("", ex);
                I3LocalLogUtil.Current.CompleteLog();
                ServiceResult result = new ServiceResult();
                result.state = (int)ServiceResultState.ServiceException;
#if DebugMode
                result.Message = ex.ToString();
#else
                result.message = ex.Message;
#endif
                json = I3JsonConvert.ToJson(result);
            }
            catch (Exception ex)
            {
                //I3LocalLogUtil.Current.LogDir = "locallog";
                I3LocalLogUtil.Current.WriteExceptionLog("", ex);
                I3LocalLogUtil.Current.CompleteLog();
                ServiceResult result = new ServiceResult();
                result.state = (int)ServiceResultState.LogicException;
#if DebugMode
                result.Message = ex.ToString();
#else
                result.message = ex.Message;
#endif
                json = I3JsonConvert.ToJson(result);
            }
            response.Write(json);
            response.Flush();
            //response.Close();  //加这句chorme浏览器报错
        }