EchoTex_Payroll/HRM.BO/Attendance/AttnRawData.cs

239 lines
8.0 KiB
C#
Raw Permalink Normal View History

2024-10-14 10:01:49 +06:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Ease.Core;
using System.Globalization;
namespace HRM.BO
{
#region AttnRawData
[Serializable]
public class AttnRawData : AuditTrailBase
{
#region Constructor
public AttnRawData()
{
CardID = 0;
EmployeeID = 0;
CardNo = string.Empty;
PunchTime = DateTime.MinValue;
EntryMode = EnumEntryMode.Unknown;
EmployeeNo = string.Empty;
}
#endregion
#region Properties
public int CardID { get; set; }
public int EmployeeID { get; set; }
public string CardNo { get; set; }
public string EmployeeNo { get; set; }
public DateTime PunchTime { get; set; }
//public DateTime PunchTimeDateString { get; set; }
public string PunchTimeDateString { get; set; }
public EnumEntryMode EntryMode { get; set; }
public string DeviceIPAddress { get; set; }
public string DeviceNo { get; set; }
public string EmployeeName { get; set; }
public bool IsMobileOfflineData { get; set; }
#region AccessCard : AccessCard
private AccessCard _accessCard;
public AccessCard AccessCard
{
get
{
//if (CardID > 0 && _accessCard == null)
//{
// _accessCard = new AccessCard();
// _accessCard = AccessCard.Get(ID.FromInteger(CardID));
//}
return this._accessCard;
}
set { _accessCard = value; }
}
#endregion
//#region Service Factory IAttnRawDataService : IAttnRawDataService
//internal static IAttnRawDataService Service
//{
// get { return Services.Factory.CreateService<IAttnRawDataService>(typeof(IAttnRawDataService)); }
//}
//#endregion
#endregion
//#region Functions
//public static ObjectsTemplate<AttnRawData> Get(DateTime fromDate, DateTime toDate, int payrollTypeID)
//{
// ObjectsTemplate<AttnRawData> attnRawDatas = new ObjectsTemplate<AttnRawData>();
// try
// {
// attnRawDatas = Service.Get(fromDate, toDate, payrollTypeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
// return attnRawDatas;
//}
//public static ObjectsTemplate<AttnRawData> Get(DateTime fromDate, DateTime toDate)
//{
// return Service.Get(fromDate, toDate);
//}
//public static ObjectsTemplate<AttnRawData> Get(DateTime fromDate, DateTime toDate, string empIDs)
//{
// return Service.Get(fromDate, toDate, empIDs);
//}
//public static DataTable GetInOutData(DateTime startDate, DateTime endDate, int employeeID)
//{
// try
// {
// return Service.GetInOutData(startDate, endDate, employeeID);
// }
// catch (ServiceException e)
// {
// throw new Exception(e.Message, e);
// }
//}
//public static EnumAttendanceDB GetAttendanceDBType()
//{
// return Service.GetAttendanceDBType();
//}
//public static ObjectsTemplate<AttnRawData> GetDataFromClientDB(DateTime punchTime)
//{
// return Service.GetDataFromClientDB(punchTime);
//}
//public static void SaveAuto(ObjectsTemplate<AttnRawData> attnRawdatas)
//{
// AttnRawData.Service.SaveAuto(attnRawdatas);
//}
//public List<SalaryProcessStatus> Process(DataTable rowdata)
//{
// List<SalaryProcessStatus> ErrorList = new List<SalaryProcessStatus>();
// AttnProcessRunSummary oRunSummary = new AttnProcessRunSummary();
// bool isInOutApplicable = ConfigurationManager.GetBoolValue("attendence", "inoutapplicable", EnumConfigurationType.Logic);
// ObjectsTemplate<AttnRawData> attnRawDatas = new ObjectsTemplate<AttnRawData>();
// ObjectsTemplate<AccessCard> oAccessCard = AccessCard.Get(EnumCardStatus.Attached, EnumCardStatus.Temporary, EnumCardStatus.Found);
// ObjectsTemplate<Employee> oEmployees = Employee.GetAllEmps();
// bool isEmpnoAndCardnoSame = ConfigurationManager.GetBoolValue("attendence", "isempnoandcardnosame", EnumConfigurationType.Logic);
// AccessCard accessCard = null;
// Employee employee = null;
// foreach (DataRow item in rowdata.Rows)
// {
// if (isEmpnoAndCardnoSame == false)
// {
// string cardNo = Convert.ToString(item["CardNo"]);
// AccessCard ocard = oAccessCard.Find(delegate (AccessCard citem) { return citem.CardNumber == cardNo; });
// if (ocard == null)
// {
// ErrorList.Add(new SalaryProcessStatus(cardNo, "", " Card information not found for the Card No:" + cardNo));
// continue;
// }
// employee = oEmployees.Find(delegate (Employee emp) { return emp.CardID.Integer == ocard.ID.Integer; });
// if (employee == null)
// {
// ErrorList.Add(new SalaryProcessStatus(cardNo, "", "This card is not yet assigned to any employee:" + cardNo));
// continue;
// }
// }
// else
// {
// string sEmployeeNo = item["CardNo"].ToString();
// employee = oEmployees.Where(o => o.EmployeeNo.ToUpper() == sEmployeeNo.ToUpper().Trim())
// .FirstOrDefault();
// if (employee == null)
// {
// ErrorList.Add(new SalaryProcessStatus(sEmployeeNo, "", " Raw Data Contains Employee's Information which is not found in system:" + sEmployeeNo));
// continue;
// }
// }
// AttnRawData oAttnRaw = new AttnRawData();
// oAttnRaw.EmployeeID = employee.ID.Integer;
// oAttnRaw.PunchTime = Convert.ToDateTime(item["Time"].ToString());
// if (isEmpnoAndCardnoSame)
// {
// oAttnRaw.CardNo = employee.EmployeeNo;
// }
// else
// {
// oAttnRaw.CardID = accessCard.ID.Integer;
// oAttnRaw.CardNo = accessCard.CardNumber;
// }
// oAttnRaw.DeviceIPAddress = item["DeviceIPAddress"].ToString();
// oAttnRaw.DeviceNo = item["DeviceNo"].ToString();
// //if (isInOutApplicable)
// //{
// // oAttnRaw.EntryMode = (EnumEntryMode)Convert.ToInt32(item["InOut"].ToString());
// //}
// //else
// //{
// // oAttnRaw.EntryMode = EnumEntryMode.Unknown;
// //}
// attnRawDatas.Add(oAttnRaw);
// }
// if (ErrorList.Count == 0)
// {
// if (attnRawDatas.Count > 0)
// {
// AttnRawData.Service.Save(attnRawDatas);
// }
// else ErrorList.Add(new SalaryProcessStatus("", "", "There is nothing to process or Save. please check your Attandance raw data"));
// }
// //AttnRawData.Service.Save(attnRawDatas);
// return ErrorList;
//}
//#endregion
}
#endregion
#region IAttnRawData Service
public interface IAttnRawDataService
{
List<AttnRawData> Get(DateTime fromDate, DateTime toDate, string empIDs, int payrollTypeID);
void SaveAuto(List<AttnRawData> attnRawData);
}
#endregion
}