[DataRow(5, 5, 0, false, 0, 0, true, 4)]     //will not advance as start date is in the future
        public void AdvanceJob_ShouldNotAdvance(int startdate, int duration, int CurrentDay, bool IsComplete, int progress, int dayssincecreation, bool iscurrentlyprogressing, int daysToAdvance)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = iscurrentlyprogressing,
                Days_Since_Creation    = dayssincecreation,
                Complete = IsComplete
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.AdvanceJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, IsComplete, "ISComplete improperly changed");
            Assert.AreEqual(J_Test.StartDate, startdate, "StartDate improperly changed");
            Assert.AreEqual(J_Test.Duration, duration, "Duration improperly changed");
            Assert.AreEqual(J_Test.Progress, progress, "Progress improperly changed");
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, iscurrentlyprogressing, "IsCurrentlyProgressing improperly changed");
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation + daysToAdvance, "Days_Since_Creation improperly advanced");
        }
        public void AdvanceJob_NegativeAdvanceThrowsException()
        {
            //arrange
            Job J_Test = new Job(0)
            {
                StartDate = 0,
                Duration  = 0,
                Progress  = 0,
                IsCurrentlyProgressing = false,
                Days_Since_Creation    = 0,
                Complete  = false,
                Recurring = false
            };
            int daysToAdvance = -1;

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);


            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act // assert
            Assert.ThrowsException <InvalidOperationException>(() => JL_Test.AdvanceJob(J_Test, daysToAdvance));
        }
        public void ProgressJob_ShouldAdvance(int startdate, int duration, int CurrentDay, int progress, int dayssincecreation, int daysToAdvance)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = true,
                Days_Since_Creation    = dayssincecreation,
                Complete = false
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.ProgressJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, false, "Complete not false");
            Assert.AreEqual(J_Test.StartDate, startdate, "StartDate improperly changed");
            Assert.AreEqual(J_Test.Duration, duration, "Duration improperly changed");
            Assert.AreEqual(J_Test.Progress, progress + daysToAdvance, "Progress improperly advanced");
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, true, "IsCurrentlyProgressing not true");
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation, "Days_Since_Creation improperly advanced");

            EAM.VerifyNoOtherCalls();
        }
Exemple #4
0
        public ActionResult GetList(SearchJob filter, int index, int count)
        {
            filter.IsOnlyRecruiting = true;
            var result = JobLogic.GetList(filter, index, count);

            return(Json(result));
        }
Exemple #5
0
        public ActionResult EditInit(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(Json(null));
            }

            try
            {
                var jobId       = int.Parse(id);
                var checkResult = UserLogic.IsJobMaster(GetOperation().UserId, jobId);
                if (checkResult.IsSuccess == false)
                {
                    return(Json(checkResult));
                }

                var result = JobLogic.GetDetail(jobId);
                return(Json(result));
            }
            catch
            {
                var result = new IsSuccessResult(ErrorCode.JobNotFound.ToString());
                return(Json(result));
            }
        }
 /// <summary>
 /// Saves the new Modul if the input was valid
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void AdoptBtn_Click(object sender, EventArgs e)
 {
     if (CheckDescriptions())
     {
         int indexOfCurrentModulpunkt     = GetCurrentIndex();
         List <ModulPartDescription> list = GetModulpartDescriptions();
         list[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
         list[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
         var            mu        = System.Web.Security.Membership.GetUser();
         Guid           owner     = (Guid)mu.ProviderUserKey;
         ArchiveLogic   al        = new ArchiveLogic();
         JobLogic       jl        = new JobLogic();
         List <Subject> subjects  = GetSubjects();
         Modul          newModule = al.CreateModul(list, ModulState.created, owner, owner, DateTime.Now, subjects, 1);
         Session["Message"] = true;
         if (newModule != null)
         {
             CheckforMessage("Neues Modul erstellt!");
             jl.CreateNewJob(ModulState.created, list, newModule, owner);
         }
         else
         {
             CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
         }
     }
 }
Exemple #7
0
        public HttpResponseMessage allowdToPrint(Job job)
        {
            UserDTO user = UserLogic.Login(new UserDTO()
            {
                userTz = job.userTz
            });
            double?AmountToPay, balance;

            if (user != null)
            {
                balance     = UserLogic.getBalanceByUser(user);
                AmountToPay = JobLogic.CalaulateJob(job);
                if (AmountToPay - balance >= 0)
                {
                    PrintHistoryLogic.AddPrint(new PrintHistoryDTO()
                    {
                        userId      = user.userId,
                        datePrint   = DateTime.Now,
                        costPrint   = AmountToPay,
                        isColorFull = job.isColorFull,
                        sumOfPages  = job.numOfPages,
                        printerName = job.printerName
                    });
                    return(Request.CreateResponse(HttpStatusCode.OK, "OK"));
                }
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "Small_balance"));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, "User_doesnt_exist"));
        }
Exemple #8
0
        public ActionResult EditSubmit(EditJob data, int?jobId)
        {
            if (!string.IsNullOrWhiteSpace(data.Photo))
            {
                var originalDirectory = new DirectoryInfo(string.Format("{0}MediaUpload\\", Server.MapPath(@"\")));
                var pathString        = Path.Combine(originalDirectory.ToString(), "JobPhoto");
                var ext       = Path.GetExtension(data.Photo);
                var photoName = "temp" + GetOperation().UserId + ext;
                data.Photo = string.Format("{0}\\{1}", pathString, photoName);
            }
            var result = JobLogic.Edit(GetOperation().UserId, data, jobId);

            return(Json(result));
        }
Exemple #9
0
 public ActionResult DetailInit(string id)
 {
     try
     {
         var jobId  = int.Parse(id);
         var result = JobLogic.GetDetail(jobId);
         return(Json(result));
     }
     catch
     {
         var result = new IsSuccessResult(ErrorCode.JobNotFound.ToString());
         return(Json(result));
     }
 }
        /// <summary>
        /// Saves the Modul with the given Modulstate und version number 1+n where n is the number, of the latest version
        /// </summary>
        /// <param name="state"></param>
        private void SaveChanges(ModulState state)
        {
            if (CheckDescriptions())
            {
                int indexOfCurrentModulpunkt = GetCurrentIndex();
                List <ModulPartDescription> modulpartdescriptions = GetModulpartDescriptions();
                List <Subject> subjects = GetSubjects();
                modulpartdescriptions[indexOfCurrentModulpunkt].Name        = NameTextBox.Text;
                modulpartdescriptions[indexOfCurrentModulpunkt].Description = DescriptionTextBox.Text;
                if (!CommentTextBox.Text.Trim().Equals(""))
                {
                    modulpartdescriptions[indexOfCurrentModulpunkt].Comment = CommentTextBox.Text;
                }



                var          mu    = System.Web.Security.Membership.GetUser();
                Guid         user  = (Guid)mu.ProviderUserKey;
                Modul        modul = GetModulByQuerystring();
                ArchiveLogic al    = new ArchiveLogic();
                JobLogic     jl    = new JobLogic();

                //create the new Modulpartdescriptions
                List <ModulPartDescription> mpdList = new List <ModulPartDescription>();
                foreach (ModulPartDescription m in modulpartdescriptions)
                {
                    ModulPartDescription toAdd = new ModulPartDescription()
                    {
                        IsNeeded    = m.IsNeeded,
                        Description = m.Description,
                        Comment     = m.Comment,
                        Name        = m.Name
                    };
                    mpdList.Add(toAdd);
                }

                Modul newModule = al.CreateModul(mpdList, state, modul.Owner, user, DateTime.Now, subjects, modul.Version + 1);

                Session["Message"] = true;
                if (newModule != null)
                {
                    CheckforMessage("Neue Version Erstellt!");
                    jl.CreateNewJob(state, mpdList, newModule, user);
                }
                else
                {
                    CheckforMessage("Ein Fehler ist aufgetreten. Es wurde kein Modul erstellt!");
                }
            }
        }
Exemple #11
0
        public static void Handle(int nSkillID, byte nSLV, Character c, CInPacket p)
        {
            // Recv [CP_UserSkillUseRequest] 67 00 56 3B 36 10 A5 C7 C9 01 01 2A 4E 00 00

            //COutPacket::COutPacket(&oPacket, 103);
            //v55 = 8;
            //v41 = get_update_time();
            //COutPacket::Encode4(&oPacket, v41);
            //COutPacket::Encode4(&oPacket, pSkill->nSkillID);
            //COutPacket::Encode1(&oPacket, nSLV);
            //v42 = CMob::GetMobID(v24);
            //COutPacket::Encode4(&oPacket, v42);
            //CClientSocket::SendPacket(TSingleton < CClientSocket >::ms_pInstance, &oPacket);

            var dwMobId = p.Decode4();

            var pMob = c.Field.Mobs[dwMobId];

            if (pMob is null ||
                GameConstants.is_not_capturable_mob(pMob.nMobTemplateId) ||
                pMob.MaxHp * 0.5 > pMob.Stats.HP ||
                !JobLogic.IsWildhunterJob(c.Stats.nJob))
            {
                return;
            }

            var bLeft = pMob.Position.X < c.Position.X;

            var bSuccess = c.Skills.Cast(nSkillID, bLeft);

            if (bSuccess)
            {
                new UserEffectPacket(UserEffect.SkillUse)
                {
                    nSkillID = nSkillID,
                    nSLV     = nSLV
                }.BroadcastEffect(c, false);

                //c.SendPacket(c.WildHunterInfo.CaptureResultLocalEffect(WildHunterCaptureResult.Success));
                //c.Field.Broadcast(c.WildHunterInfo.CaptureSuccessRemoteEffect(), c);
                c.Field.Mobs.Remove(pMob);

                c.WildHunterInfo.UpdateJaguarInfo(pMob.nMobTemplateId);
            }
        }
Exemple #12
0
        public ActionResult Apply(string id)
        {
            try
            {
                var jobId     = int.Parse(id);
                var mailTO    = JobLogic.GetCompanyEmail(jobId);
                var emailBody = "<h3>TRAILSから応募者がきました</h3>";
                var url       = "http://" + HttpContext.Request.Url.Authority + "/User/Profile/" + LoginInfo.Id;
                emailBody += "<p>応募者の情報はこちら:<a href=\"" + url + "\">" + url + "</a></p>";
                emailBody += "<p>直接応募者に返事お願いします。</p>";
                var result = SystemLogic.SendMail(Settigns.SMTP, Settigns.MailForm, mailTO, "TRAILSから応募者がきました", emailBody);
                if (result)
                {
                    return(Json(new IsSuccessResult()));
                }
            }
            catch { }

            return(Json(new IsSuccessResult("false")));
        }
        public JobDetail(Job j, JobLogic jl)
        {
            InitializeComponent();

            _jl = jl;

            dt.Columns.Add("Key");
            dt.Columns.Add("Value");

            if (j != null)
            {
                txtName.Text       = j.name;
                txtName.Enabled    = false;
                txtPath.Text       = j.path;
                txtEntryPoint.Text = j.entrypoint;

                btnSave.Text = "Modifica";

                ///TODO: controllare se l'assembly ha gli stessi parametri che abbiamo salvato nel jobs_config.json
                /// Nel caso in cui i parametri non combaciano, è necessario che venga pulita automaticamente anche la configurazione nel json

                var dictionaryDataMap = new Dictionary <string, string>();
                foreach (var entry in j.parameters)
                {
                    var row = dt.NewRow();
                    row["Key"]   = entry.Key;
                    row["Value"] = entry.Value;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                txtName.Text       = "";
                txtPath.Text       = "";
                txtEntryPoint.Text = "";
                btnSave.Text       = "Inserisci";
                btnDelete.Visible  = false;
            }

            dataGridView.DataSource = dt;
        }
Exemple #14
0
        public static bool WillDrop(double nextDouble, int mobLevel, int charLevel, short jobId, GlobalDropStruct drop, double extraRateModifier)
        {
            var levelDiff = charLevel - mobLevel;

            if (levelDiff > drop.MaxLevelDiff)
            {
                return(false);
            }

            if (mobLevel > drop.MinMobLevel)
            {
                return(false);
            }

            if (drop.Job != JobLogic.JobType.All && drop.Job != JobLogic.JobTypeFromID(jobId))
            {
                return(false);
            }

            return(nextDouble < (drop.DropRate * extraRateModifier));
        }
Exemple #15
0
        public MainPage()
        {
            _jobLogic     = new JobLogic();
            _triggerLogic = new TriggerLogic();

            InitializeComponent();

            Jobs     = _jobLogic.appoggio;
            Triggers = _triggerLogic.appoggio;

            _triggerLogic.LoadGrid(dataGridView1, Jobs);

            GridTypeNow = "T";
            try
            {
                CheckStatus();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #16
0
        public JobDetail(Job j, JobLogic jl)
        {
            InitializeComponent();

            _jl = jl;

            dt.Columns.Add("Key");
            dt.Columns.Add("Value");

            if (j != null)
            {
                txtName.Text       = j.name;
                txtName.Enabled    = false;
                txtPath.Text       = j.path;
                txtEntryPoint.Text = j.entrypoint;

                btnSave.Text = "Modifica";

                var dictionaryDataMap = new Dictionary <string, string>();
                foreach (var entry in j.parameters)
                {
                    var row = dt.NewRow();
                    row["Key"]   = entry.Key;
                    row["Value"] = entry.Value;
                    dt.Rows.Add(row);
                }
            }
            else
            {
                txtName.Text       = "";
                txtPath.Text       = "";
                txtEntryPoint.Text = "";
                btnSave.Text       = "Inserisci";
                btnDelete.Visible  = false;
            }

            dataGridView.DataSource = dt;
        }
        public MainPage()
        {
            _jobLogic     = new JobLogic();
            _triggerLogic = new TriggerLogic();
            _logLogic     = new LogLogic();

            InitializeComponent();

            Jobs     = _jobLogic.appoggio;
            Triggers = _triggerLogic.appoggio;

            EnableView(ViewTypeEnum.TRIGGER);
            _triggerLogic.LoadGrid(dataGridView1, Jobs);

            try
            {
                CheckStatus();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #18
0
        public async static Task DoJob()
        {
            List <JobInfo> jobList = await JobLogic.GetAllJobList();

            LogHelper.WriteLog("jobList:" + JsonConvert.SerializeObject(jobList));
            if (jobList != null && jobList.Count > 0)
            {
                //1.通过工厂获取一个调度器的实例
                StdSchedulerFactory factory   = new StdSchedulerFactory();
                IScheduler          scheduler = await factory.GetScheduler();

                await scheduler.Start();

                foreach (JobInfo jobInfo in jobList)
                {
                    //2.创建任务对象
                    JobDataMap dataMap = new JobDataMap();
                    dataMap.Add("JobInfo", jobInfo);
                    IJobDetail job = JobBuilder.Create <JobExcute>()
                                     .SetJobData(dataMap)
                                     .WithIdentity(jobInfo.Name, jobInfo.GroupName)
                                     .WithDescription(jobInfo.Description)
                                     .Build();

                    //3.创建触发器
                    ITrigger trigger = TriggerBuilder.Create()
                                       .WithIdentity(jobInfo.Name, jobInfo.GroupName)
                                       .WithDescription(jobInfo.Description)
                                       .StartNow()
                                       .WithCronSchedule(jobInfo.Trigger)
                                       .Build();

                    await scheduler.ScheduleJob(job, trigger);
                }
            }
        }
        [DataRow(4, 5, 5, 1, 1, 15)] //has progressed 1/5, will advance 15, will complete with 11 extra days, would complete 3 times if labled as recurring
        public void AdvanceJob_NotRecurringCompleted(int startdate, int duration, int CurrentDay, int progress, int dayssincecreation, int daysToAdvance)
        {
            //arrange
            Job J_Test = new Job(CurrentDay)
            {
                StartDate = startdate,
                Duration  = duration,
                Progress  = progress,
                IsCurrentlyProgressing = true,
                Days_Since_Creation    = dayssincecreation,
                Complete      = false,
                Recurring     = false,
                SuccessChance = 0,
                FailureChance = 0
            };

            Mock <IEventAggregator>     EAM  = new Mock <IEventAggregator>();
            Mock <RequestJobEventEvent> RJEM = new Mock <RequestJobEventEvent>();

            EAM.Setup(x => x.GetEvent <RequestJobEventEvent>()).Returns(RJEM.Object);

            JobLogic JL_Test = new JobLogic(new RandomProvider(), EAM.Object);

            //act
            JL_Test.AdvanceJob(J_Test, daysToAdvance);

            //assert
            Assert.AreEqual(J_Test.Complete, true, "Complete not false");
            Assert.AreEqual(J_Test.StartDate, startdate, "StartDate improperly changed");
            Assert.AreEqual(J_Test.Duration, duration, "Duration improperly changed");
            Assert.AreEqual(J_Test.Progress, duration, "Progress improperly advanced");
            Assert.AreEqual(J_Test.IsCurrentlyProgressing, false, "IsCurrentlyProgressing not false");
            Assert.AreEqual(J_Test.Days_Since_Creation, dayssincecreation + daysToAdvance, "Days_Since_Creation improperly advanced");

            EAM.Verify(x => x.GetEvent <RequestJobEventEvent>(), Times.Exactly(1));
        }
Exemple #20
0
        protected override void InsertItem(int index, Character user)
        {
            try
            {
                if (user.Party != null)
                {
                    foreach (var buff in user.Buffs)
                    {
                        if (buff.dwCharFromId != user.dwId)
                        {
                            continue;
                        }

                        if (buff.StatType != SecondaryStatFlag.BlueAura &&
                            buff.StatType != SecondaryStatFlag.DarkAura &&
                            buff.StatType != SecondaryStatFlag.YellowAura)
                        {
                            continue;
                        }

                        ForEachPartyMember(user.Party.PartyID,
                                           member => member.Buffs
                                           .AddAura(buff.StatType, buff.dwCharFromId, buff.nSkillID, buff.nSLV));
                        break;
                    }
                }

                //Spawn the player being added to everyone in the room
                {
                    var pPacketEnter = user.MakeEnterFieldPacket();
                    Field.EncodeFieldSpecificData(pPacketEnter, user);
                    Field.Broadcast(pPacketEnter);
                }

                //So i need to fix a bug where when u change map - u dont receive ur own dmg skin lol

                //Spawn [other players + ext data] in room to person entering
                foreach (var c in this)
                {
                    var pPacketEnter = c.MakeEnterFieldPacket();
                    Field.EncodeFieldSpecificData(pPacketEnter, c);
                    user.SendPacket(pPacketEnter);

                    //var pPacketEnterExt = CPacket.Custom.UserEnter(c.dwId, c.nDamageSkin);
                    //user.SendPacket(pPacketEnterExt);
                }

                Field.Drops.Update();                 // remove expired drops (required cuz map might be empty and thus not removing drops)

                //This must be here !!!!
                base.InsertItem(index, user);

                //Spawn entering person's extension data to everyone on map
                {
                    //var pPacketEnterExt = CPacket.Custom.UserEnter(user.dwId, user.nDamageSkin);
                    //Field.Broadcast(pPacketEnterExt);
                }

                //Spawn entering person's entities to everyone on map
                if (JobLogic.IsEvan(user.Stats.nJob) && user.Stats.nJob != 2001)
                {
                    user.Dragon = new CDragon(user);
                    user.Dragon.SpawnDragonToMap();
                }

                user.Pets.SpawnPetsToMap();

                //Spawn field entities to person entering
                Field.SendSpawnDragons(user);
                // pets are handled in UserEnterField packet

                Field.SendSpawnSummons(user);
                Field.Summons.InsertFromStorage(user);                 // needs to be after SendSpawnSummons

                Field.SendSpawnMobs(user);
                Field.SendSpawnNpcs(user);
                Field.SendSpawnReactors(user);
                Field.SendSpawnAffectedAreas(user);
                Field.SendSpawnMinirooms(user);
                Field.SendSpawnKites(user);
                Field.SendSpawnTownPortals(user);
                Field.SendSpawnOpenGates(user);
                Field.SendSpawnDrops(user);
                Field.SendActiveWeatherEffect(user);

                Field.AssignControllerMobs();
                Field.AssignControllerNpcs();

                if (Field.tFieldTimerExpiration.SecondsUntilEnd() > 0)
                {
                    user.SendPacket(CPacket.CreateClock((int)Field.tFieldTimerExpiration.SecondsUntilEnd()));
                }

                if (Field.nFieldDeathCount > -1)
                {
                    //user.SendPacket(CPacket.Custom.FieldDeathCount(Field.nFieldDeathCount));
                }

                if (user.Party != null)
                {
                    foreach (var c in this)
                    {
                        if (c.Party?.PartyID != user.Party.PartyID)
                        {
                            continue;
                        }
                        foreach (var buff in c.Buffs)
                        {
                            if (buff.dwCharFromId != c.dwId)
                            {
                                continue;
                            }
                            if (buff.StatType == SecondaryStatFlag.BlueAura ||
                                buff.StatType == SecondaryStatFlag.DarkAura ||
                                buff.StatType == SecondaryStatFlag.YellowAura)
                            {
                                user.Buffs.AddAura(buff.StatType, buff.dwCharFromId, buff.nSkillID, buff.nSLV);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                user?.Socket?.Disconnect();
            }
        }
Exemple #21
0
        /// <summary>
        /// 启动
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public ActionResult Run(JobInfo jobInfo)
        {
            Result res = new JobLogic().Run(jobInfo);

            return(Json(res));
        }
Exemple #22
0
 /// <summary>
 /// 编辑任务
 /// </summary>
 /// <param name="job"></param>
 /// <returns></returns>
 public async Task <bool> EditJob(JobInfo job)
 {
     return(await JobLogic.EditJob(job));
 }
Exemple #23
0
        public static MapleAttack ParseShoot(CInPacket p, Character c)
        {
            MapleAttack ret = new MapleAttack();

            p.Skip(8);             // -1

            var tByte1 = p.Decode1();

            ret.nDamagePerMob = (byte)(tByte1 & 0xF);
            ret.nMobCount     = (byte)((tByte1 >> 4) & 0xF);

            //c.SendMessage("Damage per mob " + ret.nDamagePerMob);
            //c.SendMessage("Mob count " + ret.nMobCount);

            p.Skip(8);                  //-1

            ret.nSkillID = p.Decode4(); //2017

            ret.ValidateSkill(c);

            if (!ret.bValidAttack)
            {
                return(ret);
            }

            var skillTemplate = MasterManager.SkillTemplates[ret.nSkillID];

            var nCombatOrders = p.Decode1(); // nCombatOrders

            p.Skip(4);                       // get_rand(pDrInfo.dr0, 0);
            p.Skip(4);                       // CCrc32::GetCrc32(pData, 4u, n, 0, 0);
            p.Skip(8);

            ret.tKeyDown = skillTemplate?.is_keydown_skill ?? false?p.Decode4() : -1;

            ret.nOption = p.Decode1();             //COutPacket::Encode1(&v498, (bSpark << 7) | (bSpiritJavelin << 6) | 8 * bShadowPartner | 4 * bMortalBlow | 2 * bSoulArrow);

            var bSpark         = (ret.nOption & 0x80) != 0;
            var bSpiritJavelin = (ret.nOption & 0x40) != 0;
            var bSerial        = (ret.nOption & 0x20) != 0;
            var bShadowPartner = (ret.nOption & 0x8) != 0;
            var bMortalBlow    = (ret.nOption & 0x4) != 0;
            var bSoulArrow     = (ret.nOption & 0x2) != 0;

            ret.bNextShootExJablin = p.Decode1() > 0;             //v339->m_bNextShootExJablin && CUserLocal::CheckApplyExJablin(v339, pSkill, nAttackAction);

            ret.nActionAndDir = p.Decode2();
            ret.bLeft         = (ret.nActionAndDir >> 15) & 1;
            ret.nAction       = ret.nActionAndDir & 0x7FFF; //nAttackAction
            p.Skip(4);                                      //CRC i think
            ret.nAttackActionType = p.Decode1();            //nAttackSpeed | 16 * nReduceCount
            ret.nAttackSpeed      = p.Decode1();

            ret.tAttackTime = p.Decode4();
            p.Skip(4);             //nPhase

            ret.nBulletItemPos     = p.Decode2();
            ret.nBulletCashItemPos = p.Decode2();
            var nShootRange0a = p.Decode1();             // nSLV (BMS)

            ret.bNoItemConsume = skillTemplate?.is_shoot_skill_not_consuming_bullet ?? false;

            if (!ret.bNoItemConsume)
            {
                if (JobLogic.is_mechanic_job(c.Stats.nJob))
                {
                    ret.bNoItemConsume = true;
                }
                else if (bSoulArrow)
                {
                    ret.bNoItemConsume = c.Buffs[(int)Skills.HUNTER_SOUL_ARROW_BOW] != null ||
                                         c.Buffs[(int)Skills.CROSSBOWMAN_SOUL_ARROW_CROSSBOW] != null ||
                                         c.Buffs[(int)Skills.WINDBREAKER_SOUL_ARROW_BOW] != null ||
                                         c.Buffs[(int)Skills.WILDHUNTER_SOUL_ARROW_CROSSBOW] != null;
                }
                else if (bSpiritJavelin)
                {
                    if (ret.bNextShootExJablin)
                    {
                        ret.bNextShootExJablin = false;
                    }
                    else
                    {
                        ret.nSpiritJavelinItemID = p.Decode4();

                        var nBulletType = (ret.nSpiritJavelinItemID % 10000) + 1;

                        c.Buffs.TryGetValue((int)Skills.NIGHTLORD_SPIRIT_JAVELIN, out AbstractBuff secondaryStat_nSpiritJavelin);

                        if (c.InventoryConsume.Get(ret.nBulletItemPos)?.nItemID != ret.nSpiritJavelinItemID)
                        {
                            c.Buffs.Remove((int)Skills.NIGHTLORD_SPIRIT_JAVELIN);                             // they have to use the same item as they
                        }
                        else
                        {
                            if (secondaryStat_nSpiritJavelin != null && nBulletType != secondaryStat_nSpiritJavelin.Stat[SecondaryStatFlag.SpiritJavelin].nValue)
                            {
                                ret.bValidAttack = false;                                 // PE
                                return(ret);
                            }

                            ret.bNoItemConsume = true;
                        }
                    }
                }
                else if (ret.bNextShootExJablin)
                {
                    ret.bNoItemConsume = true;
                }
            }

            ret.DecodeAttackInfo(p);

            p.Skip(4);             // char pos

            if (JobLogic.IsWildhunterJob(c.Stats.nJob))
            {
                var m_ptBodyRelMove = p.Decode2();                 // unsure what this is used for
            }

            p.Skip(4);             // another pos.. unsure for what

            if (ret.nSkillID == (int)Skills.STRIKER_SPARK)
            {
                ret.tReserveSpark = p.Decode4();
            }

            return(ret);
        }
Exemple #24
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public ActionResult UpdateJob(JobInfo jobInfo)
        {
            JobResult res = new JobLogic().Update(jobInfo);

            return(Json(res));
        }
Exemple #25
0
        /// <summary>
        /// 暂停
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public ActionResult Pause(JobInfo jobInfo)
        {
            JobResult result = new JobLogic().Pause(jobInfo);

            return(Json(result));
        }
Exemple #26
0
        public ActionResult Photo(string id)
        {
            var isSavedSuccessfully = true;
            var fName            = "";
            var defaultPhotoName = "temp" + GetOperation().UserId;
            var photoName        = defaultPhotoName;
            var checkResult      = new IsSuccessResult();

            try
            {
                photoName   = int.Parse(id).ToString();
                checkResult = UserLogic.IsJobMaster(GetOperation().UserId, int.Parse(id));
            }
            catch (Exception)
            {
            }

            if (checkResult.IsSuccess == false)
            {
                isSavedSuccessfully = false;
            }
            else
            {
                foreach (string fileName in Request.Files)
                {
                    var file = Request.Files[fileName];
                    fName = file.FileName;
                    if (file != null && file.ContentLength > 0)
                    {
                        var originalDirectory = new DirectoryInfo(string.Format("{0}MediaUpload\\", Server.MapPath(@"\")));
                        var pathString        = Path.Combine(originalDirectory.ToString(), "JobPhoto");
                        var isExists          = Directory.Exists(pathString);

                        if (!isExists)
                        {
                            Directory.CreateDirectory(pathString);
                        }

                        var ext       = Path.GetExtension(file.FileName);
                        var fileName1 = photoName + ext;
                        var path      = string.Format("{0}\\{1}", pathString, fileName1);
                        file.SaveAs(path);

                        if (photoName.Contains(defaultPhotoName) == false)
                        {
                            var result = JobLogic.UpdatePhoto(int.Parse(id), fileName1);
                            if (result.IsSuccess == false)
                            {
                                isSavedSuccessfully = false;
                            }
                        }
                    }
                }
            }

            if (isSavedSuccessfully)
            {
                return(Json(new { Message = fName }));
            }
            else
            {
                return(Json(new { Message = "Error in saving file" }));
            }
        }
Exemple #27
0
        /// <summary>
        /// 恢复
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public ActionResult Resume(JobInfo jobInfo)
        {
            JobResult res = new JobLogic().Resume(jobInfo);

            return(Json(res));
        }
Exemple #28
0
        public async Task Start()
        {
            Log.Initialize();
            _jobLogic     = new JobLogic();
            _triggerLogic = new TriggerLogic();

            Jobs     = _jobLogic.appoggio;
            Triggers = _triggerLogic.appoggio;

            // write code here that runs when the Windows Service starts up.
            var props = new NameValueCollection
            {
                { "quartz.serializer.type", "binary" }
            };
            var factory = new StdSchedulerFactory(props);

            scheduler = await factory.GetScheduler();

            try
            {
                //clear all
                await scheduler.Clear();

                // and start it off
                if (!scheduler.IsStarted)
                {
                    await scheduler.Start();
                }

                foreach (var itemTrigger in Triggers)
                {
                    var itemJob = Jobs.FirstOrDefault(x => x.name == itemTrigger.jobname);
                    if (itemJob == null)
                    {
                        Log.Error($"Configurazione non trovata per il job [{itemTrigger.jobname}]");
                        continue;
                    }
                    var pathAssembly = Path.Combine(ConfigurationSettings.AppSettings["PathCustomJobs"], itemJob.path);
                    var info         = new FileInfo(pathAssembly);
                    if (!info.Exists)
                    {
                        Log.Error($"Assembly non trovato [{itemJob.path}]");
                        continue;
                    }
                    var assembly =
                        Assembly.LoadFrom(pathAssembly);
                    var  types = assembly.GetTypes();
                    Type type  = null;
                    foreach (var t in types)
                    {
                        var interfaces = t.GetInterfaces();
                        if (interfaces.All(i => i != typeof(IJob)))
                        {
                            continue;
                        }

                        type = t;
                    }

                    //carica i parametri del job
                    var dictionaryDataMap = new Dictionary <string, string>();
                    foreach (var entry in itemJob.parameters)
                    {
                        dictionaryDataMap.Add(entry.Key, entry.Value);
                    }
                    var jobDataMap = new JobDataMap(dictionaryDataMap);

                    var job = JobBuilder.Create(type)
                              .WithIdentity(itemTrigger.jobname, "group1")
                              .SetJobData(jobDataMap)
                              .Build();

                    var trigger = TriggerBuilder.Create()
                                  .WithIdentity(itemTrigger.name, "group1")
                                  .StartNow()
                                  .WithCronSchedule(itemTrigger.cronexpression)
                                  .Build();
                    //Tell quartz to schedule the job using our trigger
                    await scheduler.ScheduleJob(job, trigger);
                }

                // some sleep to show what's happening
                await Task.Delay(TimeSpan.FromSeconds(60)); //60
            }
            catch (SchedulerException se)
            {
                Log.Error("SchedulerService", se);
            }
            catch (ReflectionTypeLoadException exRef)
            {
                Log.Error("SchedulerService", exRef);
            }
        }
        public static int get_weapon_mastery(Character cd, int nWeaponItemID, int nAttackType, int nSkillID,
                                             out int pnACCInc,
                                             out int pnPADInc)
        {
            pnACCInc = 0;
            pnPADInc = 0;
            var mastery = 0;

            // TODO clean this function up -> ugly af :(

            switch ((WeaponType)ItemConstants.get_weapon_type(nWeaponItemID))
            {
            case WeaponType.WT_OH_SWORD:
            case WeaponType.WT_TH_SWORD:
                if (nAttackType > 0)
                {
                    if (nSkillID != (int)Skills.SOULMASTER_SOUL_BLADE)
                    {
                        return(mastery);
                    }
                    if (nAttackType != 1)
                    {
                        return(mastery);
                    }
                }

                mastery = get_mastery_from_skill(cd, Skills.FIGHTER_WEAPON_MASTERY, out pnACCInc);

                if (mastery == 0)
                {
                    mastery = get_mastery_from_skill(cd, Skills.PAGE_WEAPON_MASTERY, out pnACCInc);
                    if (mastery != 0)
                    {
                        if (cd.Stats.SecondaryStats.rWeaponCharge != 0)
                        {
                            var tempmastery = get_mastery_from_skill(cd,
                                                                     Skills.PALADIN_ADVANCED_CHARGE,
                                                                     out var pnSubACCInc);

                            if (tempmastery > 0)
                            {
                                pnACCInc = pnSubACCInc;
                                mastery  = tempmastery;
                            }
                        }
                    }
                    else
                    {
                        mastery = get_mastery_from_skill(cd, Skills.SOULMASTER_SWORD_MASTERY, out pnACCInc);
                    }
                }

                break;

            case WeaponType.WT_OH_AXE:
            case WeaponType.WT_TH_AXE:
                if (nAttackType != 0)
                {
                    return(0);
                }
                mastery = get_mastery_from_skill(cd, Skills.FIGHTER_WEAPON_MASTERY, out pnACCInc);
                break;

            case WeaponType.WT_OH_MACE:
            case WeaponType.WT_TH_MACE:
                if (nAttackType != 0)
                {
                    return(0);
                }

                mastery = get_mastery_from_skill(cd, Skills.PAGE_WEAPON_MASTERY, out pnACCInc);
                if (cd.Stats.SecondaryStats.rWeaponCharge != 0)
                {
                    var tempmastery = get_mastery_from_skill(cd,
                                                             Skills.PALADIN_ADVANCED_CHARGE,
                                                             out var pnSubACCInc);

                    if (tempmastery > 0)
                    {
                        pnACCInc = pnSubACCInc;
                        mastery  = tempmastery;
                    }
                }
                break;

            case WeaponType.WT_DAGGER:
                if (nAttackType != 0)
                {
                    return(0);
                }

                var pSubDaggerItemSlot = cd.EquippedInventoryNormal.Get((short)BodyPart.BP_SHIELD);
                var bSubDagger         = ItemConstants.get_weapon_type(pSubDaggerItemSlot.nItemID) == (int)WeaponType.WT_SUB_DAGGER;

                mastery = get_mastery_from_skill(cd,
                                                 bSubDagger
                                                        ? Skills.DUAL1_DUAL_MASTERY
                                                        : Skills.THIEF_DAGGER_MASTERY,
                                                 out pnACCInc);
                break;

            case WeaponType.WT_SPEAR:
                if (nAttackType != 0)
                {
                    return(0);
                }

                mastery = get_mastery_from_skill(cd, Skills.SPEARMAN_WEAPON_MASTERY, out pnACCInc);
                break;

            case WeaponType.WT_POLEARM:
                if (nAttackType != 0 && (nSkillID != (int)Skills.ARAN_COMBO_SMASH &&
                                         nSkillID != (int)Skills.ARAN_COMBO_FENRIR &&
                                         nSkillID != (int)Skills.ARAN_COMBO_TEMPEST ||
                                         nAttackType != 1))
                {
                    return(mastery);
                }

                if (JobLogic.isAran(cd.Stats.nSubJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.ARAN_POLEARM_MASTERY, out pnACCInc);
                    var highMastery = get_mastery_from_skill(cd, Skills.ARAN_HIGH_MASTERY, out pnPADInc);
                    if (highMastery != 0)
                    {
                        mastery = highMastery;
                    }
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.SPEARMAN_WEAPON_MASTERY, out pnACCInc);

                    if (cd.Stats.SecondaryStats.rBeholder != 0)
                    {
                        mastery += get_mastery_from_skill(cd, Skills.DARKKNIGHT_BEHOLDER, out _);
                    }
                }
                break;

            case WeaponType.WT_BOW:
                if (nAttackType != 1)
                {
                    return(mastery);
                }

                int bowexpert;
                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery   = get_mastery_from_skill(cd, Skills.WINDBREAKER_BOW_MASTERY, out pnACCInc);
                    bowexpert = get_mastery_from_skill(cd, Skills.WINDBREAKER_BOW_EXPERT, out pnPADInc);
                }
                else
                {
                    mastery   = get_mastery_from_skill(cd, Skills.HUNTER_BOW_MASTERY, out pnACCInc);
                    bowexpert = get_mastery_from_skill(cd, Skills.BOWMASTER_BOW_EXPERT, out pnPADInc);
                }

                if (bowexpert != 0)
                {
                    mastery = bowexpert;
                }

                break;

            case WeaponType.WT_CROSSBOW:

                var bWildhunterJob = JobLogic.IsWildhunterJob(cd.Stats.nJob);
                if (nAttackType != 1 && (!bWildhunterJob || nAttackType != 0))
                {
                    return(mastery);
                }

                int xbowexpert;
                if (bWildhunterJob)
                {
                    mastery    = get_mastery_from_skill(cd, Skills.WILDHUNTER_CROSSBOW_MASTERY, out pnACCInc);
                    xbowexpert = get_mastery_from_skill(cd, Skills.WILDHUNTER_CROSSBOW_EXPERT, out pnPADInc);
                }
                else
                {
                    mastery    = get_mastery_from_skill(cd, Skills.CROSSBOWMAN_CROSSBOW_MASTERY, out pnACCInc);
                    xbowexpert = get_mastery_from_skill(cd, Skills.CROSSBOWMASTER_CROSSBOW_EXPERT, out pnPADInc);
                }

                if (xbowexpert != 0)
                {
                    mastery = xbowexpert;
                }

                break;

            case WeaponType.WT_THROWINGGLOVE:
                if (nAttackType != 1 && (nSkillID != (int)Skills.NIGHTWALKER_POISON_BOMB || nAttackType != 0))
                {
                    return(mastery);
                }

                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.NIGHTWALKER_JAVELIN_MASTERY, out pnACCInc);
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.ASSASSIN_JAVELIN_MASTERY, out pnACCInc);
                }
                break;

            case WeaponType.WT_KNUCKLE:

                if (nAttackType != 0 && (nSkillID != (int)Skills.VIPER_ENERGY_ORB && nSkillID != (int)Skills.STRIKER_SHARK_WAVE || nAttackType != 1))
                {
                    return(mastery);
                }

                if (JobLogic.IsKOC(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.STRIKER_KNUCKLE_MASTERY, out pnACCInc);
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.INFIGHTER_KNUCKLE_MASTERY, out pnACCInc);
                }
                break;

            case WeaponType.WT_GUN:
                if (nAttackType != 1 && (nSkillID != (int)Skills.CAPTAIN_AIR_STRIKE || nAttackType != 0))
                {
                    return(mastery);
                }

                if (JobLogic.is_mechanic_job(cd.Stats.nJob))
                {
                    mastery = get_mastery_from_skill(cd, Skills.MECHANIC_HN07_UPGRADE, out pnACCInc);
                    if (mastery == 0)
                    {
                        mastery = get_mastery_from_skill(cd, Skills.MECHANIC_HN07, out pnACCInc);
                    }
                }
                else
                {
                    mastery = get_mastery_from_skill(cd, Skills.GUNSLINGER_GUN_MASTERY, out pnACCInc);
                }
                break;
            }
            return(mastery);
        }
Exemple #30
0
        public void Stats(Action <StatModifier> action, bool bExclRequest = true)
        {
            var ctx = new StatModifier(Parent);

            action?.Invoke(ctx);

            if ((ctx.Flag & ModifyStatFlags.EXP) > 0)
            {
                if (ctx.EXP < 0)
                {
                    ctx.EXP = 0;
                }

                var nExpSurplus = ctx.EXP - NextLevel.get_next_level_exp(ctx.Level - 1);

                // make sure this is before levelup func
                var levels    = 0;
                var jobLevels = 0;

                int beforesp = ctx.SP;

                while (nExpSurplus >= 0)                 // while has more exp than required to reach next level
                {
                    ctx.EXP = nExpSurplus;

                    if (!ctx.try_process_levelup())
                    {
                        break;
                    }

                    nExpSurplus = ctx.EXP - NextLevel.get_next_level_exp(ctx.Level - 1);
                    levels     += 1;

                    Parent.NotifySocialChannels(SocialNotiflag.ChangeLevel);

                    var job = ctx.Job;
                    ctx.AutoJobAdvanceEvent(Parent);
                    if (job != ctx.Job)
                    {
                        jobLevels += 1;
                    }
                }

                if (levels > 0)
                {
                    if (ctx.HP > 0)
                    {
                        ctx.HP = Parent.BasicStats.nMHP;
                        ctx.MP = Parent.BasicStats.nMMP;
                    }

                    var effect = new UserEffectPacket(UserEffect.LevelUp);
                    effect.BroadcastEffect(Parent);

                    ctx.SP += (short)(jobLevels * 1);

                    var aftersp = ctx.SP - beforesp;

                    Parent.SendPacket(CPacket.IncSPMessage((byte)aftersp, ctx.Job));                     // send sp gain message
                    Parent.ValidateStat();
                }
            }

            if ((ctx.Flag & ModifyStatFlags.Money) != 0)
            {
                ctx.Money = Math.Max(0, ctx.Money);
            }

            if ((ctx.Flag & ModifyStatFlags.POP) != 0)
            {
                ctx.POP = Math.Max((short)0, ctx.POP);
            }

            if ((ctx.Flag & ModifyStatFlags.Job) != 0)
            {
                Parent.Skills.SetMasterLevels();

                var effect = new UserEffectPacket(UserEffect.JobChanged);
                effect.BroadcastEffect(Parent);

                if (JobLogic.IsEvan(ctx.Job))
                {
                    if (ctx.Job == 2200 && Parent.Dragon is null)
                    {
                        Parent.Dragon = new CDragon(Parent);
                        Parent.Quests.OnCompleteQuest(null, 22100, 0, true);
                    }

                    Parent.Dragon.SpawnDragonToMap();                     // update visuals
                }
                else
                {
                    Parent.Modify.Skills(mod =>
                    {
                        switch (ctx.Job)
                        {
                        // hacking aran skills together for now. TODO add a ForceVisible field or something to the skill class
                        case 2100:
                            mod.AddEntry(21000000, entry => entry.CurMastery = entry.MaxLevel);
                            mod.AddEntry(21001003, entry => entry.CurMastery = entry.MaxLevel);
                            break;

                        case 2110:
                            mod.AddEntry(21100000, entry => entry.CurMastery = entry.MaxLevel);
                            mod.AddEntry(21100002, entry => entry.CurMastery = entry.MaxLevel);
                            mod.AddEntry(21100004, entry => entry.CurMastery = entry.MaxLevel);
                            mod.AddEntry(21100005, entry => entry.CurMastery = entry.MaxLevel);
                            break;

                        case 2111:
                            mod.AddEntry(21110002, entry => entry.CurMastery = entry.MaxLevel);
                            break;

                        case 3300:
                            mod.AddEntry(30001061, entry => entry.nSLV = 1);
                            mod.AddEntry(30001062, entry => entry.nSLV = 1);
                            break;

                        case 3500:
                            mod.AddEntry(30001068, entry => entry.nSLV = 1);
                            break;
                        }

                        foreach (var skill in MasterManager.SkillTemplates.GetJobSkills(ctx.Job))
                        {
                            var template = MasterManager.SkillTemplates[skill];

                            if (template.MasterLevel > 0)
                            {
                                mod.AddEntry(skill, entry => entry.CurMastery = (byte)template.MasterLevel);
                            }
                        }
                    });
                }

                // notify correct channels
                Parent.NotifySocialChannels(SocialNotiflag.ChangeJob);
            }

            if ((ctx.Flag & ModifyStatFlags.HP) > 0 || (ctx.Flag & ModifyStatFlags.MaxHP) > 0)
            {
                if (ctx.HP <= 0)                 // TODO move death exp loss (and safety charm) handling here
                {
                    Parent.Field.Summons.RemoveCharSummons(Parent.dwId, SummonLeaveType.LEAVE_TYPE_USER_DEAD);
                }

                if (ctx.Job == 132)                 // dark knight
                {
                    Parent.Skills.ProcessDarkKnightDarkForce(Parent.BasicStats.nMHP);
                }
            }

            if (((ctx.Flag & ModifyStatFlags.MP) > 0 || (ctx.Flag & ModifyStatFlags.MaxMP) > 0) && ctx.Job >= 2216 && ctx.Job <= 2218)             // evan
            {
                Parent.Skills.CheckDragonFury(Parent.BasicStats.nMMP);
            }

            if ((ctx.Flag & ModifyStatFlags.BasicStat) != 0)
            {
                Parent.ValidateStat();
            }

            if (ctx.Flag > 0)
            {
                Parent.SendPacket(CPacket.StatChanged(ctx, bExclRequest));
            }
        }