public bool GetShareSettings( Guid transactionid, Guid userid, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; string funname = "GetShareSettings"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); ShareSettingsInfo ssi = new ShareSettingsInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); result = Provider.GetShareSettings(transactionid, userid, ref ssi, out error); if (result == true) { resultinfo.data = ssi; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }
public bool Share( Guid transactionid, Guid userid, List <BigFileItemInfo> infolist, out string strJsonResult) { bool result = true; strJsonResult = string.Empty; ErrorCodeInfo error = new ErrorCodeInfo(); string paramstr = string.Empty; paramstr += $"userid:{userid}"; foreach (BigFileItemInfo bi in infolist) { paramstr += $"||ID:{bi.ID}"; } string funname = "Share"; try { do { AttachResultInfo resultinfo = new AttachResultInfo(); BigAttachDBProvider Provider = new BigAttachDBProvider(); ShareSettingsInfo ssi = new ShareSettingsInfo(); result = Provider.GetShareSettings(transactionid, userid, ref ssi, out error); if (result == false) { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } string template = ssi.ShareNotificationTemplate; string filestr = string.Empty; for (int i = 0; i < infolist.Count; i++) { BigFileItemInfo info = infolist[i]; result = Provider.GetFileByID(transactionid, userid, ref info, out error); if (result == true) { filestr += $"<span>{info.FileName}<br /></span>"; } } template = template.Replace("{filename}", filestr); ShareInfo si = new ShareInfo(); result = Provider.AddShare(transactionid, userid, ref si, out error); if (result == false) { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; break; } template = template.Replace("{exptime}", si.ExpireTime.ToString("yyyy-MM-dd")); template = template.Replace("{url}", si.ShortUrl); template = template.Replace("{validatecode}", si.ValCode); if (result == true) { for (int i = 0; i < infolist.Count; i++) { BigFileItemInfo info = infolist[i]; result = Provider.AddShareFile(transactionid, si.ShareID, info.ID, out error); } resultinfo.data = template; JsonSerializerSettings jsetting = new JsonSerializerSettings(); jsetting.StringEscapeHandling = StringEscapeHandling.EscapeHtml; strJsonResult = JsonConvert.SerializeObject(resultinfo); LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), true, transactionid); result = true; break; } else { resultinfo.data = false; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); result = false; } } while (false); } catch (Exception ex) { error.Code = ErrorCode.Exception; LoggerHelper.Info(userid.ToString(), funname, paramstr, Convert.ToString(error.Code), false, transactionid); LoggerHelper.Error($"BigAttachManager调用{funname}异常", paramstr, ex.ToString(), transactionid); strJsonResult = JsonHelper.ReturnJson(false, Convert.ToInt32(error.Code), error.Info); result = false; } return(result); }