Esempio n. 1
0
        public void Createjob(Client player, int characterId, int level, int cost, JobType type)
        {
            if (!AdminController.AdminRankCheck(player, "createjob"))
            {
                return;
            }
            CharacterController characterController = player.getData("CHARACTER");

            var jobData = new Data.Job
            {
                CharacterId = characterId,
                Level       = level,
                Cost        = cost,
                Type        = type,
                PosX        = player.position.X,
                PosY        = player.position.Y,
                PosZ        = player.position.Z,
                OwnerName   = characterController.Character.Name
            };

            var jobController = new JobController(jobData);

            ContextFactory.Instance.Job.Add(jobData);
            ContextFactory.Instance.SaveChanges();
            jobController.CreateWorldEntity();

            player.sendChatMessage("~g~[СЕРВЕР]: ~w~ Добавлена работа: " + jobController.Type());
        }
Esempio n. 2
0
        public void createjob(Client player, JobType type, int Level, string IDOrName = null)
        {
            AccountController account = player.getData("ACCOUNT");

            if (account == null)
            {
                return;
            }
            if (!AdminController.AdminRankCheck("createproperty", account))
            {
                return;
            }

            Groups.GroupController groupController = null;
            if (IDOrName != null)
            {
                groupController = EntityManager.GetGroup(player, IDOrName);
                if (groupController == null)
                {
                    player.sendChatMessage("~r~ERROR: ~w~You specified an invalid group.");
                    return;
                }
            }
            Data.Job      jobData       = new Data.Job();
            JobController jobController = new JobController(jobData);

            jobController.Group = groupController;
            // _JobData.GroupID = (_GroupController == null ? null : _GroupController._GroupData.GroupID);
            if (groupController == null)
            {
                jobData.GroupId = null;
            }
            else
            {
                jobData.GroupId = groupController.Group.Id;
            }
            jobData.Type = type;

            jobData.PosX = player.position.X;
            jobData.PosY = player.position.Y;
            jobData.PosZ = player.position.Z;

            jobData.Level = Level;
            ContextFactory.Instance.Job.Add(jobData);
            ContextFactory.Instance.SaveChanges();

            jobController.CreateWorldEntity();
            player.sendChatMessage("~g~Server: ~w~ Added job: " + jobController.Type());
        }
Esempio n. 3
0
 public JobController(Data.Job jobData)
 {
     JobData = jobData;
     EntityManager.Add(this);
 }
Esempio n. 4
0
        private static Dictionary <string, object> GetJobRepresentation(Data.Job entity, bool verbose)
        {
            var    dict  = new Dictionary <string, Object>();
            string input = entity.Process.Input;
            IDictionary <string, Object> inputDict = new Dictionary <string, Object>()
            {
            };

            if (input != null)
            {
                inputDict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Object> >(input);
            }

            string output = entity.Process.Output;
            IDictionary <string, Object> outputDict = null;

            if (output != null)
            {
                outputDict = Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, Object> >(output);
            }
            string[] msg_array = null;
            if (verbose)
            {
                msg_array = entity.Messages.Select <Message, string>(s => s.Value).ToArray <string>();
            }

            Serialize.ProcessErrorList errorList = new Serialize.ProcessErrorList();

            foreach (var error in entity.Process.Errors)
            {
                var pe = new Serialize.ProcessError();
                pe.Error = error.Error;
                pe.Type  = error.Type;
                pe.Name  = error.Name;
                errorList.Add(pe);
            }

            int status;

            try
            {
                status = (int)entity.Process.Status;
            }
            catch (Exception)
            {
                status = -1;
            }

            dict["Id"]         = entity.Id;
            dict["Simulation"] = entity.Simulation.Name;
            dict["State"]      = entity.State;
            dict["Messages"]   = msg_array;
            dict["Input"]      = inputDict;
            dict["Output"]     = outputDict;
            dict["Errors"]     = errorList;
            dict["Status"]     = status;
            dict["Session"]    = entity.Session.Id;
            dict["Initialize"] = entity.Initialize;
            dict["Reset"]      = entity.Reset;

            if (entity.Consumer != null)
            {
                dict["Consumer"] = entity.Consumer.Id;
            }
            if (entity.Create != null)
            {
                dict["Create"] = ConvertDateTime((DateTime)entity.Create);
            }
            if (entity.Submit != null)
            {
                dict["Submit"] = ConvertDateTime((DateTime)entity.Submit);
            }
            if (entity.Setup != null)
            {
                dict["Setup"] = ConvertDateTime((DateTime)entity.Setup);
            }
            if (entity.Running != null)
            {
                dict["Running"] = ConvertDateTime((DateTime)entity.Running);
            }
            if (entity.Finished != null)
            {
                dict["Finished"] = ConvertDateTime((DateTime)entity.Finished);
            }

            return(dict);
        }