Esempio n. 1
0
        public ActionResult saveDataBase()
        {
            helper.DBReturnCode code = helper.DBReturnCode.NOT_EXIST;
            try
            {
                int         uID       = int.Parse(Request.Params.Get("UID"));
                string      stationID = Request.Params.Get("stationID");
                bool        rtype     = Request.Params.Get("ReportType") == "Rain" ? true : false;
                bool        trans     = Request.Params.Get("TransType") == "ByDay" ? true : false;
                string      stime     = Request.Params.Get("startTime");
                string      etime     = Request.Params.Get("endTime");
                BatchList   record    = BatchService.FindBatchRecord(uID);
                List <rain> rainList  = new List <rain>();
                for (int i = 0; i < record.Bdata.Count; i++)
                {
                    rainList.Add(new rain
                    {
                        //stationid = record.Bdata[i].
                    });
                }
                //TODO:暂时搁置
                //code = DAL.RainService.SaveBatchData(record);
            }
            catch (Exception)
            {
                return(Json(helper.DBHelper.SerializeDBReturnCode(helper.DBReturnCode.BAD_REQUEST), JsonRequestBehavior.AllowGet));
            }

            string json = helper.DBHelper.SerializeDBReturnCode(code);

            return(Json(json, JsonRequestBehavior.AllowGet));
        }
Esempio n. 2
0
        //GET:/export/saveText
        public FileResult saveText()
        {
            string appendix, content = "";

            try
            {
                int uID = int.Parse(Request.Params.Get("UID"));

                BatchList record = BatchService.FindBatchRecord(uID);
                content += "站号:" + record.StationId +
                           "/t站类:" + (record.SType == 0 ? "雨量站" : "水情站") +
                           "/t传输方式:" + (record.TType == BatchList.Types.transType.Byday ? "按日传输" : "按小时传输") +
                           "/n/n返回信息:" + record.RawInfo +
                           "/n";

                foreach (var temp in record.Bdata)
                {
                    content += "/n" + temp.BatchTime + " : " + temp.BatchValue;
                }

                content += "/n/n";

                //文件后缀名。可以用不同的方法名区分,也可以作为一个参数输入。
                appendix = "txt";
            }
            catch (Exception)
            {
                return(null);
            }
            //返回结果
            byte[] data = Encoding.UTF8.GetBytes(content);
            return(File(data, "text/plain", "批量传输" + "." + appendix));
        }