489 lines
14 KiB
C#
489 lines
14 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using Ease.CoreV35;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Ease.CoreV35.Caching;
|
|||
|
using System.Data.Linq.Mapping;
|
|||
|
|
|||
|
namespace Payroll.BO
|
|||
|
{
|
|||
|
[Serializable]
|
|||
|
public class Survey : AuditTrailBase
|
|||
|
{
|
|||
|
|
|||
|
#region Cache Store
|
|||
|
|
|||
|
private static Cache _cache = new Cache(typeof(Survey));
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Constructor
|
|||
|
public Survey()
|
|||
|
{
|
|||
|
_SurveyID = null;
|
|||
|
_title = string.Empty;
|
|||
|
_categoryID = 0;
|
|||
|
_description = string.Empty;
|
|||
|
_fromDate = DateTime.MinValue;
|
|||
|
_toDate = DateTime.MinValue;
|
|||
|
_publishDate = null;
|
|||
|
_isPublished = false;
|
|||
|
_isForCelyStoped = false;
|
|||
|
_surveyType = EnumSurveyType.None;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Properties
|
|||
|
|
|||
|
#region SurveyID : ID
|
|||
|
|
|||
|
private ID _SurveyID;
|
|||
|
public ID SurveyID
|
|||
|
{
|
|||
|
get { return _SurveyID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<ID>("SurveyID", _SurveyID, value);
|
|||
|
_SurveyID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Title : string
|
|||
|
|
|||
|
private string _title;
|
|||
|
public string Title
|
|||
|
{
|
|||
|
get { return _title; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("Title", _title, value);
|
|||
|
_title = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region CategoryID : int
|
|||
|
|
|||
|
private int _categoryID;
|
|||
|
public int CategoryID
|
|||
|
{
|
|||
|
get { return _categoryID; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<int>("CategoryID", _categoryID, value);
|
|||
|
_categoryID = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Description : string
|
|||
|
|
|||
|
private string _description;
|
|||
|
public string Description
|
|||
|
{
|
|||
|
get { return _description; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<string>("Description", _description, value);
|
|||
|
_description = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region PublishDate : DateTime
|
|||
|
|
|||
|
private DateTime? _publishDate;
|
|||
|
public DateTime? PublishDate
|
|||
|
{
|
|||
|
get { return _publishDate; }
|
|||
|
set
|
|||
|
{
|
|||
|
if (this._publishDate != value)
|
|||
|
base.OnPropertyChange<DateTime>("PublishDate", _publishDate, value);
|
|||
|
_publishDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region FromDate : DateTime
|
|||
|
|
|||
|
private DateTime _fromDate;
|
|||
|
public DateTime FromDate
|
|||
|
{
|
|||
|
get { return _fromDate; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<DateTime>("FromDate", _fromDate, value);
|
|||
|
_fromDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region ToDate : DateTime
|
|||
|
|
|||
|
private DateTime _toDate;
|
|||
|
public DateTime ToDate
|
|||
|
{
|
|||
|
get { return _toDate; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<DateTime>("ToDate", _toDate, value);
|
|||
|
_toDate = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region Survey Type : EnumSurveyType
|
|||
|
|
|||
|
private EnumSurveyType _surveyType;
|
|||
|
public EnumSurveyType SurveyType
|
|||
|
{
|
|||
|
get { return _surveyType; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<short>("SurveyType", (short)_surveyType,(short) value);
|
|||
|
_surveyType = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region IsForCelyStoped : bool
|
|||
|
|
|||
|
private bool _isForCelyStoped;
|
|||
|
public bool IsForCelyStoped
|
|||
|
{
|
|||
|
get { return _isForCelyStoped; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("IsForCelyStoped", _isForCelyStoped, value);
|
|||
|
_isForCelyStoped = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
#region IsPublished : bool
|
|||
|
|
|||
|
private bool _isPublished;
|
|||
|
public bool IsPublished
|
|||
|
{
|
|||
|
get { return _isPublished; }
|
|||
|
set
|
|||
|
{
|
|||
|
base.OnPropertyChange<bool>("IsPublished", _isPublished, value);
|
|||
|
_isPublished = value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Category
|
|||
|
private SurveyCategory _category;
|
|||
|
public SurveyCategory Category
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_category == null)
|
|||
|
{
|
|||
|
_category = SurveyCategory.Get(ID.FromInteger(_categoryID));
|
|||
|
}
|
|||
|
return _category;
|
|||
|
}
|
|||
|
set { _category = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region SurveyWeightDefinition
|
|||
|
private ObjectsTemplate<SurveyWeightDefinition> _SurveyWeightDefinitions;
|
|||
|
public ObjectsTemplate<SurveyWeightDefinition> SurveyWeightDefinitions
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_SurveyWeightDefinitions == null)
|
|||
|
{
|
|||
|
_SurveyWeightDefinitions = new ObjectsTemplate<SurveyWeightDefinition>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_SurveyWeightDefinitions = SurveyWeightDefinition.GetSurveyWeightDefinition(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _SurveyWeightDefinitions;
|
|||
|
}
|
|||
|
set { _SurveyWeightDefinitions = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Service Factory IPFTransactionService : IPFTransactionService
|
|||
|
|
|||
|
internal static ISurveyService Service
|
|||
|
{
|
|||
|
get { return Services.Factory.CreateService<ISurveyService>(typeof(ISurveyService)); }
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region SurveyQuestion property
|
|||
|
private ObjectsTemplate<SurveyQuestion> _surveyQuestions;
|
|||
|
public ObjectsTemplate<SurveyQuestion> SurveyQuestions
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_surveyQuestions == null)
|
|||
|
{
|
|||
|
_surveyQuestions = new ObjectsTemplate<SurveyQuestion>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_surveyQuestions = SurveyQuestion.GetSurveyQuestion(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _surveyQuestions;
|
|||
|
}
|
|||
|
set { _surveyQuestions = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region SurveyQuestion property
|
|||
|
private ObjectsTemplate<SurveyOrganization> _surveyOrganizations;
|
|||
|
public ObjectsTemplate<SurveyOrganization> SurveyOrganizations
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_surveyOrganizations == null || _surveyOrganizations.Count==0)
|
|||
|
{
|
|||
|
_surveyOrganizations = new ObjectsTemplate<SurveyOrganization>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_surveyOrganizations = SurveyOrganization.GetSurveyOrganization(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _surveyOrganizations;
|
|||
|
}
|
|||
|
set { _surveyOrganizations = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region SurveyEmployee property
|
|||
|
private ObjectsTemplate<SurveyEmployee> _surveyEmployees;
|
|||
|
public ObjectsTemplate<SurveyEmployee> SurveyEmployees
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_surveyEmployees == null)
|
|||
|
{
|
|||
|
_surveyEmployees = new ObjectsTemplate<SurveyEmployee>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_surveyEmployees = SurveyEmployee.GetSurveyEmployee(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _surveyEmployees;
|
|||
|
}
|
|||
|
set { _surveyEmployees = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region SurveyAnswerCount property
|
|||
|
private ObjectsTemplate<SurveyAnswerCount> _surveyAnswerCounts;
|
|||
|
public ObjectsTemplate<SurveyAnswerCount> SurveyAnswerCounts
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_surveyAnswerCounts == null)
|
|||
|
{
|
|||
|
_surveyAnswerCounts = new ObjectsTemplate<SurveyAnswerCount>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_surveyAnswerCounts = SurveyAnswerCount.GetSurveyAnswerCount(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _surveyAnswerCounts;
|
|||
|
}
|
|||
|
set { _surveyAnswerCounts = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
#region SurveyResult property
|
|||
|
private ObjectsTemplate<SurveyResult> _surveyResults;
|
|||
|
public ObjectsTemplate<SurveyResult> SurveyResults
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
if (_surveyResults == null)
|
|||
|
{
|
|||
|
_surveyResults = new ObjectsTemplate<SurveyResult>();
|
|||
|
if (!this.ID.IsUnassigned)
|
|||
|
_surveyResults = SurveyResult.GetSurveyResult(this.ID);
|
|||
|
}
|
|||
|
|
|||
|
return _surveyResults;
|
|||
|
}
|
|||
|
set { _surveyResults = value; }
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Functions
|
|||
|
|
|||
|
|
|||
|
|
|||
|
public static Survey Get(ID nID)
|
|||
|
{
|
|||
|
Survey oSurvey = null;
|
|||
|
#region Cache Header
|
|||
|
oSurvey = (Survey)_cache["Get", oSurvey];
|
|||
|
if (oSurvey != null)
|
|||
|
return oSurvey;
|
|||
|
#endregion
|
|||
|
oSurvey = Survey.Service.Get(nID);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oSurvey, "Get", oSurvey);
|
|||
|
#endregion
|
|||
|
return oSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> Get()
|
|||
|
{
|
|||
|
#region cache header
|
|||
|
ObjectsTemplate<Survey> Surveys = _cache["Get"] as ObjectsTemplate<Survey>;
|
|||
|
if (Surveys != null)
|
|||
|
return Surveys;
|
|||
|
#endregion
|
|||
|
try
|
|||
|
{
|
|||
|
Surveys = Service.Get();
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region cache footer
|
|||
|
_cache.Add(Surveys, "Get");
|
|||
|
#endregion
|
|||
|
|
|||
|
return Surveys;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> Get(DateTime today)
|
|||
|
{
|
|||
|
ObjectsTemplate<Survey> oSurvey = null;
|
|||
|
#region Cache Header
|
|||
|
oSurvey = (ObjectsTemplate<Survey>)_cache["Get"];
|
|||
|
if (oSurvey != null)
|
|||
|
return oSurvey;
|
|||
|
#endregion
|
|||
|
oSurvey = Service.Get(today);
|
|||
|
#region Cache Footer
|
|||
|
_cache.Add(oSurvey, "Get");
|
|||
|
#endregion
|
|||
|
return oSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> Get(DateTime fromDT, DateTime toDT)
|
|||
|
{
|
|||
|
ObjectsTemplate<Survey> oSurvey = null;
|
|||
|
oSurvey = Service.Get(fromDT, toDT);
|
|||
|
return oSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> Get(int categoryId, DateTime fromDT, DateTime toDT)
|
|||
|
{
|
|||
|
ObjectsTemplate<Survey> oSurvey = null;
|
|||
|
oSurvey = Service.Get(categoryId, fromDT, toDT);
|
|||
|
return oSurvey;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> GetSurveyForEmployee(Employee oEmp,DateTime dt)
|
|||
|
{
|
|||
|
ObjectsTemplate<Survey> oNewSurveys = new ObjectsTemplate<Survey>();
|
|||
|
ObjectsTemplate<Survey> oSurveys = Survey.Get(dt);
|
|||
|
foreach (Survey sr in oSurveys)
|
|||
|
{
|
|||
|
SurveyEmployee oSurveyEmployee = sr.SurveyEmployees.Find(delegate(SurveyEmployee se) { return se.EmployeeID == oEmp.ID.Integer; });
|
|||
|
if (oSurveyEmployee == null)
|
|||
|
{
|
|||
|
SurveyOrganization oSurveyOrganization = sr.SurveyOrganizations.Find(delegate(SurveyOrganization so) { return so.DepartmentID == oEmp.DepartmentID || so.LocationID == oEmp.LocationID || so.GradeID == oEmp.GradeID; });
|
|||
|
if(oSurveyOrganization !=null)
|
|||
|
oNewSurveys.Add(sr);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
oNewSurveys.Add(sr);
|
|||
|
}
|
|||
|
}
|
|||
|
return oNewSurveys;
|
|||
|
}
|
|||
|
|
|||
|
public static ObjectsTemplate<Survey> Get(int categoryId)
|
|||
|
{
|
|||
|
#region Cache Header
|
|||
|
|
|||
|
ObjectsTemplate<Survey> Surveys = _cache["Get", categoryId] as ObjectsTemplate<Survey>;
|
|||
|
if (Surveys != null)
|
|||
|
return Surveys;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
Surveys = Service.Get(categoryId);
|
|||
|
}
|
|||
|
catch (ServiceException e)
|
|||
|
{
|
|||
|
throw new Exception(e.Message, e);
|
|||
|
}
|
|||
|
|
|||
|
#region Cache Footer
|
|||
|
|
|||
|
_cache.Add(Surveys, "Get", categoryId);
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
return Surveys;
|
|||
|
}
|
|||
|
|
|||
|
public ID Save()
|
|||
|
{
|
|||
|
base.SetAuditTrailProperties();
|
|||
|
return Survey.Service.Save(this);
|
|||
|
}
|
|||
|
|
|||
|
public void Delete(ID id)
|
|||
|
{
|
|||
|
Survey.Service.Delete(id);
|
|||
|
}
|
|||
|
public void Publish(Survey survey)
|
|||
|
{
|
|||
|
Survey.Service.Publish(survey);
|
|||
|
}
|
|||
|
public void Stop(Survey survey)
|
|||
|
{
|
|||
|
Survey.Service.Stop(survey);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
#region ISurvey Service
|
|||
|
|
|||
|
public interface ISurveyService
|
|||
|
{
|
|||
|
Survey Get(ID id);
|
|||
|
ObjectsTemplate<Survey> Get();
|
|||
|
ObjectsTemplate<Survey> Get(int categoryId);
|
|||
|
ObjectsTemplate<Survey> Get(DateTime today);
|
|||
|
//ObjectsTemplate<Survey> Get(Employee oEmp);
|
|||
|
ObjectsTemplate<Survey> Get(DateTime fromDT, DateTime toDT);
|
|||
|
ObjectsTemplate<Survey> Get(int categoryId, DateTime fromDT, DateTime toDT);
|
|||
|
ID Save(Survey item);
|
|||
|
void Delete(ID id);
|
|||
|
void Publish(Survey survey);
|
|||
|
void Stop(Survey survey);
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|