public string GetAppId(string fileId) { Domain.Node node = GetNode <FileNode>(fileId); QuotaLog log = null; while (log == null && node != null) { log = _panDbContext.QuotaLogs.FirstOrDefault(ql => ql.FileId == node.Id); if (log == null) { //如果是CopyFolder产生的文件,只会存Folder的id,这里不断往上层遍历至该Folder node = GetNode <FolderNode>(node.OwnerId, node.Path); } } if (log == null) { throw new Exception("无法在Log表中找到该文件的AppId"); } return(log.AppId); }
private Domain.Quota UsingQuota(string ownerId, long size, string fileId, bool isIncrease = true) { var quota = GetQuota(ownerId); var quotaLog = new QuotaLog(ownerId, (isIncrease ? 1 : -1) * size, _appId, fileId); _quotaLogRepository.Insert(quotaLog); OptimisticConcurrencyProcessor.Process(() => { if (isIncrease) { quota.Increase(size); } else { quota.Decrease(size); } return(1); }); return(quota); }
public override string FormateContent(object primaryKey) { try { #region 变量 string content = string.Empty; int id = (int)primaryKey; string itemCodeName = string.Empty; string objectDes = string.Empty; string editTime = string.Empty; string quotaDate = string.Empty; string type = string.Empty; string oldValue = string.Empty; string newValue = string.Empty; string objectUnit = string.Empty; OperateQuotaBll quotaOper = new OperateQuotaBll(); #endregion #region 数据来源 var quotaInfo = quotaOper.GetQuotaInfoById(id); var itemCodeInfo = new NTS.WEB.BLL.Itemcode().GetItemcodeList(string.Format(" and itemcodenumber='{0}'", quotaInfo.QuotaData.ItemCode), "")[0]; QuotaLog newQoutaLog = quotaInfo.QuotaLogList[0]; #endregion #region 组织数据 itemCodeName = itemCodeInfo.ItemCodeName; objectUnit = itemCodeInfo.Unit; objectDes = quotaInfo.QuotaData.ObjectDesc; newValue = quotaInfo.QuotaData.QuotaValue.ToString(); editTime = newQoutaLog.LogTime.ToString("yyyy年MM月dd日HH时mm分ss秒"); type = quotaInfo.QuotaData.QuotaType == QuotaType.Month ? "月" : "年"; if (quotaInfo.QuotaData.QuotaType == QuotaType.Month) { quotaDate = string.Format("{0}年{1}月", quotaInfo.QuotaData.QuotaTime.Year, quotaInfo.QuotaData.QuotaTime.Month); } else if (quotaInfo.QuotaData.QuotaType == QuotaType.Year) { quotaDate = string.Format("{0}年", quotaInfo.QuotaData.QuotaTime.Year); } if (quotaInfo.QuotaLogList.Count > 1) { QuotaLog oldQUotaLog = quotaInfo.QuotaLogList[1]; oldValue = oldQUotaLog.QuotaValue.ToString(); content = string.Format("{0}用户于{1}修改\"{2}-{3}-{4}定额\":修改前为{5}kwh,修改后为{6}{7}。", _userName, editTime, objectDes, itemCodeName, type, oldValue, newValue, objectUnit); } else if (quotaInfo.QuotaLogList.Count == 1) { content = string.Format("{0}用户于{1}添加\"{2}-{3}-{4}定额\":{5}{6}。", _userName, editTime, objectDes, itemCodeName, type, newValue, objectUnit); } return(content); #endregion } catch (Exception ex) { return(ex.Message); } }