Example #1
0
        public async Task <JsonStatusResult> Logout()
        {
            try
            {
                var userId = CurUser.Identifier();
                if (userId == null)
                {
                    return(StatusMsg(HttpStatusCode.Unauthorized, "unaothorized"));
                }

                var token = CurUser.FindByType(ExternalClaimTypes.AuthToken);

                if (token != null)
                {
                    TokenRepository reps = new TokenRepository();
                    await reps.RemoveUserTokenAsync(userId.Value, token);
                }

                return(StatusMsg(HttpStatusCode.OK, "success"));
            }

            catch (HttpDataException hre)
            {
                return(StatusMsg(hre.ResponseStatus, hre.Message));
            }
            catch (Exception ex)
            {
                _logger.Error(ex);
                return(StatusMsg(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Example #2
0
        protected internal override void DoRead()
        {
            var respawnPoints = Level.NEIGHBOURS8.Select(t => CurUser.pos + t).Where(p => Actor.FindChar(p) == null && (Level.passable[p] || Level.avoid[p])).ToList();

            var nImages = Nimages;

            while (nImages > 0 && respawnPoints.Count > 0)
            {
                var index = pdsharp.utils.Random.Index(respawnPoints);

                var mob = new MirrorImage();
                mob.Duplicate(CurUser);
                GameScene.Add(mob);
                WandOfBlink.Appear(mob, respawnPoints[index]);

                respawnPoints.Remove(index);
                nImages--;
            }

            if (nImages < Nimages)
            {
                SetKnown();
            }

            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #3
0
        public ActionResult Index(int?id)
        {
            if (
                !CurUser.HasAccess(AdGroup.ServiceTech, AdGroup.ServiceAdmin, AdGroup.ServiceControler,
                                   AdGroup.ServiceEngeneer, AdGroup.ServiceManager, AdGroup.ServiceOperator))
            {
                return(HttpNotFound());
            }

            if (!id.HasValue || id <= 0)
            {
                return(RedirectToAction("New"));
            }
            Claim model = new Claim();

            try
            {
                model = new Claim(id.Value);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("HandledError", "Error", new { message = ex.Message }));
            }

            return(View(model));
        }
Example #4
0
        public ActionResult New(ClientAccess model)
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClientAccess))
            {
                RedirectToAction("AccessDenied", "Error");
            }
            try
            {
                ResponseMessage responseMessage;
                //dep.Creator = new Employee(){AdSid = GetCurUser().Sid};
                string ctrIdStr = Request.Form["ctrList"];
                int    idClientEtalon;
                int.TryParse(ctrIdStr, out idClientEtalon);
                model.IdClientEtalon = idClientEtalon;
                bool complete = model.SaveNew(out responseMessage);
                if (!complete)
                {
                    throw new Exception(responseMessage.ErrorMessage);
                }

                return(RedirectToAction("List"));
            }
            catch (Exception ex)
            {
                TempData["error"] = ex.Message;
                return(View("New", model));
            }
        }
Example #5
0
        public async Task <ActionResult> Card(int?id)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }
            var task = await TaskClaim.Get(id.Value);

            ViewBag.StateHistory = await task.GetStateHistoryAsync();

            if (CurUser.Is(AdGroup.TaskTrackerManager, AdGroup.TaskTrackerProg))
            {
                ViewBag.Checkpoints = await TaskCheckpoint.GetListAsync(id.Value);

                ViewBag.TaskFiles = await TaskFile.GetListAsync(id.Value);

                ViewBag.TaskComments = await TaskComment.GetListAsync(id.Value);

                return(View("CardPerf", task));
            }
            else
            {
                return(View("CardUser", task));
            }
        }
Example #6
0
        public override void DoSpecial()
        {
            var proto = new Shuriken();

            foreach (var mob in Dungeon.Level.mobs)
            {
                if (!Level.fieldOfView[mob.pos])
                {
                    continue;
                }

                CurUser.Sprite.Parent.Recycle <MissileSprite>().Reset(CurUser.pos, mob.pos, proto, this);

                _targets.Add(this, mob);
            }

            if (_targets.Count == 0)
            {
                GLog.Warning(TxtNoEnemies);
                return;
            }

            CurUser.HP -= (CurUser.HP / 3);

            CurUser.Sprite.DoZap(CurUser.pos);
            CurUser.Busy();
        }
Example #7
0
        public void OnSelect(int?target)
        {
            if (target == null)
            {
                return;
            }

            if (!Level.fieldOfView[target.Value] || !(Level.passable[target.Value] || Level.avoid[target.Value]) || Actor.FindChar(target.Value) != null)
            {
                GLog.Warning(TXT_FOV);
                return;
            }

            CurUser.HP -= (CurUser.HP / 3);

            foreach (var mob in Dungeon.Level.mobs.Where(mob => Level.fieldOfView[mob.pos]))
            {
                Buff.Prolong <Blindness>(mob, 2);
                mob.State = mob.WANDERING;
                mob.Sprite.Emitter().Burst(Speck.Factory(Speck.LIGHT), 4);
            }

            WandOfBlink.Appear(CurUser, target.Value);
            CellEmitter.Get(target.Value).Burst(Speck.Factory(Speck.WOOL), 10);
            Sample.Instance.Play(Assets.SND_PUFF);
            Dungeon.Level.Press(target.Value, CurUser);
            Dungeon.Observe();

            CurUser.SpendAndNext(Actor.Tick);
        }
Example #8
0
        protected internal override void DoRead()
        {
            new Flare(6, 32).Show(CurUser.Sprite, 2f);
            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            var procced = Uncurse(CurUser, CurUser.Belongings.Backpack.Items.ToArray());

            procced = Uncurse(CurUser, CurUser.Belongings.Weapon, CurUser.Belongings.Armor, CurUser.Belongings.Ring1, CurUser.Belongings.Ring2) || procced;

            Buff.Detach <Weakness>(CurUser);

            if (procced)
            {
                GLog.Positive(TxtProcced);
            }
            else
            {
                GLog.Information(TxtNotProcced);
            }

            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #9
0
        public void Upgrade(Armor armor)
        {
            Detach(CurUser.Belongings.Backpack);

            CurUser.Sprite.CenterEmitter().Start(Speck.Factory(Speck.KIT), 0.05f, 10);
            CurUser.Spend(TimeToUpgrade);
            CurUser.Busy();

            GLog.Warning(TxtUpgraded, armor.Name);

            var classArmor = ClassArmor.Upgrade(CurUser, armor);

            if (CurUser.Belongings.Armor == armor)
            {
                CurUser.Belongings.Armor = classArmor;
                ((HeroSprite)CurUser.Sprite).UpdateArmor();
            }
            else
            {
                armor.Detach(CurUser.Belongings.Backpack);
                classArmor.Collect(CurUser.Belongings.Backpack);
            }

            CurUser.Sprite.DoOperate(CurUser.pos);
            Sample.Instance.Play(Assets.SND_EVOKE);
        }
Example #10
0
        protected internal virtual void WandUsed()
        {
            CurrrentCharges--;

            UpdateQuickslot();

            CurUser.SpendAndNext(TimeToZap);
        }
Example #11
0
 public ActionResult New()
 {
     if (!CurUser.HasAccess(AdGroup.ServiceClaimClientAccess, AdGroup.ServiceControler))
     {
         RedirectToAction("AccessDenied", "Error");
     }
     //var model = new ClientAccess();
     return(View());
 }
Example #12
0
        public ActionResult List()
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClassifier, AdGroup.ServiceControler))
            {
                RedirectToAction("AccessDenied", "Error");
            }

            return(View());
        }
Example #13
0
 public void Call()
 {
     CurUser.Attack(_targets[this]);
     _targets.Remove(this);
     if (_targets.Count == 0)
     {
         CurUser.SpendAndNext(CurUser.AttackDelay());
     }
 }
Example #14
0
        public ActionResult ExportExcel()
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClassifier))
            {
                RedirectToAction("AccessDenied", "Error");
            }
            MemoryStream stream = new MemoryStream(new byte[0]);

            return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"));
        }
        protected internal override void DoRead()
        {
            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            TeleportHero(CurUser);
            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #16
0
        public ActionResult List()
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClientAccess, AdGroup.ServiceControler))
            {
                RedirectToAction("AccessDenied", "Error");
            }
            //var list = UserList.GetUserSelectionList(AdGroup.ZipClaimClient);
            var list = ClientAccess.GetList().OrderBy(x => x.Name);

            return(View(list));
        }
Example #17
0
        protected internal override void DoRead()
        {
            const int length       = Level.Length;
            var       map          = Dungeon.Level.map;
            var       mapped       = Dungeon.Level.mapped;
            var       discoverable = Level.discoverable;

            var noticed = false;

            for (var i = 0; i < length; i++)
            {
                var terr = map[i];

                if (!discoverable[i])
                {
                    continue;
                }

                mapped[i] = true;
                if ((Terrain.Flags[terr] & Terrain.SECRET) == 0)
                {
                    continue;
                }

                Level.Set(i, Terrain.discover(terr));
                GameScene.UpdateMap(i);

                if (!Dungeon.Visible[i])
                {
                    continue;
                }

                GameScene.DiscoverTile(i, terr);
                Discover(i);

                noticed = true;
            }

            Dungeon.Observe();

            GLog.Information(TxtLayout);
            if (noticed)
            {
                Sample.Instance.Play(Assets.SND_SECRET);
            }

            SpellSprite.Show(CurUser, SpellSprite.Map);
            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #18
0
        protected internal override void DoRead()
        {
            CurUser.Sprite.CenterEmitter().Start(Speck.Factory(Speck.NOTE), 0.3f, 5);
            Sample.Instance.Play(Assets.SND_LULLABY);
            Invisibility.Dispel();

            var count    = 0;
            Mob affected = null;

            foreach (var mob in Dungeon.Level.mobs)
            {
                if (!Level.fieldOfView[mob.pos])
                {
                    continue;
                }

                Buff.Affect <Sleep>(mob);

                if (mob.Buff <Sleep>() == null)
                {
                    continue;
                }

                affected = mob;
                count++;
            }

            switch (count)
            {
            case 0:
                GLog.Information("The scroll utters a soothing melody.");
                break;

            case 1:
                if (affected != null)
                {
                    GLog.Information("The scroll utters a soothing melody and the " + affected.Name + " falls asleep!");
                }
                else
                {
                    GLog.Information("The scroll utters a soothing melody.");
                }
                break;

            default:
                GLog.Information("The scroll utters a soothing melody and the monsters fall asleep!");
                break;
            }
            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #19
0
        //public JsonResult ClaimContinue(int? id, string descr)
        //{
        //    try
        //    {
        //        if (!id.HasValue) throw new ArgumentException("Не указана заявка!");
        //        ResponseMessage responseMessage;
        //        var model = new Claim();
        //        model.Id = id.Value;
        //        model.Descr = descr;
        //        bool complete = model.Save(out responseMessage);
        //        if (!complete) throw new Exception(responseMessage.ErrorMessage);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { errorMessage = ex.Message });
        //    }
        //    return Json(new { });
        //}
        //public JsonResult ClaimEnd(int? id, string descr)
        //{
        //    try
        //    {
        //        if (!id.HasValue) throw new ArgumentException("Не указана заявка!");
        //        ResponseMessage responseMessage;
        //        var model = new Claim();
        //        model.Id = id.Value;
        //        model.Descr = descr;
        //        bool complete = model.SaveAndGoEndState(out responseMessage);
        //        if (!complete) throw new Exception(responseMessage.ErrorMessage);
        //    }
        //    catch (Exception ex)
        //    {
        //        return Json(new { errorMessage = ex.Message });
        //    }
        //    return Json(new { });
        //}
        public async Task <ActionResult> List(int?state, int?client, int?topRows)
        {
            if (
                !CurUser.HasAccess(AdGroup.ServiceTech, AdGroup.ServiceAdmin, AdGroup.ServiceControler,
                                   AdGroup.ServiceEngeneer, AdGroup.ServiceManager, AdGroup.ServiceOperator))
            {
                return(HttpNotFound());
            }

            ListResult <Claim> result = await new Claim().GetListAsync(topRows: topRows, idClaimState: state, clientId: client);

            return(View(result));
        }
Example #20
0
        public ActionResult ImportExcel()
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClassifier))
            {
                RedirectToAction("AccessDenied", "Error");
            }
            //if (!user.UserCanEdit()) return RedirectToAction("AccessDenied", "Error");
            int id = 0;

            if (Request.Files.Count > 0)
            {
                try
                {
                    for (int i = 0; i < 1; i++)
                    {
                        var file = Request.Files[i];
                        if (file.ContentLength <= 0)
                        {
                            throw new ArgumentException("Файл не выбран. Выберите файл!");
                        }

                        if (Path.GetExtension(file.FileName) != ".xlsx" && Path.GetExtension(file.FileName) != ".xls")
                        {
                            throw new ArgumentException("Файл не был загружен. Формат файла отличается от XLS и XLSX.");
                        }

                        byte[] fileData = null;
                        using (var br = new BinaryReader(file.InputStream))
                        {
                            fileData = br.ReadBytes(file.ContentLength);
                        }


                        //var doc = new Document() { Data = fileData, Name = file.FileName };
                        ResponseMessage responseMessage;
                        Classifier.SaveFromExcel(fileData, out responseMessage);
                        //bool complete = doc.Save(out responseMessage);
                        //if (!complete) throw new Exception(responseMessage.ErrorMessage);
                        //TempData["noPdf"] = noPdf;
                    }
                }
                catch (Exception ex)
                {
                    TempData["ServerErrorExcel"] = ex.Message;
                    return(RedirectToAction("List"));
                }
            }
            return(RedirectToAction("List"));
        }
Example #21
0
        protected internal override void DoRead()
        {
            new Flare(5, 32).Color(0xFF0000, true).Show(CurUser.Sprite, 2f);
            Sample.Instance.Play(Assets.SND_READ);
            Invisibility.Dispel();

            var count    = 0;
            Mob affected = null;

            foreach (var mob in Dungeon.Level.mobs.ToArray())
            {
                if (!Level.fieldOfView[mob.pos])
                {
                    continue;
                }

                var terror = Buff.Affect <Terror>(mob, Terror.Duration);
                terror.Source = CurUser;

                count++;
                affected = mob;
            }

            switch (count)
            {
            case 0:
                GLog.Information("The scroll emits a brilliant flash of red light");
                break;

            case 1:
                if (affected != null)
                {
                    GLog.Information("The scroll emits a brilliant flash of red light and the " + affected.Name + " flees!");
                }
                else
                {
                    GLog.Information("The scroll emits a brilliant flash of red light");
                }
                break;

            default:
                GLog.Information("The scroll emits a brilliant flash of red light and the monsters flee!");
                break;
            }
            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #22
0
        protected override void OnThrow(int cell)
        {
            var enemy = Actor.FindChar(cell);

            if (enemy == null || enemy == CurUser)
            {
                base.OnThrow(cell);
            }
            else
            {
                if (!CurUser.Shoot(enemy, this))
                {
                    Miss(cell);
                }
            }
        }
Example #23
0
        protected internal override void DoRead()
        {
            foreach (var mob in Dungeon.Level.mobs)
            {
                mob.Beckon(CurUser.pos);
            }

            GLog.Warning("The scroll emits a challenging roar that echoes throughout the dungeon!");
            SetKnown();

            CurUser.Sprite.CenterEmitter().Start(Speck.Factory(Speck.SCREAM), 0.3f, 3);
            Sample.Instance.Play(Assets.SND_CHALLENGE);
            Invisibility.Dispel();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #24
0
        public async Task <ActionResult> List(string tsts, string spec = null, string author = null, string prjs = null)
        {
            string[] statesStr = String.IsNullOrEmpty(tsts) ? new string[0] : tsts.Split(',');
            int[]    states    = Array.ConvertAll <string, int>(statesStr, int.Parse);

            string[] projectsStr = String.IsNullOrEmpty(prjs) ? new string[0] : prjs.Split(',');
            int[]    projects    = Array.ConvertAll <string, int>(projectsStr, int.Parse);

            if (CurUser.Is(AdGroup.TaskTrackerManager))
            {
                //if (states == null || !states.Any())
                //{
                //    states = TaskState.GetManagerDefaultList().Select(x=>x.TaskStateId).ToArray();
                //}

                var list = await TaskClaim.GetListAsync(CurUser, spec, author, states, projects);

                list = list.OrderByDescending(x => x.DateCreate);
                return(View("ListManager", list));
            }
            else if (CurUser.Is(AdGroup.TaskTrackerProg))
            {
                //if (states == null || !states.Any())
                //{
                //    states = TaskState.GetProgDefaultList().Select(x => x.TaskStateId).ToArray();
                //}

                //spec = CurUser.Sid;
                var list = await TaskClaim.GetListAsync(CurUser, spec, author, states, projects);

                list = list.OrderByDescending(x => x.DateCreate);
                return(View("ListProg", list));
            }
            else
            {
                //if (states == null || !states.Any())
                //{
                //    states = TaskState.GetUserDefaultList().Select(x => x.TaskStateId).ToArray();
                //}

                //author = CurUser.Sid;
                var list = await TaskClaim.GetListAsync(CurUser, spec, author, states, projects);

                list = list.OrderByDescending(x => x.DateCreate);
                return(View("ListUser", list));
            }
        }
Example #25
0
        public ActionResult ClientSheetPdf(int id)
        {
            if (!CurUser.HasAccess(AdGroup.ServiceClaimClientAccess, AdGroup.ServiceControler))
            {
                RedirectToAction("AccessDenied", "Error");
            }
            HtmlToPdf converter = new HtmlToPdf();

            string url         = Url.Action("ClientSheet", new { id = id });
            var    leftPartUrl = String.Format("{0}://{1}:{2}", Request.RequestContext.HttpContext.Request.Url.Scheme, Request.RequestContext.HttpContext.Request.Url.Host, Request.RequestContext.HttpContext.Request.Url.Port);

            url = String.Format("{1}{0}", url, leftPartUrl);
            PdfDocument  doc    = converter.ConvertUrl(url);
            MemoryStream stream = new MemoryStream();

            doc.Save(stream);
            return(File(stream.ToArray(), "application/pdf"));
        }
Example #26
0
        public void ConfirmCancelation()
        {
            var wndOptions = new WndOptions(Name, TxtWarning, TxtYes, TxtNo);

            wndOptions.SelectAction = index =>
            {
                switch (index)
                {
                case 0:
                    CurUser.SpendAndNext(TimeToRead);
                    IdentifiedByUse = false;
                    break;

                case 1:
                    GameScene.SelectItem(ItemSelector, Mode, InventoryTitle);
                    break;
                }
            };
            GameScene.Show(wndOptions);
        }
Example #27
0
 public void Delete(int id)
 {
     if (!CurUser.HasAccess(AdGroup.ServiceClaimClientAccess))
     {
         RedirectToAction("AccessDenied", "Error");
     }
     try
     {
         ResponseMessage responseMessage;
         bool            complete = ClientAccess.Delete(id, out responseMessage);
         if (!complete)
         {
             throw new Exception(responseMessage.ErrorMessage);
         }
     }
     catch (Exception ex)
     {
         TempData["error"] = ex.Message;
     }
 }
        protected internal override void DoRead()
        {
            GameScene.Flash(new Color(0xFFFFFF));

            Sample.Instance.Play(Assets.SND_BLAST);
            Invisibility.Dispel();

            foreach (var mob in Dungeon.Level.mobs.Where(mob => Level.fieldOfView[mob.pos]))
            {
                Buff.Prolong <Blindness>(mob, pdsharp.utils.Random.Int(3, 6));
                mob.Damage(pdsharp.utils.Random.IntRange(1, mob.HT * 2 / 3), this);
            }

            Buff.Prolong <Blindness>(CurUser, pdsharp.utils.Random.Int(3, 6));
            Dungeon.Observe();

            SetKnown();

            CurUser.SpendAndNext(TimeToRead);
        }
Example #29
0
        public virtual void Choose(HeroSubClass way)
        {
            Detach(CurUser.Belongings.Backpack);

            CurUser.Spend(TimeToRead);
            CurUser.Busy();

            CurUser.subClass = way;

            CurUser.Sprite.DoOperate(CurUser.pos);
            Sample.Instance.Play(Assets.SND_MASTERY);

            SpellSprite.Show(CurUser, SpellSprite.Mastery);
            CurUser.Sprite.Emitter().Burst(Speck.Factory(Speck.MASTERY), 12);
            GLog.Warning("You have chosen the way of the {0}!", Utils.Capitalize(way.Title));

            if (way == HeroSubClass.BERSERKER && CurUser.HP <= CurUser.HT * Fury.Level)
            {
                Buff.Affect <Fury>(CurUser);
            }
        }
Example #30
0
        public override void DoSpecial()
        {
            foreach (var mob in Dungeon.Level.mobs)
            {
                if (!Level.fieldOfView[mob.pos])
                {
                    continue;
                }

                Buff.Affect <Burning>(mob).Reignite(mob);
                Buff.Prolong <Roots>(mob, 3);
            }

            CurUser.HP -= (CurUser.HP / 3);

            CurUser.Spend(Actor.Tick);
            CurUser.Sprite.DoOperate(CurUser.pos);
            CurUser.Busy();

            CurUser.Sprite.CenterEmitter().Start(ElmoParticle.Factory, 0.15f, 4);
            Sample.Instance.Play(Assets.SND_READ);
        }