Ejemplo n.º 1
0
        public bool RemoveFunctionChain(string key, JobTodo Todo = null, JobToDoCondition toDoCheck = null,
                                        JobAutoDropCondition autoDropCondition = null, bool isExecuteImmediately = true)
        {
            JobRepeatBase Job = JobList.Find(job => job.key.Equals(key));

            if (Job == null)
            {
                return(false);
            }

            StopCoroutine(Job.worker);

            Job.jobTodo          -= Todo;
            Job.jobToDoCheck     -= toDoCheck;
            Job.jobAutoDropCheck -= autoDropCondition;

            if (Job.jobTodo == null)
            {
                Job.state = JOB_STATE.JOB_EMPTY;
                return(true);
            }

            if (isExecuteImmediately)
            {
                Job.state = JOB_STATE.JOB_STANDBY;
                StartCoroutine(Job.worker);
            }
            return(true);
        }
Ejemplo n.º 2
0
        public static IJob GetJob(string name)
        {
            var find = JobList.Find(o => o.Name == name);

            if (find != null)
            {
                return(find);
            }
            return(null);
        }
Ejemplo n.º 3
0
        public bool RemoveJob(string key)
        {
            JobRepeatBase findJob = JobList.Find(job => job.key.Equals(key));

            if (findJob == null)
            {
                return(false);
            }

            DestroyImmediate(findJob.gameObject);
            return(JobList.Remove(findJob));
        }
Ejemplo n.º 4
0
        public bool JobStart(string key)
        {
            JobRepeatBase findJob = JobList.Find(job => job.key.Equals(key));

            if (findJob == null)
            {
                return(false);
            }

            StopCoroutine(findJob.worker);

            findJob.state = JOB_STATE.JOB_STANDBY;
            StartCoroutine(findJob.worker);
            return(true);
        }
Ejemplo n.º 5
0
        public bool ChangeJobDelay(string key, float newDelay)
        {
            JobRepeatBase findJob = JobList.Find(job => job.key.Equals(key));

            if (findJob == null)
            {
                return(false);
            }

            findJob.repeatDelay = newDelay;
            StopCoroutine(findJob.worker);

            findJob.state = JOB_STATE.JOB_STANDBY;
            StartCoroutine(findJob.worker);
            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Job RepeatManager > Adding Job
        /// <para>key = JobKeyName,
        /// todo = ExecuteFunctionPointer,
        /// delay = Update Sequence Delay(Seconds),
        /// repeatCount = Total Execute Count,
        /// parameter = params object[] : Your Parameter
        /// todoCondition = Execute Condition(true = Available Execute, false = Block Execute),
        /// autoDropCondition = Job Drop Condition(Flag : true = Drop, false = MoveNext)</para>
        /// </summary>
        public bool AddDelegateJob(string key, JobTodo toDo, float delay = 1.0f, int repeatCount = 0, object[] parameter = null,
                                   JobEndAction endActionWhenDrop        = null,
                                   JobToDoCondition toDoCondition        = null, JobAutoDropCondition autoDropCondition = null, bool isImmediately = true)
        {
            // Already Registered Job Check
            if (JobList.Find(job => job.key.Equals(key)) != null)
            {
                return(false);
            }

            GameObject JobObject = new GameObject(key);

            JobObject.transform.parent = this.transform;
            JobRepeatBase newJob = JobObject.AddComponent <JobRepeatBase>();

            newJob.key              = key;
            newJob.jobCoroutine     = null;
            newJob.jobTodo          = toDo;
            newJob.repeatDelay      = delay;
            newJob.repeatCount      = repeatCount;
            newJob.excuteCount      = 0;
            newJob.jobToDoCheck     = toDoCondition;
            newJob.jobAutoDropCheck = autoDropCondition;
            newJob.jobEndAction     = endActionWhenDrop;
            newJob.state            = JOB_STATE.JOB_STANDBY;
            newJob.worker           = CoJobHandle(key);
            newJob.parameter        = parameter;

            if (toDo == null)
            {
                Debug.LogWarningFormat("Are You Sure Adding Empty Job? Todo Parameter is null (key:{0})", key);
                newJob.state = JOB_STATE.JOB_EMPTY;
            }

            newJob.repeatDelay = newJob.repeatDelay < m_MinDelayTime ? m_MinDelayTime : newJob.repeatDelay;
            JobList.Add(newJob);

            if (isImmediately)
            {
                StartCoroutine(newJob.worker);
            }

            return(true);
        }
Ejemplo n.º 7
0
        private IEnumerator CoJobHandle(string key)
        {
            yield return(null);

            JobRepeatBase findJob = JobList.Find(x => x.key == key);

            if (findJob == null)
            {
                yield break;
            }

            switch (findJob.state)
            {
            case JOB_STATE.JOB_EMPTY:
                yield break;

            case JOB_STATE.JOB_STANDBY:
                if (findJob.jobToDoCheck != null)
                {
                    if (findJob.jobToDoCheck(findJob.parameter))
                    {
                        findJob.state = JOB_STATE.JOB_WORKING;

                        findJob.jobTodo?.Invoke(findJob.parameter);
                        if (findJob.jobCoroutine != null)
                        {
                            yield return(StartCoroutine(findJob.jobCoroutine));
                        }

                        findJob.excuteCount++;
                        if (findJob.excuteCount >= findJob.repeatCount && findJob.repeatCount != 0)
                        {
                            findJob.state = JOB_STATE.JOB_DROP;
                        }
                        else
                        {
                            findJob.state = JOB_STATE.JOB_WAITING;
                        }
                    }
                }
                else
                {
                    findJob.state = JOB_STATE.JOB_WORKING;
                    findJob.jobTodo?.Invoke(findJob.parameter);
                    if (findJob.jobCoroutine != null)
                    {
                        yield return(StartCoroutine(findJob.jobCoroutine));
                    }

                    findJob.excuteCount++;
                    if (findJob.excuteCount >= findJob.repeatCount && findJob.repeatCount != 0)
                    {
                        findJob.state = JOB_STATE.JOB_DROP;
                    }
                    else
                    {
                        findJob.state = JOB_STATE.JOB_WAITING;
                    }
                }

                if (findJob.jobAutoDropCheck != null)
                {
                    if (findJob.jobAutoDropCheck(findJob.parameter))
                    {
                        findJob.state = JOB_STATE.JOB_DROP;
                        break;
                    }
                }
                break;

            case JOB_STATE.JOB_WAITING:
                WaitForSeconds WaitForDelay = new WaitForSeconds(findJob.repeatDelay);
                yield return(WaitForDelay);

                findJob.state = JOB_STATE.JOB_STANDBY;
                break;

            case JOB_STATE.JOB_DROP:
                yield break;
            }

            yield return(StartCoroutine(CoJobHandle(findJob.key)));
        }
Ejemplo n.º 8
0
 public JobRepeatBase GetJobBase(string key)
 {
     return(JobList.Find(x => x.key == key));
 }
Ejemplo n.º 9
0
        public static JobList buildJobList(string strSuffixCode, string strCountry, AspectResultSet aspectResultSet, HealthResultSet healthResultSet, LevelResultSet levelResultSet, string strClusterCode, string strCluster)
        {
            //do a match, but only include those inside a cluster
            JobList jl = new JobList();
            JobItem ji;
            string aspecttblname = strCountry;

            //mrm 15/8/2006 change SQL to exclude Talent jobs
            DataTable dtAspects = CCLib.Cache.GetCachedDataTableWithNoExpire("MM_ALL_JOBST_" + strSuffixCode, "SELECT tblAspects" + aspecttblname + ".OccNumber, Central, Secondary, ID, Other, Education, EssentialSkills, DesirableSkills, Talent, OccName FROM Jobinfo" + strSuffixCode + " INNER JOIN tblAspects" + aspecttblname + " ON Jobinfo" + strSuffixCode + ".OccNumber = tblAspects" + aspecttblname + ".OccNumber WHERE (Talent IS NULL) or (Talent=0) ORDER BY OccName");
            bool[] levelvals = new bool[MaxNoOfLevels + 1];
            bool[] healthvals = new bool[MaxNoOfHealth + 1];
            int[] aspectres = new int[MaxNoOfAspects + 1];
            CreateFastClientArrays(aspectResultSet, levelResultSet, healthResultSet, healthvals, levelvals, aspectres);
            //set up arrays for fast matching
            foreach (DataRow rt in dtAspects.Rows)
            {
                ji = new JobItem();
                ji.Score = ScoreArticle(rt, healthvals, levelvals, aspectres, ref ji.MatchCat, ref ji.MatchMore);
                //get job score
                ji.JobRef = Convert.ToInt16(rt["OccNumber"].ToString());
                ji.JobTitle = rt["OccName"].ToString();
                if (((int)ji.MatchCat / 100) < 6)
                {
                    jl.Add(ji);
                };

            };
            //sort the list by score
            jl.Sort(delegate(JobItem x, JobItem y) { return Comparer.Default.Compare(y.Score, x.Score); });
            // we only want the top 40
            if (jl.Count > 40)
            {
                jl.RemoveRange(40, jl.Count - 40);
            };
            //prepare rank
            int i = 1;
            foreach (JobItem ji1 in jl)
            {
                ji1.Rank = i;
                i++;
            };
            //now we check against the clusters table
            //next section is more or less lifted from cluster.aspx
            DataTable dtCluster = CCLib.Cache.GetCachedDataTable("Cluster" + strSuffixCode , "select * from Clusters" + strSuffixCode + "_View");
            DataRow[] drsClusterCodes;
            string strClusterType = strCluster;
            string strSQL=strClusterType+"= '"+strClusterCode.Replace("'","''")+"' or "+strClusterType+" like '"+strClusterCode.Replace("'","''")+",%' or "+strClusterType+" like '%,"+strClusterCode.Replace("'","''")+"' or "+strClusterType+" like '%,"+strClusterCode.Replace("'","''")+",%'";
            drsClusterCodes = dtCluster.Select(strSQL);
            //yuk!! sequential search - need to check for better way
            JobList jlResultList = new JobList();
            JobItem jitmp;
            foreach (DataRow dr in drsClusterCodes)
            {
                int strOccNumber = (int)dr["OccNumber"]; //copy into local variable to keep things quick
                jitmp = jl.Find(delegate(JobItem ji1) { return ji1.JobRef == strOccNumber; });
                if (jitmp!=null) {jlResultList.Add(jitmp);};
            }
            jlResultList.Sort(delegate(JobItem x, JobItem y) { return Comparer.Default.Compare(y.Score, x.Score); });

            return (jlResultList);
        }