Пример #1
0
        public override void OnSaveData()
        {
            try
            {
                JarsResource saveObj = defaultBindingSource.Current as JarsResource;
                var          store   = new StoreResource()
                {
                    Resource = saveObj.ConvertTo <ResourceDto>()
                };
                var resp = ServiceClient.Post(store);

                //if the response was good, then notify the others.
                if (resp.ResponseStatus == null)
                {
                    saveObj = resp.Resource.ConvertTo <JarsResource>();
                    Context.ServiceClient.Post(new ResourcesNotification()
                    {
                        FromUserName = Context.LoggedInUser.UserName,
                        Selector     = SelectorTypes.store,
                        Ids          = new List <int>()
                        {
                            resp.Resource.Id
                        }
                    });
                }
                base.OnSaveData();
            }
            catch (Exception exS)
            {
                OnExceptionEvent(exS);
            }
        }
Пример #2
0
        public void AssignRulesToEntities()
        {
            JarsResource resource = FakeDataHelper.FakeResources[0];

            JarsJob testJob = FakeDataHelper.FakeJarsJobs[1];

            //set up a rule for a target entity where target entity can not be changed
            IJarsRule singleEntityRule = JarsRulePopupForm.AddRuleOnEntity(resource, testJob.GetType());

            Assert.IsTrue(!string.IsNullOrEmpty(singleEntityRule.TargetCriteriaString));

            ////set up a rule for an entity type instead of a certain entity
            //IEntityRule singleTypeRule = EntityRuleForm.AddRuleOnEntity(resource);
            //Assert.IsTrue(singleTypeRule.TargetTypeName == typeof(Resource).Name && singleTypeRule.SourceTypeName == typeof(Resource).Name);


            ////set up a rule for an entity type that relies on values from another entity type
            //IEntityRule linkedTypeRule = EntityRuleForm.AddRuleOnEntity(resource, typeof(JarsJob));
            //Assert.IsTrue(linkedTypeRule.TargetTypeName == typeof(Resource).Name
            //    && linkedTypeRule.SourceTypeName == typeof(JarsJob).Name
            //    && !string.IsNullOrEmpty(linkedTypeRule.SourceCriteriaString)
            //    && !string.IsNullOrEmpty(linkedTypeRule.TargetCriteriaString));


            singleEntityRule = JarsRulePopupForm.EditRuleOnEntity(resource, singleEntityRule);
            Assert.IsTrue(!string.IsNullOrEmpty(singleEntityRule.TargetCriteriaString));
        }
Пример #3
0
        public override void OnAddData()
        {
            base.OnAddData();
            //Create a new resource record
            JarsResource newOp = defaultBindingSource.AddNew() as JarsResource;

            defaultBindingSource.Position = defaultBindingSource.IndexOf(newOp);
        }
Пример #4
0
        public static void Show(JarsResource resource, List <Lazy <Core.Interfaces.Processors.IProcessor, IProcessorMetadata> > list, SchedulerControl schedulerControl)
        {
            ResourcePluginsForm frm = new ResourcePluginsForm
            {
                _resource         = resource,
                _resourcePlugins  = list,
                _schedulerControl = schedulerControl
            };

            frm.textEdit1.Text = resource.DisplayName;
            frm.textEdit2.Text = resource.ExtRef;
            frm.BuildPluginList();
            //now just show the form plugins should be visible on show..
            frm.ShowDialog();
        }
Пример #5
0
 private void UpdateLinkedBindingSources()
 {
     if (defaultBindingSource.Current is JarsResource)
     {
         groupsBindingSource.DataSource = ((JarsResource)defaultBindingSource.Current).Groups;
         skillsBindingSource.DataSource = ((JarsResource)defaultBindingSource.Current).Skills;
         JarsResource      res           = defaultBindingSource.Current as JarsResource;
         IList <IJarsRule> filterCondLst = ResourceEntityRulesList.Where(c => c.TargetTypeName == res.GetType().Name&& c.TargetCriteriaString.Contains($"[Id] = {res.Id}")).OrderBy(c => c.Id).ToList();
         gcConditions.InvokeIfRequired(c => c.DataSource = filterCondLst);
         entityRuleBindingSource.DataSource = gcConditions.DataSource;
         gridControlGroups.InvokeIfRequired(c => c.Refresh());
         gridControlSkills.InvokeIfRequired(c => c.Refresh());
         gcConditions.InvokeIfRequired(c => c.Refresh());
     }
 }
Пример #6
0
        public void Create_Resource_Jobs_Attachment_and_Lines()
        {
            IJarsJobRepository nhRep = _repFactory.GetDataRepository <IJarsJobRepository>();

            //create op
            for (int i = 0; i < 5; i++)
            {
                JarsResource res = new JarsResource
                {
                    DisplayName = $"Test{i}",
                    ExtRef1     = $"T00{i}",
                    IsActive    = true,
                    Skills      = new List <JarsResourceSkill> {
                        new JarsResourceSkill {
                            MaxLevel = 10, Description = "Test Skill", DocumentCode = $"SK0{i}T"
                        }
                    },
                    MobileNo = $"0{i}234{i}2312{i}"
                };

                //res = resrep.CreateUpdate(res, "TEST");

                JarsJobAttachment ja = new JarsJobAttachment {
                    Name = "Attach Test"
                };

                JarsJob baseJob = new JarsJob
                {
                    StartDate   = DateTime.Now.Subtract(new TimeSpan(2, 0, 0)),
                    EndDate     = DateTime.Now,
                    Description = $"IJob Job{i}",
                    Location    = $" IJob for Testing job {i}",
                    ExtRefId    = $"0{i}{i}{i}",
                    ResourceId  = res.Id
                };
                baseJob.Attachments.Add(ja);

                JarsJobLine line = new JarsJobLine {
                    Resource = res, LineCode = $"TEST0{i}", OriginalQty = 1, LineNum = 1, ExternalJobRef = baseJob.ExtRefId
                };

                baseJob.JobLines.Add(line);

                nhRep.CreateUpdate(baseJob, "TEST_LOOP");
            }
        }
Пример #7
0
 public override bool OnDeleteData()
 {
     try
     {
         if (base.OnDeleteData(true))
         {
             JarsResource delObj = defaultBindingSource.Current as JarsResource;
             var          delReq = new DeleteResource {
                 Id = delObj.Id
             };
             ServiceClient.Delete(delReq);
             defaultBindingSource.RemoveCurrent();
             defaultBindingSource.ResetBindings(false);
         }
         //call this after the record removal was successful.
     }
     catch (Exception exD)
     {
         OnExceptionEvent(exD);
     }
     return(base.OnDeleteData());
 }
Пример #8
0
        public static IList <JarsResource> GetDefaultResources()
        {
            IList <JarsResource> _Resources = new List <JarsResource>();
            JarsResource         cp1        = new JarsResource
            {
                IsActive            = true,
                IsMobileResource    = true,
                DayStartTime        = TimeSpan.FromHours(7.30),
                DayEndTime          = TimeSpan.FromHours(7.30).Add(TimeSpan.FromHours(8)),
                ExtRef              = "CRP01",
                VehicleRegistration = "VEH1",
                FirstName           = "Carpin",
                LastName            = "Terra",
                CreatedBy           = crmo,
                MobileNo            = "01234567890",
                eMail = "*****@*****.**"
                        //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Carpenter", ExpiryMatters = false, DocumentCode = "CAPRQUAL01" } }
            };

            cp1.DisplayName = cp1.GenerateDisplayName(false, true, true);
            //cp1.Groups.Add(new JarsResourceGroup { Code = "CP", IsActive = true, Name = "Carpenters", SortIndex = 0, CreatedBy = crmo });

            JarsResource el1 = new JarsResource
            {
                IsActive            = true,
                IsMobileResource    = true,
                DayStartTime        = TimeSpan.FromHours(8.00),
                DayEndTime          = TimeSpan.FromHours(7.30).Add(TimeSpan.FromHours(8)),
                ExtRef              = "ELE01",
                VehicleRegistration = "VEH2",
                FirstName           = "Elli",
                LastName            = "Tris",
                CreatedBy           = crmo,
                MobileNo            = "01234567890",
                eMail = "*****@*****.**"
                        //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Electrician", ExpiryMatters = true, DocumentCode = "ELECQUAL01", StartDate = DateTime.Now.AddDays(-3), EndDate = DateTime.Now.AddYears(2) } }
            };

            el1.DisplayName = el1.GenerateDisplayName(false, true, true);
            //el1.Groups.Add(new JarsResourceGroup { Code = "EL", IsActive = true, Name = "Electricians", SortIndex = 1, CreatedBy = crmo });

            JarsResource pl1 = new JarsResource
            {
                IsActive            = true,
                IsMobileResource    = true,
                DayStartTime        = TimeSpan.FromHours(8.30),
                DayEndTime          = TimeSpan.FromHours(8.30).Add(TimeSpan.FromHours(8)),
                ExtRef              = "PLU01",
                VehicleRegistration = "VEH3",
                FirstName           = "Plumbi",
                LastName            = "Erro",
                CreatedBy           = crmo,
                MobileNo            = "01234567890",
                eMail = "*****@*****.**"
                        //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Certified Plumber", ExpiryMatters = true, DocumentCode = "PLUMBQUAL01", StartDate = DateTime.Now.AddDays(-3), EndDate = DateTime.Now.AddYears(2) } }
            };

            pl1.DisplayName = pl1.GenerateDisplayName(false, true, true);
            //pl1.Groups.Add(new JarsResourceGroup {  Code = "PL", IsActive = true, Name = "Plumbers", SortIndex = 2, CreatedBy = crmo });

            JarsResource fn1 = new JarsResource
            {
                IsActive            = true,
                IsMobileResource    = true,
                DayStartTime        = TimeSpan.FromHours(8.00),
                DayEndTime          = TimeSpan.FromHours(8.00).Add(TimeSpan.FromHours(8)),
                ExtRef1             = "FEN01",
                VehicleRegistration = "VEH4",
                FirstName           = "Fenn",
                LastName            = "Sirr",
                CreatedBy           = crmo,
                MobileNo            = "01234567890",
                eMail = "*****@*****.**"
                        //Skills = new List<OperativeSkill>() { new OperativeSkill { CurrentLevel = 100, Description = "Carpenter", ExpiryMatters = false, DocumentCode = "FENCQUAL01" } }
            };

            fn1.DisplayName = fn1.GenerateDisplayName(false, true, true);
            //fn1.Groups.Add(new JarsResourceGroup { Code = "FN", IsActive = true, Name = "Fencing", SortIndex = 3, CreatedBy = crmo });

            JarsResource ph1 = new JarsResource
            {
                IsActive            = true,
                IsMobileResource    = false,
                DayStartTime        = TimeSpan.FromHours(8),
                DayEndTime          = TimeSpan.FromHours(8).Add(TimeSpan.FromHours(8)),
                VehicleRegistration = "",
                FirstName           = "Cherry",
                LastName            = "Picker",
                CreatedBy           = crmo,
            };

            ph1.DisplayName = ph1.GenerateDisplayName(false, true, true);
            //ph1.Groups.Add(new JarsResourceGroup {  Code = "MT", IsActive = true, Name = "Multi Traders", SortIndex = 5, CreatedBy = crmo });
            //ph1.Groups.Add(new JarsResourceGroup {  Code = "EQUIP", IsActive = true, Name = "Equipment", SortIndex = 6, CreatedBy = crmo });


            _Resources.Add(cp1);
            _Resources.Add(el1);
            _Resources.Add(pl1);
            _Resources.Add(fn1);
            _Resources.Add(ph1);

            return(_Resources);
        }
Пример #9
0
        private void ctrl_btnManUsers_Click(object sender, EventArgs e)
        {
            IList <SearchEntity <int> > existingUsers = new List <SearchEntity <int> >();
            IList <SearchEntity <int> > AllUsers      = new List <SearchEntity <int> >();

            foreach (JarsResource user in resourceBindingSource.List)
            {
                existingUsers.Add(new SearchEntity <int> {
                    DisplayText = user.DisplayName, ValueId = user.Id, IsSelected = true
                });
            }

            List <JarsResource> AllOpps = ServiceClient.Get(new FindResources()
            {
                IsActive = true, FetchEagerly = false
            }).Resources.ConvertAll(r => r.ConvertTo <JarsResource>());

            foreach (JarsResource user in AllOpps)
            {
                AllUsers.Add(new SearchEntity <int> {
                    DisplayText = user.DisplayName, ValueId = user.Id, IsSelected = false
                });
            }

            IList <SearchEntity <int> > returnList = SelectEntitiesForm.ShowForm(existingUsers, AllUsers, "Select Users");
            //convert the return list to the entities.
            IList <JarsResource> newList = new List <JarsResource>();

            foreach (var sEnt in returnList)
            {
                JarsResource resource = AllOpps.FirstOrDefault(op => op.Id.ToString() == sEnt.ValueId.ToString());
                if (resource != null)
                {
                    newList.Add(resource);
                }
            }

            //see the notes at the top of the class!!
            //we need to make sure we don't end up with a circular reference, so we need to clean the resource group for serialization.

            (defaultBindingSource.Current as ResourceGroupDto).Resources.Clear();

            foreach (var nOp in newList)
            {
                JarsResource op = (defaultBindingSource.Current as JarsResourceGroup).Resources.FirstOrDefault(g => g.Id == nOp.Id);
                if (op == null)
                {
                    if (!nOp.Groups.Contains(defaultBindingSource.Current as JarsResourceGroup))
                    {
                        nOp.Groups.Add(defaultBindingSource.Current as JarsResourceGroup);
                    }

                    (defaultBindingSource.Current as JarsResourceGroup).Resources.Add(nOp);
                }
                else
                {
                    if (!op.Groups.Contains(defaultBindingSource.Current as JarsResourceGroup))
                    {
                        op.Groups.Add(defaultBindingSource.Current as JarsResourceGroup);
                    }
                }
            }
            foreach (var opP in (defaultBindingSource.Current as JarsResourceGroup).Resources)
            {
                foreach (var opPg in opP.Groups)
                {
                    opPg.Resources = null;
                }
            }
            // operativeBindingSource.ResetBindings(false);
            UpdateLinkedBindingSources();
        }