public void NUnit_CardHistory_Domain_Get()
 {
     string status = string.Empty;
     Att_RosterServices service = new Att_RosterServices();
     var repo = service.GetAllUseEntity<Att_RosterEntity>(ref status);
     Console.Write("Total Record: " + repo.Count());
 }
 public void NUnit_CardHistory_Domain_GetById()
 {
     Att_RosterServices service = new Att_RosterServices();
     var model = new Att_Roster { Id = 1 };
     string status = string.Empty;
     var result = service.GetById<Att_RosterEntity>(model.Id, ref status) as Att_RosterEntity;
     NUnit.Framework.Assert.IsNotNull(result);
     Console.Write("SearchResult: " + result.Id
         + " | " + result.ProfileID
         + " | " + result.Comment
         );
 }
Example #3
0
 //SonVo - 20140617 - chuyển thành trạng thái Sumit
 public ActionResult SubmitRoster(string selectedIds)
 {
     List<Guid> ids = new List<Guid>();
     if (selectedIds != null)
     {
         ids = selectedIds
            .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
            .Select(x => new Guid(x))
            .ToList();
     }
     Att_RosterServices service = new Att_RosterServices();
     service.SubmitRoster(ids);
     return Json("");
 }
 public void NUnit_CardHistory_Domain_Edit()
 {
     Att_RosterServices service = new Att_RosterServices();
     var model = new Att_Roster
     {
         Id = 1,
         ProfileID = 1,
         Comment = "Update Name ",
     };
     string result = service.Edit(model);
     if (result != string.Empty)
     {
         Console.WriteLine("Process Success >>> Update >>> " + model.Id
                 + " | " + model.ProfileID
                 + " | " + model.Comment
                 );
     }
 }
 public void NUnit_CardHistory_Domain_Add()
 {
     Att_RosterServices service = new Att_RosterServices();
     string result = string.Empty;
     int countSC = 0;
     for (int i = 1; i <= 10; i++)
     {
         var model = new Att_Roster
         {
             ProfileID = 1,
             Comment = "Comment " + i
         };
         result = service.Add(model);
         if (result != string.Empty)
         {
             countSC += 1;
             Console.WriteLine("Process Success >>> Create >>> " + model.Id
                 + " | " + model.Comment
                 );
         }
     }
     Console.WriteLine("Total success record: " + countSC);
 }
Example #6
0
        public Att_RosterModel Post([Bind]Att_RosterModel model)
        {
            ActionService service = new ActionService(UserLogin);
            var baseService = new BaseService();
            string status = string.Empty;
            var hrService = new Hre_ProfileServices();
            string strMessages = string.Empty;
            var rosterService = new Att_RosterServices();
            var sysAllSetttingService = new Sys_AllSettingServices();
            #region Validate
            string message = string.Empty;
            var checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Att_RosterModel>(model, "Att_Roster", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            checkValidate = HRM.Business.Main.Domain.ValidatorService.OnValidateData<Att_RosterModel>(model, "Att_ProfileNotRoster", ref message);
            if (!checkValidate)
            {
                model.ActionStatus = message;
                return model;
            }
            if (string.IsNullOrEmpty(model.OrgStructureIDs) && string.IsNullOrEmpty(model.ProfileIds) && model.ProfileID == Guid.Empty)
            {
                message = string.Format(ConstantMessages.FieldNotAllowNull.TranslateString(), ("ProfileID").TranslateString());
                model.ActionStatus = message;
                return model;
            }
            #endregion

            List<Guid> lstProfileIDs = new List<Guid>();

            if(!string.IsNullOrEmpty(model.OrgStructureIDs))
            {
                List<object> listObj = new List<object>();
                listObj.Add(model.OrgStructureIDs);
                listObj.Add(string.Empty);
                listObj.Add(string.Empty);
                var lstProfile = hrService.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure,UserLogin, ref status).Select(s => s.ID).ToList();
               lstProfileIDs.AddRange(lstProfile);
            }
            else if (model.ProfileIds != null && model.ProfileIds!="")
            {
               var listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray();
               lstProfileIDs.AddRange(listGuid);
            }
            var lstRosterEntity_Validate = new List<Att_RosterEntity>();
            foreach (var item in lstProfileIDs)
            {
                Att_RosterEntity rosterEntity = model.CopyData<Att_RosterEntity>();
                rosterEntity.ProfileID = item;
                if (rosterEntity.ID != null && rosterEntity.ID!= Guid.Empty)
                {
                }
                else
                {
                    rosterEntity.ID = Guid.NewGuid();
                }
                lstRosterEntity_Validate.Add(rosterEntity);
            }
            var key = AppConfig.HRM_ATT_ALLOWSAVEDUPLICATE.ToString();
            var lstSysAllSetting = sysAllSetttingService.GetData<Sys_AllSettingEntity>(key,ConstantSql.hrm_sys_sp_get_AllSettingByKey,UserLogin, ref status).FirstOrDefault();


            var ValidateLess12Hour = AppConfig.HRM_ATT_VALIDATE_ROSTER_NON_CONTINUE_12HOUR.ToString();
            var lstSysSetting_ValidateLess12Hour = sysAllSetttingService.GetData<Sys_AllSettingEntity>(ValidateLess12Hour, ConstantSql.hrm_sys_sp_get_AllSettingByKey,UserLogin, ref status).FirstOrDefault();
            if (lstSysSetting_ValidateLess12Hour != null && lstSysSetting_ValidateLess12Hour.Value1==bool.TrueString)
            {
                string Err = string.Empty;
                Err = rosterService.ValidateShiftHourContinue(lstRosterEntity_Validate);
                if (Err != string.Empty)
                {
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + Err);
                    return model;
                }
            }

            if (!string.IsNullOrEmpty(model.OrgStructureIDs))
            {
                List<object> listObj = new List<object>();
                listObj.Add(model.OrgStructureIDs);
                listObj.Add(string.Empty);
                listObj.Add(string.Empty);
                var lstProfile = hrService.GetData<Hre_ProfileEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure,UserLogin, ref status).Select(s => s.ID).ToList();
                if(lstProfile.Count==0 || lstProfile == null)
                {
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Info + "," + strMessages + ConstantMessages.FieldDuplicate);
                    return model;
                }
                if(lstProfile != null && model.ProfileIds != null)
                {
                        Guid[] listGuid = null;
                        listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray();
                        lstProfile = lstProfile.Where(s => !listGuid.Contains(s)).ToList();
                }
                List<Att_RosterEntity> lstRosterEntity = new List<Att_RosterEntity>();
                List<object> paraRoster = new List<object>();
                paraRoster.AddRange(new object[4]);
                paraRoster[0]=(object)model.OrgStructureIDs;
                paraRoster[1]=null;
                paraRoster[2]=null;
                paraRoster[3]=null;
                var listRosterData = rosterService.GetData<Att_RosterEntity>(paraRoster, ConstantSql.hrm_att_getdata_Roster,UserLogin, ref status);
                foreach (var item in lstProfile)
                {
                    Att_RosterModel modelSave = model.CopyData<Att_RosterModel>();
                    var listRoster = listRosterData.Where(s => s.ProfileID == item);
                    if (modelSave.Type != RosterType.E_CHANGE_SHIFT.ToString()
                        && modelSave.Type != RosterType.E_TIME_OFF.ToString() 
                        && listRoster != null 
                        && listRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart))
                    {
                        strMessages += listRoster.FirstOrDefault().ProfileName + ", ";
                        continue;
                    }
                    modelSave.ProfileID = item;
                    Att_RosterEntity rosterEntity = modelSave.CopyData<Att_RosterEntity>();
                    lstRosterEntity.Add(rosterEntity);
                }
                if (strMessages == "" && lstRosterEntity.Count > 0)
                {
                    model.ActionStatus = rosterService.Add(lstRosterEntity);
                }
                else
                {
                    if (lstSysAllSetting != null && lstSysAllSetting.Value1 == bool.TrueString && lstRosterEntity.Count > 0)
                    {
                        model.ActionStatus = rosterService.Add(lstRosterEntity);
                    }
                    else if (lstSysAllSetting.Value1 == bool.FalseString)
                    {
                        model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                        return model;
                    }
                    else if(lstRosterEntity.Count == 0)
                    {
                        model.SetPropertyValue(Constant.ActionStatus, NotificationType.Info + "," + strMessages + ConstantMessages.FieldDuplicate);
                        return model;
                    }
                }
                return model;
            }
            //Xử lý khi chọn nhiều nhân viên
            if (model.ProfileIds != null && model.ProfileIds.IndexOf(',') > 0 && model.OrgStructureIDs == null)
            {
                Guid[] listGuid = null;
                listGuid = model.ProfileIds.Split(',').Select(s => Guid.Parse(s)).ToArray();
                List<Att_RosterEntity> lstRosterEntity = new List<Att_RosterEntity>();
                foreach (var item in listGuid)
                {
                    Att_RosterModel modelSave = model.CopyData<Att_RosterModel>();
                    var listRoster = service.GetData<Att_RosterEntity>(item, ConstantSql.hrm_att_sp_get_RosterByProfileId, ref status);
                    if (modelSave.Type != RosterType.E_CHANGE_SHIFT.ToString()
                        && modelSave.Type != RosterType.E_TIME_OFF.ToString()
                        && listRoster != null
                        && listRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart))
                    {
                        strMessages += listRoster.FirstOrDefault().ProfileName + ", ";
                        continue;
                    }
                    modelSave.ProfileID = item;
                    Att_RosterEntity rosterEntity = modelSave.CopyData<Att_RosterEntity>();
                    lstRosterEntity.Add(rosterEntity);
                }
                if(strMessages == "")
                {
                    model.ActionStatus = rosterService.Add(lstRosterEntity);
                }
                else
                {
                    if (lstSysAllSetting != null && lstSysAllSetting.Value1 == bool.TrueString)
                    {
                        model.ActionStatus = rosterService.Add(lstRosterEntity);
                    }
                    else
                    {
                        model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                        return model;
                    }
                }
                return model;
            }
            //Xử lý khi chỉ chọn 1 nhân viên
            if(model.ID == Guid.Empty){
                var lstRoster = service.GetData<Att_RosterEntity>(model.ProfileID, ConstantSql.hrm_att_sp_get_RosterByProfileId, ref status);
                if (model.Type != RosterType.E_CHANGE_SHIFT.ToString()
                    && model.Type != RosterType.E_TIME_OFF.ToString()
                    && lstRoster != null 
                    && lstRoster.Any(d => d.DateStart <= model.DateEnd && d.DateEnd >= model.DateStart))
                {
                    strMessages = lstRoster.FirstOrDefault().ProfileName + ",";
                    model.SetPropertyValue(Constant.ActionStatus, NotificationType.Error + "," + strMessages + ConstantMessages.FieldDuplicate);
                    return model;
                }
                return service.UpdateOrCreate<Att_RosterEntity, Att_RosterModel>(model);
            }
            return service.UpdateOrCreate<Att_RosterEntity, Att_RosterModel>(model);
        }
Example #7
0
        public static void GetRosterGroup(List<Guid> lstProfileID, DateTime? DateFrom, DateTime? DateTo, string userLogin, out List<Att_RosterEntity> lstRosterTypeGroup, out List<Att_RosterGroup> lstRosterGroup)
        {
            var _attRoster = new Att_RosterServices();
            var _attRosterGroup = new Att_RosterGroupServices();
            string status = string.Empty;

            lstRosterGroup = new List<Att_RosterGroup>();
            lstRosterTypeGroup = new List<Att_RosterEntity>();

            string E_APPROVED = RosterStatus.E_APPROVED.ToString();
            string E_ROSTERGROUP = RosterType.E_ROSTERGROUP.ToString();

            var lstobject = new List<object>();
            lstobject.AddRange(new object[10]);
            lstobject[8] = 1;
            lstobject[9] = int.MaxValue;

            var lstobject1 = new List<object>();
            lstobject1.AddRange(new object[6]);
            lstobject1[4] = 1;
            lstobject1[5] = int.MaxValue;

            if (DateFrom == null || DateTo == null)
            {
                lstRosterTypeGroup = _attRoster.GetData<Att_RosterEntity>(lstobject, ConstantSql.hrm_att_sp_get_Roster, userLogin, ref status).Where(m => lstProfileID.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP).ToList<Att_RosterEntity>();
                lstRosterGroup = _attRosterGroup.GetData<Att_RosterGroupEntity>(lstobject1, ConstantSql.hrm_att_sp_get_RosterGroup,userLogin, ref status).Where(m => m.DateStart != null && m.DateEnd != null).ToList<Att_RosterGroupEntity>().CopyData<List<Att_RosterGroup>>();
            }
            else
            {
                lstRosterTypeGroup = _attRoster.GetData<Att_RosterEntity>(lstobject, ConstantSql.hrm_att_sp_get_Roster, userLogin, ref status).Where(m => lstProfileID.Contains(m.ProfileID) && m.Status == E_APPROVED && m.Type == E_ROSTERGROUP && m.DateStart <= DateTo).ToList<Att_RosterEntity>();
                lstRosterGroup = _attRosterGroup.GetData<Att_RosterGroupEntity>(lstobject1, ConstantSql.hrm_att_sp_get_RosterGroup, userLogin, ref status).Where(m => m.DateStart != null && m.DateEnd != null && m.DateStart <= DateTo && m.DateEnd >= DateFrom).ToList<Att_RosterGroupEntity>().CopyData<List<Att_RosterGroup>>();
            }
        }
 public void NUnit_CardHistory_Domain_Remove()
 {
     Att_RosterServices service = new Att_RosterServices();
     int rs = 0;
     var model = new Att_Roster { Id = 1 };
     string result = service.Remove<Att_RosterEntity>(model.Id);
     if (result != string.Empty)
     {
         rs += 1;
         Console.WriteLine("Process Success >>> Remove >>> " + model.Id);
     }
 }
 public void NUnit_CardHistory_Domain_Delete()
 {
     Att_RosterServices service = new Att_RosterServices();
     int rs = 0;
     var model = new Att_Roster { Id = 2 };
     string result = service.Delete<Att_RosterEntity>(model.Id);
     if (result != null)
     {
         rs += 1;
         Console.WriteLine("Process Success >>> Delete >>> " + model.Id);
     }
 }