@ -139,34 +139,41 @@ namespace djy.Service.AFR
}
}
public List < Common CodeValu e> GetPort ( string strlink , int page , int limit )
public List < Common Mappi Code> GetPort ( string strlink , int page , int limit )
{
try
{
if ( page = = 0 & & limit = = 0 )
{
var List = DbBus . Get ( DbList . Common ) . Select < CodePort > ( ) . WhereIf ( strlink ! = "" , x = > x . Code . Contains ( strlink . Trim ( ) ) | | x . EnName . Contains ( strlink . Trim ( ) ) ) . ToList ( ) . Select ( x = > new CommonCodeValue
{
Code = x . Code ,
Value = x . EnName ,
} ) . Distinct ( ) . ToList ( ) ;
return List ;
}
else
{
var List = DbBus . Get ( DbList . Common ) . Select < CodePort > ( ) . WhereIf ( strlink ! = "" , x = > x . Code . Contains ( strlink . Trim ( ) ) | | x . EnName . Contains ( strlink . Trim ( ) ) ) . Page ( page , limit ) . ToList ( ) . Select ( x = > new CommonCodeValue
{
Code = x . Code ,
Value = x . EnName ,
} ) . Distinct ( ) . ToList ( ) ;
return List ;
}
}
catch ( Exception e )
{
throw ;
}
//try
//{
//if (page == 0 && limit == 0)
//{
var List = DbBus . Get ( DbList . Common )
. Select < CodePort , MappingPort > ( )
. InnerJoin ( ( cp , mp ) = > cp . Code = = mp . Code )
. Where ( ( cp , mp ) = > mp . Module = = "AFR" )
. ToList ( ( cp , mp ) = > new CommonMappiCode
{
//Code = cp.Code,
//Value = cp.EnName,
Code = null ,
Value = null ,
MapCode = mp . MapCode ,
MapName = mp . MapName
} ) ;
return List ;
//}
//else
//{
// var List = DbBus.Get(DbList.Common).Select<CodePort>().WhereIf(strlink != "", x => x.Code.Contains(strlink.Trim()) || x.EnName.Contains(strlink.Trim())).Page(page, limit).ToList().Select(x => new CommonCodeValue
// {
// Code = x.Code,
// Value = x.EnName,
// }).Distinct().ToList();
// return List;
//}
//}
//catch (Exception e)
//{
// throw;
//}
}
public List < CommonCodeValue > GetVessel ( string strlink , int page , int limit )
@ -1260,5 +1267,41 @@ namespace djy.Service.AFR
await DbAMS . Insert ( list ) . WithTransaction ( tran ) . ExecuteAffrowsAsync ( ) ;
}
}
public async Task < List < AFRAddrTemplate > > GetTemplate ( string type , string name )
{
var data = await DbAMS . Select < AFRAddrTemplate > ( )
. WhereIf ( ! string . IsNullOrEmpty ( type ) , t = > t . Type = = Convert . ToByte ( type ) )
. WhereIf ( ! string . IsNullOrEmpty ( name ) , t = > t . Name . Contains ( name ) )
. OrderByDescending ( t = > t . CreateTime )
. ToListAsync ( ) ;
return data ;
}
public async Task SaveTemplate ( AFRAddrTemplate input )
{
DateTime nowTime = DateTime . Now ;
if ( string . IsNullOrEmpty ( input . GID ) )
{
input . GID = Guid . NewGuid ( ) . ToString ( ) ;
input . LastUpdate = nowTime ;
input . CreateTime = nowTime ;
await DbAMS . Insert ( input ) . ExecuteAffrowsAsync ( ) ;
}
else
{
input . LastUpdate = nowTime ;
await DbAMS . Update < AFRAddrTemplate > ( ) . SetSource ( input ) . Where ( t = > t . GID = = input . GID ) . ExecuteAffrowsAsync ( ) ;
}
}
public async Task DeleteTemplate ( string ids )
{
await DbAMS . Delete < AFRAddrTemplate > ( )
. Where ( t = > ids . Contains ( t . GID ) )
. ExecuteAffrowsAsync ( ) ;
}
}
}
}