当前位置: 首页>>代码示例>>C#>>正文


C# UnitOfWork.CreateQueryable方法代码示例

本文整理汇总了C#中UnitOfWork.CreateQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# UnitOfWork.CreateQueryable方法的具体用法?C# UnitOfWork.CreateQueryable怎么用?C# UnitOfWork.CreateQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnitOfWork的用法示例。


在下文中一共展示了UnitOfWork.CreateQueryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SyncCardHistory

        public void SyncCardHistory()
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                string syncType = SyncDataType.Sync_Card_History.ToString();

                var listSyncInfo = unitOfWork.CreateQueryable<Cat_Sync>(d => d.Code == syncType
                    && (!d.IsFromInner.HasValue || !d.IsFromInner.Value)).Select(d => new
                    {
                        d.ID,
                        d.Code,
                        d.SyncName,
                        d.ServerName,
                        d.UserName,
                        d.PassWord,
                        d.DatabaseName,
                        d.InnerTable,
                        d.OuterTable,
                        d.IsFromInner
                    }).ToList();

                var listSyncID = listSyncInfo.Select(d => d.ID).ToArray();

                var listSyncItemInfo = unitOfWork.CreateQueryable<Cat_SyncItem>(d =>
                    d.SyncID.HasValue && listSyncID.Contains(d.SyncID.Value)).Select(d => new
                    {
                        d.IsExcluded,
                        d.InnerField,
                        d.OuterField,
                        d.AllowNull,
                        d.AllowDuplicate,
                        d.DuplicateGroup,
                        d.FilterValues,
                        d.SyncID
                    }).ToList();

                foreach (var syncInfo in listSyncInfo)
                {
                    string connectionString = DbClientHelper.BuildSqlConnectionString(syncInfo.ServerName,
                        syncInfo.DatabaseName, syncInfo.UserName, syncInfo.PassWord);

                    var syncItems = listSyncItemInfo.Where(d => d.SyncID == syncInfo.ID);
                    SqlConnection connection = new SqlConnection(connectionString);

                    using (DbCommander commander = new DbCommander(connection))
                    {

                    }
                }
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:52,代码来源:SyncDataRepository.cs

示例2: CompleteComputingTask

        public void CompleteComputingTask(Guid asynTaskID, Guid userID,
            int totalComputed, int totalProfile, DataErrorCode dataErrorCode)
        {
            #region Lưu Sys_AsynTask khi xử lý xong

            if (asynTaskID != Guid.Empty)
            {
                using (var taskContext = new VnrHrmDataContext())
                {
                    IUnitOfWork taskunitOfWork = new UnitOfWork(taskContext);
                    var asynTask = taskunitOfWork.CreateQueryable<Sys_AsynTask>(s => s.ID == asynTaskID).FirstOrDefault();

                    if (asynTask != null)
                    {
                        asynTask.PercentComplete = 1D;
                        asynTask.TimeEnd = DateTime.Now;
                        asynTask.Status = AsynTaskStatus.Done.ToString();

                        var time = asynTask.TimeEnd.Value.Subtract(asynTask.TimeStart).TotalMinutes;
                        asynTask.Description += " - Result: " + totalComputed + "/" + totalProfile;
                        asynTask.Description += " - Time: " + time.ToString("N2");

                        if (dataErrorCode == DataErrorCode.Locked)
                        {
                            asynTask.PercentComplete = 1D;//Không cần nhân với 100
                            asynTask.Description = "Dữ Liệu Quẹt Thẻ Đã Bị Khóa";
                        }

                        dataErrorCode = taskunitOfWork.SaveChanges();
                    }
                }
            }

            #endregion
        }
开发者ID:dtafe,项目名称:vnr,代码行数:35,代码来源:Can_TamServices.cs

示例3: GetEnumDataInfo

        public static List<EnumDataInfo> GetEnumDataInfo(Type enumType)
        {
            var listEnumDataInfo = Utilities.GetEnumDataInfo(enumType);

            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);

                var listEnumName = unitOfWork.CreateQueryable<Sys_EnumFilter>(Guid.Empty,
                    d => d.EnumType == enumType.Name).Select(d => d.EnumName).ToList();

                if (listEnumName != null && listEnumName.Count() > 0)
                {
                    listEnumDataInfo = listEnumDataInfo.Where(d => !listEnumName.Contains(d.Name)).ToList();
                }

                foreach (var item in listEnumDataInfo)
                {
                    var enumValue = Enum.Parse(enumType, item.Name);
                    item.Translate = item.Name.TranslateString();
                }
            }

            return listEnumDataInfo;
        }
开发者ID:dtafe,项目名称:vnr,代码行数:25,代码来源:EnumRepository.cs

示例4: ImportInterviewResult


//.........这里部分代码省略.........
                    }).ToList();

                    var listCandidate = new List<Rec_Candidate>().Select(d => new
                    {
                        d.ID,
                        d.CodeCandidate,
                        d.CandidateName
                    }).ToList();

                    var listGroupCondition = new List<Rec_GroupCondition>().Select(d => new
                    {
                        d.ID,
                        d.Code,
                        d.GroupName
                    }).ToList();

                    var listRecruitmentHistory = new List<Rec_RecruitmentHistory>().Select(d => new
                    {
                        d.ID,
                        d.CandidateID,
                        d.DateApply
                    }).ToList();

                    var listInterview = new List<Rec_Interview>().Select(d => new
                    {
                        d.ID,
                        d.CandidateID,
                        d.GroupConditionID,
                        d.RecruitmentHistoryID
                    }).ToList();

                    foreach (var item in listLanguageCode.Chunk(1000))
                    {
                        listLanguage.AddRange(unitOfWork.CreateQueryable<Cat_NameEntity>(d =>
                            item.Contains(d.Code)).Select(d => new
                            {
                                d.ID,
                                d.Code
                            }).ToList());
                    }

                    foreach (var item in listJobVacancyCode.Chunk(1000))
                    {
                        listJobVacancy.AddRange(unitOfWork.CreateQueryable<Rec_JobVacancy>(d =>
                            item.Contains(d.Code)).Select(d => new
                            {
                                d.ID,
                                d.Code
                            }).ToList());
                    }

                    foreach (var item in listCandidateCode.Chunk(1000))
                    {
                        listCandidate.AddRange(unitOfWork.CreateQueryable<Rec_Candidate>(d =>
                            item.Contains(d.CodeCandidate)).Select(d => new
                            {
                                d.ID,
                                d.CodeCandidate,
                                d.CandidateName
                            }).ToList());
                    }

                    foreach (var item in listGroupConditionCode.Chunk(1000))
                    {
                        listGroupCondition.AddRange(unitOfWork.CreateQueryable<Rec_GroupCondition>(d =>
                            item.Contains(d.Code)).Select(d => new
开发者ID:dtafe,项目名称:vnr,代码行数:67,代码来源:Rec_ImportInterviewResultService.cs

示例5: UpdateUserMasterDataGroup

        public void UpdateUserMasterDataGroup(Guid userID, List<Guid?> listMasterDataGroupID)
        {
            if (userID != Guid.Empty && listMasterDataGroupID != null)
            {
                using (var context = new VnrHrmDataContext())
                {
                    IUnitOfWork unitOfWork = new UnitOfWork(context);

                    var listMasterDataGroupNumber = unitOfWork.CreateQueryable<Cat_MasterDataGroup>(d => d.OrderNumber.HasValue
                        && listMasterDataGroupID.Contains(d.ID)).Select(d => d.OrderNumber.Value).ToList();

                    var userMasterDataGroup = unitOfWork.CreateQueryable<Sys_UserMasterData>(d =>
                        d.UserID == userID).FirstOrDefault();

                    if (userMasterDataGroup == null)
                    {
                        userMasterDataGroup = new Sys_UserMasterData
                        {
                            UserID = userID
                        };

                        unitOfWork.AddObject(typeof(Sys_UserMasterData), userMasterDataGroup);
                    }

                    userMasterDataGroup.MasterDataGroups = listMasterDataGroupNumber.ToBinary();
                    userMasterDataGroup.MasterDataGroup = string.Join(",", listMasterDataGroupNumber);
                    unitOfWork.SaveChanges(userID);
                }
            }

        }
开发者ID:dtafe,项目名称:vnr,代码行数:31,代码来源:Sys_UserServices.cs

示例6: CheckData

        private void CheckData(List<ImportRosterModel> listRoster, bool check12Hours, bool isAllowEditFutureRoster,
            bool isAllowEditPastRoster, List<string> listProfileCode, List<Cat_Shift> listShiftInfo)
        {
            #region Kiểm tra dữ liệu lỗi

            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                var listRosterCorrect = ImportObjects[LoginUserID];
                var listRosterError = InvalidObjects[LoginUserID];

                var listProfileInfo = unitOfWork.CreateQueryable<Hre_Profile>(LoginUserID,
                    d => listProfileCode.Contains(d.CodeEmp.ToUpper())).Select(d => new { d.ID, d.CodeEmp }).ToList();

                var listProfileID = listProfileInfo.Select(d => d.ID).Distinct().ToList();
                var dateStart = listRoster.Select(d => d.DateStart).OrderBy(d => d).FirstOrDefault();
                var dateEnd = listRoster.Select(d => d.DateEnd).OrderBy(d => d).LastOrDefault();
                var monthStart = dateStart.Date.AddDays(1 - dateStart.Day);
                var monthEnd = monthStart.AddMonths(1).AddSeconds(-1);
                var checkDate = dateStart.AddDays(-1);

                string cancelStatus = RosterStatus.E_CANCEL.ToString();
                string rejectStatus = RosterStatus.E_REJECTED.ToString();
                var currentDate = unitOfWork.CurrentDate();

                var listOldRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.Status != cancelStatus
                    && d.Status != rejectStatus && listProfileID.Contains(d.ProfileID) && d.DateStart <= dateEnd
                    && d.DateEnd >= checkDate).Select(d => new
                    {
                        d.ProfileID,
                        d.DateStart,
                        d.DateEnd,
                        d.MonShiftID,
                        d.TueShiftID,
                        d.WedShiftID,
                        d.ThuShiftID,
                        d.FriShiftID,
                        d.SatShiftID,
                        d.SunShiftID,
                        d.Status,
                        d.Type
                    }).ToList();

                foreach (var roster in listRoster)
                {
                    var profileInfo = listProfileInfo.Where(d => d.CodeEmp != null
                        && d.CodeEmp.ToUpper() == roster.CodeEmp).FirstOrDefault();

                    if (profileInfo != null)
                    {
                        roster.ProfileID = profileInfo.ID;
                        string shiftNotFound = string.Empty;
                        var listShiftNotFound = new List<string>();

                        if (!string.IsNullOrWhiteSpace(roster.MonShift))
                        {
                            var shiftInfo = listShiftInfo.Where(d =>
                                d.Code == roster.MonShift).FirstOrDefault();

                            if (shiftInfo != null)
                            {
                                roster.MonShiftID = shiftInfo.ID;
                            }
                            else
                            {
                                if (!listShiftNotFound.Contains(roster.MonShift))
                                {
                                    listShiftNotFound.Add(roster.MonShift);
                                    shiftNotFound += (string.IsNullOrWhiteSpace(shiftNotFound)
                                        ? string.Empty : ",") + roster.MonShift;
                                }
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(roster.TueShift))
                        {
                            var shiftInfo = listShiftInfo.Where(d =>
                                d.Code == roster.TueShift).FirstOrDefault();

                            if (shiftInfo != null)
                            {
                                roster.TueShiftID = shiftInfo.ID;
                            }
                            else
                            {
                                if (!listShiftNotFound.Contains(roster.TueShift))
                                {
                                    listShiftNotFound.Add(roster.TueShift);
                                    shiftNotFound += (string.IsNullOrWhiteSpace(shiftNotFound)
                                        ? string.Empty : ",") + roster.TueShift;
                                }
                            }
                        }

                        if (!string.IsNullOrWhiteSpace(roster.WedShift))
                        {
                            var shiftInfo = listShiftInfo.Where(d =>
                                d.Code == roster.WedShift).FirstOrDefault();

                            if (shiftInfo != null)
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:ImportRosterService.cs

示例7: IsConnected

        public bool IsConnected(AppConfig tamConfig, bool checkState, ref string serverTamLogConfig)
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                string settingkey = tamConfig.ToString();

                var listSetting = unitOfWork.CreateQueryable<Sys_AllSetting>(Guid.Empty,
                    d => d.Name.Contains(settingkey)).ToArray();

                string serverName = listSetting.Where(m => m.Name == settingkey + AppConfig.SERVERNAME).Select(m => m.Value1).FirstOrDefault();
                string userName = listSetting.Where(m => m.Name == settingkey + AppConfig.USERID).Select(m => m.Value1).FirstOrDefault();
                string password = listSetting.Where(m => m.Name == settingkey + AppConfig.PASSWORD).Select(m => m.Value1).FirstOrDefault();
                string dbName = listSetting.Where(m => m.Name == settingkey + AppConfig.DBNAME).Select(m => m.Value1).FirstOrDefault();
                string isActivated = listSetting.Where(m => m.Name == settingkey + AppConfig.ISACTIVATED).Select(m => m.Value1).FirstOrDefault();

                string tableName = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.TABLENAME).Select(m => m.Value1).FirstOrDefault();
                string dataColName = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.DATACOLNAME).Select(m => m.Value1).FirstOrDefault();
                string cardColName = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.CARDCOLNAME).Select(m => m.Value1).FirstOrDefault();
                string typeColName = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.TYPE).Select(m => m.Value1).FirstOrDefault();

                string filterColumn = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.FILTERDATA).Select(m => m.Value1).FirstOrDefault();
                string filterData = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.FILTERDATASPLIT).Select(m => m.Value1).FirstOrDefault();
                string machineCode = listSetting.Where(m => m.Name == tamConfig.ToString() + AppConfig.MACHINECODE).Select(m => m.Value1).FirstOrDefault();
                string isByCodeEmp = listSetting.Where(m => m.Name == settingkey + AppConfig.ISCODEEMP).Select(m => m.Value1).FirstOrDefault();

                if (listSetting != null && listSetting.Count() > 0)
                {
                    string connectString = "provider=SQLOLEDB;DATA SOURCE=" + serverName + ";Initial Catalog="
                        + dbName + ";USER ID=" + userName + ";Password=" + password + ";";

                    try
                    {
                        if (!checkState || isActivated == bool.TrueString)
                        {
                            System.Data.OleDb.OleDbConnection cn = new System.Data.OleDb.OleDbConnection();
                            cn.ConnectionString = connectString;
                            cn.Open();
                            cn.Close();
                        }
                        else
                        {
                            return false;
                        }
                    }
                    catch (System.Exception)
                    {
                        return false;
                    }

                    if (isActivated == bool.TrueString)
                    {
                        serverTamLogConfig = connectString + "|"
                                    + tableName + "|"
                                    + dataColName + "|"
                                    + cardColName + "|"
                                    + typeColName + "|"
                                    + filterColumn + "|"
                                    + filterData + "|"
                                    + machineCode + "|"
                                    + isByCodeEmp;
                    }

                    return true;
                }

                return false;
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:69,代码来源:Can_TamServices.cs

示例8: SyncTAMLog

        public void SyncTAMLog(Guid userID, Guid taskID, bool isExcept, DateTime dateFrom, DateTime dateTo,
            List<Guid> listOrgStructureID, List<Guid> listPayrollGroupID, List<Guid> listWorkplaceID)
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                string waitStatus = ProfileStatusSyn.E_WAITING.ToString();

                var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(userID);

                if (listOrgStructureID != null && listOrgStructureID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.OrgStructureID.HasValue
                        && listOrgStructureID.Contains(d.OrgStructureID.Value));
                }

                if (listPayrollGroupID != null && listPayrollGroupID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.PayrollGroupID.HasValue
                        && listPayrollGroupID.Contains(d.PayrollGroupID.Value));
                }

                if (listWorkplaceID != null && listWorkplaceID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.WorkPlaceID.HasValue
                        && listWorkplaceID.Contains(d.WorkPlaceID.Value));
                }

                var listProfileID = profileQueryable.Where(d => (d.StatusSyn == null || d.StatusSyn != waitStatus)
                    && (d.DateQuit == null || d.DateQuit.Value > dateFrom)).Select(d => d.ID).ToList();

                SyncTAMLog(userID, taskID, isExcept, dateFrom, dateTo, listProfileID);
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:34,代码来源:Can_TamServices.cs

示例9: GetReportProfileInformation


//.........这里部分代码省略.........
                //    IDNo = d.IDNo,
                //    IDDateOfIssue = d.IDDateOfIssue,
                //    IDPlaceOfIssue = d.IDPlaceOfIssue,
                //    DateHire = d.DateHire,
                //    DateQuit = d.DateQuit,
                //    StatusSyn = d.StatusSyn,
                //    PositionName = d.Cat_Position.PositionName,
                //    SalaryClassName = d.Cat_SalaryClass.SalaryClassName,
                //    EducationLevelName = d.Cat_NameEntity.NameEntityName,
                //    GraduatedLevelName = d.Cat_NameEntity1.NameEntityName,
                //    CostCentreName = d.Cat_CostCentre.CostCentreName,
                //    EthnicGroupName = d.Cat_EthnicGroup.EthnicGroupName,
                //    OrgStructureID=d.OrgStructureID


                //}).ToList();

                #region code BC
                List<Guid> lstProfileIDs = lstProfile.Select(m => m.ID).Distinct().ToList();
                string E_APPROVED = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();

                var lstContractAll = new List<Hre_Contract>().Select(m => new
                {
                    m.ID,
                    m.ContractTypeID,
                    m.ProfileID,
                    m.DateStart,
                    m.DateEnd,
                    m.ContractNo
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstContractAll.AddRange(unitOfWork.CreateQueryable<Hre_Contract>(Guid.Empty, m => m.Status == E_APPROVED
                        && lstProfileID.Contains(m.ProfileID) && m.DateStart <= monthEnd && m.DateEnd >= monthStart).Select(m => new
                        {
                            m.ID,
                            m.ContractTypeID,
                            m.ProfileID,
                            m.DateStart,
                            m.DateEnd,
                            m.ContractNo
                        }).ToList());
                }

                List<Guid> lstContractIDs = lstContractAll.Select(m => m.ID).ToList();
                var lstAppendixContract = new List<Hre_AppendixContract>().Select(m => new
                {
                    m.ID,
                    m.ContractID,
                    m.Code,
                    m.DateofEffect,
                    m.DateEndAppendixContract
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstAppendixContract.AddRange(unitOfWork.CreateQueryable<Hre_AppendixContract>(Guid.Empty,
                        m => lstContractID.Contains(m.ContractID)).Select(m => new
                        {
                            m.ID,
                            m.ContractID,
                            m.Code,
                            m.DateofEffect,
                            m.DateEndAppendixContract
                        }).ToList());
开发者ID:dtafe,项目名称:vnr,代码行数:67,代码来源:Hre_ReportServices.cs

示例10: ComputeAttendance

        public DataErrorCode ComputeAttendance(Guid asynTaskID, Guid userID,
            DateTime monthYear, Guid cutOffDurationID, List<Guid> listOrgStructureID,
            List<Guid> listPayrollGroupID, List<Guid> listWorkplaceID, bool onlyQuitEmp)
        {
            DataErrorCode dataErrorCode = DataErrorCode.Success;
            Hre_ProfileEntity[] listProfile = null;

            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);

                var profileQueryable = unitOfWork.CreateQueryable<Hre_Profile>(userID);

                if (listOrgStructureID != null && listOrgStructureID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.OrgStructureID.HasValue
                        && listOrgStructureID.Contains(d.OrgStructureID.Value));
                }

                if (listPayrollGroupID != null && listPayrollGroupID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.PayrollGroupID.HasValue
                        && listPayrollGroupID.Contains(d.PayrollGroupID.Value));
                }

                if (listWorkplaceID != null && listWorkplaceID.Count() > 0)
                {
                    profileQueryable = profileQueryable.Where(d => d.WorkPlaceID.HasValue
                        && listWorkplaceID.Contains(d.WorkPlaceID.Value));
                }

                if (onlyQuitEmp)
                {
                    DateTime monthEnd = monthYear.AddMonths(1).AddSeconds(-1);
                    profileQueryable = profileQueryable.Where(d => d.DateQuit.HasValue
                        && d.DateQuit <= monthEnd);
                }

                listProfile = profileQueryable.Select(d => new Hre_ProfileEntity
                {
                    ID = d.ID,
                    CodeEmp = d.CodeEmp,
                    CodeAttendance = d.CodeAttendance,
                    OrgStructureID = d.OrgStructureID,
                    DateHire = d.DateHire,
                    DateQuit = d.DateQuit
                }).ToArray<Hre_ProfileEntity>();
            }

            ComputeAttendance(asynTaskID, userID, monthYear,
                cutOffDurationID, out dataErrorCode, listProfile);

            return dataErrorCode;
        }
开发者ID:dtafe,项目名称:vnr,代码行数:54,代码来源:Att_AttendanceServices.cs

示例11: Save

        /// <summary>
        /// Convert và lưu dữ liệu import vào database.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="listImportData"></param>
        /// <returns></returns>
        public bool Save(Guid userID, IList listImportData, string userLogin)
        {
            bool result = false;

            if (!isDataSaved)
            {
                if (listImportData != null && listImportData.Count > 0)
                {
                    using (var context = new VnrHrmDataContext())
                    {
                        IUnitOfWork unitOfWork = new UnitOfWork(context);
                        var objectType = listImportData[0].GetPropertyValue(Constant.ObjectType);

                        IList listObj = new ArrayList();
                        var status = DataErrorCode.Success;

                        if (objectType != null)
                        {
                            if (this.ImportMode == ImportDataMode.Update || this.ImportMode == ImportDataMode.Skip)
                            {
                                var listObjectID = listImportData.AsQueryable().Select(Constant.ID).GetList().OfType<Guid>().Distinct().ToArray();
                                listEntityResult = unitOfWork.CreateQueryable(Guid.Empty, (Type)objectType, "@0.Contains(outerIt." + Constant.ID + ")", listObjectID).GetList();

                                foreach (var importData in listImportData)
                                {
                                    var objectID = importData.GetPropertyValue(Constant.ID).TryGetValue<Guid>();
                                    var objectDuplicate = listEntityResult.AsQueryable().Where(Constant.ID + " = @0", objectID).FirstOrDefault();

                                    if (objectDuplicate != null)
                                    {
                                        //Copy dữ liệu import vào dữ liệu trong database
                                        importData.CopyData(objectDuplicate, Constant.ID);
                                    }
                                    else if (this.ImportMode == ImportDataMode.Skip)
                                    {
                                        objectDuplicate = ((Type)objectType).CreateInstance();
                                        importData.CopyData(objectDuplicate, Constant.ID);
                                        unitOfWork.AddObject((Type)objectType, objectDuplicate);
                                    }

                                    if (objectDuplicate != null)
                                    {
                                        listObj.Add(objectDuplicate);
                                    }

                                    var currentIndex = listImportData.IndexOf(importData);

                                    if ((currentIndex + 1) == listImportData.Count || (currentIndex > 0
                                        && listImportData.IndexOf(importData) % 9999 == 0))
                                    {
                                        status = unitOfWork.SaveChanges(userID, true);
                                    }

                                    if (ProgressChanged != null)
                                    {
                                        double percent = ((double)listImportData.IndexOf(importData) / (double)listImportData.Count) * 100;
                                        ProgressChanged(new ProgressEventArgs
                                        {
                                            ID = UserID,
                                            Name = "SaveData",
                                            Value = "SaveData".TranslateString(),
                                            Percent = (int)percent
                                        });
                                    }
                                }

                                result = true;
                            }
                            else
                            {
                                listEntityResult = ((Type)objectType).CreateList();

                                foreach (var importData in listImportData)
                                {
                                    var objectDuplicate = ((Type)objectType).CreateInstance();
                                    importData.CopyData(objectDuplicate, Constant.ID);
                                    unitOfWork.AddObject((Type)objectType, objectDuplicate);

                                    var currentIndex = listImportData.IndexOf(importData);

                                    if ((currentIndex + 1) == listImportData.Count || (currentIndex > 0
                                        && listImportData.IndexOf(importData) % 9999 == 0))
                                    {
                                        status = unitOfWork.SaveChanges(userID, true);
                                    }

                                    if (ProgressChanged != null)
                                    {
                                        double percent = ((double)listImportData.IndexOf(importData) / (double)listImportData.Count) * 100;
                                        ProgressChanged(new ProgressEventArgs
                                        {
                                            ID = UserID,
                                            Name = "SaveData",
                                            Value = "SaveData".TranslateString(),
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:ImportService.cs

示例12: ComputeWorkday

        private int ComputeWorkday(Guid asynTaskID, Guid userID, int totalProfile, int totalComputed, double timeoutMinutes,
            DateTime dateFrom, DateTime dateTo, out DataErrorCode dataErrorCode, params Hre_ProfileEntity[] listProfile)
        {
            List<Att_Workday> listWorkday = new List<Att_Workday>();
            List<Att_Workday> listWorkdayChecked = new List<Att_Workday>();
            List<Att_Workday> listWorkdayAnalyze = new List<Att_Workday>();

            dateFrom = dateFrom <= DateTime.MinValue ? DateTime.Now : dateFrom;
            dateTo = dateTo <= DateTime.MinValue ? DateTime.Now : dateTo;
            DateTime dateStart = dateFrom.AddDays(-1);
            DateTime dateEnd = dateTo.AddDays(1);

            using (var context = new VnrHrmDataContext())
            {
                var workHistoryServices = new Hre_WorkHistoryServices();
                var leavedayServices = new Att_LeavedayServices();
                var unitOfWork = new UnitOfWork(context);

                string waitStatus = ProfileStatusSyn.E_WAITING.ToString();
                string rosterStatus = RosterStatus.E_APPROVED.ToString();
                string leaveDayStatus = LeaveDayStatus.E_APPROVED.ToString();
                String appConfigInfo = AppConfig.E_SERVER_TAM.ToString();
                string E_LEAVE_EARLY = PregnancyType.E_LEAVE_EARLY.ToString();

                string workdaySrcType = WorkdaySrcType.E_MANUAL.ToString();
                string workdayStatus1 = WorkdayStatus.E_APPROVED.ToString();
                string workdayStatus2 = WorkdayStatus.E_WAIT_APPROVED.ToString();
                var listProfileID = listProfile.Select(d => d.ID).ToArray();

                #region Delete Workday đã tổng hợp trước đó

                if (unitOfWork.CheckLock(typeof(Att_Workday), dateFrom, dateTo))
                {
                    dataErrorCode = DataErrorCode.Locked;

                    CompleteComputingTask(asynTaskID, userID,
                        totalComputed, totalProfile, dataErrorCode);

                    return listWorkday.Count();
                }
                else
                {
                    Task task = Task.Run(() => DeleteWorkday(userID, dateFrom, dateTo,
                        workdaySrcType, workdayStatus1, workdayStatus2, listProfileID));
                }

                #endregion

                #region Khởi tạo dữ liệu cho lần tổng hợp

                var tamScanLogQueryable = unitOfWork.CreateQueryable<Att_TAMScanLog>(Guid.Empty, d => d.ProfileID.HasValue
                    && listProfileID.Contains(d.ProfileID.Value) && d.TimeLog.HasValue && d.TimeLog >= dateStart && d.TimeLog <= dateEnd);

                //Danh sách quẹt thẻ theo điều kiện được chọn
                var listAllTamScanLog = tamScanLogQueryable.Select(d => new Att_TAMScanLogEntity
                {
                    ID = d.ID,
                    ProfileID = d.ProfileID,
                    CardCode = d.CardCode,
                    CodeEmp = d.CodeEmp,
                    TimeLog = d.TimeLog,
                    SrcType = d.SrcType,
                    Type = d.Type
                }).ToList();

                var listRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.Status == rosterStatus && d.DateStart <= dateEnd
                    && d.DateEnd >= dateStart.Date && listProfileID.Contains(d.ProfileID)).Select(d => new Att_RosterEntity
                    {
                        ID = d.ID,
                        ProfileID = d.ProfileID,
                        RosterGroupName = d.RosterGroupName,
                        Type = d.Type,
                        Status = d.Status,
                        DateEnd = d.DateEnd,
                        DateStart = d.DateStart,
                        MonShiftID = d.MonShiftID,
                        TueShiftID = d.TueShiftID,
                        WedShiftID = d.WedShiftID,
                        ThuShiftID = d.ThuShiftID,
                        FriShiftID = d.FriShiftID,
                        SatShiftID = d.SatShiftID,
                        SunShiftID = d.SunShiftID,
                        MonShift2ID = d.MonShiftID,
                        TueShift2ID = d.TueShift2ID,
                        WedShift2ID = d.WedShift2ID,
                        ThuShift2ID = d.ThuShift2ID,
                        FriShift2ID = d.FriShift2ID,
                        SatShift2ID = d.SatShift2ID,
                        SunShift2ID = d.SunShift2ID
                    }).ToList();

                var listRosterGroup = unitOfWork.CreateQueryable<Att_RosterGroup>(Guid.Empty, m => m.DateStart != null && m.DateEnd != null
                    && m.DateStart <= dateEnd && m.DateEnd >= dateStart.Date).Select(d => new Att_RosterGroupEntity
                    {
                        ID = d.ID,
                        DateEnd = d.DateEnd,
                        DateStart = d.DateStart,
                        MonShiftID = d.MonShiftID,
                        TueShiftID = d.TueShiftID,
                        WedShiftID = d.WedShiftID,
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Att_WorkDayServices.cs

示例13: DeleteWorkday

        private void DeleteWorkday(Guid userID, DateTime dateFrom, DateTime dateTo,
            string workdaySrcType, string workdayStatus1, string workdayStatus2, params Guid[] listProfileID)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = new UnitOfWork(context);
                int pageSize = 2000;//tối đa là 2100 parameter

                foreach (var listProfileIDBySize in listProfileID.Chunk(pageSize))
                {
                    var workdayQueryable = unitOfWork.CreateQueryable<Att_Workday>(userID, d => d.WorkDate >= dateFrom.Date && d.WorkDate <= dateTo
                        && (d.SrcType == null || d.SrcType != workdaySrcType) && (d.Status == null || (d.Status != workdayStatus1 && d.Status != workdayStatus2))
                        && (listProfileID.Contains(d.ProfileID) || (d.Hre_Profile.IsDelete.HasValue && d.Hre_Profile.IsDelete.Value)));

                    var result = unitOfWork.Delete(workdayQueryable);
                }
            }
        }
开发者ID:dtafe,项目名称:vnr,代码行数:18,代码来源:Att_WorkDayServices.cs

示例14: SaveRoster

        public DataErrorCode SaveRoster()
        {
            var dataErrorCode = DataErrorCode.Success;
            var ListRosterCorrect = GetImportObject();

            if (ListRosterCorrect != null && ListRosterCorrect.Count() > 0)
            {
                using (var context = new VnrHrmDataContext())
                {
                    IUnitOfWork unitOfWork = new UnitOfWork(context);
                    var listDuplicate = new List<Att_Roster>();

                    var listRoster = ListRosterCorrect.Select(d =>
                        new Att_Roster
                        {
                            ProfileID = d.ProfileID,
                            DateStart = d.DateStart,
                            DateEnd = d.DateEnd,
                            MonShiftID = d.MonShiftID,
                            TueShiftID = d.TueShiftID,
                            WedShiftID = d.WedShiftID,
                            ThuShiftID = d.ThuShiftID,
                            FriShiftID = d.FriShiftID,
                            SatShiftID = d.SatShiftID,
                            SunShiftID = d.SunShiftID,
                            Type = RosterType.E_DEFAULT.ToString(),
                            Status = RosterStatus.E_APPROVED.ToString()
                        }).ToArray();

                    if (ImportType == ImportRosterType.OverrideMonth)
                    {
                        var listProfileID = listRoster.Select(d => d.ProfileID).Distinct().ToList();
                        var dateStart = listRoster.Where(d => d.DateStart > SqlDateTime.MinValue.Value).Select(d => d.DateStart.Date).OrderBy(d => d).FirstOrDefault();
                        var dateEnd = dateStart.AddMonths(1).Date;//Sau này nếu nghiệp vụ thay đổi chỉ xóa những ngày khai báo thì lấy max của cột DateEnd trong danh sách

                        //Không xóa theo kiểu miền giao DateStart và DateEnd -> có thể sai trường hợp roster dài nhiều tháng
                        unitOfWork.Delete<Att_Roster>(unitOfWork.CreateQueryable<Att_Roster>(d => d.DateStart >= dateStart
                            && d.DateEnd <= dateEnd && listProfileID.Contains(d.ProfileID)));
                    }
                    else if (ImportType == ImportRosterType.OverrideHasValue)
                    {
                        var listProfileID = listRoster.Select(d => d.ProfileID).Distinct().ToList();
                        var dateStart = listRoster.Where(d => d.DateStart > SqlDateTime.MinValue.Value).Select(d => d.DateStart.Date).OrderBy(d => d).FirstOrDefault();
                        var dateEnd = listRoster.Where(d => d.DateEnd > SqlDateTime.MinValue.Value).Select(d => d.DateEnd.Date).OrderBy(d => d).LastOrDefault();

                        var listOldRoster = unitOfWork.CreateQueryable<Att_Roster>(Guid.Empty, d => d.DateStart <= dateEnd
                            && d.DateEnd >= dateStart && listProfileID.Contains(d.ProfileID)).ToList<Att_Roster>();

                        foreach (var roster in listRoster)
                        {
                            DateTime rosterStart = roster.DateStart.Date;
                            DateTime rosterEnd = roster.DateEnd.Date;

                            for (DateTime date = rosterStart; date <= rosterEnd; date = date.AddDays(1))
                            {
                                var oldRoster = listOldRoster.Where(d => d.DateStart.Date <= date &&
                                    d.DateEnd.Date >= date && d.ProfileID == roster.ProfileID).FirstOrDefault();

                                if (oldRoster != null)
                                {
                                    if (date.DayOfWeek == DayOfWeek.Monday && roster.MonShiftID.HasValue)
                                    {
                                        oldRoster.MonShiftID = roster.MonShiftID;
                                        roster.MonShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Tuesday && roster.TueShiftID.HasValue)
                                    {
                                        oldRoster.TueShiftID = roster.TueShiftID;
                                        roster.TueShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Wednesday && roster.WedShiftID.HasValue)
                                    {
                                        oldRoster.WedShiftID = roster.WedShiftID;
                                        roster.WedShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Thursday && roster.ThuShiftID.HasValue)
                                    {
                                        oldRoster.ThuShiftID = roster.ThuShiftID;
                                        roster.ThuShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Friday && roster.FriShiftID.HasValue)
                                    {
                                        oldRoster.FriShiftID = roster.FriShiftID;
                                        roster.FriShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Saturday && roster.SatShiftID.HasValue)
                                    {
                                        oldRoster.SatShiftID = roster.SatShiftID;
                                        roster.SatShiftID = null;
                                    }
                                    else if (date.DayOfWeek == DayOfWeek.Sunday && roster.SunShiftID.HasValue)
                                    {
                                        oldRoster.SunShiftID = roster.SunShiftID;
                                        roster.SunShiftID = null;
                                    }
                                }
                            }

                            if ((!roster.MonShiftID.HasValue && !roster.TueShiftID.HasValue && !roster.WedShiftID.HasValue
                                && !roster.ThuShiftID.HasValue && !roster.FriShiftID.HasValue && !roster.SatShiftID.HasValue
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:ImportRosterService.cs

示例15: GetReportProfileQuitV2

        public DataTable GetReportProfileQuitV2(List<Guid> listOrgID, DateTime monthStart, DateTime monthEnd,
            string codeEmp, string profileName, Guid? resignReasonID, Guid? typeOfStopID, Guid? jobTitleID, Guid? positionID, Guid? workPlaceID, bool isCreateTemplate,
            string nameReport, string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                IUnitOfWork unitOfWork = new UnitOfWork(context);
                var repoCat_ContractType = new CustomBaseRepository<Cat_ContractType>(unitOfWork);
                var repoHre_Contract = new CustomBaseRepository<Hre_Contract>(unitOfWork);
                var repoHre_AppendixContract = new CustomBaseRepository<Hre_AppendixContract>(unitOfWork);
                var repoCat_OrgStructure = new CustomBaseRepository<Cat_OrgStructure>(unitOfWork);
                var repoCat_OrgStructureType = new CustomBaseRepository<Cat_OrgStructureType>(unitOfWork);
                var lstContracType = repoCat_ContractType.FindBy(s => s.IsDelete == null).ToList();
                DataTable tb = GetSchema_ProfileQuitV2(nameReport, lstContracType);
                string status = string.Empty;
                List<object> listModel = new List<object>();
                listModel = new List<object>();
                listModel.AddRange(new object[19]);
                listModel[3] = positionID;
                listModel[6] = jobTitleID;
                listModel[8] = monthStart;
                listModel[9] = monthEnd;
                listModel[10] = resignReasonID;
                listModel[11] = typeOfStopID;
                listModel[12] = workPlaceID;
                listModel[17] = 1;
                listModel[18] = Int32.MaxValue - 1;
                List<Hre_ProfileEntity> lstProfile = GetData<Hre_ProfileEntity>(listModel, ConstantSql.hrm_hr_sp_get_ProfileQuit, userLogin,ref status);

                if (!string.IsNullOrWhiteSpace(codeEmp))
                {
                    lstProfile = lstProfile.Where(d => d.CodeEmp != null && d.CodeEmp.Contains(codeEmp)).ToList();
                }

                if (!string.IsNullOrWhiteSpace(profileName))
                {
                    lstProfile = lstProfile.Where(d => d.ProfileName.Contains(profileName)).ToList();
                }

                if (listOrgID != null && listOrgID.Count() > 0)
                {
                    lstProfile = lstProfile.Where(d => d.OrgStructureID.HasValue && listOrgID.Contains(d.OrgStructureID.Value)).ToList();
                }

                #region code BC

                string E_APPROVED = HRM.Infrastructure.Utilities.EnumDropDown.Status.E_APPROVED.ToString();
                List<Guid> lstProfileIDs = lstProfile.Select(m => m.ID).Distinct().ToList();

                var lstContractAll = new List<Hre_Contract>().Select(m => new
                {
                    m.ID,
                    m.ContractTypeID,
                    m.ProfileID,
                    m.DateStart,
                    m.DateEnd,
                    m.ContractNo,
                    m.DateUpdate
                }).ToList();

                foreach (var lstProfileID in lstProfileIDs.Chunk(1000))
                {
                    lstContractAll.AddRange(unitOfWork.CreateQueryable<Hre_Contract>(Guid.Empty, m => m.Status == E_APPROVED
                        && lstProfileID.Contains(m.ProfileID) && m.DateStart <= monthEnd && m.DateEnd >= monthStart).Select(m => new
                        {
                            m.ID,
                            m.ContractTypeID,
                            m.ProfileID,
                            m.DateStart,
                            m.DateEnd,
                            m.ContractNo,
                            m.DateUpdate
                        }).ToList());
                }

                List<Guid> lstContractIDs = lstContractAll.Select(m => m.ID).ToList();
                var lstAppendixContract = new List<Hre_AppendixContract>().Select(m => new
                {
                    m.ID,
                    m.ContractID,
                    m.Code,
                    m.DateofEffect,
                    m.DateEndAppendixContract
                }).ToList();

                foreach (var lstContractID in lstContractIDs.Chunk(1000))
                {
                    lstAppendixContract.AddRange(unitOfWork.CreateQueryable<Hre_AppendixContract>(Guid.Empty,
                        m => lstContractID.Contains(m.ContractID)).Select(m => new
                        {
                            m.ID,
                            m.ContractID,
                            m.Code,
                            m.DateofEffect,
                            m.DateEndAppendixContract
                        }).ToList());
                }

                var lstOrg = repoCat_OrgStructure.GetAll().ToList();
                var orgTypes = repoCat_OrgStructureType.GetAll().ToList();
//.........这里部分代码省略.........
开发者ID:dtafe,项目名称:vnr,代码行数:101,代码来源:Hre_ReportServices.cs


注:本文中的UnitOfWork.CreateQueryable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。