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 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 SurveyQuestions { get; set; } public List SurveyOrganizations { get; set; } public List SurveyEmployees { get; set; } public List SurveyAnswerCounts { get; set; } public List 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 _SurveyWeightDefinitions; //public List SurveyWeightDefinitions //{ // get // { // if (_SurveyWeightDefinitions == null) // { // _SurveyWeightDefinitions = new List(); // 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(typeof(ISurveyService)); } //} //#endregion //#region SurveyQuestion property //private List _surveyQuestions; //public List SurveyQuestions //{ // get // { // if (_surveyQuestions == null) // { // _surveyQuestions = new List(); // if (!this.ID.IsUnassigned) // _surveyQuestions = SurveyQuestion.GetSurveyQuestion(this.ID); // } // return _surveyQuestions; // } // set { _surveyQuestions = value; } //} //#endregion //#region SurveyQuestion property //private List _surveyOrganizations; //public List SurveyOrganizations //{ // get // { // if (_surveyOrganizations == null || _surveyOrganizations.Count==0) // { // _surveyOrganizations = new List(); // if (!this.ID.IsUnassigned) // _surveyOrganizations = SurveyOrganization.GetSurveyOrganization(this.ID); // } // return _surveyOrganizations; // } // set { _surveyOrganizations = value; } //} //#endregion //#region SurveyEmployee property //private List _surveyEmployees; //public List SurveyEmployees //{ // get // { // if (_surveyEmployees == null) // { // _surveyEmployees = new List(); // if (!this.ID.IsUnassigned) // _surveyEmployees = SurveyEmployee.GetSurveyEmployee(this.ID); // } // return _surveyEmployees; // } // set { _surveyEmployees = value; } //} //#endregion //#region SurveyAnswerCount property //private List _surveyAnswerCounts; //public List SurveyAnswerCounts //{ // get // { // if (_surveyAnswerCounts == null) // { // _surveyAnswerCounts = new List(); // if (!this.ID.IsUnassigned) // _surveyAnswerCounts = SurveyAnswerCount.GetSurveyAnswerCount(this.ID); // } // return _surveyAnswerCounts; // } // set { _surveyAnswerCounts = value; } //} //#endregion //#region SurveyResult property //private List _surveyResults; //public List SurveyResults //{ // get // { // if (_surveyResults == null) // { // _surveyResults = new List(); // 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 Get() //{ // #region cache header // List Surveys = _cache["Get"] as List; // 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 Get(DateTime today) //{ // List oSurvey = null; // #region Cache Header // oSurvey = (List)_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 GetSurveyForEmployee(Employee oEmp,DateTime dt) //{ // List oNewSurveys = new List(); // List 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 Get(int categoryId) //{ // #region Cache Header // List Surveys = _cache["Get", categoryId] as List; // 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 Get(DateTime dateTime1, DateTime dateTime2) //{ // return Service.Get( dateTime1, dateTime2); //} //public static List Get(int p, DateTime dateTime1, DateTime dateTime2) //{ // return Service.Get(p, dateTime1, dateTime2); //} } #region ISurvey Service public interface ISurveyService { Survey Get(int id); List Get(); List GetWithCategoryID(int categoryId); List Get(DateTime today); //List Get(Employee oEmp); int Save(Survey item); void Delete(int id); void Publish(Survey survey); void Stop(Survey survey); List Get(DateTime dateTime1, DateTime dateTime2); List Get(int p, DateTime dateTime1, DateTime dateTime2); List GetQuestionSetByCategoryID(int categoryID); } #endregion }