126 lines
2.6 KiB
C#
126 lines
2.6 KiB
C#
///////////////////////////////////////////////////////////
|
|
// Bool.cs
|
|
// Implementation of Class ScheduleableUserCanSelect
|
|
// CSLA type: Read-only object
|
|
// Created on: 11-Jan-2006
|
|
// Object design: John
|
|
// Coded: John 11-Jan-2006
|
|
///////////////////////////////////////////////////////////
|
|
|
|
using System;
|
|
using System.Data;
|
|
using CSLA.Data;
|
|
using GZTW.Data;
|
|
using CSLA;
|
|
using System.Threading;
|
|
using CSLA.Security;
|
|
using System.ComponentModel;
|
|
|
|
|
|
|
|
namespace GZTW.AyaNova.BLL
|
|
{
|
|
|
|
[Serializable,EditorBrowsable(EditorBrowsableState.Never)]
|
|
internal class ScheduleableUserCanSelect : ReadOnlyBase
|
|
{
|
|
|
|
//Ensures a chosen scheduleable user is active, is scheduleable etc
|
|
//Used by workorderitemscheduleduser labor etc
|
|
//in case people try to use the api to set inactive users and
|
|
//circumvent licensing
|
|
#region Attributes
|
|
private bool mSelectable;
|
|
|
|
#endregion
|
|
|
|
#region Constructor
|
|
|
|
/// <summary>
|
|
/// Private constructor to prevent direct instantiation
|
|
/// </summary>
|
|
private ScheduleableUserCanSelect()
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Static methods
|
|
|
|
|
|
|
|
public static bool GetItem(Guid UserID)
|
|
{
|
|
if(AyaBizUtils._CE) return true;
|
|
return ((ScheduleableUserCanSelect)DataPortal.Fetch(new Criteria( UserID))).mSelectable;
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region DAL DATA ACCESS
|
|
///
|
|
/// <param Bool="Criteria"></param>
|
|
protected override void DataPortal_Fetch(object Criteria)
|
|
{
|
|
Criteria crit = (Criteria)Criteria;
|
|
SafeDataReader dr = null;
|
|
this.mSelectable=false;
|
|
try
|
|
{
|
|
dr=DBUtil.GetReaderFromSQLString(
|
|
//************************************************************
|
|
"SELECT aUser.AACTIVE, aUser.aUserType FROM " +
|
|
"aUser " +
|
|
"WHERE aUser.aID=@ID"
|
|
,crit.UserID
|
|
//************************************************************
|
|
);
|
|
|
|
if(dr.Read())
|
|
{
|
|
if(dr.GetBoolean("AACTIVE") == true && (UserTypes)dr.GetInt16("aUserType") == UserTypes.Schedulable)
|
|
this.mSelectable = true;
|
|
else
|
|
this.mSelectable = false;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
dr.Close();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region criteria
|
|
/// <summary>
|
|
/// Criteria for identifying existing object
|
|
/// </summary>
|
|
[Serializable]
|
|
private class Criteria
|
|
{
|
|
|
|
|
|
public Guid UserID;
|
|
|
|
public Criteria( Guid _UserID)
|
|
{
|
|
UserID=_UserID;
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
}//end Bool
|
|
|
|
}//end Boolspace GZTW.AyaNova.BLL |