每一次都是大放血

This commit is contained in:
yubaolee
2017-11-29 20:49:14 +08:00
parent e36664d5f6
commit b7a72f62c0
80 changed files with 12919 additions and 12884 deletions

View File

@@ -12,7 +12,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{

View File

@@ -1,8 +1,8 @@
using System.Linq;
using Infrastructure;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -1,5 +1,5 @@
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -1,153 +0,0 @@
using Infrastructure;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenAuth.App
{
public class CategoryManagerApp
{
public IUnitWork _unitWork { get; set; }
public CategoryManagerApp(IUnitWork unitWork)
{
_unitWork = unitWork;
}
public List<Category> LoadAll()
{
return _unitWork.Find<Category>(null).ToList();
}
/// <summary>
/// 加载一个分类及子分类全部Categorys
/// </summary>
public GridData Load(string parentId, int pageindex, int pagesize)
{
IQueryable<Category> categories;
int total = 0;
if (parentId == string.Empty)
{
categories = _unitWork.Find<Category>(pageindex, pagesize);
total = _unitWork.GetCount<Category>();
}
else
{
var ids = GetSubCategories(parentId);
categories = _unitWork.Find<Category>(pageindex, pagesize, "SortNo", u => ids.Contains(u.Id));
// total = _repository.GetCategoryCntInOrgs(ids);
}
var query = from c in categories
join category in _unitWork.Find<Category>(null) on c.ParentId equals category.Id into temp
from category in temp.DefaultIfEmpty()
select new
{
c.CascadeId,
c.Name,
c.ParentId,
ParentName = category.Name,
c.SortNo,
c.Status,
c.Id
};
return new GridData()
{
count = total,
data = query.ToList()
};
}
/// <summary>
/// 获取当前组织的所有下级组织
/// </summary>
private string[] GetSubCategories(string orgId)
{
var category = Find(orgId);
var categories = _unitWork.Find<Category>(u => u.CascadeId.Contains(category.CascadeId)).Select(u => u.Id).ToArray();
return categories;
}
public Category Find(string id)
{
var category = _unitWork.FindSingle<Category>(u => u.Id == id);
if (category == null) return new Category();
return category;
}
public void Delete(string[] ids)
{
_unitWork.Delete<Category>(u =>ids.Contains(u.Id));
}
public void AddOrUpdate(Category model)
{
Category category = new Category();
model.CopyTo(category);
ChangeModuleCascade(category);
if (category.Id == string.Empty)
{
_unitWork.Add(category);
}
else
{
//获取旧的的CascadeId
var CascadeId = _unitWork.FindSingle<Category>(o => o.Id == category.Id).CascadeId;
//根据CascadeId查询子分类
var categorys = _unitWork.Find<Category>(u => u.CascadeId.Contains(CascadeId) && u.Id != category.Id).OrderBy(u => u.CascadeId).ToList();
_unitWork.Update(category);
//更新子分类的CascadeId
foreach (var a in categorys)
{
ChangeModuleCascade(a);
_unitWork.Update(a);
}
_unitWork.Save();
}
}
#region
//修改对象的级联ID生成类似XXX.XXX.X.XX
private void ChangeModuleCascade(Category org)
{
string cascadeId;
int currentCascadeId = 1; //当前结点的级联节点最后一位
var sameLevels = _unitWork.Find<Category>(o => o.ParentId == org.ParentId && o.Id != org.Id);
foreach (var obj in sameLevels)
{
int objCascadeId = int.Parse(obj.CascadeId.TrimEnd('.').Split('.').Last());
if (currentCascadeId <= objCascadeId) currentCascadeId = objCascadeId + 1;
}
if (org.ParentId != null && org.ParentId != string.Empty)
{
var parentOrg = _unitWork.FindSingle<Category>(o => o.Id == org.ParentId);
if (parentOrg != null)
{
cascadeId = parentOrg.CascadeId + currentCascadeId +".";
}
else
{
throw new Exception("未能找到该组织的父节点信息");
}
}
else
{
cascadeId = ".0." + currentCascadeId +".";
}
org.CascadeId = cascadeId;
}
#endregion
}
}

View File

@@ -1,6 +1,6 @@
using OpenAuth.Domain;
using System.Collections.Generic;
using OpenAuth.Domain.Interface;
using System.Collections.Generic;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -82,7 +82,6 @@
<ItemGroup>
<Compile Include="AuthoriseService.cs" />
<Compile Include="BaseApp.cs" />
<Compile Include="CategoryManagerApp.cs" />
<Compile Include="AuthorizeApp.cs" />
<Compile Include="Extention\IWF_Runtime.cs" />
<Compile Include="Extention\WF_Runtime.cs" />

View File

@@ -1,9 +1,9 @@
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.App.ViewModel;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -1,9 +1,8 @@

using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -3,8 +3,7 @@ using System.Web;
using System.Web.Mvc;
using Infrastructure;
using Infrastructure.Cache;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.SSO

View File

@@ -10,7 +10,7 @@
// ***********************************************************************
using System.Linq;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
{

View File

@@ -1,9 +1,9 @@
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using OpenAuth.App.Request;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App
@@ -115,8 +115,7 @@ namespace OpenAuth.App
BizCode = user.BizCode,
Name = user.Name,
Sex = user.Sex,
Status = user.Status,
Type = user.Type
Status = user.Status
});
}
string[] orgIds = view.OrganizationIds.Split(',').ToArray();

View File

@@ -1,7 +1,7 @@
using System;
using Infrastructure;
using OpenAuth.Domain;
using System.Collections.Generic;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.ViewModel
{

View File

@@ -14,7 +14,7 @@
using System;
using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.ViewModel
{

View File

@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.ViewModel

View File

@@ -14,7 +14,7 @@
using System.Collections.Generic;
using Infrastructure;
using OpenAuth.Domain;
using OpenAuth.Repository.Domain;
namespace OpenAuth.App.ViewModel

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{

View File

@@ -5,8 +5,8 @@ using Infrastructure;
using OpenAuth.App.Extention;
using OpenAuth.App.SSO;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{
@@ -22,8 +22,8 @@ namespace OpenAuth.App
/// <summary>
/// 获取实例进程信息实体
/// </summary>
/// <param name="keyVlaue"></param>
/// <returns></returns>
/// <param name="keyVlaue">The key vlaue.</param>
/// <returns>WFProcessInstance.</returns>
public WFProcessInstance GetEntity(string keyVlaue)
{
try

View File

@@ -2,8 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using OpenAuth.App.ViewModel;
using OpenAuth.Domain;
using OpenAuth.Domain.Interface;
using OpenAuth.Repository.Domain;
using OpenAuth.Repository.Interface;
namespace OpenAuth.App
{