Ejemplo n.º 1
0
        public static JobIndexGroup CreateJobIndexGroup(IJobIndexRepository jobIndexRepository, string name, string dictionaryName)
        {
            var jobIndexGroup = new JobIndexGroup(jobIndexRepository.GetNextId(), Period, null, name, dictionaryName);

            jobIndexRepository.Add(jobIndexGroup);
            return(jobIndexGroup);
        }
Ejemplo n.º 2
0
        private void copyAbstractJobIndex(Period currentPeriod, AbstractJobIndexId sourceAbstractJobIndexId, AbstractJobIndexId parentId)
        {
            List<AbstractJobIndex> childs = new List<AbstractJobIndex>();
            JobIndexGroup newJobIndexGroup = null;
            var srvManagerJobIndex = jobIndexServiceFactory.Create();
            try
            {
                var jobIndexService = srvManagerJobIndex.GetService();
                var sourceAbstractJobIndex = jobIndexService.GetJobIndexById(sourceAbstractJobIndexId);
                if (sourceAbstractJobIndex is JobIndexGroup)
                {
                    var sourceGroup = sourceAbstractJobIndex as JobIndexGroup;
                    newJobIndexGroup = jobIndexService.AddJobIndexGroup(currentPeriod.Id, parentId, sourceGroup.Name, sourceGroup.DictionaryName);
                    childs = jobIndexService.GetAllAbstractJobIndexByParentId(sourceGroup.Id);
                }
                else if (sourceAbstractJobIndex is JobIndex)
                {
                    var sourceJobIndex = sourceAbstractJobIndex as JobIndex;
                    jobIndexService.AddJobIndex(currentPeriod.Id, parentId, sourceJobIndex.SharedJobIndexId,
                        sourceJobIndex.CustomFieldValues.ToDictionary(c => c.Key, c => c.Value), sourceJobIndex.IsInquireable, sourceJobIndex.CalculationOrder, sourceJobIndex.CalculationLevel);
                }
            }
            finally
            {
                jobIndexServiceFactory.Release(srvManagerJobIndex);
            }

            foreach (AbstractJobIndex abstactIndex in childs)
                copyAbstractJobIndex(currentPeriod, abstactIndex.Id, newJobIndexGroup.Id);

        }
Ejemplo n.º 3
0
 public JobIndexGroup AddJobIndexGroup(PeriodId periodId, AbstractJobIndexId parentId, string name,
                                       string dictionaryName)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             var           id     = jobIndexRep.GetNextId();
             var           period = periodRep.GetById(periodId);
             JobIndexGroup parent = null;
             if (parentId != null)
             {
                 parent = jobIndexRep.GetJobIndexGroupById(new AbstractJobIndexId(parentId.Id));
             }
             var jobIndexGroup = new JobIndexGroup(id, period, parent, name, dictionaryName);
             jobIndexRep.Add(jobIndexGroup);
             tr.Complete();
             return(jobIndexGroup);
         }
     }
     catch (Exception exp)
     {
         var res = jobIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Ejemplo n.º 4
0
 public JobIndexGroup UpdateJobIndexGroup(AbstractJobIndexId jobIndexGroupId, AbstractJobIndexId parentId,
                                          string name,
                                          string dictionaryName)
 {
     try
     {
         using (var tr = new TransactionScope())
         {
             JobIndexGroup parent = null;
             if (parentId != null)
             {
                 parent = jobIndexRep.GetJobIndexGroupById(parentId);
             }
             var group = jobIndexRep.GetJobIndexGroupById(jobIndexGroupId);
             if (parentId != null && parent.PeriodId != group.PeriodId)
             {
                 throw new ArgumentException("parentId is not valid");
             }
             group.Update(parent, name, dictionaryName);
             tr.Complete();
             return(group);
         }
     }
     catch (Exception exp)
     {
         var res = jobIndexRep.TryConvertException(exp);
         if (res == null)
         {
             throw;
         }
         throw res;
     }
 }
Ejemplo n.º 5
0
        private void setInitData(Period period)
        {
            //todo:Damn fu.... very bad code for this section
            var behaviaralId            = jobIndexRepository.GetNextId();
            var behaviaralJobIndexGroup = new JobIndexGroup(behaviaralId, period, null, "شاخص های رفتاری", "BehaviouralGroup");

            jobIndexRepository.Add(behaviaralJobIndexGroup);

            var performanceId            = jobIndexRepository.GetNextId();
            var performanceJobIndexGroup = new JobIndexGroup(performanceId, period, null, "شاخص های عملکردی", "PerformanceGroup");

            jobIndexRepository.Add(performanceJobIndexGroup);

            var uniGroupId     = unitIndexRepository.GetNextId();
            var unitIndexGroup = new UnitIndexGroup(uniGroupId, period, null, "گروه شاخص های سازمانی", "OrganizationUnitGroup");

            unitIndexRepository.Add(unitIndexGroup);
        }
Ejemplo n.º 6
0
        public static void CreateJobIndex(IJobIndexRepository jobIndexRepository, PMSAdmin.Domain.Model.JobIndices.JobIndex adminJobIndex,
                                          JobIndexGroup jobIndexGroup, bool isInquireable, Dictionary <PMSAdmin.Domain.Model.CustomFieldTypes.CustomFieldType, string> customFieldsDictionary, long clacLevel)
        {
            var sharedJobIndex = new SharedJobIndex(new SharedJobIndexId(adminJobIndex.Id.Id), adminJobIndex.Name,
                                                    adminJobIndex.DictionaryName);
            var jobIndex = new JobIndex(jobIndexRepository.GetNextId(), Period, sharedJobIndex, jobIndexGroup,
                                        isInquireable, clacLevel);
            var sharedCustomFieldsDic =
                customFieldsDictionary.ToDictionary(
                    c =>
                    new SharedJobIndexCustomField(new SharedJobIndexCustomFieldId(c.Key.Id.Id), c.Key.Name,
                                                  c.Key.DictionaryName, c.Key.MinValue, c.Key.MaxValue),
                    c => c.Value);

            jobIndex.UpdateCustomFields(sharedCustomFieldsDic);
            jobIndexRepository.Add(jobIndex);
            jobIndices.Add(jobIndex);
        }
Ejemplo n.º 7
0
        public void JobIndexPointTest()
        {
            PMSAdmin.Domain.Model.JobIndices.JobIndex      jobIndex;
            PMSAdmin.Domain.Model.JobPositions.JobPosition jobPosition;
            PMSAdmin.Domain.Model.Jobs.Job   job;
            PMSAdmin.Domain.Model.Units.Unit unit;
            RuleEngineBasedPolicy            policy;
            long x = 190;

            using (var tr = new TransactionScope())
                using (var adminSession = PMSAdminSession.GetSession())
                {
                    policy = new RuleEngineBasedPolicy(new PolicyId(x), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(policy);
                    var jobIndexCategory = new PMSAdmin.Domain.Model.JobIndices.JobIndexCategory(
                        new PMSAdmin.Domain.Model.JobIndices.AbstractJobIndexId(x + 1), null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(jobIndexCategory);
                    jobIndex = new PMSAdmin.Domain.Model.JobIndices.JobIndex(
                        new PMSAdmin.Domain.Model.JobIndices.AbstractJobIndexId(x + 2), jobIndexCategory, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(jobIndex);

                    unit = new PMSAdmin.Domain.Model.Units.Unit(new PMSAdmin.Domain.Model.Units.UnitId(x + 3), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(unit);
                    job = new PMSAdmin.Domain.Model.Jobs.Job(new PMSAdmin.Domain.Model.Jobs.JobId(x + 4), Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(job);
                    jobPosition = new JobPosition(new PMSAdmin.Domain.Model.JobPositions.JobPositionId(x + 5)
                                                  , Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    adminSession.Save(jobPosition);

                    adminSession.Flush();
                    tr.Complete();
                }

            long     y = x - 4;
            Employee emp;

            using (var tr = new TransactionScope())
                using (var session = PMSSession.GetSession())
                {
                    var policy2 = session.Get <MITD.PMS.Domain.Model.Policies.RuleEngineBasedPolicy>(
                        new MITD.PMS.Domain.Model.Policies.PolicyId(policy.Id.Id));
                    var period = new Period(new PeriodId(y), Guid.NewGuid().ToString(), DateTime.Now, DateTime.Now, 91);

                    //period.Activate(null);
                    session.Save(period);
                    emp = new Employee(Guid.NewGuid().ToString(), period, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    session.Save(emp);
                    var calc = new Calculation(new CalculationId(y), period, policy2, Guid.NewGuid().ToString(), DateTime.Now, "1");
                    session.Save(calc);
                    var jobIndexGroup = new JobIndexGroup(new AbstractJobIndexId(y), period, null, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    session.Save(jobIndexGroup);
                    var ji = new JobIndex(new AbstractJobIndexId(y + 1), period, new SharedJobIndex(
                                              new SharedJobIndexId(jobIndex.Id.Id), jobIndex.Name, jobIndex.DictionaryName), jobIndexGroup, true);
                    session.Save(ji);
                    var j = new Job(period, new SharedJob(new SharedJobId(job.Id.Id), job.Name, job.DictionaryName));
                    session.Save(j);
                    var u = new Unit(period, new SharedUnit(new SharedUnitId(unit.Id.Id), unit.Name, unit.DictionaryName), null);
                    session.Save(u);
                    var jp = new Domain.Model.JobPositions.JobPosition(period, new SharedJobPosition(
                                                                           new SharedJobPositionId(jobPosition.Id.Id), jobPosition.Name, jobPosition.DictionaryName), null, j, u);
                    session.Save(jp);
                    EmployeePoint p = new JobIndexPoint(new CalculationPointId(y), period, emp, calc, jp, ji, "hh", 10);
                    session.Save(p);
                    p = new SummaryEmployeePoint(new CalculationPointId(y + 1), period, emp, calc, "ff", 10);
                    session.Save(p);
                    session.Flush();
                    tr.Complete();
                }
            using (var tr = new TransactionScope())
                using (var session = PMSSession.GetSession())
                {
                    var lst = session.Query <EmployeePoint>().ToList();
                    session.Flush();
                    tr.Complete();
                }
        }
Ejemplo n.º 8
0
        public void JobIndexInPeriodTest()
        {
            long nextAbsIndexId;
            long jobIndexId;

            using (var session = PMSSession.GetSession())
                using (session.BeginTransaction())
                {
                    var period = session.Query <Period>().FirstOrDefault();

                    nextAbsIndexId =
                        session.CreateSQLQuery("Select next value for dbo.Periods_AbstractJobIndexSeq").UniqueResult <long>();
                    var rootJobIndexCat = new JobIndexGroup(new AbstractJobIndexId(nextAbsIndexId), period, null,
                                                            Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    session.Save((AbstractJobIndex)rootJobIndexCat);

                    SharedJobIndex            sharedJobIndex;
                    SharedJobIndexCustomField sharedJobIndexCustomField;

                    using (var sessionAdmin = PMSAdminSession.GetSession())
                    {
                        var pmsAdminJobIndex =
                            sessionAdmin.Query <MITD.PMSAdmin.Domain.Model.JobIndices.JobIndex>().FirstOrDefault();
                        sharedJobIndex = new SharedJobIndex(new SharedJobIndexId(pmsAdminJobIndex.Id.Id),
                                                            pmsAdminJobIndex.Name, pmsAdminJobIndex.DictionaryName);

                        var customFld = sessionAdmin.Query <CustomFieldType>().SingleOrDefault();
                        sharedJobIndexCustomField =
                            new SharedJobIndexCustomField(new SharedJobIndexCustomFieldId(customFld.Id.Id), customFld.Name,
                                                          customFld.DictionaryName, 1, 100);
                    }

                    nextAbsIndexId =
                        session.CreateSQLQuery("Select next value for dbo.Periods_AbstractJobIndexSeq").UniqueResult <long>();
                    var jobIndex = new JobIndex(new AbstractJobIndexId(nextAbsIndexId), period, sharedJobIndex,
                                                rootJobIndexCat, true);
                    jobIndex.UpdateCustomFields(new Dictionary <SharedJobIndexCustomField, string>()
                    {
                        { sharedJobIndexCustomField, "asdasdasdasd" }
                    });

                    session.Save(jobIndex);
                    session.Transaction.Commit();
                }
            using (var session = PMSSession.GetSession())
                using (session.BeginTransaction())
                {
                    var jobIndex =
                        session.Query <JobIndex>().SingleOrDefault(j => j.Id == new AbstractJobIndexId(nextAbsIndexId));

                    //    var rootJobIndexCat = session.Query<JobIndexCategory>().SingleOrDefault(p => p.Id == new AbstractJobIndexId(nextAbsIndexId));



                    //    nextAbsIndexId = session.CreateSQLQuery("Select next value for dbo.AbstractJobIndexSeq").UniqueResult<long>();
                    //    var jobIndexCat = new JobIndexCategory(new AbstractJobIndexId(nextAbsIndexId), rootJobIndexCat, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    //    session.Save((AbstractJobIndex)jobIndexCat);

                    //    jobIndexId = session.CreateSQLQuery("Select next value for dbo.AbstractJobIndexSeq").UniqueResult<long>();
                    //    var jobIndex = new JobIndex(new AbstractJobIndexId(jobIndexId), jobIndexCat, Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
                    //    session.Save((AbstractJobIndex)jobIndex);

                    //    session.Transaction.Commit();
                }
        }