Beispiel #1
0
        protected void BatchInsert()
        {
            if (batchInsertRealtimeList == null || batchInsertRealtimeList.Count == 0)
            {
                return;
            }
            List <CEntityRealTime> realtimeList = new List <CEntityRealTime>();

            lock (batchInsertRealtimeList)
            {
                realtimeList.AddRange(batchInsertRealtimeList);
                batchInsertRealtimeList.Clear();
            }
            Dictionary <string, object> param = new Dictionary <string, object>();
            string suffix = "/currentdata/insertCurrentdataCS";
            string url    = "http://" + urlPrefix + suffix;

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(realtimeList, Newtonsoft.Json.Formatting.None, timeConverter);

            param["currentdata"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
                CDBLog.Instance.AddInfo(string.Format("添加{0}行到实时数据表", realtimeList.Count));
            }
            catch (Exception e)
            {
                Debug.WriteLine("添加雨量信息失败");
            }
        }
Beispiel #2
0
 public static string Serialize <T>(T entity)
 {
     Newtonsoft.Json.Converters.IsoDateTimeConverter iso
         = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
     iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     return(Newtonsoft.Json.JsonConvert.SerializeObject(entity, iso));
 }
        public static void ConfigureWebApi(this IAppBuilder app, HttpConfiguration config)
        {
            config.IncludeErrorDetailPolicy = GetErrorDetailPolicy();

            // Web API configuration and services
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            // JSON serialization
            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
                new CamelCasePropertyNamesContractResolver();

            // force 8601 date format
            var converter = new Newtonsoft.Json.Converters.IsoDateTimeConverter
            {
                DateTimeStyles = System.Globalization.DateTimeStyles.AdjustToUniversal
            };

            config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(converter);

            // CORS
            var enableCorsAttr = new EnableCorsAttribute($"{Constants.Urls.WebUrl}", "*", "*");

            enableCorsAttr.ExposedHeaders.Add("file-name");
            config.EnableCors(enableCorsAttr);
        }
        public override string QueryResult()
        {
            JsonModel jsonModel = new JsonModel();

            try
            {
                ParamModel paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);
                TF.RunSafty.BLL.Workshop          bllPlace  = new TF.RunSafty.BLL.Workshop();
                List <TF.RunSafty.Model.WorkShop> placeList = bllPlace.GetCheJianList("");
                jsonModel.result    = 0;
                jsonModel.resultStr = "提交成功";

                ArrayName an = new ArrayName();
                jsonModel.data   = an;
                an.ArrayWorkShop = 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 void TestConsumerStateChangeNotification()
        {
            // Consumer JobStateChange
            var env = new RPCEnvelope();
            var con = new JobStateChange();

            env.Message   = con;
            env.Operation = con.GetType().Name;
            con.Id        = Guid.NewGuid();
            con.Timestamp = DateTime.UtcNow;
            con.State     = "Setup";

            var iso = new Newtonsoft.Json.Converters.IsoDateTimeConverter();

            iso.DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK";

            string json = Newtonsoft.Json.JsonConvert
                          .SerializeObject(env, iso);

            // Orchestrator JobStateChange
            JToken token = JObject.Parse(json);
            String op    = (string)token.SelectToken("Operation");
            JToken msg   = token.SelectToken("Mesage");

            Assert.IsTrue(op == "JobStateChange");

            var serializer = new Newtonsoft.Json.JsonSerializer();

            Newtonsoft.Json.JsonReader reader = token["Message"].CreateReader();

            var job = serializer.Deserialize <JobStateChange>(reader);

            Assert.AreEqual(((JobStateChange)env.Message).State, job.State);
        }
        public JsonResult FilterData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string searchprm)
        {
            SearchFilter searchFilter = ScanTimeApprovalManager.SearchData(requestModel);
            ScanTimeApprovalSqlParameters parameters = new ScanTimeApprovalSqlParameters();
            var dateTimeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                DateTimeFormat = "dd/MM/yyyy"
            };
            SearchParams param = new SearchParams();

            if (!string.IsNullOrEmpty(searchprm))
            {
                param = JsonConvert.DeserializeObject <SearchParams>(searchprm, dateTimeConverter);
            }

            parameters.FromDate       = param.StartDate ?? SystemConfig.CurrentDate.AddDays(-30);
            parameters.ToDate         = param.EndDate ?? SystemConfig.CurrentDate;
            parameters.UserLoggedIn   = CustomerAuthorize.CurrentUser.EmployeeCode;
            parameters.ShowWaiting    = param.ShowMissing == "on";
            parameters.StartRow       = (requestModel.Start / requestModel.Length) + 1;
            parameters.EndRow         = requestModel.Length;
            parameters.OrderBy        = string.IsNullOrEmpty(searchFilter.OrderBy) ? "EmployeeNo" : searchFilter.OrderBy;
            parameters.OrderDirection = searchFilter.OrderDirection == "ASC" ? 1 : 0;
            parameters.FilterBy       = parameters.FilterBy = requestModel.Search.Value;
            parameters.ShowUnNoReg    = false;

            ScanTimeApprovalCollection collection = ScanTimeApprovalManager.GetAll(parameters);
            int totalRecord = 0;

            if (collection.Count > 0)
            {
                totalRecord = collection[0].TotalRecord;
            }
            return(Json(new DataTablesResponse(requestModel.Draw, collection, totalRecord, totalRecord), JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        /// <summary>
        /// 删除某条水情数据
        /// </summary>
        /// <param name="stationid"></param>
        /// <param name="time"></param>
        public static void DeleteHourWater(string stationid, DateTime time)
        {
            water v = new water {
                stationid = stationid, datatime = time
            };
            List <water> listWater = new List <water>();

            listWater.Add(v);
            Dictionary <string, object> param = new Dictionary <string, object>();
            //string suffix = "user/updateUser";
            string url = suffix + "/water/deleteWater";

            //string url = "http://127.0.0.1:8088/water/deleteWater";
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(listWater, Newtonsoft.Json.Formatting.None, timeConverter);

            param["water"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
            }
            catch (Exception e)
            {
                Debug.Print(e.Message + "数据库保存失败");
            }
            //using (LNRRDB ln = new LNRRDB())
            //{
            //    water w = new water();
            //    w = ln.water.First(i => (i.stationid) == stationid && i.datatime == time);
            //    ln.water.Remove(w);
            //    ln.SaveChanges();
            //}
        }
Beispiel #8
0
        private string getJsonQueryCarData(string key, string CID)
        {
            string r = "";

            //string strCid = "";
            try
            {
                ComSqlHelper   oSqlUtil = new ComSqlHelper();
                SqlParameter[] oaPara;

                //参数构建
                oaPara    = new SqlParameter[2];
                oaPara[0] = new SqlParameter("@cid", CID);
                //oaPara[1] = new SqlParameter("@cid", CID);
                DataTable dt = new DataTable();
                dt = oSqlUtil.FillDataSet(key, "JLJGPT_CarInforCarDataSelect", oaPara, "CarData", 30).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                    timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
                    r = JsonConvert.SerializeObject(dt, timeConverter);
                }
            }
            catch (Exception)
            {
                r = "";
            }
            return(r);
        }
Beispiel #9
0
        private string getJsonQueryRourt(string key)
        {
            string r = "";

            //string strCid = "";
            try
            {
                ComSqlHelper   oSqlUtil = new ComSqlHelper();
                SqlParameter[] oaPara;

                //参数构建
                oaPara = new SqlParameter[0];

                DataTable dt = new DataTable();
                dt = oSqlUtil.FillDataSet(key, "QSProc_GetQsLine", oaPara, "RourtData", 30).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                    timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
                    r = JsonConvert.SerializeObject(dt, timeConverter);
                }
            }
            catch (Exception)
            {
                r = "";
            }
            return(r);
        }
Beispiel #10
0
        public ActionResult GetThemeList(int id)
        {
            string key      = HCRequest.GetString("key");
            string weixinid = "";//酒店微信id

            if (!key.Equals("") && key.Contains("@"))
            {
                weixinid = key.Split('@')[0];//酒店微信id
            }

            int    curpage   = HCRequest.getInt("page");    //
            int    pagesize  = HCRequest.getInt("pagesize");
            int    sort      = HCRequest.getInt("sort");    //距离,价格高低 排序
            string themetype = HCRequest.GetString("type"); //多个类型逗号隔开
            string endcity   = HCRequest.GetString("cityname");
            string keyworks  = HCRequest.GetString("keyworks");



            List <LXS_ThemeView> listTheme = TravelThemeLogic.GetThemeList(weixinid, curpage, pagesize, sort, themetype, endcity, keyworks);

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeFormat = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listTheme, timeFormat);

            return(Json(
                       new
            {
                success = true,
                msg = strJson,
                nextpage = listTheme.Count == pagesize ? curpage + 1 : curpage
            }
                       ));
        }
Beispiel #11
0
        /// <summary>
        /// 修改某条电压数据
        /// </summary>
        /// <param name="stationid"></param>
        /// <param name="time"></param>
        /// <param name="value"></param>
        public static void AlterHourVoltage(string stationid, DateTime time, decimal value)
        {
            voltage v = new voltage {
                stationid = stationid, datatime = time, data = value
            };
            List <voltage> listVoltage = new List <voltage>();

            listVoltage.Add(v);
            Dictionary <string, object> param = new Dictionary <string, object>();
            //string suffix = "user/updateUser";
            string url = suffix + "/voltage/updateVoltage";

            //string url = "http://127.0.0.1:8088/voltage/updateVoltage";
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(listVoltage, Newtonsoft.Json.Formatting.None, timeConverter);

            param["voltage"] = jsonStr;
            try
            {
                string resultJson = HttpHelper.Post(url, param);
            }
            catch (Exception e)
            {
                Debug.Print(e.Message + "数据库保存失败");
            }
            //using (LNRRDB ln = new LNRRDB())
            //{
            //    voltage v = new voltage();
            //    v = ln.voltage.First(i => (i.stationid) == stationid && i.datatime == time);
            //    v.data = value;
            //    ln.SaveChanges();
            //}
        }
Beispiel #12
0
        public ActionResult GetMyThemeList(int id)
        {
            string key      = HCRequest.GetString("key");
            string weixinid = "";//酒店微信id
            string uwx      = "";

            if (!key.Equals("") && key.Contains("@"))
            {
                weixinid = key.Split('@')[0];//酒店微信id
                uwx      = key.Split('@')[1];
            }

            int curpage  = HCRequest.getInt("page");//
            int pagesize = HCRequest.getInt("pagesize");

            List <LXS_ThemeView> listTheme = TravelThemeLogic.GetMyThemeList(uwx, curpage, pagesize);

            Newtonsoft.Json.Converters.IsoDateTimeConverter timeFormat = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeFormat.DateTimeFormat = "yyyy-MM-dd";//"yyyy-MM-dd HH:mm:ss";
            string strJson = Newtonsoft.Json.JsonConvert.SerializeObject(listTheme, timeFormat);

            return(Json(
                       new
            {
                success = true,
                msg = strJson,
                nextpage = listTheme.Count == pagesize ? curpage + 1 : curpage
            }
                       ));
        }
Beispiel #13
0
        public override string QueryResult()
        {
            JsonModel  model   = new JsonModel();
            ParamModel p       = new ParamModel();
            DataTable  table   = null;
            DataTable  tblFile = null;
            ParamModel param   = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);

            this.clientid = param.cid;
            TF.RunSafty.BLL.TAB_FileGroup bllFileGroup = new TF.RunSafty.BLL.TAB_FileGroup();
            TF.RunSafty.BLL.TAB_ReadDoc   bllFile      = new TF.RunSafty.BLL.TAB_ReadDoc();
            try
            {
                table           = bllFileGroup.GetAllList().Tables[0];
                tblFile         = bllFile.GetAllListWithFileType(clientid).Tables[0];
                model.result    = "0";
                model.returnStr = "返回成功";
                model.TypeList  = table;
                model.FileList  = tblFile;
            }
            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";
            string result = Newtonsoft.Json.JsonConvert.SerializeObject(model, timeConverter).Replace(":null", ":\"\"");

            return(result);
        }
        /// <summary>
        /// 用于实体操作记录日志
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <param name="logType"></param>
        /// <param name="operUser"></param>
        public static void AddLogInfo <T>(T entity, Infrastructure.Crosscutting.Function.LoggerType logType,
                                          iPow.Infrastructure.Data.DataSys.Sys_AdminUser operUser)
        {
            if (entity != null)
            {
                var log = new DataSys.Sys_AdminUserLog();

                log.AddTime     = System.DateTime.Now;
                log.IpAddress   = Infrastructure.Crosscutting.Function.StringHelper.GetRealIP();
                log.PageUrl     = Infrastructure.Crosscutting.Function.StringHelper.GetCurrentUrl();
                log.ReferrerUrl = Infrastructure.Crosscutting.Function.StringHelper.GetReferrerUrl();
                log.State       = true;
                if (operUser != null)
                {
                    log.UserId = operUser.id;
                }
                log.TypeId       = (int)logType;
                log.ShortMessage = logType.ToString() + " " + entity.GetType().Name;
                Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
                timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(entity, Newtonsoft.Json.Formatting.Indented, timeConverter);
                log.FullMessage = json;
                AddLogInfo(log);
            }
        }
Beispiel #15
0
        public JsonModel Getsignplanlist(string input)
        {
            JsonModel jsonModel = new JsonModel();

            try
            {
                ParamModel             paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(input);
                Bll_Plan_Rest          bllPlace   = new Bll_Plan_Rest();
                List <Modal_Plan_Rest> placeList  = bllPlace.GetPlanTrain(paramModel.dtStartTime, paramModel.dtEndTime, paramModel.strJiaoluGUID);
                jsonModel.result    = 0;
                jsonModel.resultStr = "提交成功";
                planArrays p = new planArrays();
                jsonModel.data       = p;
                p.strTrainJiaoLuGUID = paramModel.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(jsonModel);
        }
Beispiel #16
0
 public static string GetJsonString(object obj)
 {
     Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
     //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
     timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     return(Newtonsoft.Json.JsonConvert.SerializeObject(obj, Newtonsoft.Json.Formatting.None, timeConverter));
 }
Beispiel #17
0
        /// <summary>
        /// 发送手机验证码
        /// </summary>
        /// <param name="vercode"></param>
        /// <param name="sim"></param>
        /// <returns></returns>
        public static string SendSmsVerCode(string vercode, string sim)
        {
            PushRequestModel ds = new PushRequestModel();

            ds.projectid  = 30001;
            ds.sequ       = DateTime.Now.Second;
            ds.serviceid  = 20002;
            ds.tosystemid = 20003;
            SmsCodeModel sc = new SmsCodeModel();

            sc.vercode = vercode;
            sc.sim     = sim;
            ds.para    = sc;
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss";
            string strReq = JsonConvert.SerializeObject(ds, timeConverter);
            int    resss  = SendSMSToPhone(strReq);


            if (resss == 200)
            {
                return("");
            }
            else
            {
                LogHelper.WriteInfo("SmsSend:Req " + strReq, false, true);
                LogHelper.WriteInfo("SmsSend:Resp " + resss, false, true);
                return(resss.ToString());
            }
        }
Beispiel #18
0
        public string GetOrderGroups(string data)
        {
            JsonModel jsonModel = new JsonModel();

            TF.Api.Utilities.Validation validater = new TF.Api.Utilities.Validation();
            try
            {
                OrderGroupQuery paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <OrderGroupQuery>(data);
                //验证数据正确性,非空字段不能为空
                if (validater.IsNotNullPropertiesValidated(paramModel.data))
                {
                    string        jiaoluID   = paramModel.data.trainmanjiaoluID;
                    List <string> placeIDs   = new List <string>();
                    string        trainmanID = paramModel.data.trainmanID;
                    placeIDs.AddRange(paramModel.data.placeID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                    List <OrderGroup> groups = this.GetOrderGroups(jiaoluID, placeIDs, trainmanID);
                    jsonModel.data      = groups;
                    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";
            string result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter);

            return(result);
        }
Beispiel #19
0
        public override string QueryResult()
        {
            JsonModel jsonModel = new JsonModel();

            try
            {
                PlanSign paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <PlanSign>(this.Data);

                TF.RunSafty.BLL.Tab_Plan_Rest bllPlace = new TF.RunSafty.BLL.Tab_Plan_Rest();
                string strJiaoLu = "";
                foreach (TF.RunSaftyAPI.App_Api.Public.IGetPlanRestByWorkShopAndTime.JiaoLu JiaoLuId in paramModel.data.JiaoLuAry)
                {
                    strJiaoLu += "'" + JiaoLuId.strTrainJiaoLuGUID + "',";
                }
                strJiaoLu = strJiaoLu.Substring(0, strJiaoLu.Length - 1);
                List <TF.RunSafty.Model.TAB_Plan_Rest> placeList = bllPlace.GetPlanListByTimeAndWorkShop(strJiaoLu, paramModel.data.dtStartTime, paramModel.data.dtEndTime);
                jsonModel.result    = 0;
                jsonModel.resultStr = "提交成功";
                ArrayName an = new ArrayName();
                jsonModel.data = an;
                an.signplanary = 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));
        }
Beispiel #20
0
        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var response = context.HttpContext.Response;

            if (!string.IsNullOrWhiteSpace(this.ContentType))
            {
                response.ContentType = this.ContentType;
            }
            else
            {
                response.ContentType = "application/json";
            }

            if (this.ContentEncoding != null)
            {
                response.ContentEncoding = this.ContentEncoding;
            }

            if (this.Data != null)
            {
                var timeFormat = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                var json = Newtonsoft.Json.JsonConvert.SerializeObject(Data, Newtonsoft.Json.Formatting.Indented, timeFormat);
                response.Write(json);
            }
        }
            public override void ExecuteResult(ControllerContext context)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }

                if (this.JsonRequestBehavior == JsonRequestBehavior.DenyGet &&
                    String.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
                {
                    throw new InvalidOperationException("GET not allowed! Change JsonRequestBehavior to AllowGet.");
                }

                var response = context.HttpContext.Response;

                response.ContentType = String.IsNullOrEmpty(this.ContentType) ? "application/json" : this.ContentType;

                if (this.ContentEncoding != null)
                {
                    response.ContentEncoding = this.ContentEncoding;
                }

                if (Data != null)
                {
                    // Using Json.NET serializer
                    var          isoConvert  = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                    const string _dateFormat = "dd/MM/yyyy HH:mm:ss";
                    isoConvert.DateTimeFormat = _dateFormat;
                    response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(Data, isoConvert));
                }
            }
Beispiel #22
0
        public string Getsignplanlistbyjiaoluary(string input)
        {
            OutJsonModel jsonModel = new OutJsonModel();

            try
            {
                TrainmanData paramModel = Newtonsoft.Json.JsonConvert.DeserializeObject <TrainmanData>(input);

                Bll_Plan_Rest bllPlace  = new Bll_Plan_Rest();
                string        strJiaoLu = "";
                foreach (JiaoLu JiaoLuId in paramModel.JiaoLuAry)
                {
                    strJiaoLu += "'" + JiaoLuId.strTrainJiaoLuGUID + "',";
                }
                strJiaoLu = strJiaoLu.Substring(0, strJiaoLu.Length - 1);
                List <Modal_Plan_Rest> placeList = bllPlace.GetPlanListByTimeAndWorkShop(strJiaoLu, paramModel.dtStartTime, paramModel.dtEndTime);
                jsonModel.result    = 0;
                jsonModel.resultStr = "提交成功";
                ArrayName an = new ArrayName();
                jsonModel.data = an;
                an.signplanary = 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));
        }
Beispiel #23
0
        public override string QueryResult()
        {
            JsonModel  jsonModel = new JsonModel();
            ParamModel param     = Newtonsoft.Json.JsonConvert.DeserializeObject <ParamModel>(this.Data);

            TF.RunSafty.Logic.MonthWorkTimeBLL bllWorkTime = new TF.RunSafty.Logic.MonthWorkTimeBLL();
            int       nTotalWorkCount = 0;
            decimal   ntotalMinutes   = 0m;
            DataTable table           = null;

            try
            {
                table = bllWorkTime.GetWorkTimeByTrainman(param.strTrainmanGUID, param.dtBeginTime, param.dtEndTime);
                if (table != null)
                {
                    nTotalWorkCount = table.Rows.Count;
                    ntotalMinutes   = Convert.ToDecimal(table.Compute("sum(fTotalTime)", ""));
                }
                jsonModel.Detail          = table;
                jsonModel.ntotalMinutes   = ntotalMinutes.ToString();
                jsonModel.nTotalWorkCount = nTotalWorkCount.ToString();
            }
            catch (Exception ex)
            {
                TF.CommonUtility.LogClass.logex(ex, "");
            }
            jsonModel.result    = "0";
            jsonModel.resultStr = "返回成功";
            Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
            //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            string result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonModel, timeConverter).Replace(":null", ":\"\"");

            return(result);
        }
Beispiel #24
0
        public string GetContact(int con_id)
        {
            var current  = 1;
            var rowCount = 10;

            try
            {
                var count = 0;
                Dictionary <string, object> contact =
                    CustomerService.GetContact(Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_NUM].ToString(), con_id);

                Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter =
                    new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                var contacts = JsonConvert.SerializeObject(contact, timeConverter); //quoOdrs 是对象集合
                //利用IsoDateTimeConverter这个类设置日期格式就可以了。
                return(contacts);
            }
            catch (Exception ex)
            {
                LogHelper.Error("用户id为" + Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_ID].ToString() +
                                "的用户获取联系人信息失败", ex);
                return("{\"Rows\":[],\"Total\":\"0\"}");
            }
        }
Beispiel #25
0
        public static bool TryParse(string json, out Contract contract)
        {
            try
            {
                var conv = new Newtonsoft.Json.Converters.IsoDateTimeConverter();

                var set = new JsonSerializerSettings
                {
                    TypeNameHandling           = TypeNameHandling.Auto,
                    NullValueHandling          = NullValueHandling.Ignore,
                    ReferenceLoopHandling      = ReferenceLoopHandling.Serialize,
                    PreserveReferencesHandling = PreserveReferencesHandling.Objects,
                    DateFormatHandling         = DateFormatHandling.MicrosoftDateFormat,
                    Formatting = Formatting.Indented
                };

                set.Converters.Add(conv);

                contract = JsonConvert.DeserializeObject <Contract>(json, set);

                return(true);
            }
            catch (Exception e)
            {
                contract = null;
                return(false);
            }
        }
Beispiel #26
0
        /// <summary>
        /// 作者:王赟
        /// 时间:2014-12-18
        /// 描述:重载GetJsonResult方法,添加时间格式参数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <param name="root"></param>
        /// <param name="time">
        /// </param>
        /// <param name="totalCount"></param>
        /// <returns></returns>
        public static ContentResult GetJsonResult <T>(IEnumerable <T> list, string root, string time, int?totalCount) where T : new()
        {
            StringBuilder builder = new StringBuilder("{");

            //[{"id":1},{"id":2}]
            var dateTime = new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                DateTimeFormat = time
            };
            string json = JsonConvert.SerializeObject(list, Formatting.Indented, dateTime);

            builder.AppendFormat("\"{0}\":\"{1}\",", STATUS, STATUS_TRUE);
            builder.AppendFormat("\"{0}\":\"{1}\",", MSG, MSG_OK);
            if (totalCount == null)
            {
                builder.AppendFormat("\"{0}\":\"\",", TOTAL);
            }
            else
            {
                builder.AppendFormat("\"{0}\":{1},", TOTAL, totalCount);
            }
            builder.AppendFormat("\"{0}\":{1}", root, json);
            builder.Append("}");

            return(ContentResult(builder));
        }
Beispiel #27
0
 private string getJson(object rg)
 {
     Newtonsoft.Json.Converters.IsoDateTimeConverter isoDateTimeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
     //设置日期格式
     isoDateTimeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
     //序列化
     return(JsonConvert.SerializeObject(rg, isoDateTimeConverter));
 }
Beispiel #28
0
        public static string ToJson(this object obj, string datetimeformats)
        {
            var timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                DateTimeFormat = datetimeformats
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(obj, timeConverter));
        }
Beispiel #29
0
        public static string ToJson(this object obj)
        {
            var timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
            };

            return(Newtonsoft.Json.JsonConvert.SerializeObject(obj, timeConverter));
        }
Beispiel #30
0
        /// <summary>序列化</summary>
        /// <param name="obj">object </param>
        /// <returns></returns>
        public static string ToJson(object obj)
        {
            var idtc = new Newtonsoft.Json.Converters.IsoDateTimeConverter {
                DateTimeFormat = "yyyy-MM-dd hh:mm:ss"
            };

            return(JsonConvert.SerializeObject(obj, idtc));
        }
Beispiel #31
0
 public string GetAllMember()
 {
     IMemberService tmpService = UnityHelper.UnityResolve<IMemberService>();
     var data = tmpService.GetMemberByQueryList(InitQueryEntity());
     Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter();
     timeConverter.DateTimeFormat = ConstUtils.CONST_SHOW_DATE_FORMAT;
     var tmpdata = JsonConvert.SerializeObject(data.Tables[2], timeConverter);
     var result = "{\"total\":" + data.Tables[1].Rows[0]["TotalRecordsCount"].ToString() + ",\"rows\":" + tmpdata + " }";
     return result;
 }
Beispiel #32
0
    public static string JsonEncode(this object o)
    {
        string DateTimeFormat = "yyyy-MM-dd HH:mm:ss";

        if (o == null)
        {
            return null;
        }
        if ((o != null) && ((o.GetType() == typeof(string)) || (o.GetType() == typeof(string))))
        {
            return o.ToString();
        }

        Newtonsoft.Json.Converters.IsoDateTimeConverter converter = new Newtonsoft.Json.Converters.IsoDateTimeConverter
        {
            DateTimeFormat = DateTimeFormat
        };

        return Newtonsoft.Json.JsonConvert.SerializeObject(o, new Newtonsoft.Json.JsonConverter[] { converter });
    }
        public string GetContact(int con_id)
        {
            var current = 1;
            var rowCount = 10;

            try
            {
                var count = 0;
                Dictionary<string, object> contact =
                    CustomerService.GetContact(Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_NUM].ToString(), con_id);

                Newtonsoft.Json.Converters.IsoDateTimeConverter timeConverter =
                    new Newtonsoft.Json.Converters.IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                var contacts = JsonConvert.SerializeObject(contact, timeConverter); //quoOdrs 是对象集合
                //利用IsoDateTimeConverter这个类设置日期格式就可以了。
                return contacts;
            }
            catch (Exception ex)
            {
                LogHelper.Error("用户id为" + Session[teaCRMKeys.SESSION_USER_COMPANY_INFO_ID].ToString() +
                                "的用户获取联系人信息失败", ex);
                return "{\"Rows\":[],\"Total\":\"0\"}";
            }
        }
Beispiel #34
0
        protected string GetData()
        {
            #region
            dynamic stu1 = new ExpandoObject();
            stu1.sid = "STU2014082201";
            stu1.name = "STU1";
            stu1.sex = "0";
            stu1.grade = "初一";
            stu1.className = "一(1)班";
            stu1.brithday = new DateTime(2000, 1, 1);
            stu1.remark = "";

            dynamic stu2 = new ExpandoObject();
            stu2.sid = "STU2014082202";
            stu2.name = "STU2";
            stu2.sex = "1";
            stu2.grade = "初一";
            stu2.className = "一(1)班";
            stu2.brithday = new DateTime(1999, 6, 7);
            stu2.remark = "";

            dynamic stu3 = new ExpandoObject();
            stu3.sid = "STU2014082203";
            stu3.name = "STU3";
            stu3.sex = "0";
            stu3.grade = "初一";
            stu3.className = "一(1)班";
            stu3.brithday = new DateTime(2001, 2, 10);
            stu3.remark = "";

            dynamic stu4 = new ExpandoObject();
            stu4.sid = "STU2014082204";
            stu4.name = "STU4";
            stu4.sex = "1";
            stu4.grade = "初一";
            stu4.className = "一(2)班";
            stu4.brithday = new DateTime(1998, 7, 7);
            stu4.remark = "";

            dynamic stu5 = new ExpandoObject();
            stu5.sid = "STU2014082206";
            stu5.name = "STU6";
            stu5.sex = "1";
            stu5.grade = "初二";
            stu5.className = "二(1)班";
            stu5.brithday = new DateTime(2000, 5, 1);
            stu5.remark = "";
            #endregion

            dynamic stu6 = new ExpandoObject();
            stu6.sid = "STU2014082206";
            stu6.name = "STU6";
            stu6.sex = "0";
            stu6.grade = "初二";
            stu6.className = "二(1)班";
            stu6.brithday = new DateTime(2000, 6, 12);
            stu6.remark = "";

            dynamic stu7 = new ExpandoObject();
            stu7.sid = "STU2014082207";
            stu7.name = "STU7";
            stu7.sex = "1";
            stu7.grade = "初二";
            stu7.className = "二(1)班";
            stu7.brithday = new DateTime(1999, 7, 8);
            stu7.remark = "";

            dynamic stu8 = new ExpandoObject();
            stu8.sid = "STU2014082208";
            stu8.name = "STU8";
            stu8.sex = "0";
            stu8.grade = "初二";
            stu8.className = "二(2)班";
            stu8.brithday = new DateTime(2001, 10, 15);
            stu8.remark = "";

            dynamic stu9 = new ExpandoObject();
            stu9.sid = "STU2014082209";
            stu9.name = "STU9";
            stu9.sex = "0";
            stu9.grade = "初二";
            stu9.className = "二(2)班";
            stu9.brithday = new DateTime(2002, 8, 8);
            stu9.remark = "";

            dynamic stu10 = new ExpandoObject();
            stu10.sid = "STU2014082210";
            stu10.name = "STU10";
            stu10.sex = "0";
            stu10.grade = "初三";
            stu10.className = "三(1)班";
            stu10.brithday = new DateTime(2000, 12, 1);
            stu10.remark = "";

            dynamic stu11 = new ExpandoObject();
            stu11.sid = "STU2014082211";
            stu11.name = "STU11";
            stu11.sex = "0";
            stu11.grade = "初三";
            stu11.className = "三(1)班";
            stu11.brithday = new DateTime(1998, 7, 7);
            stu11.remark = "";

            dynamic stu12 = new ExpandoObject();
            stu12.sid = "STU2014082212";
            stu12.name = "STU12";
            stu12.sex = "1";
            stu12.grade = "初三";
            stu12.className = "三(1)班";
            stu12.brithday = new DateTime(1999, 7, 8);
            stu12.remark = "";

            dynamic stu13 = new ExpandoObject();
            stu13.sid = "STU2014082213";
            stu13.name = "STU13";
            stu13.sex = "0";
            stu13.grade = "初三";
            stu13.className = "三(1)班";
            stu13.brithday = new DateTime(1998, 7, 7);
            stu13.remark = "";

            dynamic stu14 = new ExpandoObject();
            stu14.sid = "STU2014082214";
            stu14.name = "STU114";
            stu14.sex = "1";
            stu14.grade = "初三";
            stu14.className = "三(2)班";
            stu14.brithday = new DateTime(2000, 3, 5);
            stu14.remark = "";

            dynamic stu15 = new ExpandoObject();
            stu15.sid = "STU2014082215";
            stu15.name = "STU15";
            stu15.sex = "1";
            stu1.grade = "初三";
            stu15.className = "三(2)班";
            stu15.brithday = new DateTime(1999, 12, 1);
            stu15.remark = "";

            dynamic reslut = new ExpandoObject();
            reslut.total = 100;
            reslut.rows = new[]
            {
                stu1,stu2,stu3,stu4,stu5,
                stu6,stu7,stu8,stu9,stu10,
                stu11,stu12,stu13,stu14,stu15
            };

            var timeConvert = new Newtonsoft.Json.Converters.IsoDateTimeConverter
            {
                DateTimeFormat = "yyyy-MM-dd"
            };
            return Newtonsoft.Json.JsonConvert.SerializeObject(reslut, timeConvert);
        }
Beispiel #35
0
        ///Get Customer Data
        public ActionResult GetCustomerVisitDetailData(string id)
        {
            CustomerVisitManager CustomerVisitEntity = null;
            string sSql = "SELECT * FROM SGP_CustomerVisit WHERE ID = @ID";
            DataTable dt = DbHelperSQL.Query(sSql, new SqlParameter("@ID", id)).Tables[0];
            if (dt.Rows.Count > 0)
            {
                CustomerVisitEntity = ModelHandler<CustomerVisitManager>.FillModel(dt.Rows[0]);
            }

            var dateConverter = new Newtonsoft.Json.Converters.IsoDateTimeConverter { DateTimeFormat = "MM/dd/yyyy" };
            ViewData["json"] = Newtonsoft.Json.JsonConvert.SerializeObject(CustomerVisitEntity, dateConverter);

            return Content(Convert.ToString(ViewData["json"]), "application/json");
        }