Converts a DateTime to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).
Inheritance: DateTimeConverterBase
 public ActionResult GetHistory(TableHistory th)
 {
     List<TableHistoryCustom> list = new List<TableHistoryCustom>();
     IsoDateTimeConverter iso = new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
     try
     {
         int total = 0;
         var Start = int.Parse(Request.Form["start"] ?? "0");
         if (Request["limit"] != null)
         {
             var Limit = Convert.ToInt32(Request["limit"]);
         }
         _tableHistoryMgr = new TableHistoryMgr(connectionString);
         list =  _tableHistoryMgr.GetHistoryByCondition(th, out total);
         return Content("{succes:true,totalCount:" + total + ",item:" + JsonConvert.SerializeObject(list, Formatting.None, iso) + "}");
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         return new EmptyResult();
     }
 }
示例#2
0
        /// <summary>
        /// 对象转换为Json字符串
        /// </summary>
        /// <param name="jsonObject">对象</param>
        /// <returns>Json字符串</returns>
        public static String ToJson(Object jsonObject)
        {
            var sw         = new StringWriter();
            var isoConvert = new Newtonsoft.Json.Converters.IsoDateTimeConverter();

            isoConvert.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            //if (FormatDate)
            var jsonConverter = new JsonConverter[] { isoConvert };


            var serializer = JsonSerializer.Create(
                new JsonSerializerSettings
            {
                Converters            = jsonConverter,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                NullValueHandling     = NullValueHandling.Ignore
            }
                );

            using (JsonWriter jsonWriter = new JsonTextWriter(sw))
            {
                //if (FormatJson != false)
                jsonWriter.Formatting = Formatting.Indented;
                serializer.Serialize(jsonWriter, jsonObject);
            }
            return(sw.ToString());
        }
示例#3
0
    public override string QueryResult()
    {
        JsonModel jsonModel = new JsonModel();

        try
        {
            ParamModel paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);
            TF.RunSafty.BLL.Tab_Plan_Rest          bllPlace  = new TF.RunSafty.BLL.Tab_Plan_Rest();
            List <TF.RunSafty.Model.TAB_Plan_Rest> placeList = bllPlace.GetPlanTrain(paramModel.data.dtStartTime, paramModel.data.dtEndTime, paramModel.data.strJiaoluGUID);
            jsonModel.result    = 0;
            jsonModel.resultStr = "提交成功";
            planArrays p = new planArrays();
            jsonModel.data       = p;
            p.strTrainJiaoLuGUID = paramModel.data.strJiaoluGUID;
            p.strCurPlanGUID     = "";
            p.planArray          = bllPlace.GetPlaceList(placeList);
        }
        catch (Exception ex)
        {
            TF.CommonUtility.LogClass.logex(ex, "");
            jsonModel.result    = 1;
            jsonModel.resultStr = "提交失败" + ex.Message;
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
    }
        public HttpResponseBase GetCertificateCategory()
        {
            string json = string.Empty;
            int totalCount = 0;
            List<CertificateCategoryQuery> stores = new List<CertificateCategoryQuery>();
            CertificateCategoryQuery query = new CertificateCategoryQuery();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["searchcontent"]))
                {
                    query.searchcon = Request.Params["searchcontent"].ToString().Trim();
                }
                _inspectionReport = new InspectionReportMgr(mySqlConnectionString);
                stores = _inspectionReport.GetCertificateCategoryList(query, out totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Newtonsoft.Json.Formatting.Indented, timeConverter) + "}";//返回json數據

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#5
0
    //编辑谈判记录的时候进来
    protected void GetTPJLData()
    {
        string RecID = "";
        string ResID = "";

        if (Request["RecID"] != null)
        {
            RecID = Request["RecID"];
        }
        if (Request["ResID"] != null)
        {
            ResID = Request["ResID"];
        }
        WebServices.Services Resource = new WebServices.Services();
        DataTable            ppDt     = Resource.GetDataListByResourceID(ResID, false, " and id=" + RecID).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        String str = Newtonsoft.Json.JsonConvert.SerializeObject(ppDt, timeConverter);

        if (ppDt.Rows.Count > 0)
        {
            DataTable sunDt = Resource.GetDataListByResourceID("383153238947", false, " and 谈判系统编号='" + ppDt.Rows[0]["谈判系统编号"] + "'").Tables[0];
            str = str.Substring(0, str.Length - 1);
            String str1 = Newtonsoft.Json.JsonConvert.SerializeObject(sunDt, timeConverter);
            str = str + "," + str1.Substring(1, str1.Length - 1);
        }
        Response.Write(str);
    }
示例#6
0
 public string ToJson()
 {
     IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
     //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
     timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     return JsonConvert.SerializeObject(this, Formatting.Indented, timeConverter); ;
 }
        public JsonResult GetNewChats(string lastUpdate)
        {
            DateTime? dateLastUpdate = null;
            if (!string.IsNullOrEmpty(lastUpdate))
            {
                var format = "dd/MM/yyyy"; // your datetime format
                var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = format };
                dateLastUpdate = JsonConvert.DeserializeObject<DateTime>(lastUpdate, dateTimeConverter).AddHours(-3);
            }

            var loggedUser = Session.GetLoggedUser();
            var chatBll = new Domain.BLL.ChatBLL();
            var newMessages = chatBll.GetNewMessages(loggedUser.ID, dateLastUpdate).Select(pm => new
            {
                friendId = pm.PessoaRemetenteId,
                message = pm.Mensagem,
                imageUrl = pm.Pessoas1.Imagens.Url,
                fullName = pm.Pessoas1.Nome + " " + pm.Pessoas1.Sobrenome,
                sendDate = pm.DataEnvio.ToString("dd/mm/yyyy HH:mm:ss")
            }).ToList();
            return Json(new
            {
                lastUpdate = DateTime.Now,
                newMessages = newMessages,
                countNewMessages = chatBll.GetNewMessagesCount(loggedUser.ID)
            }, JsonRequestBehavior.DenyGet);
        }
 public HttpResponseBase GetVendorProductSpec()
 {
     string json = string.Empty;
     DataTable _dt = new DataTable();
     ProductQuery query = new ProductQuery();
     int totalCount = 0;
     try
     {
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
         query.Product_Id = Convert.ToUInt32(Request.Params["product_id"]);
         _IProductMgr = new ProductMgr(mySqlConnectionString);
         _dt = _IProductMgr.GetVendorProductSpec(query, out  totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dt, Formatting.Indented, timeConverter) + "}";
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json.ToString());
     this.Response.End();
     return this.Response;
 }
        /// <summary>
        /// 獲取列表數據
        /// </summary>
        /// <returns></returns>
        public  HttpResponseBase  GetList()
        {

            List<PageErrorLogQuery> stores = new List<PageErrorLogQuery>();
            string json = string.Empty;
            try
            {
                PageErrorLogQuery query = new PageErrorLogQuery();
                query.Start = Convert.ToInt32(Request.Params["Start"] ?? "0");
                if (!string.IsNullOrEmpty(Request.Params["Limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["Limit"]);
                }

                query.searchType = Convert.ToInt32(Request.Params["errorType"]);
                query.searchKey = Request.Params["searchKey"];
                query.startT = Request.Params["startT"];
                query.endT = Request.Params["endT"];
                ///獲取滿足條件的數據
                stores = pelMgr.GetData(query,out  totalCount);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            catch (Exception)
            {
                json = "{success:false}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#10
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            if (!String.IsNullOrEmpty(ContentType))
            {
                response.ContentType = ContentType;
            }
            else
            {
                response.ContentType = "application/json";
            }
            if (ContentEncoding != null)
            {
                response.ContentEncoding = ContentEncoding;
            }
            if (Data != null)
            {
                // Using Json.NET serializer
                IsoDateTimeConverter isoConvert = new IsoDateTimeConverter();
                isoConvert.DateTimeFormat = _dateFormat;
                response.Write(JsonConvert.SerializeObject(Data, isoConvert));
            }
        }
        /// <inheritdoc />
        public virtual void Initialize(HttpControllerSettings controllerSettings, HttpControllerDescriptor controllerDescriptor)
        {
            if (controllerSettings == null)
            {
                throw new ArgumentNullException("controllerSettings");
            }

            JsonMediaTypeFormatter jsonFormatter = new JsonMediaTypeFormatter();
            JsonSerializerSettings serializerSettings = jsonFormatter.SerializerSettings;

            // Set up date/time format to be ISO 8601 but with 3 digits and "Z" as UTC time indicator. This format
            // is the JS-valid format accepted by most JS clients.
            IsoDateTimeConverter dateTimeConverter = new IsoDateTimeConverter()
            {
                Culture = CultureInfo.InvariantCulture,
                DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFZ",
                DateTimeStyles = DateTimeStyles.AdjustToUniversal
            };

            // Ignoring default values while serializing was affecting offline scenarios as client sdk looks at first object in a batch for the properties.
            // If first row in the server response did not include columns with default values, client sdk ignores these columns for the rest of the rows
            serializerSettings.DefaultValueHandling = DefaultValueHandling.Include;
            serializerSettings.NullValueHandling = NullValueHandling.Include;
            serializerSettings.Converters.Add(new StringEnumConverter());
            serializerSettings.Converters.Add(dateTimeConverter);
            serializerSettings.MissingMemberHandling = MissingMemberHandling.Error;
            serializerSettings.CheckAdditionalContent = true;
            serializerSettings.ContractResolver = new ServiceContractResolver(jsonFormatter);
            controllerSettings.Formatters.Remove(controllerSettings.Formatters.JsonFormatter);
            controllerSettings.Formatters.Insert(0, jsonFormatter);
        }
示例#12
0
    public override string QueryResult()
    {
        JsonModel jsonModel = new JsonModel();

        try
        {
            CallWork paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <CallWork>(this.Data);
            TF.RunSafty.BLL.TAB_MsgCallWork          bllPlace  = new TF.RunSafty.BLL.TAB_MsgCallWork();
            List <TF.RunSafty.Model.TAB_MsgCallWork> placeList = bllPlace.GetAllMsg(paramModel.data.nStartState, paramModel.data.nEndState);
            jsonModel.result    = 0;
            jsonModel.resultStr = "提交成功";
            ArrayName an = new ArrayName();
            jsonModel.data = an;
            an.MsgAry      = bllPlace.GetPlaceList(placeList);
        }
        catch (Exception ex)
        {
            TF.CommonUtility.LogClass.logex(ex, "");
            jsonModel.result    = 1;
            jsonModel.resultStr = "提交失败" + ex.Message;
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
    }
示例#13
0
        public static void Register(HttpConfiguration config)
        {
            config.Formatters.Remove(config.Formatters.FormUrlEncodedFormatter);
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            var exceptionHandler = new WikiDownWebApiExceptionHandler();
            config.Services.Replace(typeof(IExceptionHandler), exceptionHandler);

            var formatting = (DevEnvironment.IsDebug) ? Formatting.Indented : Formatting.None;
            var contractResolver = new CamelCasePropertyNamesContractResolver();
            var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fff" };

            var jsonSerializerSettings = config.Formatters.JsonFormatter.SerializerSettings;

            jsonSerializerSettings.Formatting = formatting;
            jsonSerializerSettings.ContractResolver = contractResolver;
            jsonSerializerSettings.Converters.Add(dateTimeConverter);

            config.IncludeErrorDetailPolicy = DevEnvironment.IsDebug
                                                  ? IncludeErrorDetailPolicy.Always
                                                  : IncludeErrorDetailPolicy.Default;

            config.MapHttpAttributeRoutes();

            config.EnsureInitialized();
        }
示例#14
0
 public HttpResponseBase LoadCondition()
 {
     string json = string.Empty;
     List<EdmListConditoinSubQuery> store = new List<EdmListConditoinSubQuery>();
     EdmListConditoinSubQuery query = new EdmListConditoinSubQuery();
     _edmlistsubMgr = new EdmListConditoinSubMgr(sqlConnectionString);
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["conditionName"]))
         {
             query.elcm_name = Request.Params["conditionName"];
         }
         store = _edmlistsubMgr.LoadCondition(query);
         if (store != null)
         {
             IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
             timeConverter.DateTimeFormat = "yyyy-MM-dd";
             json = "{success:true" + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
示例#15
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
                throw new ArgumentNullException("context");

            HttpResponseBase response = context.HttpContext.Response;

            if (!string.IsNullOrEmpty(ContentType))
                response.ContentType = ContentType;
            else
                response.ContentType = "application/json";

            if (ContentEncoding != null)
                response.ContentEncoding = ContentEncoding;

            if (Data != null)
            {
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();

                timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";

                string json = JsonConvert.SerializeObject(Data, Formatting.None, timeConverter);

                response.Write(json);
                response.End();
            }
        }
示例#16
0
 protected ContentResult JsonStringRseult2(object data = null)
 {
     IsoDateTimeConverter iso = new IsoDateTimeConverter();
     iso.DateTimeFormat = "yyyy-MM-dd";
     var result = new { success = true, data = data };
     return Content(JsonConvert.SerializeObject(result,iso));
 }
示例#17
0
 /// <summary>
 /// Static constructor to cache everything we can
 /// </summary>
 static JsonNetResult()
 {
     //let's create a new instance of the cached properties
     CachedJsonSerializerSettings = new JsonSerializerSettings();
     CachedIsoDateTimeConverter = new IsoDateTimeConverter();
     JsonContentType = AspNetConstants.JsonContentType;
 }
示例#18
0
    private string GetDataByWGJKHTS()
    {
        WebServices.Services Resource = new WebServices.Services();
        string    str = "";
        DataTable dt  = new DataTable();

        string Condition = Request["Condition"];
        string Seaxs     = Request["Seaxs"];


        string sql = "select C3_401291000526 客户全称 ,C3_551182758185 分配  from CT401290367151 ";

        sql += " WHERE  isnull(C3_551182775673,'1900-01-01') <dateadd(month,-2,GETDATE()) ";
        sql += " and isnull(C3_551182786094,'1900-01-01') <dateadd(month,-6,GETDATE())  ";
        if (Seaxs != "" && Seaxs != null)
        {
            sql += " and C3_401291000526  like '%" + Seaxs + "%'";
        }
        if (Condition != "")
        {
            sql += Condition;
        }
        sql += " order by C3_551182758185 asc,C3_401291000526 asc";
        string[] changePassWord = Common.getChangePassWord();
        dt = Resource.SelectData(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);

        return(str);
    }
        /// <summary>
        /// 獲取商品數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetTrialProdCateList()
        {
            List<TrialProdCateQuery> store = new List<TrialProdCateQuery>();
            string json = string.Empty;
            try
            {
                TrialProdCateQuery query = new TrialProdCateQuery();
                #region 獲取query對象數據
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");

                if (!string.IsNullOrEmpty(Request.Form["limit"]))
                {
                    query.Limit = Convert.ToInt32(Request.Params["limit"]);
                }
                #endregion
                _trialProdMgr = new TrialProdCateMgr(mySqlConnectionString);
                _prodMgr = new ProductMgr(mySqlConnectionString);
                prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);//實例化對象mgr
                _giftMgr = new PromotionsAmountGiftMgr(mySqlConnectionString);
                _trialMgr = new PromotionsAmountTrialMgr(mySqlConnectionString);
                int totalCount = 0;
                store = _trialProdMgr.Query(query, out totalCount);

                foreach (var item in store)
                {
                    item.product_name = _prodMgr.QueryClassify(Convert.ToUInt32(item.product_id)).Product_Name;
                    item.category_name = prodCateMgr.QueryAll(new ProductCategory { category_id = item.category_id }).FirstOrDefault().category_name;
                    if (item.event_id.StartsWith("T1") || item.event_id.StartsWith("T2"))
                    {
                        int id = Convert.ToInt16(item.event_id.Substring(2).ToString());
                        item.event_name = _trialMgr.GetModel(id).name;
                    }
                    if (item.event_id.StartsWith("G3"))
                    {
                        int id = Convert.ToInt16(item.event_id.Substring(2).ToString());
                        item.event_name = _giftMgr.GetModel(id).name;
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
            }

            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false}";
            }


            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
 public HttpResponseBase GetUserOrdersSubtotalList()
 {
     int totalCount = 0;
     List<UserOrdersSubtotalQuery> stores = new List<UserOrdersSubtotalQuery>();
     string json = string.Empty;
     try
     {
         csMgr = new ConsumeStatisticMgr(SqlConnectionString);
         UserOrdersSubtotalQuery query = new UserOrdersSubtotalQuery();
         query.Start = Convert.ToInt32(Request.Params["Start"] ?? "0");
         if (!string.IsNullOrEmpty(Request.Params["Limit"]))
         {
             query.Limit = Convert.ToInt32(Request.Params["Limit"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["startMoney"]))
         {
             query.startMoney = Convert.ToDouble(Request.Params["startMoney"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["endMoney"]))
         {
             query.endMoney = Convert.ToDouble(Request.Params["endMoney"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["startTime"]))
         {
             query.startTime = Convert.ToDateTime(Request.Params["startTime"]);
             query.startTime = Convert.ToDateTime(query.startTime.ToString("yyyy-MM-dd HH:mm:ss"));
         }
         if (!string.IsNullOrEmpty(Request.Params["endTime"]))
         {
             query.endTime = Convert.ToDateTime(Request.Params["endTime"]);
             query.endTime = Convert.ToDateTime(query.endTime.ToString("yyyy-MM-dd HH:mm:ss"));
         }
         if (!string.IsNullOrEmpty(Request.Params["searchType"]))
         {
             query.searchType = Convert.ToInt32(Request.Params["searchType"]);
         }
         if (!string.IsNullOrEmpty(Request.Params["searchKey"]))
         {
             query.searchKey = Request.Params["searchKey"];
         }
         stores = csMgr.GetUserOrdersSubtotal(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
 public static string AsJson(this object o)
 {
     var dateConverter = new IsoDateTimeConverter
     {
         DateTimeFormat = "yyyy-MM-dd"
     };
     return JsonConvert.SerializeObject(o, dateConverter);
 }
示例#22
0
 public string 转化成Json带答案()
 {
     IsoDateTimeConverter iso = new IsoDateTimeConverter();
     iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     string json = JsonConvert.SerializeObject(this, Formatting.Indented, iso);
     json = json.Replace("\"小题型Enum\": " + 小题型Enum + "", "\"小题型Enum\":\"" + 小题型Enum + "\"");
     return json;
 }
示例#23
0
 /// <summary>
 /// object 转 JSON 字符串
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="DateTimeFormat">时间格式化</param>
 /// <returns></returns>
 public static string ToJson(this object obj, string DateTimeFormat = "yyyy-MM-dd HH:mm:ss")
 {
     Newtonsoft.Json.Converters.IsoDateTimeConverter dtFmt = new Newtonsoft.Json.Converters.IsoDateTimeConverter
     {
         DateTimeFormat = DateTimeFormat
     };
     return(Newtonsoft.Json.JsonConvert.SerializeObject(obj, dtFmt));
 }
示例#24
0
        public HttpResponseBase GetNewsList()
        {
            string json = string.Empty;
            List<NewsContentQuery> store = new List<NewsContentQuery>();
            NewsContentQuery query = new NewsContentQuery();
            try
            {
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
                _INewsContentMgr = new NewsContentMgr(mySqlConnectionString);
                int totalCount = 0;
                if (!string.IsNullOrEmpty(Request.Params["searchCon"]))
                {
                    query.searchCon = Request.Params["searchCon"];
                }
                if (!string.IsNullOrEmpty(Request.Params["search_con"]))
                {
                    query.search_con = Request.Params["search_con"];
                }
                if (!string.IsNullOrEmpty(Request.Params["date"]))
                {
                    query.date = Request.Params["date"];
                }
                if (!string.IsNullOrEmpty(Request.Params["start_time"]))
                {
                    query.start_time = Convert.ToDateTime(Request.Params["start_time"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"]))
                {
                    query.end_time = Convert.ToDateTime(Request.Params["end_time"]);
                }
                store = _INewsContentMgr.GetNewsList(query, out totalCount);
                foreach (var item in store)
                {
                    item.s_news_show_start = CommonFunction.GetNetTime(item.news_show_start);
                    item.s_news_show_end = CommonFunction.GetNetTime(item.news_show_end);
                    item.s_news_createdate = CommonFunction.GetNetTime(item.news_createdate);
                    item.s_news_updatedate = CommonFunction.GetNetTime(item.news_updatedate);
                    item.news_content = Server.HtmlDecode(Server.HtmlDecode(item.news_content));
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public long Save(string jsonMachine)
        {
            var format = "dd/MM/yyyy"; // your datetime format
            var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = format };
            var machine = JsonConvert.DeserializeObject<Domain.Repository.Equipamentos>(jsonMachine, dateTimeConverter);

            machine = new Domain.BLL.EquipamentoBLL().Save(machine);
            return machine.ID;
        }
        public int Save(string jsonExercise)
        {
            var format = "dd/MM/yyyy"; // your datetime format
            var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = format };
            var exercise = JsonConvert.DeserializeObject<Domain.Repository.Exercicios>(jsonExercise, dateTimeConverter);

            exercise = new Domain.BLL.ExerciseBLL().Save(exercise);
            return exercise.ID;
        }
示例#27
0
 public static string ToJson(this object obj)
 {
     IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
     timeConverter.DateTimeFormat = "yyyy-MM-dd";
     //string json = JsonConvert.SerializeObject(DateTime.Now, Formatting.Indented, timeConverter);
     if (obj == null)
         return string.Empty;
     return JsonConvert.SerializeObject(obj, Formatting.Indented, timeConverter);
 }
示例#28
0
 public static void ConfigApi(HttpConfiguration config)
 {
     var jsonFormatter = new JsonMediaTypeFormatter();
     var settings = jsonFormatter.SerializerSettings;
     IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
     timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     settings.Converters.Add(timeConverter);
     settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
     config.Services.Replace(typeof(IContentNegotiator), new JsonContentNegotiator(jsonFormatter));
 }
示例#29
0
    /// <summary>
    /// 按后台表字段的排序来获取记录值
    /// </summary>
    /// <param name="argRecID"></param>
    /// <param name="argResid"></param>
    /// <param name="argCondition"></param>
    /// <returns></returns>
    public static string getSortDynamicFieldRecords(string argRecID, string argResid, string argCondition)
    {
        DataTable vDT = Resource.GetDataListByResourceID(argResid, false, CommonMethod.FilterSql(" and id=" + argRecID)).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        string str = Newtonsoft.Json.JsonConvert.SerializeObject(vDT, timeConverter);

        return("{\"total\":" + vDT.Rows.Count + ",\"rows\":" + str + "}");
    }
    public override string QueryResult()
    {
        JsonModel jsonModel = new JsonModel();

        try
        {
            ParamModel paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);
            TF.RunSafty.BLL.getAllSign bllPlace = new TF.RunSafty.BLL.getAllSign();
            List <TF.RunSafty.Model.Model_Plan_ToBeTake> plans = bllPlace.GetPlanTrain(paramModel.data.strPlanGUID);
            jsonModel.result    = 0;
            jsonModel.resultStr = "提交成功";
            //jsonModel.data = bllPlace.GetPlaceList(placeList);

            if (plans.Count > 0)
            {
                PlanBeginWork work = new PlanBeginWork();
                work.strCheCi       = plans[0].StrTrainNo;
                work.dtCallWorkTime = plans[0].dtCallWorkTime.ToString();
                work.dtWaitWorkTime = plans[0].dtWaitWorkTime.ToString();

                work.strTrainmanGUID1 = plans[0].strTrainmanGUID1;
                work.strTrainmanGUID2 = plans[0].strTrainmanGUID2;
                work.strTrainmanGUID3 = plans[0].strTrainmanGUID3;
                work.strTrainmanGUID4 = plans[0].strTrainmanGUID4;

                work.strTrainmanName1 = plans[0].strTrainmanName1;
                work.strTrainmanName2 = plans[0].strTrainmanName2;
                work.strTrainmanName3 = plans[0].strTrainmanName3;
                work.strTrainmanName4 = plans[0].strTrainmanName4;

                work.strTrainmanNumber1 = plans[0].strTrainmanNumber1;
                work.strTrainmanNumber2 = plans[0].strTrainmanNumber2;
                work.strTrainmanNumber3 = plans[0].strTrainmanNumber3;
                work.strTrainmanNumber4 = plans[0].strTrainmanNumber4;


                work.NNeedRest  = plans[0].NNeedRest;
                work.NPlanState = plans[0].NPlanState;

                jsonModel.data      = work;
                jsonModel.result    = 0;
                jsonModel.resultStr = "提交成功";
            }
        }
        catch (Exception ex)
        {
            TF.CommonUtility.LogClass.logex(ex, "");
            jsonModel.result    = 1;
            jsonModel.resultStr = "提交失败" + ex.Message;
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
    }
        /// <summary>
        ///     Registers the configuration
        /// </summary>
        public static void Register(HttpConfiguration config)
        {
            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat;
            config.Formatters.JsonFormatter.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Utc;
            config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            var isoConverter = new IsoDateTimeConverter {DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"};
            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(isoConverter);
        }
示例#32
0
 public override void ExecuteResult(ControllerContext context)
 {
     if (context == null) { throw new ArgumentNullException("context"); }
     HttpResponseBase response = context.HttpContext.Response;
     if (Data != null)
     {
         var timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
         //这里使用自定义日期格式,默认是ISO8601格式
         response.Write(JsonConvert.SerializeObject(Data, Formatting.Indented, timeConverter));
     }
 }
示例#33
0
        public JsonNetResult()
        {
            SerializerSettings = new JsonSerializerSettings();
            var converter = new IsoDateTimeConverter
            {
                DateTimeFormat = "yyyy-MM-dd"
            };
            SerializerSettings.Converters.Add(converter);

            this.Formatting = Formatting.Indented;
        }
示例#34
0
        /// <summary>
        /// 根据订单编码获取大货列表
        /// </summary>
        public static OrderListResult PullBulkDataList(List<string> goodsCodes, string token)
        {
            var paras = new Dictionary<string, object>();
            paras.Add("bulkGoodsCodes", string.Join(",", goodsCodes.ToArray()));
            paras.Add("access_token", token);

            string resultStr = HttpRequest.RequestServer(ApiOption.pullBulkDataList, paras, RequestType.Post);
            var format = "yyyyMMddHHmmssfffzzz"; // your datetime format
            var dateTimeConverter = new IsoDateTimeConverter { DateTimeFormat = format };

            return JsonConvert.DeserializeObject<OrderListResult>(resultStr, dateTimeConverter);
        }
示例#35
0
        /// <summary>
        ///配置全局设置
        /// </summary>
        /// <param name="config">config</param>
        protected static void Configure(HttpConfiguration config)
        {
            #region  日期返回格式化

            var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
            var timeConverter = new IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd";
            json.SerializerSettings.Converters.Add(timeConverter);

            #endregion
        }
示例#36
0
    public void SerializeDateTimeOffset()
    {
      IsoDateTimeConverter converter = new IsoDateTimeConverter();

      DateTimeOffset d = new DateTimeOffset(2000, 12, 15, 22, 11, 3, 55, TimeSpan.Zero);
      string result;

      result = JavaScriptConvert.SerializeObject(d, converter);
      Assert.AreEqual(@"""2000-12-15T22:11:03.0550000+00:00""", result);

      Assert.AreEqual(d, JavaScriptConvert.DeserializeObject<DateTimeOffset>(result, converter));
    }
示例#37
0
        public CustomJsonResult()
        {
            //JSON序列化设置
            jsetting = new JsonSerializerSettings();
            jsetting.NullValueHandling = NullValueHandling.Ignore;

            //设置日期时间的格式,与DataTime类型的ToString格式相同
            IsoDateTimeConverter iso = new IsoDateTimeConverter();
            iso.DateTimeFormat = dateTimeFormat;

            jsetting.Converters.Add(iso);
        }
示例#38
0
    public static string GetDataByUserDefinedSql(string ResID, int PageIndex, int PageSize, string SortField, string SortBy, string UserID, string QueryKeystr, string ROW_NUMBER_ORDER, bool argNoPaging, List <ReportFoot> argReportFoots = null, bool argIsReport = false, string argCondition = "")
    {
        if (argIsReport)
        {
            argNoPaging    = true;
            argReportFoots = null;
        }

        DataSet   ds = GetDataListPage(ResID, PageIndex, PageSize, SortField, SortBy, UserID, QueryKeystr, ROW_NUMBER_ORDER, argNoPaging, argCondition);
        DataTable dt = ds.Tables[0];

        string[] temp = ROW_NUMBER_ORDER.Split(',');
        for (int i = 0; i < temp.Length; i++)
        {
            if (temp[i].Split('=').Length > 1)
            {
                dt.Columns.Add(temp[i].Split('=')[0]);
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    dt.Rows[j][temp[i].Split('=')[0]] = dt.Rows[j][temp[i].Split('=')[1]].ToString();
                }
            }
        }
        if (ds == null || ds.Tables.Count == 0)
        {
            return("");
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        string str = Newtonsoft.Json.JsonConvert.SerializeObject(ds.Tables[0], timeConverter);

        if (QueryKeystr.Trim() != "")
        {
            if (QueryKeystr.Substring(0, 4).ToLower().Trim() == "and")
            {
            }
            else
            {
                QueryKeystr = " and " + QueryKeystr;
            }
        }

        int RowCount = Resource.GetDataListByResID(ResID, "", QueryKeystr, UserID).Tables[0].Rows.Count;

        if (argIsReport)
        {
            return(str);
        }
        else
        {
            return("{\"total\":" + RowCount + ",\"rows\":" + str + "}");
        }
    }
示例#39
0
        public static string GetFormatedJsonString(JsonModel mode)
        {
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            JsonSerializerSettings nullValueSetting = new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Include
            };

            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            nullValueSetting.Converters.Add(timeConverter);
            return(Newtonsoft.Json.JsonConvert.SerializeObject(mode, Newtonsoft.Json.Formatting.None, nullValueSetting));
        }
示例#40
0
文件: JSON.cs 项目: zhuqibiao/DFZ
        public static string Encode(object o)
        {
            if(o == null || o.ToString() == "null") return null;

            if (o != null && (o.GetType() == typeof(String) || o.GetType() == typeof(string)))
            {
                return o.ToString();
            }
            IsoDateTimeConverter dt = new IsoDateTimeConverter();
            dt.DateTimeFormat = DateTimeFormat;
            return JsonConvert.SerializeObject(o, dt);
        }
示例#41
0
    //// 带参申请访问令牌
    //public static string GetToken(string login_type, string paramsStr)
    //{

    //    try
    //    {
    //        string userCode = "";
    //        string pwd = "";
    //        string stamptime = GetTimestamp();
    //        string[] parlist = paramsStr.Split('&');
    //        string third_party_msg = "";
    //        string third_party_type = "";
    //        if (parlist != null)
    //        {
    //            for (int i = 0; i < parlist.Length; i++)
    //            {
    //                if (parlist[i].Split('=')[0].ToString().Equals("user_account"))
    //                {
    //                    userCode = parlist[i].Split('=')[1].ToString();
    //                }
    //                if (parlist[i].Split('=')[0].ToString().Equals("user_pwd"))
    //                {
    //                    pwd = parlist[i].Split('=')[1].ToString();
    //                }
    //                if (parlist[i].Split('=')[0].ToString().Equals("third_party_msg"))
    //                {
    //                    third_party_msg = parlist[i].Split('=')[1].ToString();
    //                }
    //                if (parlist[i].Split('=')[0].ToString().Equals("third_party_type"))
    //                {
    //                    third_party_type = parlist[i].Split('=')[1].ToString();
    //                }

    //            }
    //        }
    //        string Md5_Pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd.Trim(), "MD5");
    //        OAuth oauth = new OAuth();
    //        List<Parameter> listParams = new List<Parameter>();
    //        listParams.Add(new Parameter("login_type", login_type));
    //        listParams.Add(new Parameter("user_account", userCode));
    //        listParams.Add(new Parameter("user_pwd", Md5_Pwd));
    //        listParams.Add(new Parameter("third_party_type", third_party_type));
    //        listParams.Add(new Parameter("third_party_msg", third_party_msg));
    //        string url = starturl + "api/token/get";
    //        string querySting = null;
    //        string newUrl = oauth.GetOauthUrl(url, key, appsecret, "", listParams, out querySting);
    //        // 获取页面返回数据
    //        string outData = Get_Http(newUrl);

    //        return outData;
    //    }
    //    catch (Exception)
    //    {

    //        return "";
    //    }

    //}


    ////修改会员信息
    //public static string Vipmodify(string token, List<MCMP.IF.Common.Parameter> listParams,VipUser user)
    //{
    //    string json = "";
    //    OAuth oauth = new OAuth();
    //    string querySting = null;
    //    string url = starturl + "api/vip/modify";
    //    string newUrl = oauth.GetOauthUrl(url, key, appsecret, token, listParams, out querySting);
    //    json = DataHelp.Get_Http_Params(newUrl, JsonHelper.JsonSerializer(user));


    //    return json;
    //}

    public static string ToJson(object info)
    {
        if (null == info)
        {
            return(string.Empty);
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
        string Result = JsonConvert.SerializeObject(info, timeConverter);

        return(Result);
    }
示例#42
0
    protected string GetDataDictionary(string keyCode)
    {
        Services ws     = new Services();
        string   strSql = "select KeyTitle id, KeyTitle text from dbo.DataDictionary where ParentId=(select ID from dbo.DataDictionary  where KeyCode='" + keyCode + "')";

        string[]  changePassWord = Common.getChangePassWord();
        DataTable dt             = ws.SelectData(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";

        return(Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter));
    }
示例#43
0
        /// <summary>
        /// 将Object转换成STREAM
        /// </summary>
        /// <param name="bject"></param>
        /// <returns></returns>
        public Stream ToStreams(Object obj, string dateTimeFormat = "yyyy'-'MM'-'dd")
        {
            MemoryStream ms = new MemoryStream();
            StreamWriter sw = new StreamWriter(ms);

            sw.AutoFlush = true;
            IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();

            timeConverter.DateTimeFormat = dateTimeFormat;
            sw.Write(JsonConvert.SerializeObject(obj, timeConverter));
            ms.Position = 0;
            return(ms);
        }
        public static string ObjectToJson(object o)
        {
            string rlt = string.Empty;
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

            string result = JsonConvert.SerializeObject(o, Formatting.Indented, timeConverter);

            rlt = result.Replace("null", "\"\"");
            //rlt = result.Replace("/upload/", System.Configuration.ConfigurationManager.AppSettings["WebPath"] + "/upload/");
            return(rlt);
        }
示例#45
0
    protected string GetDataListBySql(string sql)
    {
        string resultStr;

        WebServices.Services Resource       = new WebServices.Services();
        string[]             changePassWord = Common.getChangePassWord();

        DataTable dt = Resource.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        // //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        //timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm";
        resultStr = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        return(resultStr);
    }
示例#46
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="tableName">表名、视图名、查询语句</param>
        /// <param name="selectedColumns">要显示的字段列表,</param>
        /// <param name="idColumn">主键</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageCount">分页大小</param>
        /// <param name="where">过滤条件</param>
        /// <param name="orderby">排序字段</param>
        /// <param name="sort">排序, 只能取desc或者asc</param>
        /// <returns></returns>
        private static string GetSearchData(string tableName, string selectedColumns, string idColumn, int pageIndex, int pageCount, string where, string orderby, string sort)
        {
            int       recordCount = 0;
            JsonModel jsonModel   = new JsonModel();

            jsonModel.total = 0;
            SqlParameter parameter = new SqlParameter("RecordCount", recordCount);

            parameter.Direction = ParameterDirection.Output;
            DataSet    set     = new DataSet();
            SqlCommand command = new SqlCommand("pro_page", new SqlConnection(SqlHelper.ConnString));

            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(parameter);
            command.Parameters.AddWithValue("QueryStr", tableName);
            command.Parameters.AddWithValue("PageSize", pageCount);
            command.Parameters.AddWithValue("PageCurrent", pageIndex);
            command.Parameters.AddWithValue("FdShow", selectedColumns);
            command.Parameters.AddWithValue("IdentityStr", idColumn);
            command.Parameters.AddWithValue("WhereStr", where);
            command.Parameters.AddWithValue("OrderField", orderby);
            command.Parameters.AddWithValue("FdOrder", sort);
            try
            {
                command.Connection.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                adapter.Fill(set);
                if (set != null)
                {
                    if (set.Tables.Count > 0)
                    {
                        jsonModel.total = (int)command.Parameters["RecordCount"].Value;
                        jsonModel.rows  = set.Tables[0];
                    }
                }
            }
            catch (Exception ex)
            {
                TF.CommonUtility.LogClass.logex(ex, "");
            }
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, Newtonsoft.Json.Formatting.None, timeConverter));
        }
示例#47
0
        public override string QueryResult()
        {
            DataModel dataModel       = Newtonsoft.Json.JsonConvert.DeserializeObject <DataModel>(this.Data);
            string    strWorkShopGUID = dataModel.WorkShopGUID;
            string    cid             = dataModel.cid;
            JsonModel jsonModel       = new JsonModel();

            jsonModel.result    = "0";
            jsonModel.resultStr = "返回成功";
            TF.Api.BLL.KaoQinBLL bllKaoQin = new TF.Api.BLL.KaoQinBLL();
            DataTable            table     = bllKaoQin.GetKaoQinByWorkShopGUID(strWorkShopGUID);

            jsonModel.Content = table;
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
        }
示例#48
0
    protected string GetDataByResEmpty(string ResID)
    {
        string json   = "";
        string strSql = " select ID,[NAME] 资源名称,SHOW_ENABLE 是否启用,RES_IsDefaultMenu 是否默认,RES_EMPTYRESOURCEURL 资源链接,RES_EMPTYRESOURCETARGET 打开方式,Res_Comments 资源说明信息,RES_ROWCOLOR3_WHERE 资源图标 from dbo.CMS_RESOURCE  where ID=" + ResID;

        string[]  changePassWord = Common.getChangePassWord();
        DataTable dt             = ws.SelectData(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        // timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        // //项目助理的合计工时

        string strS = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);

        json  = "{\"total\":" + dt.Rows.Count + ",\"rows\":" + strS;
        json += ",\"footer\":[{}]";
        json += "}";
        return(json);
    }
示例#49
0
    protected void GetEditorData()
    {
        String ResID     = Request.QueryString["ResID"];
        String RecID     = Request.QueryString["RecID"];
        string searchstr = "";

        WebServices.Services Resource = new WebServices.Services();

        if (ResID == "460222389874")
        {
            searchstr = " and DOCID ='" + RecID + "'";
        }
        else
        {
            searchstr = " and id=" + RecID;
        }

        DataTable ppDt = Resource.GetDataListByResourceID(ResID, false, searchstr).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        String str = Newtonsoft.Json.JsonConvert.SerializeObject(ppDt, timeConverter);

        //方案系统编号,加载方案扩展表的时候用 430590206015//方案扩展表的ResID
        String FAXTBH = Request.QueryString["FAXTBH"];

        if (FAXTBH != null && FAXTBH != "")
        {
            DataTable sunDt = Resource.GetDataListByResourceID("430590206015", false, " and 方案系统编号='" + FAXTBH + "'").Tables[0];
            String    str1  = Newtonsoft.Json.JsonConvert.SerializeObject(sunDt, timeConverter);
            str = str + "[#]" + str1;
            String lxrxtbh = sunDt.Rows[0]["联系人系统编号"].ToString();
            if (lxrxtbh != null && lxrxtbh != "")
            {
                //查询品牌方案关联的联系人系统编号
                DataTable lxrDt = Resource.GetDataListByResourceID("379264068953", false, " and 联系人系统编号='" + lxrxtbh + "'").Tables[0];
                String    str2  = Newtonsoft.Json.JsonConvert.SerializeObject(lxrDt, timeConverter);
                str = str + "[#]" + str2;
            }
        }
        Response.Write(str);
    }
示例#50
0
    protected string GetDataByResourceInfo()
    {
        string ResID  = Request["ResID"].ToString();
        string json   = "";
        string strSql = "select ID,QTLabel 前台标签,SettingsNum 列表配置号 ,KeyWord 关键字 ,ShowTitle 显示Title ,ENKeyWord 参数关键字 ,Value 值  from SysSettings where Value='" + ResID + "'";

        string[]  changePassWord = Common.getChangePassWord();
        DataTable dt             = ws.SelectData(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        // //项目助理的合计工时

        string strS = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);

        json  = "{\"total\":" + dt.Rows.Count + ",\"rows\":" + strS;
        json += ",  \"footer\" :[{}]";
        json += "}";
        return(json);
    }
示例#51
0
    protected string GetFilesInfo(string ResID, string ParentResID, string ParentRecID)
    {
        string strJson = "";

        WebServices.Services Resource   = new Services();
        DataTable            dtRelation = Resource.GetRelationTable(ParentResID).Tables[0];

        DataRow[] drs = dtRelation.Select("ChildResourceID=" + ResID);
        if (drs.Length > 0)
        {
            string strSql = "select ID,DocID,DocHostName,(DOC2_NAME+'.'+DOC2_EXT) DocName,cast(ROUND(DOC2_SIZE/1024,1) as decimal(18,1)) DocSize,DOC2_CRTTIME CreateDate from (select Res.ID, Res." + drs[0]["ChildColName"] + ",Res.DocID from " + drs[0]["ChildTableName"] + " Res where " + drs[0]["ChildColName"] + " in (select " + drs[0]["ParentColName"] + " from " + drs[0]["ParentTableName"] + " where ID='" + ParentRecID + "'))T ";
            strSql += " join Cms_DocumentCenter Doc on Doc.DOC2_ID=T.DocID ";
            string[]  changePassWord = Common.getChangePassWord();
            DataTable dt             = Resource.SelectData(strSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
            strJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        }
        return(strJson);
    }
示例#52
0
    private string GetDataByWGJKHTX()
    {
        WebServices.Services Resource = new WebServices.Services();
        string    str = "";
        DataTable dt  = new DataTable();
        string    sql = "select C3_404495328556 客户全称,C3_423050441017 销售   from CT401290331886  WHERE  C3_404495328556 NOT IN ( ";

        sql += " select C3_480524157728 from CT480524075049 WHERE C3_480524183775 BETWEEN '" + DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd") + "' AND GETDATE()) ";
        if (Request["Seaxs"] != null && Request["Seaxs"].ToString() != "")
        {
            sql += " and C3_423050441017 like '%" + Request["Seaxs"].ToString() + "%'";
        }
        sql += " GROUP BY C3_404495328556 ,C3_423050441017  ORDER BY C3_423050441017 ";
        string[] changePassWord = Common.getChangePassWord();
        dt = Resource.SelectData(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        return(str);
    }
示例#53
0
    private string GetDataByFDDXM()
    {
        WebServices.Services Resource = new WebServices.Services();
        string    str        = "";
        DataTable dt         = new DataTable();
        string    seaBegDate = Request["seaBegDate"];
        string    seaEndDate = Request["seaEndDate"];

        if (seaBegDate != null && seaBegDate != "" && seaEndDate != null && seaEndDate != "")
        {
            string sql = "SELECT   C3_316013848869 督导, COUNT(C3_285435595640) 累计新开项目, SUM(CASE WHEN ISNULL(C3_285435594890,0)=0 THEN 1 ELSE 0 END) 累计未确认项目,";
            sql += " SUM(CASE WHEN ISNULL(C3_285435594890,0)<>0 AND ISNULL(C3_332437985389,0)=0 THEN 1 ELSE 0 END) 累计已确认未开票项目";
            sql += " from CT285435593984 WHERE C3_285435594453 BETWEEN '" + Convert.ToDateTime(seaBegDate).ToString("yyyy-MM-dd") + "' AND '" + Convert.ToDateTime(seaEndDate).ToString("yyyy-MM-dd") + "' GROUP BY C3_316013848869";
            string[] changePassWord = Common.getChangePassWord();
            dt = Resource.SelectData(sql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
            str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        }
        return(str);
    }
示例#54
0
    private string GetfDataByYSKTJ()
    {
        WebServices.Services Resource = new WebServices.Services();
        string str = "";

        if (Request["SKRQ"] != null && Request["SKRQ"] != "")
        {
            DateTime skrq = Convert.ToDateTime(Request["SKRQ"]);
            string   sql  = "select SUM(C3_401795702260) 本月回款 from CT401290354058  ";
            sql += " where Year(C3_475688833284)='" + skrq.Year + "' and MONTH(C3_475688833284)='" + skrq.Month + "';  ";
            sql += " SELECT sum(C3_403033088714) 本月开票 FROM ct401290382901  ";
            sql += " where Year(C3_404405195524)='" + skrq.Year + "' and MONTH(C3_404405195524)='" + skrq.Month + "';  ";
            sql += " SELECT sum(C3_403007677105) 三个月内应收款 FROM ct401290382901   ";
            sql += " where C3_404405195524 between   dateadd(day,-90,'" + skrq + "')  and '" + skrq + "';";
            sql += " SELECT sum(C3_403007677105) 三个月以上应收款 FROM ct401290382901  ";
            sql += " where  C3_404405195524 <   dateadd(day,-90,'" + skrq + "') ;  ";
            sql += " SELECT sum(C3_403007677105) 应收款总额 FROM ct401290382901 where  C3_404405195524 < '" + skrq + "';";
            string[] changePassWord = Common.getChangePassWord();

            DataSet   ds = Resource.Query(sql, changePassWord[0], changePassWord[1], changePassWord[2]);
            DataTable dt = new DataTable();
            dt.Columns.Add("本月回款");
            dt.Columns.Add("本月开票");
            dt.Columns.Add("三个月内合计");
            dt.Columns.Add("三个月内应收款");
            dt.Columns.Add("三个月以上应收款");
            dt.Columns.Add("应收款总额");
            dt.Rows.Add();
            dt.Rows[0]["本月回款"]     = ds.Tables[0].Rows[0]["本月回款"].ToString();
            dt.Rows[0]["本月开票"]     = ds.Tables[1].Rows[0]["本月开票"].ToString();
            dt.Rows[0]["三个月内应收款"]  = ds.Tables[2].Rows[0]["三个月内应收款"].ToString();
            dt.Rows[0]["三个月以上应收款"] = ds.Tables[3].Rows[0]["三个月以上应收款"].ToString();
            dt.Rows[0]["应收款总额"]    = ds.Tables[4].Rows[0]["应收款总额"].ToString();

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
            str = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        }
        return("{\"total\":1 ,\"rows\":" + str + "}");
    }
示例#55
0
    protected string GetDataByUserDefinedSql()
    {
        string UserDefinedSql = "";

        if (Request["UserDefinedSql"] != null)
        {
            UserDefinedSql = Request["UserDefinedSql"].ToString().Trim();
        }
        string[]  changePassWord = Common.getChangePassWord();
        DataTable dt             = ws.SelectData(UserDefinedSql, changePassWord[0], changePassWord[1], changePassWord[2]).Tables[0];

        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd";
        // //项目助理的合计工时

        string strS = Newtonsoft.Json.JsonConvert.SerializeObject(dt, timeConverter);
        string json = "{\"total\":" + dt.Rows.Count + ",\"rows\":" + strS;

        json += ",  \"footer\" :[{}]";
        json += "}";
        return(json);
    }
示例#56
0
        /// <summary>
        /// 生产JSON格式的数据文档
        /// </summary>
        /// <returns></returns>
        private void saveOnLine()
        {
            //判断文件的存在
            if (File.Exists(Constants.wechatjson))
            {
                File.Delete(Constants.wechatjson);
            }
            else
            {
                File.Create(Constants.wechatjson);
            }
            MongOnLine           mongOnLine    = new MongOnLine(Constants.daname);
            List <OnLineModel>   list          = mongOnLine.obtainAll();
            IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            string dateTimeFormat = "yyyy'-'MM'-'dd";

            timeConverter.DateTimeFormat = dateTimeFormat;
            String json = JsonConvert.SerializeObject(list, timeConverter);

            saveBrand(list);
            System.IO.File.WriteAllText(Constants.wechatjson, json, Encoding.UTF8);
        }
示例#57
0
        public override string QueryResult()
        {
            JsonModel  model = new JsonModel();
            DataTable  table = null;
            ParamModel param = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);

            this.clientid = param.cid;
            TF.Api.BLL.Bll_Tab_Led_File bllLed = new TF.Api.BLL.Bll_Tab_Led_File();
            try
            {
                table           = bllLed.GetLedFileList(clientid);
                model.result    = "0";
                model.returnStr = "返回成功";
                model.FileList  = table;
            }
            catch (Exception ex)
            {
            }
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            return(Newtonsoft.Json.JsonConvert.SerializeObject(model, timeConverter));
        }
    public override string QueryResult()
    {
        JsonModel jsonModel = new JsonModel();

        try
        {
            ParamModel paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);
            TF.RunSafty.BLL.Plan.TAB_Plan_Train         bll_Plan_Train = new TF.RunSafty.BLL.Plan.TAB_Plan_Train();
            List <TF.RunSafty.Model.TrainManPlanforLed> placeList      = bll_Plan_Train.GetPlanTrain(paramModel.strClientGUID, paramModel.strMinute);
            jsonModel.result    = 0;
            jsonModel.resultStr = "提交成功";
            jsonModel.Convert(placeList);
        }
        catch (Exception ex)
        {
            TF.CommonUtility.LogClass.logex(ex, "");
            jsonModel.result    = 1;
            jsonModel.resultStr = "提交失败" + ex.Message;
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
    }
示例#59
0
    public override string QueryResult()
    {
        JsonModel jsonModel = new JsonModel();

        try
        {
            ParamModel paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);
            TF.RunSafty.BLL.Tab_Config_LED_Class_Order          bllPlace   = new TF.RunSafty.BLL.Tab_Config_LED_Class_Order();
            List <TF.RunSafty.Model.Tab_Config_LED_Class_Order> recordList = bllPlace.GetTrainnosOfTrainJiaolu(paramModel.strClientGUID);
            jsonModel.result    = 0;
            jsonModel.resultStr = "提交成功";
            jsonModel.Convert(recordList);
        }
        catch (Exception ex)
        {
            TF.CommonUtility.LogClass.logex(ex, "");
            jsonModel.result    = 1;
            jsonModel.resultStr = "提交失败" + ex.Message;
        }
        Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        return(Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter));
    }
示例#60
0
        internal T JsonTo <T>(string jsonText)
        {
            if (String.IsNullOrEmpty(jsonText))
            {
                return(default(T));
            }
            Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();
            json.NullValueHandling      = Newtonsoft.Json.NullValueHandling.Ignore;
            json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
            json.MissingMemberHandling  = Newtonsoft.Json.MissingMemberHandling.Ignore;
            json.ReferenceLoopHandling  = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            json.Converters.Add(timeConverter);

            StringReader sr     = new StringReader(jsonText);
            T            result = default(T);

            using (Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr))
            {
                result = (T)json.Deserialize(reader, typeof(T));
            }
            return(result);
        }