You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

259 lines
4.6 KiB

using EC.Service.Organization;
using EC.Service.Transport;
using System;
using System.Collections.Generic;
namespace EC.AutoWeightServer.Center
{
public class ServiceCenter
{
private static CompanyService _companyService;
private static UserService _userService;
private static SiteService _siteService;
private static SupplierService _supplierService;
private static TruckService _truckService;
private static TrailerService _trailerService;
private static DriverService _driverService;
private static AuthService _authService;
private static IniService _iniService;
private static MonthPlanService _monthPlanService;
private static TransportBillService _billService;
private static PhotoService _photoService;
private static readonly Dictionary<Type, object> LockDict = new Dictionary<Type, object>();
private static readonly object LockDictObj = new object();
private static object GetLockDictObj(Type type)
{
if (!LockDict.ContainsKey(type))
{
lock (LockDictObj)
{
if (!LockDict.ContainsKey(type))
{
LockDict.Add(type, new object());
}
}
}
return LockDict[type];
}
public static CompanyService CompanyService
{
get
{
{
lock (GetLockDictObj(typeof(CompanyService)))
{
if (_companyService == null)
{
_companyService = new CompanyService();
}
}
}
return _companyService;
}
}
public static UserService UserService
{
get
{
if (_userService == null)
{
lock (GetLockDictObj(typeof(UserService)))
{
if (_userService == null)
{
_userService = new UserService();
}
}
}
return _userService;
}
}
public static SiteService SiteService
{
get
{
if (_siteService == null)
{
lock (GetLockDictObj(typeof(CompanyService)))
{
if (_siteService == null)
{
_siteService = new SiteService();
}
}
}
return _siteService;
}
}
public static SupplierService SupplierService
{
get
{
if (_supplierService == null)
{
lock (GetLockDictObj(typeof(SupplierService)))
{
if (_supplierService == null)
{
_supplierService = new SupplierService();
}
}
}
return _supplierService;
}
}
public static DriverService DriverService
{
get
{
if (_driverService == null)
{
lock (GetLockDictObj(typeof(DriverService)))
{
if (_driverService == null)
{
_driverService = new DriverService();
}
}
}
return _driverService;
}
}
public static TruckService TruckService
{
get
{
if (_truckService == null)
{
lock (GetLockDictObj(typeof(TruckService)))
{
if (_truckService == null)
{
_truckService = new TruckService();
}
}
}
return _truckService;
}
}
public static TrailerService TrailerService
{
get
{
if (_trailerService == null)
{
lock (GetLockDictObj(typeof(TrailerService)))
{
if (_trailerService == null)
{
_trailerService = new TrailerService();
}
}
}
return _trailerService;
}
}
public static AuthService AuthService
{
get
{
if (_authService == null)
{
lock (GetLockDictObj(typeof(AuthService)))
{
if (_authService == null)
{
_authService = new AuthService();
}
}
}
return _authService;
}
}
public static IniService IniService
{
get
{
if (_iniService == null)
{
lock (GetLockDictObj(typeof(IniService)))
{
if (_iniService == null)
{
_iniService = new IniService();
}
}
}
return _iniService;
}
}
public static MonthPlanService MonthPlanService
{
get
{
if (_monthPlanService == null)
{
lock (GetLockDictObj(typeof(MonthPlanService)))
{
if (_monthPlanService == null)
{
_monthPlanService = new MonthPlanService();
}
}
}
return _monthPlanService;
}
}
public static TransportBillService BillService
{
get
{
if (_billService == null)
{
lock (GetLockDictObj(typeof(TransportBillService)))
{
if (_billService == null)
{
_billService = new TransportBillService();
}
}
}
return _billService;
}
}
public static PhotoService PhotoService
{
get
{
if (_photoService == null)
{
lock (GetLockDictObj(typeof(PhotoService)))
{
if (_photoService == null)
{
_photoService = new PhotoService();
}
}
}
return _photoService;
}
}
}
}