public JobFactory(JOB_TYPE type) { this.Messages = new QueueThreadSafe <Message>(); this.Type = type; JobHandles = new DictionaryThreadSafe <int, IJobHandle>(); }
public IJobHandle f_createNew(IJob job) { IJobHandle handle = null; JOB_TYPE type = job.Type; switch (type) { case JOB_TYPE.NONE: case JOB_TYPE.REQUEST_URL: // factory IJobFactory fac; if (this.JobFactories.ContainsKey(type)) { fac = this.JobFactories[type]; } else { fac = new JobFactory(type); this.JobFactories.Add(type, fac); } handle = fac.f_createNew(job); break; default: // singleton if (!this.JobSingletons.ContainsKey(type)) { handle = new JobHandle(job); this.JobSingletons.Add(type, handle); } break; } return(handle); }
public JobBaseUrl(IJobContext jobContext, JOB_TYPE type) { this.JobContext = jobContext; this.Id = jobContext.f_getTotalJob() + 1; this.Type = type; this.Status = 1; /* 1: init */ }
public void HoverOnCitizen(GameObject go) { JOB_TYPE jobType = (JOB_TYPE)System.Enum.Parse(typeof(JOB_TYPE), go.name); lblCitizenInfo.text = jobType.ToString() + "'s: \n\n"; for (int i = 0; i < currentDisplayingCityTile.cityAttributes.citizens.Count; i++) { Citizen currentCitizen = currentDisplayingCityTile.cityAttributes.citizens [i]; if (currentCitizen.job.jobType == jobType) { lblCitizenInfo.text += "Name: " + currentCitizen.name + "\n"; lblCitizenInfo.text += "Level: " + currentCitizen.level.ToString() + "\n"; lblCitizenInfo.text += "Assigned Tile: " + currentCitizen.assignedTile.name + "\n"; // lblCitizenInfo.text += "Upgrade Reqs: "; // if (jobType != JOB_TYPE.MERCHANT) { // for (int j = 0; j < currentCitizen.GetUpgradeRequirements ().resource.Count; j++) { // Resource currentResource = currentCitizen.GetUpgradeRequirements ().resource [j]; // lblCitizenInfo.text += currentResource.resourceType.ToString () + " - " + currentResource.resourceQuantity.ToString () + "\n"; // } // lblCitizenInfo.text += "\n"; // } } } goCitizenInfo.SetActive(true); }
public void CopyData(Job job) { this._jobType = job.jobType; this._citizen = job.citizen; this._upgradeRequirements = job.upgradeRequirements; this._resourcesProduced = job.resourcesProduced; this._residence = job.residence; }
internal void ChangeJob(JOB_TYPE jobType) { this._job = GetJob(jobType); this._job.citizen = this; // if (jobType != JOB_TYPE.PIONEER) { // UpdateUpgradeRequirements (); // } }
public JobWorker(IJobContext jobContext, JOB_TYPE type) { this.Messages = new QueueThreadSafe <Message>(); this.JobContext = jobContext; this.Id = jobContext.f_getTotalJob() + 1; this.Type = type; this.Status = 1; /* 1: init */ }
public JobBase(IJobContext jobContext, JOB_TYPE type) { this.Messages = new ConcurrentQueue <Message>(); this.JobContext = jobContext; this.Id = jobContext.f_getTotalJob() + 1; this.Type = type; this.Status = 1; /* 1: init */ }
public Citizen(JOB_TYPE jobType, CityTest city) { this._id = GetID() + 1; this.name = "CITIZEN" + this._id; this._job = GetJob(jobType); // this._job = new Job(); // this._job.CopyData(GetJob (jobType)); this._city = city; this._level = 1; AssignJobToCitizen(); SetLastID(this._id); }
public void f_sendRequestMessages(JOB_TYPE type, Message[] ms, Func <IJobHandle, Guid, bool> responseCallbackDoneAll) { foreach (Message m in ms) { Guid id = m.GetMessageId(); if (m.f_getTimeOut() > 0) { long timeOut = DateTime.Now.Ticks / 1000 + m.f_getTimeOut(); this.MessagesRequestTimeOut.Add(timeOut, id); } this.MessagesRequest.Add(id, m); } }
public bool f_sendRequestMessages(JOB_TYPE type, Message[] ms, Func <IJobHandle, Guid, bool> responseCallbackDoneAll) { if (this.JobFactories.ContainsKey(type)) { if (responseCallbackDoneAll != null) { if (this.MessageContext != null) { this.MessageContext.f_sendRequestMessages(type, ms, responseCallbackDoneAll); } } this.JobFactories[type].f_sendRequests(ms); } else if (this.JobSingletons.ContainsKey(type)) { //this.JobSingletons[type].f_sendMessages(ms); } return(false); }
public Job GetJob(JOB_TYPE jobType) { switch (jobType) { case JOB_TYPE.ALCHEMIST: return(new Alchemist()); // case JOB_TYPE.ARCHER: // return new Archer (); // case JOB_TYPE.BRAWLER: // return new Brawler (); case JOB_TYPE.FARMER: return(new Farmer()); case JOB_TYPE.HUNTER: return(new Hunter()); case JOB_TYPE.MINER: return(new Miner()); case JOB_TYPE.QUARRYMAN: return(new Quarryman()); case JOB_TYPE.WOODSMAN: return(new Woodsman()); case JOB_TYPE.PIONEER: return(new Pioneer()); case JOB_TYPE.MERCHANT: return(new Merchant()); default: return(new Job()); } }
public int GetRelevantResourceValueByJobType(JOB_TYPE jobType) { switch (jobType) { case JOB_TYPE.FARMER: return(farmingValue); case JOB_TYPE.HUNTER: return(huntingValue); case JOB_TYPE.WOODSMAN: return(woodValue); case JOB_TYPE.QUARRYMAN: return(stoneValue); case JOB_TYPE.MINER: return(metalValue); case JOB_TYPE.ALCHEMIST: return(manaValue); } return(-1); }
public JobNeeds(JOB_TYPE jobType, Resource resource) { this.jobType = jobType; this.resource = resource; }
public JobFactoryBase(JOB_TYPE type) { this.JobHandles = new ConcurrentDictionary <int, IJobHandle>(); this.Messages = new ConcurrentQueue <Message>(); this.Type = type; }
public static string create_job(JOB_TYPE type, string group_name, Dictionary <string, object> para = null, string schedule = null) { if (para == null) { para = new Dictionary <string, object>() { } } ; group_name = group_name.ToLower(); string name = group_name + "." + DateTime.Now.ToString("yyMMdd-HHmmss-fff"); if (!string.IsNullOrEmpty(schedule)) { name += "." + schedule; } JobDataMap m = new JobDataMap(); m.Put("ID___", name); m.Put("SCHEDULE___", schedule); m.Put("TYPE___", type); m.Put("CURRENT_ID___", 0); m.Put("COUNTER___", new ConcurrentDictionary <long, bool>()); m.Put("PARA___", para); JobBuilder job = null; TriggerBuilder trigger = null; switch (type) { case JOB_TYPE.CRAWLER_NET: case JOB_TYPE.CRAWLER_CURL: job = JobBuilder.Create <JobCrawler>(); break; case JOB_TYPE.API_JS: job = JobBuilder.Create <JobApiJS>(); break; } if (job != null) { job = job.WithIdentity(name, group_name).UsingJobData(m); trigger = TriggerBuilder.Create(); if (!string.IsNullOrEmpty(schedule)) { trigger = trigger.WithSchedule(CronScheduleBuilder.CronSchedule(schedule)); } trigger = trigger.StartNow(); var j = job.Build(); var t = trigger.Build(); m_scheduler.ScheduleJob(j, t); m_job.TryAdd(name, j); m_trigger.TryAdd(name, t); m_scheduler.ScheduleJob(j, t).Wait(); return(name); } return(string.Empty); }
public JobFactoryUrl(JOB_TYPE type) : base(type) { }