Ejemplo n.º 1
0
 => services.RegisterJob(new JobInfo(jobType, identifier)
 {
     RequiredInternetAccess = requiredNetwork,
     RunOnForeground        = runInForeground,
     Repeat     = true,
     Parameters = parameters?.ToDictionary()
 });
Ejemplo n.º 2
0
        public List <Job> listUnassignedJobByCategoryAndType(jobCategory category, jobType type)
        {
            try
            {
                List <Job> jobs           = new List <Job>();
                List <Job> unassignedJobs = new List <Job>();
                jobs = listJobsByCategoryAndType(category, type);

                foreach (Job job in jobs)
                {
                    if (job.JobStatus == "Unassigned")
                    {
                        unassignedJobs.Add(job);
                    }
                }

                if (unassignedJobs.Count > 0)
                {
                    return(unassignedJobs);
                }

                return(new List <Job>());
            }
            catch (Exception e)
            {
                MessageBox.Show("JobBusinessLogic : getUnassignedJobByType ERROR:" + e.Message);
                throw;
            }
        }
Ejemplo n.º 3
0
    //Public method 2 to increase resources, based on job
    public void updateCount(jobType type, sourceType source, float multiplier)
    {
        if (type == jobType.Farmer)
        {
            oldCount[0] = foodCount;

            foodCount = incCount(rescType.Food, foodCount, source, multiplier);
        }
    }
Ejemplo n.º 4
0
        public static jobType ToDto(JobTypeVM vm)
        {
            jobType dto = new jobType();

            dto.code        = vm.Code;
            dto.description = vm.Description;
            dto.id          = vm.Id;
            dto.name        = vm.Name;
            return(dto);
        }
Ejemplo n.º 5
0
        public virtual HttpResponseMessage Put(
            [FromUri] string serviceName,
            [FromUri] Guid id,
            [FromBody] jobType item,
            [MatrixParameter] string[] zoneId    = null,
            [MatrixParameter] string[] contextId = null)
        {
            CheckAuthorisation(serviceName, zoneId, contextId, new Right(RightType.UPDATE, RightValue.APPROVED));

            return(Request.CreateResponse(HttpStatusCode.Forbidden));
        }
Ejemplo n.º 6
0
 public static JobTypeVM FromDto(jobType dto, JobTypeVM vm = null)
 {
     if (vm == null)
     {
         vm = new JobTypeVM();
     }
     vm.Code        = dto.code;
     vm.Description = dto.description;
     vm.Id          = dto.id;
     vm.Name        = dto.name;
     return(vm);
 }
Ejemplo n.º 7
0
    //Get amount tasked to job
    public int taskedToJob(jobType type)
    {
        int temp = 0;

        switch (type)
        {
        case jobType.Farmer:
            return(temp = farmerPeons);

        default:  return(temp);
        }
    }
Ejemplo n.º 8
0
    private jobType StringToJobType(string stringJob)
    {
        jobType passMe = new jobType();

        if (stringJob.Equals("Farmer"))
        {
            passMe = jobType.Farmer;
        }
        if (passMe == jobType.empty)
        {
            Debug.LogError("No jobType found for StringToJobType " + passMe.ToString());
        }
        return(passMe);
    }
Ejemplo n.º 9
0
    private jobType[] jobTypeArray()
    {
        jobType[] types;
        string[]  stringTypes;

        stringTypes = Enum.GetNames(typeof(jobType));
        types       = new jobType[stringTypes.Length];

        for (int i = 1; i < stringTypes.Length; i++)
        {
            types[i] = StringToJobType(stringTypes[i]);
        }

        return(types);
    }
Ejemplo n.º 10
0
        public List <Job> listJobsByCategoryAndType(jobCategory category, jobType type)
        {
            try
            {
                DataTable  jobData = new DataTable();
                List <Job> jobs    = new List <Job>();
                switch (category)
                {
                case jobCategory.hardware:
                    jobs = listJobByCategory(jobCategory.hardware);
                    break;

                case jobCategory.software:
                    jobs = listJobByCategory(jobCategory.software);
                    break;

                default:
                    break;
                }
                switch (type)
                {
                case jobType.installation:
                    jobs = jobs.Except(listJobByType(jobType.installation)).ToList();
                    break;

                case jobType.repair:
                    jobs = jobs.Except(listJobByType(jobType.repair)).ToList();
                    break;

                default:
                    break;
                }
                if (jobs.Count > 0)
                {
                    return(jobs);
                }
                return(new List <Job>());
            }
            catch (Exception e)
            {
                MessageBox.Show("JobBusinessLogic : getJobByType ERROR:" + e.Message);
                throw;
            }
        }
Ejemplo n.º 11
0
        private async void EditItem()
        {
            JobTypeVM vm = this.SelectedItem.DeepClone();

            vm.IsDirty              = false;
            vm.IsEditing            = true;
            vm.IsNew                = false;
            this.IsEditing          = true;
            this.CurrentEditingItem = vm;
            bool isSaveClick = await this.EditItemDialog?.ShowDialogAsync("添加", vm);

            if (isSaveClick)
            {
                jobType[] items = new jobType[] { JobTypeConvertUtil.ToDto(vm) };
                int       count = await AppCxt.Current.DataPortal.UpdateJobTypes(items);

                this.ClearEditingState();
                this.RefreshItemsAsync();
            }
        }
Ejemplo n.º 12
0
        public RegisterViewModel(INavigation navigation)
        {
            try
            {
                this.Navigation = navigation;
                IsMaleLocal     = new bool();
                isenabel        = true;
                isenabelbtn     = true;
                Basicinfos      = new EmployeeCurrentProfile();
                SkillsListView  = new ObservableCollection <SkillsModel>();
                SelectedItem    = new jobType();
                if (EmployeeSkills == null)
                {
                    EmployeeSkills = new ObservableCollection <SkillsModel>();
                }
                if (JobType == null)
                {
                    JobType = new List <jobType>();
                }
                if (JobTypeForProfile == null)
                {
                    JobTypeForProfile = new ObservableCollection <jobType>();
                }
                if (RBM == null)
                {
                    RBM = new RegisterBindingModel();
                }

                if (Basicinfos == null)
                {
                    Basicinfos = new EmployeeCurrentProfile();
                }
                GetData();
                typesasync();
            }
            catch (Exception ex)
            {
                var logged = new LoggedException.LoggedException("Error in RegisterViewModel consturctor", ex);
                logged.LoggAPI();
            }
        }
Ejemplo n.º 13
0
        public List <Job> listJobByType(jobType type)
        {
            try
            {
                DataTable  jobData = new DataTable();
                List <Job> jobs    = new List <Job>();
                switch (type)
                {
                case jobType.installation:
                    jobData = db.ListJobsByType("Installation");
                    break;

                case jobType.repair:
                    jobData = db.ListJobsByType("Repair");
                    break;

                case jobType.callCentre:
                    jobData = db.ListJobsByType("CallCentre");
                    break;

                default:
                    break;
                }
                if (jobData.Rows.Count > 0)
                {
                    for (int i = 0; i < jobData.Rows.Count; i++)
                    {
                        jobs.Add(new Job(data: jobData, i: i));
                    }
                    return(jobs);
                }

                return(new List <Job>());
            }
            catch (Exception e)
            {
                MessageBox.Show("JobBusinessLogic : getJobByType ERROR:" + e.Message);
                throw;
            }
        }
Ejemplo n.º 14
0
        private async void AddItem()
        {
            JobTypeVM vm = new JobTypeVM()
            {
                Id = Guid.NewGuid().ToString()
            };

            vm.IsDirty              = true;
            vm.IsEditing            = true;
            vm.IsNew                = true;
            this.IsEditing          = true;
            this.CurrentEditingItem = vm;
            bool isSaveClick = await this.EditItemDialog?.ShowDialogAsync("添加", vm);

            if (isSaveClick)
            {
                jobType[] items = new jobType[] { JobTypeConvertUtil.ToDto(vm) };
                int       count = await AppCxt.Current.DataPortal.AddJobTypes(items);

                this.ClearEditingState();
                this.RefreshItemsAsync();
            }
        }
Ejemplo n.º 15
0
 public void CancelJob(jobType job)
 {
     if (AttackComp && (job == jobType.all || job == jobType.attack))
     {
         AttackComp.Stop();
     }
     if (BuilderComp && (job == jobType.all || job == jobType.building))
     {
         BuilderComp.Stop();
     }
     if (CollectorComp && (job == jobType.all || job == jobType.collecting))
     {
         CollectorComp.CancelDropOff();
         CollectorComp.Stop();
     }
     if (HealerComp && (job == jobType.all || job == jobType.healing))
     {
         HealerComp.Stop();
     }
     if (ConverterComp && (job == jobType.all || job == jobType.converting))
     {
         ConverterComp.Stop();
     }
 }
Ejemplo n.º 16
0
        public virtual HttpResponseMessage Post([FromUri] string serviceName, [FromUri] string jobName, [FromBody] jobType item, [MatrixParameter] string[] zone = null, [MatrixParameter] string[] context = null)
        {
            string sessionToken = CheckAuthorisation(serviceName, zone, context, new Right(RightType.CREATE, RightValue.APPROVED));

            HttpResponseMessage result;

            try
            {
                bool hasAdvisoryId    = ProviderUtils.IsAdvisoryId(item.id);
                bool?_mustUseAdvisory = HttpUtils.GetMustUseAdvisory(Request.Headers);
                bool mustUseAdvisory  = _mustUseAdvisory.HasValue && _mustUseAdvisory.Value;

                IFunctionalService service = getService(serviceName);

                if (!service.AcceptJob(serviceName, jobName))
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Service " + serviceName + " does not handle jobs named " + jobName));
                }

                if (hasAdvisoryId && !mustUseAdvisory)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request failed for creating job for " + serviceName + " as object ID provided (" + item.id + "), but mustUseAdvisory is not specified or is false.\n" +
                                                       !Guid.Empty.ToString().Equals(item.id)));
                }

                if (!hasAdvisoryId && mustUseAdvisory)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request requires use of advisory id, but none has been supplied."));
                }

                Guid id = service.Create(item, zone: (zone == null ? null : zone[0]), context: (context == null ? null : context[0]));

                if (SettingsManager.ProviderSettings.JobBinding)
                {
                    service.Bind(id, getOwnerId(sessionToken));
                }

                jobType job = service.Retrieve(id, zone: (zone == null ? null : zone[0]), context: (context == null ? null : context[0]));

                string uri = Url.Link("ServicesRoute", new { controller = serviceName, id = id });

                result = Request.CreateResponse <jobType>(HttpStatusCode.Created, job);
                result.Headers.Location = new Uri(uri);
            }
            catch (AlreadyExistsException e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.Conflict, e);
            }
            catch (ArgumentException e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Object to create Job is invalid.\n ", e);
            }
            catch (CreateException e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request failed for Job.\n ", e);
            }
            catch (RejectedException e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.NotFound, "Create request rejected for Job" + (item.id == null ? "" : " with advisory id " + item.id) + ".\n", e);
            }
            catch (QueryException e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Request failed for Job.\n", e);
            }
            catch (Exception e)
            {
                result = Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e);
            }
            return(result);
        }