public NewErrorModel DownloadFileModel(DownloadFileModel downloadFileModel) { try { using (DDContext context = new DDContext()) { string url = string.Empty; if (ConfigurationManager.AppSettings["hao"].ToString() == "2") { url = "17e245o364.imwork.net:49415"; } else { url = System.Web.HttpContext.Current.Request.Url.Authority; } //生成下载链接 string downLoadLink = string.Format("{0}/ProjectNew/DownLoad?path=~/{1}", url, downloadFileModel.path); //推送盯盘下载链接 return(new NewErrorModel() { data = downLoadLink, error = new Error(0, "请复制链接到浏览器中下载!", "1") { }, }); } } catch (Exception ex) { throw ex; } }
public NewErrorModel DownloadFileModel(DownloadFileModel downloadFileModel) { try { using (DDContext context = new DDContext()) { //查找MediaId //FileInfos fileInfo = context.FileInfos.Where(f => f.FilePath == downloadFileModel.path).First(); //string mediaId = fileInfo.MediaId; //if (string.IsNullOrEmpty(mediaId)) //{ string url = string.Empty; if (ConfigurationManager.AppSettings["hao"].ToString() == "2") { url = "17e245o364.imwork.net:49415"; } else { url = System.Web.HttpContext.Current.Request.Url.Authority; } //生成下载链接 string downLoadLink = string.Format("{0}/ProjectNew/DownLoad?path=~/{1}", url, downloadFileModel.path); //推送盯盘下载链接 return(new NewErrorModel() { data = downLoadLink, error = new Error(0, "请复制链接到浏览器中下载!", "1") { }, }); //} //else //{ // DingTalkServersController dingTalkServersController = new DingTalkServersController(); // FileSendModel fileSendModel = new FileSendModel() // { // Media_Id = mediaId, // UserId = downloadFileModel.userId // }; // string result = await dingTalkServersController.SendFileMessage(fileSendModel); // return new NewErrorModel() // { // data = result, // error = new Error(0, "已推送至钉钉工作通知中!", "0") { }, // }; //} } } catch (Exception ex) { return(new NewErrorModel() { error = new Error(2, ex.Message, "") { }, }); } }