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


C# Converters.IsoDateTimeConverter类代码示例

本文整理汇总了C#中Newtonsoft.Json.Converters.IsoDateTimeConverter的典型用法代码示例。如果您正苦于以下问题:C# IsoDateTimeConverter类的具体用法?C# IsoDateTimeConverter怎么用?C# IsoDateTimeConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IsoDateTimeConverter类属于Newtonsoft.Json.Converters命名空间,在下文中一共展示了IsoDateTimeConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetHistory

 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();
     }
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:25,代码来源:ProductHistoryController.cs

示例2: GetCertificateCategory

        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;
        }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:33,代码来源:InspectionReportController.cs

示例3: LoadCondition

 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;
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:33,代码来源:EdmSController.cs

示例4: GetVendorProductSpec

 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;
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:30,代码来源:VendorStockController.cs

示例5: Register

        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();
        }
开发者ID:sebnilsson,项目名称:WikiDown,代码行数:26,代码来源:WebApiConfig.cs

示例6: JsonNetResult

 /// <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;
 }
开发者ID:dibiancoj,项目名称:ToracLibrary,代码行数:10,代码来源:JsonNetResult.cs

示例7: ToJson

 public string ToJson()
 {
     IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
     //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
     timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     return JsonConvert.SerializeObject(this, Formatting.Indented, timeConverter); ;
 }
开发者ID:BusinessSystem,项目名称:BusinessSystem,代码行数:7,代码来源:MsgInfo.cs

示例8: GetList

        /// <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;
        }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:39,代码来源:PageErrorLogController.cs

示例9: ExecuteResult

        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();
            }
        }
开发者ID:jamezoon,项目名称:XF,代码行数:27,代码来源:DateJsonResult.cs

示例10: Initialize

        /// <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);
        }
开发者ID:jwallra,项目名称:azure-mobile-apps-net-server-1,代码行数:32,代码来源:MobileAppControllerAttribute.cs

示例11: ExecuteResult

        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));
            }
        }
开发者ID:bob1457,项目名称:CommunityMarket,代码行数:29,代码来源:CustomJsonResult.cs

示例12: JsonStringRseult2

 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));
 }
开发者ID:cityjoy,项目名称:DapperCodeSmith,代码行数:7,代码来源:BaseController.cs

示例13: GetNewChats

        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);
        }
开发者ID:ramonrepositorio,项目名称:CareFit,代码行数:27,代码来源:ChatController.cs

示例14: GetUserOrdersSubtotalList

 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;
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:59,代码来源:ConsumeStatisticController.cs

示例15: GetTrialProdCateList

        /// <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;
        }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:63,代码来源:TrialProdCateController.cs


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