去除静态变量Funs.DB
This commit is contained in:
@@ -8,8 +8,6 @@ namespace BLL
|
||||
{
|
||||
public static class AttachFileService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 添加附件存储信息
|
||||
/// </summary>
|
||||
@@ -24,8 +22,9 @@ namespace BLL
|
||||
newAttachFile.AttachUrl = attachFile.AttachUrl;
|
||||
newAttachFile.MenuId = attachFile.MenuId;
|
||||
|
||||
db.AttachFile.InsertOnSubmit(newAttachFile);
|
||||
db.SubmitChanges();
|
||||
var db1 = Funs.DB;
|
||||
db1.AttachFile.InsertOnSubmit(newAttachFile);
|
||||
db1.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -34,12 +33,13 @@ namespace BLL
|
||||
/// <param name="workArea"></param>
|
||||
public static void updateAttachFile(Model.AttachFile attachFile)
|
||||
{
|
||||
Model.AttachFile newAttachFile = db.AttachFile.FirstOrDefault(x => x.AttachFileId == attachFile.AttachFileId);
|
||||
var db1 = Funs.DB;
|
||||
Model.AttachFile newAttachFile = db1.AttachFile.FirstOrDefault(x => x.AttachFileId == attachFile.AttachFileId);
|
||||
newAttachFile.ToKeyId = attachFile.ToKeyId;
|
||||
newAttachFile.AttachSource = attachFile.AttachSource;
|
||||
newAttachFile.AttachUrl = attachFile.AttachUrl;
|
||||
newAttachFile.MenuId = attachFile.MenuId;
|
||||
db.SubmitChanges();
|
||||
db1.SubmitChanges();
|
||||
|
||||
}
|
||||
|
||||
@@ -49,12 +49,13 @@ namespace BLL
|
||||
/// <param name="workAreaId"></param>
|
||||
public static void DeleteAttachFile(string rootPath, string toKeyId, string menuId)
|
||||
{
|
||||
Model.AttachFile att = db.AttachFile.FirstOrDefault(e => e.ToKeyId == toKeyId && e.MenuId == menuId);
|
||||
var db1 = Funs.DB;
|
||||
Model.AttachFile att = db1.AttachFile.FirstOrDefault(e => e.ToKeyId == toKeyId && e.MenuId == menuId);
|
||||
if (att != null)
|
||||
{
|
||||
BLL.UploadFileService.DeleteFile(rootPath, att.AttachUrl);
|
||||
db.AttachFile.DeleteOnSubmit(att);
|
||||
db.SubmitChanges();
|
||||
db1.AttachFile.DeleteOnSubmit(att);
|
||||
db1.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user