EchoTex_Payroll/HRM.BO/Survey/Survey.cs
2024-10-14 10:01:49 +06:00

497 lines
14 KiB
C#

using Ease.Core.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
namespace HRM.BO
{
public class Survey : AuditTrailBase
{
#region Constructor
public Survey()
{
_SurveyID = 0;
_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 int _SurveyID;
public int SurveyID
{
get { return _SurveyID; }
set
{
_SurveyID = value;
}
}
#endregion
#region Title : string
private string _title;
public string Title
{
get { return _title; }
set
{
_title = value;
}
}
#endregion
#region CategoryID : int
private int _categoryID;
public int CategoryID
{
get { return _categoryID; }
set
{
_categoryID = value;
}
}
#endregion
#region Description : string
private string _description;
public string Description
{
get { return _description; }
set
{
_description = value;
}
}
#endregion
#region PublishDate : DateTime
private DateTime? _publishDate;
public DateTime? PublishDate
{
get { return _publishDate; }
set
{
if (this._publishDate != value)
_publishDate = value;
}
}
#endregion
#region FromDate : DateTime
private DateTime _fromDate;
public DateTime FromDate
{
get { return _fromDate; }
set
{
_fromDate = value;
}
}
#endregion
#region ToDate : DateTime
private DateTime _toDate;
public DateTime ToDate
{
get { return _toDate; }
set
{
_toDate = value;
}
}
#endregion
#region Survey Type : EnumSurveyType
private EnumSurveyType _surveyType;
public EnumSurveyType SurveyType
{
get { return _surveyType; }
set
{
_surveyType = value;
}
}
#endregion
#region IsForCelyStoped : bool
private bool _isForCelyStoped;
public bool IsForCelyStoped
{
get { return _isForCelyStoped; }
set
{
_isForCelyStoped = value;
}
}
#endregion
#region IsPublished : bool
private bool _isPublished;
public bool IsPublished
{
get { return _isPublished; }
set
{
_isPublished = value;
}
}
#endregion
public SurveyCategory Category { get; set; }
public List<SurveyWeightDefinition> SurveyWeightDefinitions { get; set; }
public int NoOfQuestions { get; set; }
public string CategoryName { get; set; }
public double? EstimatedTime { get; set; }
public double? ActualTime { get; set; }
public int PassMark { get; set; }
public List<SurveyQuestion> SurveyQuestions { get; set; }
public List<SurveyOrganization> SurveyOrganizations { get; set; }
public List<SurveyEmployee> SurveyEmployees { get; set; }
public List<SurveyAnswerCount> SurveyAnswerCounts { get; set; }
public List<SurveyResult> SurveyResults { get; set; }
//#region Category
//private SurveyCategory _category;
//public SurveyCategory Category
//{
// get
// {
// if (_category == null)
// {
// _category = SurveyCategory.Get((_categoryID));
// }
// return _category;
// }
// set { _category = value; }
//}
//#endregion
//#region SurveyWeightDefinition
//private List<SurveyWeightDefinition> _SurveyWeightDefinitions;
//public List<SurveyWeightDefinition> SurveyWeightDefinitions
//{
// get
// {
// if (_SurveyWeightDefinitions == null)
// {
// _SurveyWeightDefinitions = new List<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 List<SurveyQuestion> _surveyQuestions;
//public List<SurveyQuestion> SurveyQuestions
//{
// get
// {
// if (_surveyQuestions == null)
// {
// _surveyQuestions = new List<SurveyQuestion>();
// if (!this.ID.IsUnassigned)
// _surveyQuestions = SurveyQuestion.GetSurveyQuestion(this.ID);
// }
// return _surveyQuestions;
// }
// set { _surveyQuestions = value; }
//}
//#endregion
//#region SurveyQuestion property
//private List<SurveyOrganization> _surveyOrganizations;
//public List<SurveyOrganization> SurveyOrganizations
//{
// get
// {
// if (_surveyOrganizations == null || _surveyOrganizations.Count==0)
// {
// _surveyOrganizations = new List<SurveyOrganization>();
// if (!this.ID.IsUnassigned)
// _surveyOrganizations = SurveyOrganization.GetSurveyOrganization(this.ID);
// }
// return _surveyOrganizations;
// }
// set { _surveyOrganizations = value; }
//}
//#endregion
//#region SurveyEmployee property
//private List<SurveyEmployee> _surveyEmployees;
//public List<SurveyEmployee> SurveyEmployees
//{
// get
// {
// if (_surveyEmployees == null)
// {
// _surveyEmployees = new List<SurveyEmployee>();
// if (!this.ID.IsUnassigned)
// _surveyEmployees = SurveyEmployee.GetSurveyEmployee(this.ID);
// }
// return _surveyEmployees;
// }
// set { _surveyEmployees = value; }
//}
//#endregion
//#region SurveyAnswerCount property
//private List<SurveyAnswerCount> _surveyAnswerCounts;
//public List<SurveyAnswerCount> SurveyAnswerCounts
//{
// get
// {
// if (_surveyAnswerCounts == null)
// {
// _surveyAnswerCounts = new List<SurveyAnswerCount>();
// if (!this.ID.IsUnassigned)
// _surveyAnswerCounts = SurveyAnswerCount.GetSurveyAnswerCount(this.ID);
// }
// return _surveyAnswerCounts;
// }
// set { _surveyAnswerCounts = value; }
//}
//#endregion
//#region SurveyResult property
//private List<SurveyResult> _surveyResults;
//public List<SurveyResult> SurveyResults
//{
// get
// {
// if (_surveyResults == null)
// {
// _surveyResults = new List<SurveyResult>();
// if (!this.ID.IsUnassigned)
// _surveyResults = SurveyResult.GetSurveyResult(this.ID);
// }
// return _surveyResults;
// }
// set { _surveyResults = value; }
//}
//#endregion
#endregion
//#region Functions
//public static Survey Get(int 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 List<Survey> Get()
//{
// #region cache header
// List<Survey> Surveys = _cache["Get"] as List<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 List<Survey> Get(DateTime today)
//{
// List<Survey> oSurvey = null;
// #region Cache Header
// oSurvey = (List<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 List<Survey> GetSurveyForEmployee(Employee oEmp,DateTime dt)
//{
// List<Survey> oNewSurveys = new List<Survey>();
// List<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 List<Survey> Get(int categoryId)
//{
// #region Cache Header
// List<Survey> Surveys = _cache["Get", categoryId] as List<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 int Save()
//{
// base.SetAuditTrailProperties();
// return Survey.Service.Save(this);
//}
//public void Delete(int id)
//{
// Survey.Service.Delete(id);
//}
//public void Publish(Survey survey)
//{
// Survey.Service.Publish(survey);
//}
//public void Stop(Survey survey)
//{
// Survey.Service.Stop(survey);
//}
//#endregion
//public static List<Survey> Get(DateTime dateTime1, DateTime dateTime2)
//{
// return Service.Get( dateTime1, dateTime2);
//}
//public static List<Survey> Get(int p, DateTime dateTime1, DateTime dateTime2)
//{
// return Service.Get(p, dateTime1, dateTime2);
//}
}
#region ISurvey Service
public interface ISurveyService
{
Survey Get(int id);
List<Survey> Get();
List<Survey> GetWithCategoryID(int categoryId);
List<Survey> Get(DateTime today);
//List<Survey> Get(Employee oEmp);
int Save(Survey item);
void Delete(int id);
void Publish(Survey survey);
void Stop(Survey survey);
List<Survey> Get(DateTime dateTime1, DateTime dateTime2);
List<Survey> Get(int p, DateTime dateTime1, DateTime dateTime2);
List<Survey> GetQuestionSetByCategoryID(int categoryID);
}
#endregion
}