Exemplo n.º 1
0
        public SharedJobIndex GetSharedJobIndex(SharedJobIndexId jabIndexId)
        {
            var jobIndex  = jobIndexService.GetBy(new PMSAdminModel.JobIndices.AbstractJobIndexId(jabIndexId.Id));
            var sharedJob = new SharedJobIndex(new SharedJobIndexId(jobIndex.Id.Id), jobIndex.Name, jobIndex.DictionaryName);

            return(sharedJob);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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();
                }
        }