金山文档服务器暂不可用,wps金山文档在线编辑--.Net 接入指南

///

///获取文件元数据///

///

[Route("v1/3rd/file/info")]

[HttpGet]public JsonResult info(string _w_signature,string_w_appid)

{var res = newJsonResult();

response_wpsModel wpsModel= newresponse_wpsModel();

userModel user= newuserModel();

user.id= "576590854";

user.name= "kls-dev";

//用户权限

user.permission= "write";

user.avatar_url= "http://XXXXX.com/图片20180813135932.jpg";

fileModel f= newfileModel();

//文件主键,要确保唯一

f.id= "id2019110609261";

f.name= "文件名.xlsx";

f.version= 1;

f.size= 200;

f.creator=user.name;

f.create_time= long.Parse(TimeHelper.GetCurrentTimestamp(false));

f.modifier=user.name;

f.modify_time=long.Parse(TimeHelper.GetCurrentTimestamp(false)) ;

//文件的云地址

f.download_url= "";

user_aclModel acl= newuser_aclModel();

acl.rename= 1;

acl.history= 1;

f.user_acl=acl;

f.watermark=newwatermarkModel();

wpsModel.file=f;

wpsModel.user=user;returnJson(wpsModel,JsonRequestBehavior.AllowGet);

}

//补充时间戳帮助类

///

/// 时间相关

///

public static class TimeHelper

{

///

/// 获取当前时间戳

///

/// 精度(毫秒)设置 true,则生成13位的时间戳;精度(秒)设置为 false,则生成10位的时间戳;默认为 true

///

public static string GetCurrentTimestamp(bool millisecond = true)

{

return DateTime.Now.ToTimestamp(millisecond);

}

///

/// 转换指定时间得到对应的时间戳

///

///

/// 精度(毫秒)设置 true,则生成13位的时间戳;精度(秒)设置为 false,则生成10位的时间戳;默认为 true

/// 返回对应的时间戳

public static string ToTimestamp(this DateTime dateTime, bool millisecond = true)

{

return dateTime.ToTimestampLong(millisecond).ToString();

}

///

/// 转换指定时间得到对应的时间戳

///

///

/// 精度(毫秒)设置 true,则生成13位的时间戳;精度(秒)设置为 false,则生成10位的时间戳;默认为 true

/// 返回对应的时间戳

public static long ToTimestampLong(this DateTime dateTime, bool millisecond = true)

{

var ts = dateTime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);

return millisecond ? Convert.ToInt64(ts.TotalMilliseconds) : Convert.ToInt64(ts.TotalSeconds);

}

///

/// 转换指定时间戳到对应的时间

///

/// (10位或13位)时间戳

/// 返回对应的时间

public static DateTime ToDateTime(this string timestamp)

{

var tz = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1, 0, 0, 0, 0));

return timestamp.Length == 13

? tz.AddMilliseconds(Convert.ToInt64(timestamp))

: tz.AddSeconds(Convert.ToInt64(timestamp));

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值