//public IEnumerable<T_TMS_EmployeeTimesheetWeeklyDetails> Post(string method, [FromBody] EMPWeelFilter value)
 //{
 //    return T_TMS_EmployeeTimesheetWeeklyDetailsManager.Search(value);
 //}
 public System.Data.DataTable Post(string method, [FromBody] EMPWeelFilter value, string action)
 {
     return(T_TMS_EmployeeTimesheetWeeklyDetailsManager.EmployeeWeeklyReport(value));
 }
        public ContentResult GetEmpWeeklyData([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel, string searchprm)//, int EntityID = 10002,  DateTime? fromdate = null, DateTime? todate = null)
        {
            EMPWeelFilter ObjPara = new EMPWeelFilter()
            {
                EmployeeCode = CurrentUser.EmployeeCode,
                FromDate     = new DateTime(2017, 08, 15),
                ToDate       = new DateTime(2017, 09, 15)
            };

            if (!string.IsNullOrEmpty(searchprm))
            {
                ObjPara = JsonConvert.DeserializeObject <EMPWeelFilter>(searchprm,
                                                                        new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    DateFormatString  = "dd/MM/yyyy"
                });
            }
            //   ObjPara.EmployeeCode = 1863;
            //EMPTMSPara SearchKey = new EMPTMSPara()
            //{
            //    EntityID = 10002,
            //    DeptID = 0,
            //    @FromDate = fromdate ,
            //    @ToDate = todate,
            //    OrderBy = "EmployeeNo",
            //    OrderDirection = "DESC",
            //    Page = (requestModel.Start / requestModel.Length) + 1,
            //    PageSize = requestModel.Length,
            //};
            //fromdate = fromdate == null ? SystemConfig.CurrentDate : fromdate;
            //todate = todate == null ? SystemConfig.CurrentDate : todate;
            //ObjPara.OrderBy = "DeptName";
            //ObjPara.OrderDirection = "ASC";
            //ObjPara.Page = (requestModel.Start / requestModel.Length) + 1;
            //ObjPara.PageSize = requestModel.Length;
            DataTable collection = new DataTable();

            collection = T_TMS_EmployeeTimesheetWeeklyDetailsManager.EmployeeTMSWeeeklyFilter(ObjPara);

            System.Data.DataColumn newColumn = new System.Data.DataColumn("Accumulate", typeof(System.String));
            //newColumn.DefaultValue = "Summary";
            collection.Columns.Add(newColumn);
            int            TotalRecord = 0;
            EmpWeekSummary myWeek      = new EmpWeekSummary();

            if (collection.Rows.Count > 0)
            {
                for (int i = 0; i < collection.Rows.Count; i++)
                {
                    //collection.Rows[i]["Accumulate"] = data(collection.Rows[i],i,out myWeek);
                    data(collection.Rows[i], i, ref myWeek);
                }
                myWeek.TotalWorkHour             = 42;
                collection.Rows[1]["Accumulate"] = myWeek.IntoWeek;
                collection.Rows[2]["Accumulate"] = myWeek.WorkHourString;
                collection.Rows[3]["Accumulate"] = myWeek.OTSummary == 0? "":myWeek.OTString.ToString();
                collection.Rows[4]["Accumulate"] = myWeek.LeaveSummary == 0 ? "" : myWeek.LeaveString.ToString();
                collection.Rows[5]["Accumulate"] = myWeek.UnNoregSummary == 0 ? "" : myWeek.UnoRegString.ToString();
                collection.Rows[6]["Accumulate"] = myWeek.LackingHour == 0 ? "" : myWeek.LackingHourString;
                TotalRecord = Convert.ToInt32(collection.Rows.Count);
            }

            IEnumerable <DataRow> rows = collection.AsEnumerable().ToList();
            object temp = new object();

            foreach (var item in rows)
            {
                temp = item.Table;
            }
            //DataTablesResponseExtend results = new DataTablesResponseExtend(requestModel.Draw, temp, TotalRecord, TotalRecord);
            return(Content(JsonConvert.SerializeObject(new DataTablesResponseExtend(requestModel.Draw, temp, TotalRecord, TotalRecord)), "application/json"));
        }
Example #3
0
        public virtual void Execute()
        {
            try
            {
                SearchFilter SearchKey   = new SearchFilter();
                DateTime     CurrentDate = SystemConfig.CurrentDate.AddDays(-1);
                SearchKey.ColumnsName    = "EmployeeCode,EntityID,DateID";
                SearchKey.CompanyID      = 1;
                SearchKey.Page           = 1;
                SearchKey.PageSize       = 10;
                SearchKey.OrderBy        = "EmployeeCode";
                SearchKey.OrderDirection = "Desc";


                SearchKey.Condition = "  DateID='" + CurrentDate.ToString("yyyy-MM-dd") + "' ";
                // SearchKey.Condition = "  DateID='2017-09-13' ";
                T_TMS_EmployeeDailyTimesheetTransactionCollection obj;
                Models.EmpTaskFilter filter = new Models.EmpTaskFilter();
                filter.DateID = CurrentDate;

                for (int i = 10001; i < 10005; i++)
                {
                    SearchKey.Keyword = i.ToString();
                    obj = T_TMS_EmployeeDailyTimesheetTransactionManager.Search(SearchKey);
                    if (obj.Count == 0)
                    {
                        //insert day
                        filter.EntityID           = i;
                        filter.WorkingTimeGroupID = null;
                        if (i == 10003)
                        {
                            filter.WorkingTimeGroupID = 1;
                        }

                        EmpTaskManager.EmployeeGroup_Daily_Add(filter);
                    }
                }
                T_TMS_EmployeeTimesheetWeeklyDetailsCollection mycol;
                SearchKey.Condition = "  WorkDate='" + CurrentDate.ToString("yyyy-MM-dd") + "' ";
                for (int i = 10001; i < 10005; i++)
                {
                    SearchKey.Keyword = i.ToString();
                    mycol             = T_TMS_EmployeeTimesheetWeeklyDetailsManager.Search(SearchKey);
                    if (mycol.Count == 0)
                    {
                        //insert day
                        filter.EntityID           = i;
                        filter.WorkingTimeGroupID = null;
                        if (i == 10003)
                        {
                            filter.WorkingTimeGroupID = 1;
                        }

                        EmpTaskManager.Employee_Weekly_Add(filter);
                    }
                }
                //T_TMS_EmployeeDailyTimesheetTransactionCollection obj = T_TMS_EmployeeDailyTimesheetTransactionManager.Search(SearchKey);
            }
            catch (Exception exc)
            {
                // _logger.Error(string.Format("Error sending e-mail. {0}", exc.Message), exc);
            }
            finally
            {
                //queuedEmail.SentTries = queuedEmail.SentTries + 1;
                //    _queuedEmailService.UpdateQueuedEmail(queuedEmail);
            }
        }