コード例 #1
0
        public IHttpActionResult FetchBuildingInfo()
        {
            IBuilding building;

            try
            {
                building = Cad.FetchBuilding(User.Identity.GetUserId());
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok <IBuilding>(building));
        }
コード例 #2
0
        public IHttpActionResult FetchFacilities()
        {
            IEnumerable <IFacility> facilities;

            try
            {
                facilities = Cad.FetchFacilities(User.Identity.GetUserId());
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok <IEnumerable <IFacility> >(facilities));
        }
コード例 #3
0
        public IHttpActionResult FetchFacility(int id)
        {
            IFacility facility;

            try
            {
                facility = Cad.FetchFacility(User.Identity.GetUserId(), id);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok <IFacility>(facility));
        }
コード例 #4
0
        public async Task <IHttpActionResult> CreateTenant(RegisterTenantModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };
            var password = GeneratePassword();

            var result = await UserManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                ITenant tenant;
                try
                {
                    tenant = Cad.CreateTenant(model.FirstName, model.LastName, model.DoB, model.Phone, user.Id,
                                              model.ApartmentId, User.Identity.GetUserId());
                    UserManager.AddToRole(user.Id, "Tenant");
                }
                catch (ConnectedApartmentsException e)
                {
                    UserManager.Delete(user);
                    return(BadRequest(e.Message));
                }
                catch (Exception)
                {
                    return(InternalServerError());
                }

                var emailService = new EmailService();
                emailService.SendTenantCreationEmail(model.Email, password);
                return(Ok <ITenant>(tenant));
            }
            else
            {
                return(GetErrorResult(result));
            }
        }
コード例 #5
0
        public async Task <IHttpActionResult> CreateBuilding(RegisterBuildingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };

            var result = await UserManager.CreateAsync(user, model.Password);

            model.Password = "";
            if (result.Succeeded)
            {
                try
                {
                    Cad.CreateBuilding(model.FirstName, model.LastName, model.DateOfBirth, model.Phone, user.Id,
                                       model.BuildingName, model.Address);
                    UserManager.AddToRole(user.Id, "BuildingManager");
                }
                catch (ConnectedApartmentsException e)
                {
                    UserManager.Delete(user);
                    return(BadRequest(e.Message));
                }
                catch (Exception)
                {
                    return(InternalServerError());
                }

                var emailService = new EmailService();
                emailService.SendBuildingCreationEmail(model.Email);
                return(GetResponse());
            }
            else
            {
                return(GetErrorResult(result));
            }
        }
コード例 #6
0
        public object DeleteOrder(object message)
        {
            Messenger msg = (Messenger)message;

            if ((msg.Data[0])[0] != null)
            {//Vérifier la liste des données pour une commande
                Cad.ExecuteNonQuery(Mapping.DeleteOrder());
                ArrayList list = new ArrayList();

                list.Add(true);

                msg.Data = new List <ArrayList>();
                msg.Data.Add(list);
            }
            else
            {
                msg.Error = "Veuillez renseigner toutes les valeurs dans la variable Data du message";
            }
            return(msg);
        }
コード例 #7
0
        public IHttpActionResult UpdateBuilding(BuildingBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.UpdateBuilding(User.Identity.GetUserId(), model.BuildingName, model.Address);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
            return(GetResponse());
        }
コード例 #8
0
        public IHttpActionResult EditAccount(EditAccountModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.UpdatePerson(model.FirstName, model.LastName, model.DoB, model.Phone, User.Identity.GetUserId());
                return(GetResponse());
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
コード例 #9
0
        public IHttpActionResult CreateFacility(FacilityRegisterModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.CreateFacility(User.Identity.GetUserId(), model.Level, model.Number);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
            return(GetResponse());
        }
コード例 #10
0
        public IHttpActionResult UpdateTenant(TenantUpdateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.UpdateTenant(model.UserId, model.FirstName, model.LastName, model.DateofBirth, model.Phone);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
            return(GetResponse());
        }
コード例 #11
0
        public IHttpActionResult CancelBooking(BmBookingCancelModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.CancelBooking(User.Identity.GetUserId(), model.FacilityId, model.BookingId);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
            return(GetResponse());
        }
コード例 #12
0
        public IHttpActionResult ChangeApartment(ChangeApartmentModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.ChangeApartment(model.UserId, model.ApartmentId);
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(GetResponse());
        }
コード例 #13
0
        public IHttpActionResult CreateApartment(ApartmentBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                Cad.CreateApartment(model.Level, model.Number, model.TenantsAllowed, model.FacingDirection,
                                    User.Identity.GetUserId());
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
            return(GetResponse());
        }
コード例 #14
0
        public IHttpActionResult GetUserInfo()
        {
            var externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity);

            var model = new UserInfoViewModel
            {
                Email         = User.Identity.GetUserName(),
                HasRegistered = externalLogin == null,
                LoginProvider = externalLogin?.LoginProvider,
                Roles         = UserManager.GetRoles(User.Identity.GetUserId())
            };

            try
            {
                if (model.Roles[0] == "Tenant")
                {
                    var tenant   = Cad.FetchTenant(User.Identity.GetUserId());
                    var userinfo = new TenantInformationModel(model, tenant);
                    return(Ok <TenantInformationModel>(userinfo));
                }
                else if (model.Roles[0] == "BuildingManager")
                {
                    var bm       = Cad.FetchBuildingManager(User.Identity.GetUserId());
                    var userinfo = new PersonInformationModel(model, bm);
                    return(Ok <PersonInformationModel>(userinfo));
                }
            }
            catch (ConnectedApartmentsException e)
            {
                return(BadRequest(e.Message));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }

            return(Ok <UserInfoViewModel>(model));
        }
コード例 #15
0
        private void btn_sair_Click(object sender, EventArgs e)
        {
            Cad newCad = new Cad();

            newCad.ShowDialog();
        }
コード例 #16
0
        public override Task DivideLine(string line)
        {
            if (line.Contains(" CITC "))
            {
                CitC.Add(line);
            }

            else if (line.Contains(" LOGIN: "******" LOGIN MISC: "))
            {
                LoginMisc.Add(line);
            }
            else if (line.Contains(" QUIT MISC: "))
            {
                QuitMisc.Add(line);
            }

            else if (line.Contains(" (AA)(BAN) "))
            {
                Bans.Add(line);
            }
            else if (line.Contains(" (AA)(MUTE) "))
            {
                Mutes.Add(line);
            }
            else if (line.Contains(" (AA)(JAIL) "))
            {
                Jails.Add(line);
            }
            else if (line.Contains(" (AA)(CONTACTADMIN) "))
            {
                Cad.Add(line);
            }
            else if (line.Contains(" (AA)(SUPPORT) "))
            {
                Support.Add(line);
            }

            else if (line.Contains(" opened '") && line.Contains(" ms"))
            {
                LogsFetched.Add(line);
            }
            else if (line.Contains(" [CM] ") && line.Contains(" set "))
            {
                Reports.Add(line);
            }
            else if (line.Contains("[Complaint ID") && line.Contains(" replied with "))
            {
                Reports.Add(line);
            }
            else if (line.Contains(" warped to ") || line.Contains(" WL: "))
            {
                if (line.Contains("WL: 0") || line.Contains("with 0 stars Dim: 0"))
                {
                    PossibleAbuse.Add(line);
                }
                else
                {
                    RegisteredAbuse.Add(line);
                }
            }

            /*else if (line.Contains(" warped to ") && !line.Contains(" WL: 0") && !line.Contains(" (EM) "))
             *  RegisteredAbuse.Add(line);
             * else if (line.Contains(" warped to ") && line.Contains(" WL: 0") && !line.Contains(" (EM) "))
             *  PossibleAbuse.Add(line);
             * else if (line.Contains(" ST ") && (!line.Contains("from 0") && line.Contains("wanted points.")))
             *  RegisteredAbuse.Add(line);*/
            else if (line.Contains(" ST ") && line.Contains("from 0 wanted points."))
            {
                PossibleAbuse.Add(line);
            }
            else if (line.Contains("abuse") ||
                     line.Contains("recommendation") ||
                     line.Contains("leak") ||
                     line.Contains("bias") ||
                     line.Contains("accept") ||
                     line.Contains("jcm") ||
                     line.Contains("rcm") ||
                     line.Contains("scm")
                     )
            {
                PossibleAbuse.Add(line);
            }

            else if (line.Contains("object. ID:"))
            {
                DutyRelated.Add(line);
            }
            else if (line.Contains("changed account:"))
            {
                DutyRelated.Add(line);
            }
            else if (line.Contains("changed the password of account"))
            {
                DutyRelated.Add(line);
            }
            else if (line.Contains("checked the PIN code of account"))
            {
                DutyRelated.Add(line);
            }
            else if (line.Contains("zone 0 p"))
            {
                DutyRelated.Add(line);
            }

            else if (line.Contains(" (PP) "))
            {
                PendingPunishments.Add(line);
            }
            else
            {
                Other.Add(line);
            }
            return(Task.CompletedTask);
        }
コード例 #17
0
ファイル: Acclog.cs プロジェクト: SanderCC/citlogs
        public override Task DivideLine(string line)
        {
            Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} started job.");
            if (line.Length < 5)
            {
                Console.WriteLine($"{DateTime.Now} Line too small, skipped.");
            }
            else if (line.Contains(" TC: "))
            {
                Team.Add(line);
            }
            else if (line.Contains(" MC LS:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" MC LV:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" MC SF:"))
            {
                Main.Add(line);
            }
            else if (line.Contains(" (ADVERT) "))
            {
                Advert.Add(line);
            }
            else if (line.Contains(" (MYC "))
            {
                Country.Add(line);
            }

            else if (line.Contains(" (sup) "))
            {
                Support.Add(line);
            }
            else if (line.Contains(" (cad) "))
            {
                Cad.Add(line);
            }

            else if (line.Contains(" KILL: "))
            {
                KillDeaths.Add(line);
            }
            else if (line.Contains(" DEATH: "))
            {
                KillDeaths.Add(line);
            }
            else if (line.Contains(" killed themselves via command"))
            {
                KillDeaths.Add(line);
            }

            else if (line.Contains(" GrC ("))
            {
                Group.Add(line);
            }
            else if (line.Contains(" SC ("))
            {
                Squad.Add(line);
            }
            else if (line.Contains(" UC ("))
            {
                Unit.Add(line);
            }
            else if (line.Contains(" (alliance) "))
            {
                Group.Add(line);
            }

            else if (line.Contains(" SMS from "))
            {
                Sms.Add(line);
            }
            else if (line.Contains(" SMS to "))
            {
                Sms.Add(line);
            }

            else if (line.Contains(" T$ "))
            {
                TTransactions.Add(line);
                if (line.Contains("(CITphoneTran"))
                {
                    PlayerTransactions.Add(line);
                }
                else if (line.Contains("CIThit"))
                {
                    Hit.Add(line);
                }
            }
            else if (line.Contains(" G$ "))
            {
                GTransactions.Add(line);
                if (line.Contains("(CITphoneTran"))
                {
                    PlayerTransactions.Add(line);
                }
                else if (line.Contains("CIThit"))
                {
                    Hit.Add(line);
                }
            }
            else if (line.Contains(" BT: "))
            {
                PlayerTransactions.Add(line);
            }

            else if (line.Contains(" (FMSG) "))
            {
                Fmsg.Add(line);
            }
            else if (line.Contains(" (LOCF)["))
            {
                Fmsg.Add(line);
            }

            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }
            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }
            else if (line.Contains(" (LOC)["))
            {
                Local.Add(line);
            }

            else if (line.Contains(" LC "))
            {
                Emergency.Add(line);
            }

            else if (line.Contains(" GroupPromotion: "))
            {
                Group.Add(line);
            }

            else if (line.Contains(" modify "))
            {
                Inventory.Add(line);
            }
            else if (line.Contains(" Crafting "))
            {
                Inventory.Add(line);
            }
            else if (line.Contains(") sold "))
            {
                Trading.Add(line);
            }
            else if (line.Contains(" (Bought "))
            {
                Trading.Add(line);
            }

            else if (line.Contains(" NC "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" LOGIN MISC: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" LOGIN: "******" LOGIN WEPS: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT MISC: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT WEPS: "))
            {
                JoinQuit.Add(line);
            }
            else if (line.Contains(" QUIT WEPS: "))
            {
                JoinQuit.Add(line);
            }

            else
            {
                Other.Add(line);
            }

            Console.WriteLine($"{DateTime.Now} Thread {Thread.CurrentThread.ManagedThreadId} ended job.");
            return(Task.CompletedTask);
        }