/// <summary>
        ///  اگر پرسنل با شناسه های ورودی نیاز به محاسبه داشت آن را در قالب شی "پرسنل قابل محاسبه" برمی گرداند
        ///  اگر تاریخ آخرین محاسبه پرسنل کوچکتر از تاریخ ورودی بود یا محاسباتش نا معتبر بود، آن پرسنل برای محاسبه واکشی می گردد
        /// </summary>
        /// <param name="PrsId"></param>
        /// <param name="Date"></param>
        /// <returns></returns>
        public IList <ExecutablePersonCalculation> GetAllByPrsIds(IList <decimal> Persons, DateTime Date)
        {
            GTS.Clock.Model.Temp.Temp tempAlias = null;
            TempRepository            tempRep   = new TempRepository(false);
            string operationGUID = tempRep.InsertTempList(Persons);

            GTS.Clock.Model.Temp.Temp   tempObjAlias = null;
            ExecutablePersonCalculation cfpAlias     = null;
            Person personAlias = null;

            var tmpList = QueryOver.Of <GTS.Clock.Model.Temp.Temp>(() => tempObjAlias)
                          .Where(() => tempObjAlias.ObjectID == cfpAlias.PersonId)
                          .And(() => tempObjAlias.OperationGUID == operationGUID)
                          .Select(x => x.ObjectID);

            IList <ExecutablePersonCalculation> result = NHibernateSession.QueryOver(() => cfpAlias)
                                                         .Where(x => (x.FromDate < Date.Date) || (x.FromDate == Date.Date && !x.CalculationIsValid))
                                                         .WithSubquery
                                                         .WhereExists(tmpList)
                                                         .List <ExecutablePersonCalculation>();

            tempRep.DeleteTempList(operationGUID);
            return(result);
            //return NHibernateSession.QueryOver<ExecutablePersonCalculation>()
            //                        .Where(x => !x.CalculationIsValid)
            //                        .AndRestrictionOn(x => x.PersonId).IsIn(Persons.ToArray<decimal>())
            //                        .List<ExecutablePersonCalculation>();
        }
Ejemplo n.º 2
0
        public IList <RuleTemplate> GetRuleTemplates(decimal[] ruleTemplateIds)
        {
            if (ruleTemplateIds == null)
            {
                return(new List <RuleTemplate>());
            }
            RuleTemplate         ruleTemplateAlias = null;
            IList <decimal>      accessableIDs     = ruleTemplateIds;
            IList <RuleTemplate> result            = new List <RuleTemplate>();
            IList <RuleTemplate> ruleTemplateList  = new List <RuleTemplate>();

            if (accessableIDs.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                ruleTemplateList = NHibernateSession.QueryOver <RuleTemplate>()
                                   .WhereRestrictionOn(x => x.ID)
                                   .IsIn(ruleTemplateIds)
                                   .List <RuleTemplate>();
            }
            else
            {
                GTS.Clock.Model.Temp.Temp tempAlias = null;
                TempRepository            tempRep   = new TempRepository(false);
                string operationGUID = tempRep.InsertTempList(accessableIDs);
                ruleTemplateList = NHibernateSession.QueryOver <RuleTemplate>(() => ruleTemplateAlias)
                                   .JoinAlias(() => ruleTemplateAlias.TempList, () => tempAlias)
                                   .Where(() => tempAlias.OperationGUID == operationGUID)
                                   .List <RuleTemplate>();
                tempRep.DeleteTempList(operationGUID);
            }
            return(ruleTemplateList);
        }
        public IList <ArchiveConceptValue> LoadArchiveValueList(IList <decimal> personList, int year, int rangeOrder)
        {
            personList = base.CheckListParameter(personList).ToList();
            ArchiveConceptValue cnpValues = null;
            SecondaryConcept    concept   = null;
            Person personAlias            = null;

            IList <decimal>             accessableIDs = personList;
            IList <ArchiveConceptValue> result        = new List <ArchiveConceptValue>();

            if (accessableIDs.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                result = NHibernateSession.QueryOver <ArchiveConceptValue>(() => cnpValues)
                         .JoinAlias(() => cnpValues.Person, () => personAlias)
                         .Where(() => cnpValues.RangeOrder == rangeOrder)
                         .And(() => cnpValues.Year == year)
                         .And(() => personAlias.ID.IsIn(personList.ToArray()))
                         .List();
            }
            else
            {
                GTS.Clock.Model.Temp.Temp tempAlias = null;
                TempRepository            tempRep   = new TempRepository(false);
                string operationGUID = tempRep.InsertTempList(accessableIDs);
                result = NHibernateSession.QueryOver <ArchiveConceptValue>(() => cnpValues)
                         .JoinAlias(() => cnpValues.Person, () => personAlias)
                         .JoinAlias(() => personAlias.TempList, () => tempAlias)
                         .Where(() => tempAlias.OperationGUID == operationGUID)
                         .And(() => cnpValues.RangeOrder == rangeOrder)
                         .And(() => cnpValues.Year == year)
                         .List();
                tempRep.DeleteTempList(operationGUID);
            }
            return(result);
        }
        public void DeleteUnderManagmentPersonsWithOrganicInfo(decimal flowId, IList <decimal> PersonIds)
        {
            string SQLCommand = string.Empty;

            if (PersonIds.Count < operationBatchSizeValue && operationBatchSizeValue < 2100)
            {
                SQLCommand = @"DELETE FROM TA_UnderManagementsPersons WHERE underManagementPersons_PersonID IN (:PersonIds) and underManagementPersons_FlowID =:flowId";
                base.NHibernateSession.CreateSQLQuery(SQLCommand)
                .SetParameterList("PersonIds", PersonIds.ToArray())
                .SetParameter("flowId", flowId)
                .ExecuteUpdate();
            }
            else
            {
                TempRepository tempRep       = new TempRepository(false);
                string         operationGUID = tempRep.InsertTempList(PersonIds);
                SQLCommand = @"Delete under FROM TA_UnderManagementsPersons under
                               INNER JOIN TA_Temp temp
                               ON    underManagementPersons_PersonID = temp.temp_ObjectID
                               WHERE temp_OperationGUID =:operationGUID  and underManagementPersons_FlowID =:flowId
                                ";
                base.NHibernateSession.CreateSQLQuery(SQLCommand)
                .SetParameter("operationGUID", operationGUID)
                .SetParameter("flowId", flowId)
                .ExecuteUpdate();
                tempRep.DeleteTempList(operationGUID);
            }
        }
        /// <summary>
        /// پست سازمانی دسته ای از پرسنل را برمیگرداند
        /// </summary>
        /// <param name="personIds"></param>
        /// <returns></returns>
        public IList <OrganizationUnit> GetOrganizationUsnitByPersonIds(IList <decimal> personIds)
        {
            IList <decimal>          accessableIDs        = personIds;
            IList <OrganizationUnit> organizationUnitList = new List <OrganizationUnit>();

            if (accessableIDs.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                organizationUnitList = GetByCriteria(new CriteriaStruct(Utility.Utility.GetPropertyName(() => new OrganizationUnit().Person.ID), personIds.ToArray(), CriteriaOperation.IN));
            }
            else
            {
                OrganizationUnit          organizationUnitAlias = null;
                Person                    personAlias           = null;
                GTS.Clock.Model.Temp.Temp tempAlias             = null;
                TempRepository            tempRep       = new TempRepository(false);
                string                    operationGUID = tempRep.InsertTempList(accessableIDs);
                organizationUnitList = NHSession.QueryOver <OrganizationUnit>(() => organizationUnitAlias)
                                       .JoinAlias(() => organizationUnitAlias.Person, () => personAlias)
                                       .JoinAlias(() => personAlias.TempList, () => tempAlias)
                                       .Where(() => tempAlias.OperationGUID == operationGUID)
                                       .List <OrganizationUnit>();
                tempRep.DeleteTempList(operationGUID);
            }
            return(organizationUnitList);
        }
Ejemplo n.º 6
0
        public Dictionary <decimal, decimal> GetUivalidationPersonIdList(IList <decimal> personIdList)
        {
            Dictionary <decimal, decimal> UiValidationGroupPersonIdDic = new Dictionary <decimal, decimal>();
            string SQLCommand = string.Empty;

            if (personIdList.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                SQLCommand = @" select prs_Id,prsTA_UIValidationGroupID from  TA_PersonTASpec as pts
                                   inner join TA_Person prs
                                   on pts.prsTA_ID = prs.Prs_ID
                                   inner join TA_UIValidationGroup as uvg
								   on  pts.prsTA_UIValidationGroupID = uvg.UIValGrp_ID 
                                   where  pts.prsTA_ID in (:personlist) and prs.Prs_Active =1 and prs.prs_IsDeleted =0
                                   and prsTA_UIValidationGroupID is  not null
                                   group by prsTA_UIValidationGroupID,prs_Id ";
                var resultList = NHibernateSession.CreateSQLQuery(SQLCommand)
                                 .SetParameterList("personlist", personIdList.ToArray()).List <object>();
                foreach (var item in resultList)
                {
                    UiValidationGroupPersonIdDic.Add(Convert.ToDecimal(((object[])(item))[0]), Convert.ToDecimal(((object[])(item))[1]));
                }
            }
            else
            {
                TempRepository tempRep       = new TempRepository(false);
                string         operationGUID = tempRep.InsertTempList(personIdList);
                SQLCommand = @"select prs_Id,prsTA_UIValidationGroupID from  TA_PersonTASpec as pts
                                   inner join TA_Person prs
                                   on pts.prsTA_ID = prs.Prs_ID
                                   Inner Join TA_Temp temp
                                   on prs.Prs_ID=temp.temp_ObjectID 
                                   inner join TA_UIValidationGroup as uvg
								   on   pts.prsTA_UIValidationGroupID = uvg.UIValGrp_ID 
                                   where   prs.Prs_Active =1 and prs.prs_IsDeleted =0 and temp_OperationGUID =:operationGUID
                                   and prsTA_UIValidationGroupID is  not null
                                   group by prsTA_UIValidationGroupID,prs_Id
                              ";
                var resultList = NHibernateSession.CreateSQLQuery(SQLCommand)
                                 .SetParameter("operationGUID", operationGUID).List <object>();
                tempRep.DeleteTempList(operationGUID);
                foreach (var item in resultList)
                {
                    UiValidationGroupPersonIdDic.Add(Convert.ToDecimal(((object[])(item))[0]), Convert.ToDecimal(((object[])(item))[1]));
                }
            }

            return(UiValidationGroupPersonIdDic);
        }
        public IList <decimal> GetExsitsArchivePersons(IList <decimal> personList, int Year, int rangeOrder)
        {
            personList = base.CheckListParameter(personList).ToList();
            ArchiveConceptValue cnpValues  = null;
            Person           personAlias   = null;
            IList <decimal>  accessableIDs = personList;
            IList <object[]> result        = new List <object[]>();

            if (accessableIDs.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                result = NHibernateSession
                         .QueryOver <ArchiveConceptValue>(() => cnpValues)
                         .JoinAlias(() => cnpValues.Person, () => personAlias)
                         .Where(() => cnpValues.RangeOrder == rangeOrder)
                         .And(() => cnpValues.Year == Year)
                         .And(() => personAlias.ID.IsIn(personList.ToArray()))
                         .Select
                         (
                    Projections.Group <ArchiveConceptValue>(x => x.PersonId),
                    Projections.Count <ArchiveConceptValue>(x => x.PersonId)
                         )
                         .List <object[]>();
            }
            else
            {
                GTS.Clock.Model.Temp.Temp tempAlias = null;
                TempRepository            tempRep   = new TempRepository(false);
                string operationGUID = tempRep.InsertTempList(accessableIDs);
                result = NHibernateSession
                         .QueryOver <ArchiveConceptValue>(() => cnpValues)
                         .JoinAlias(() => cnpValues.Person, () => personAlias)
                         .JoinAlias(() => personAlias.TempList, () => tempAlias)
                         .Where(() => cnpValues.RangeOrder == rangeOrder)
                         .And(() => cnpValues.Year == Year)
                         .Select
                         (
                    Projections.Group <ArchiveConceptValue>(x => x.PersonId),
                    Projections.Count <ArchiveConceptValue>(x => x.PersonId)
                         )
                         .List <object[]>();
                tempRep.DeleteTempList(operationGUID);
            }
            var persons = from o in result
                          select(decimal) o.First();

            return(persons.ToList());
        }
        public void InsertUnderManagmentPersons(IList <decimal> personIds, IList <decimal> flowIds)
        {
            string SQLCommand = string.Empty;

            if (personIds.Count < operationBatchSizeValue && operationBatchSizeValue < 2100)
            {
                foreach (decimal flowid in flowIds)
                {
                    SQLCommand = "insert into TA_UnderManagementsPersons (underManagementPersons_FlowID , underManagementPersons_PersonID) " +
                                 "select " + flowid.ToString() + " , Prs_ID from TA_Person where Prs_ID in (:personIds) and " +
                                 "Prs_ID not in(select underMng_PersonID " +
                                 "from TA_UnderManagment " +
                                 "where underMng_PersonID in (:personIds) and underMng_Contains = 1 and underMng_FlowID = " + flowid.ToString() + "" +
                                 ")";
                    base.NHibernateSession.CreateSQLQuery(SQLCommand)
                    .SetParameterList("personIds", personIds.ToArray())
                    .ExecuteUpdate();
                }
            }
            else
            {
                foreach (decimal flowid in flowIds)
                {
                    TempRepository temp          = new TempRepository(false);
                    string         operationGUID = temp.InsertTempList(personIds);
                    SQLCommand = "insert into TA_UnderManagementsPersons (underManagementPersons_FlowID , underManagementPersons_PersonID) " +
                                 "select " + flowid.ToString() + " , Prs_ID from TA_Person " +
                                 "inner join ta_temp temp" +
                                 " on Prs_ID = temp.temp_ObjectID " +
                                 " where  temp.temp_OperationGUID =:operationGUID  and " +
                                 " Prs_ID not in(select underMng_PersonID " +
                                 " from TA_UnderManagment " +
                                 " inner join ta_temp temp " +
                                 " on  underMng_PersonID = temp.temp_objectID " +
                                 " where temp.temp_OperationGUID =:operationGUID and underMng_Contains = 1 and underMng_FlowID = " + flowid.ToString() + "" +
                                 " )";

                    base.NHibernateSession.CreateSQLQuery(SQLCommand)
                    .SetParameter("operationGUID", operationGUID)
                    .ExecuteUpdate();
                    temp.DeleteTempList(operationGUID);
                }
            }
        }
Ejemplo n.º 9
0
        public IList <decimal> GetUivalidationIdList(IList <decimal> personIdList)
        {
            IList <decimal> UiValidationGroupIdList = new List <decimal>();
            string          SQLCommand = string.Empty;

            if (personIdList.Count < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                SQLCommand = @" select prsTA_UIValidationGroupID from  TA_PersonTASpec as pts
                                   inner join TA_Person prs
                                   on pts.prsTA_ID = prs.Prs_ID
                                   inner join TA_UIValidationGroup as uvg
								   on  pts.prsTA_UIValidationGroupID = uvg.UIValGrp_ID 
                                   where  pts.prsTA_ID in (:personlist) and prs.Prs_Active =1 and prs.prs_IsDeleted =0
                                   and prsTA_UIValidationGroupID is  not null
                                   group by prsTA_UIValidationGroupID
                                 ";
                UiValidationGroupIdList = NHibernateSession.CreateSQLQuery(SQLCommand)
                                          .SetParameterList("personlist", personIdList.ToArray()).List <decimal>();
            }
            else
            {
                TempRepository tempRep       = new TempRepository(false);
                string         operationGUID = tempRep.InsertTempList(personIdList);
                SQLCommand = @"select prsTA_UIValidationGroupID from  TA_PersonTASpec as pts
                                   inner join TA_Person prs
                                   on pts.prsTA_ID = prs.Prs_ID
                                   Inner Join TA_Temp temp
                                   on prs.Prs_ID=temp.temp_ObjectID 
                                   inner join TA_UIValidationGroup as uvg
								   on   pts.prsTA_UIValidationGroupID = uvg.UIValGrp_ID 
                                   where   prs.Prs_Active =1 and prs.prs_IsDeleted =0 and temp_OperationGUID =:operationGUID
                                   and prsTA_UIValidationGroupID is  not null
                                   group by prsTA_UIValidationGroupID
                              ";
                UiValidationGroupIdList = NHibernateSession.CreateSQLQuery(SQLCommand)
                                          .SetParameter("operationGUID", operationGUID)
                                          .List <decimal>();
                tempRep.DeleteTempList(operationGUID);
            }

            return(UiValidationGroupIdList);
        }
Ejemplo n.º 10
0
        public IList <Flow> GetAllByAccessGroupName(string name, decimal[] restrictionIds)
        {
            if (restrictionIds == null || restrictionIds.Length == 0)
            {
                return(new List <Flow>());
            }
            decimal[]    accessableIDs = restrictionIds;
            IList <Flow> list          = new List <Flow>();

            if (accessableIDs.Count() < this.operationBatchSizeValue && this.operationBatchSizeValue < 2100)
            {
                string HQLCommand = @"select flw from Flow as flw
                                inner join flw.AccessGroup as access
                                where access.Name like :accessName
                                AND flw.IsDeleted=0 AND flw.ID in (:ids)";

                list = base.NHibernateSession.CreateQuery(HQLCommand)
                       .SetParameter("accessName", String.Format("%{0}%", name))
                       .SetParameterList("ids", base.CheckListParameter(restrictionIds))
                       .List <Flow>();
            }
            else
            {
                TempRepository tempRep       = new TempRepository(false);
                string         operationGUID = tempRep.InsertTempList(accessableIDs);
                string         HQLCommand    = @"select flw from Flow as flw
                                inner join flw.AccessGroup as access
                                INNER JOIN flw.TempList tmp
                                where tmp.OperationGUID = :operationGUID and access.Name like :accessName
                                AND flw.IsDeleted=0 ";

                list = base.NHibernateSession.CreateQuery(HQLCommand)
                       .SetParameter("accessName", String.Format("%{0}%", name))
                       .SetParameter("operationGUID", operationGUID)
                       .List <Flow>();
                tempRep.DeleteTempList(operationGUID);
            }
            return(list);
        }
        public void InsertUnderManagmentPersons(decimal personId, IList <decimal> flowIds)
        {
            string SQLCommand = string.Empty;

            if (flowIds.Count < operationBatchSizeValue && operationBatchSizeValue < 2100)
            {
                SQLCommand = @"INSERT INTO TA_UnderManagementsPersons( underManagementPersons_FlowID , underManagementPersons_PersonID)                                                                                                       
                                  SELECT flow_ID ,:personId
	                              FROM (SELECT flow_ID FROM TA_Flow     
		                                WHERE flow_Deleted = 0 and flow_ID in (:flowIds)
			                           ) Flow			
                                 ";
                base.NHibernateSession.CreateSQLQuery(SQLCommand)
                .SetParameterList("flowIds", flowIds.ToArray())
                .SetParameter("personId", personId)
                .ExecuteUpdate();
            }
            else
            {
                TempRepository temp          = new TempRepository(false);
                string         operationGUID = temp.InsertTempList(flowIds);
                SQLCommand = @"INSERT INTO TA_UnderManagementsPersons( underManagementPersons_FlowID , underManagementPersons_PersonID)                                                                                                       
                                  SELECT flow_ID ,:personId
	                              FROM (SELECT flow_ID FROM TA_Flow
                                        INNER JOIN TA_Temp temp
                                        ON    flow_ID = temp.temp_ObjectID
		                                WHERE flow_Deleted = 0 and temp.temp_OperationGUID =:operationGUID
			                           ) Flow			
                                   ";
                base.NHibernateSession.CreateSQLQuery(SQLCommand)
                .SetParameter("operationGUID", operationGUID)
                .SetParameter("personId", personId)
                .ExecuteUpdate();
                temp.DeleteTempList(operationGUID);
            }
        }