예제 #1
0
        protected string GetTime(string timeStamp)
        {
            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            long     lTime   = long.Parse(timeStamp + "0000000");
            TimeSpan toNow   = new TimeSpan(lTime);

            return(FormatUtils.DatetimeToString(dtStart.Add(toNow)));
        }
예제 #2
0
        //上传二进制数据(文件 )  图片  语音 等 如果是视频需要两次上传(发送之前还需要上传一次)
        public override string InsertData(out string msg, HttpContext context = null)
        {
            if (type == "text")
            {
            }
            method = "POST";
            Url    = "http://file.api.weixin.qq.com/cgi-bin/media/upload?access_token=" + Token + "&type=" + type;
            //设置buffer  获取上传文件的字节流
            msg = "";
            string wxstring = "";
            //如果是素材库,就不再使用此函数
            bool isEND = GetBuffer(out msg, context);

            if (isEND)
            {
                wxstring = WXRequestString(out msg, context);
            }
            else if (msg == "")
            {
                return("分块上传完成");
            }
            else if (msg != "")
            {
                return(msg);
            }
            //this.SearchData(out msg);

            buffer = new List <Byte[]>();//清空数据

            WX_Media media = JsonConvert.DeserializeObject <WX_Media>(wxstring);

            media.filename = filename;//记录保存到本地的文件名
            media.cjsj     = GetTime(media.created_at);
            DateTime dt = FormatUtils.ParseDatetimeString(media.cjsj);

            dt        = dt.AddDays(3);//只保存在服务器上三天
            media.yxq = FormatUtils.DatetimeToString(dt);

            if (media.created_at != "")
            {
                return(JsonConvert.SerializeObject(media));
            }
            return("上传失败");
        }
예제 #3
0
 public static string GetDbServerTimeStr(DbCommand cmd)
 {
     return(FormatUtils.DatetimeToString(GetDbServerTime(cmd)));
 }