Inheritance: ApiController
Esempio n. 1
0
        void WriteCraftToHistory()
        {
            Craft craft = new Craft(_resultPrice, _outcomePrice, _resultFloat, DateTime.Now.Date.ToShortDateString());

            if (steamItemOverlayURL == "")
            {
                CraftHistoryHandler.AddCraft(craft);
                CraftHistoryHandler.Save();
            }
            else if (IsSteamOverlayURLValid(steamItemOverlayURL))
            {
                if (!WebController.CheckConnection())
                {
                    MessageBox.Show((string)Application.Current.Resources["NetworkDisable"]);
                    return;
                }
                Scin scin = JsonSerializer.Deserialize <Scin>(WebController.GetItemProp(steamItemOverlayURL));
                craft.imageUrl    = scin.imageurl;
                craft.outcomeName = scin.full_item_name;
                craft.rarity      = scin.rarity;
                CraftHistoryHandler.AddCraft(craft);
                CraftHistoryHandler.Save();
            }
            else
            {
                if (MessageBoxResult.Yes.Equals(MessageBox.Show((string)Application.Current.Resources["ErrorSteamOverlayURLWrongTitle"], (string)Application.Current.Resources["ErrorSteamOverlayURLWrongText"], MessageBoxButton.YesNo, MessageBoxImage.Error)))
                {
                    CraftHistoryHandler.AddCraft(craft);
                    CraftHistoryHandler.Save();
                }
            }
        }
Esempio n. 2
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            WebController controller = filterContext.Controller as WebController;
            User          u          = (User)HttpContext.Current.Session["user"];
            bool          check      = false;

            if ((controller.lever == 2 || controller.lever == 3))
            {
                if (u != null)
                {
//                User u = (User) HttpContext.Current.Session["user"];
                    string actionName     = filterContext.ActionDescriptor.ActionName;
                    string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
                    foreach (Role role in u.roles)
                    {
                        if (role.contain(controllerName, actionName))
                        {
                            check = true;
                        }
                    }
                }

                if (check == false)
                {
                    controller.HttpContext.Response.Redirect("/");
                }
            }

            base.OnActionExecuting(filterContext);
        }
        /// <summary>
        /// If <paramref name="returnUrl"/> is valid it will redirect to it,
        /// otherwise will redirect to landing page
        /// </summary>
        /// <param name="controller">The instance of
        /// <see cref="WebController"/>.</param>
        /// <param name="returnUrl">The return URL.</param>
        /// <param name="interactionService">The instance of
        /// <see cref="IIdentityServerInteractionService"/> used to
        /// validate returnUrl.</param>
        /// <returns>The created <see cref="RedirectResult"/> for
        /// the response.</returns>
        public static IActionResult RedirectToReturnUrl(
            this WebController controller,
            string returnUri,
            IIdentityServerInteractionService interactionService)
        {
            if (interactionService.IsValidReturnUrl(returnUri))
            {
                return(controller.Redirect(returnUri));
            }

            IdentityBaseContext idbContext =
                controller.HttpContext.GetIdentityBaseContext();

            if (idbContext?.Client != null)
            {
                returnUri = idbContext.Client.TryGetReturnUri(returnUri);
            }

            if (String.IsNullOrWhiteSpace(returnUri))
            {
                throw new ApplicationException("Invalid returnUri");
            }

            return(controller.Redirect(returnUri));
        }
Esempio n. 4
0
 public void StartWebServer(int port = 8006)
 {
     webServer = new WebController();
     WebController.NewDebugMessage   += Debug;
     WebController.NewFrameToProcess += ProccessNewFrame;
     webServer.StartAll(port);
 }
Esempio n. 5
0
        public void AddForm_ReturnsAViewResult()
        {
            var controller = new WebController(mockTodoService.Object);

            var result = controller.AddForm();

            Assert.IsType <ViewResult>(result);
        }
Esempio n. 6
0
 public void Setup()
 {
     Db  = new AppDb("server=metrics-database.c3qkgc3zryke.us-east-1.rds.amazonaws.com;user id=master;password=connection;port=3306;database=metrics");
     Err = new ErrorRateController(Db);
     Log = new LoginController(Db);
     Tra = new TransactionController(Db);
     Web = new WebController(Db);
 }
Esempio n. 7
0
        public void GetWebPrivateData()
        {
            WebController web    = new WebController();
            var           result = web.GetWebPrivateData(2, 2021);

            //
            // TODO: Add constructor logic here
            //
        }
Esempio n. 8
0
        public void GetHelpDeskTickets()
        {
            WebController web = new WebController();

            var result = web.GetHelpDeskTickets(2, 2021);

            //
            // TODO: Add constructor logic here
            //
        }
Esempio n. 9
0
        public async Task OpenWebPage(string url)
        {
            _webController = await ChromecastService.ChromeCastClient.LaunchWeb();

            await Task.Delay(5000);

            await _webController.LoadUrl(url);

            await Task.Delay(5000);
        }
Esempio n. 10
0
        private async static void ChromeCastClient_Connected(object sender, EventArgs e)
        {
            System.Console.WriteLine("Connected to chromecast");
            if (_controller == null)
            {
                _webController = await ChromecastService.ChromeCastClient.LaunchWeb();

                //await _controller.LoadUrl("https://www.youtube.com");
            }
        }
Esempio n. 11
0
        static void Main()
        {
            WebController.StartCrawler();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Context = new ApplicationContext(new LoginContaForm());
            Application.Run(Context);
        }
 /// <summary>
 /// Redirects to login page.
 /// </summary>
 /// <param name="controller">The instance of
 /// <see cref="WebController"/>.</param>
 /// <param name="returnUrl">The return URL.</param>
 /// <returns>The created <see cref="RedirectResult"/> for
 /// the response.</returns>
 public static IActionResult RedirectToLogin(
     this WebController controller,
     string returnUrl)
 {
     return(controller.RedirectToAction(
                "Index",
                "Login",
                new { ReturnUrl = returnUrl }
                ));
 }
Esempio n. 13
0
        public void About()
        {
            // Arrange
            WebController controller = new WebController();

            // Act
            ViewResult result = controller.About() as ViewResult;

            // Assert
            Assert.AreEqual("Your application description page.", result.ViewBag.Message);
        }
Esempio n. 14
0
        public void Contact()
        {
            // Arrange
            WebController controller = new WebController();

            // Act
            ViewResult result = controller.Contact() as ViewResult;

            // Assert
            Assert.IsNotNull(result);
        }
Esempio n. 15
0
        public void AddNewTodoPost_ReturnsARedirect_CallsServiceMethod()
        {
            mockTodoService.Setup(s => s.AddNewTodo(It.IsAny <Todo>())).Verifiable();
            var controller = new WebController(mockTodoService.Object);

            var result = controller.AddNewTodo(CreateTodo("test"));

            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", redirectToActionResult.ActionName);
            mockTodoService.Verify();
        }
Esempio n. 16
0
        public void DeleteTodo_ReturnsARedirect_CallsServiceMethod()
        {
            mockTodoService.Setup(s => s.DeleteById(It.IsAny <long>())).Verifiable();
            var controller = new WebController(mockTodoService.Object);

            var result = controller.DeleteTodo(0);

            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Index", redirectToActionResult.ActionName);
            mockTodoService.Verify();
        }
Esempio n. 17
0
        public string Doss()
        {
            Random rand = new Random();

            while (true)
            {
                WebController.GetHtml(Address,
                                      Proxy != null ? Proxy[rand.Next(0, Proxy.Count)] : null,
                                      UserAgents != null ? UserAgents[rand.Next(0, userAgent.Count)] : null,
                                      Referers != null ? Referers[rand.Next(0, referer.Count)] : null);
                Thread.Sleep(rand.Next(TimeMin, TimeMax));
            }
        }
Esempio n. 18
0
        private async void btnDisconnect_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Disconnecting...";
            if (MainForm._webController != null)
            {
                await MainForm._webController.StopApplication();

                MainForm._webController = null;
                lblStatus.Text          = "Disconnected";
                return;
            }
            lblStatus.Text = "Not Connected";
        }
 void Awake() {
     World = _World;
     LandWaterMask = _LandWaterMask;
     GT = transform.GetComponent<GameTime>();
     WM = transform.GetComponent<WorldManager>();
     AEM = transform.GetComponent<AnomalousEventManager>();
     TEM = transform.GetComponent<TimedEventManager>();
     CM = transform.GetComponent<ColorManager>();
     NM  = transform.GetComponent<NotificationManager>();
     GOI = transform.GetComponent<GoIManager>();
     POI = transform.GetComponent<PoIManager>();        
     WC = transform.GetComponent<WebController>();
     
 }
Esempio n. 20
0
        public ActionResult Story(string alias, string name)
        {
            if (ConfigurationManager.AppSettings["StartingPoint"] == "index.dev.html")
            {
                return(View("IndexDev"));
            }
            else
            {
                var controller = new WebController();
                var story      = controller.GetStory(alias, name);
                var model      = new StoryMetaModel(story);

                return(View("Story", model));
            }
        }
Esempio n. 21
0
        public void EditForm_ResturnsAViewResult_WithATodo_CallsServiceMethod()
        {
            var expected = CreateTodo("test");

            mockTodoService.Setup(s => s.GetTodoById(It.IsAny <long>())).Returns(expected).Verifiable();
            var controller = new WebController(mockTodoService.Object);

            var result = controller.EditForm(0);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <Todo>(viewResult.ViewData.Model);

            Assert.Equal(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(model));
            mockTodoService.Verify();
        }
Esempio n. 22
0
        protected void Application_Start()
        {
            try
            {
                AreaRegistration.RegisterAllAreas();
                RouteConfig.RegisterRoutes(RouteTable.Routes);

                var remoteConfig = (RemoteConfig)ConfigurationManager.GetSection("remoteConfig");
                WebController.Configure(remoteConfig);
            }
            catch (Exception e)
            {
                //todo: write log
            }
        }
Esempio n. 23
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     try
     {
         if (System.Convert.ToString(value) == "")
         {
             return(null);
         }
         return(WebController.GetImageByURL(System.Convert.ToString(value)));
     }
     catch (Exception)
     {
         return(null);
     }
 }
Esempio n. 24
0
        public void Index_ReturnsAViewResult_WithAListOfTodos_CallsServiceMethod()
        {
            var expected = CreateTodos(10);

            mockTodoService.Setup(s => s.GetAllTodos()).Returns(expected).Verifiable();
            var controller = new WebController(mockTodoService.Object);

            var result = controller.Index();

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <IEnumerable <Todo> >(viewResult.ViewData.Model);

            Assert.Equal(10, model.Count());
            mockTodoService.Verify();
        }
        public virtual void OnAuthorization(AuthorizationContext filterContext)
        {
            if (filterContext.IsChildAction || this.SkipAuthorize(filterContext.ActionDescriptor))
            {
                return;
            }

            AdminSession session = null;

            WebController webController = filterContext.Controller as WebController;

            if (webController != null)
            {
                session = webController.CurrentSession;
            }
            else
            {
                session = MultiBank.Extention.WebUtils.GetCurrentSession();
            }

            if (session != null)
            {
                return;
            }

            HttpRequestBase httpRequest = filterContext.HttpContext.Request;

            if (httpRequest.IsAjaxRequest())
            {
                Result        result        = Result.CreateResult(ResultStatus.NotLogin, "未登录或登录超时,请重新登录");
                string        json          = JsonHelper.Serialize(result);
                ContentResult contentResult = new ContentResult()
                {
                    Content = json
                };
                filterContext.Result = contentResult;
                return;
            }
            else
            {
                string url = System.Web.Mvc.UrlHelper.GenerateContentUrl("~/Account/Login", filterContext.HttpContext);
                //url = string.Concat(url, "?returnUrl=", httpRequest.RawUrl);

                RedirectResult redirectResult = new RedirectResult(url);
                filterContext.Result = redirectResult;
                return;
            }
        }
Esempio n. 26
0
        public ActionResult Foto(string alias, string name)
        {
            if (ConfigurationManager.AppSettings["StartingPoint"] == "index.dev.html")
            {
                return(View("IndexDev"));
            }
            else
            {
                var controller = new WebController();
                var photo      = controller.GetPhoto(alias, name);

                var model = new FotoMetaModel(photo);

                return(View("Foto", model));
            }
        }
Esempio n. 27
0
        public void HttpRequestsOnApiUrlsReturnsNotNull()
        {
            MainForm  mf        = new MainForm();
            Stopwatch stopWatch = new Stopwatch();


            for (int i = 0; i < mf.JsonUrls.Count; i++)
            {
                stopWatch.Restart();
                var res = WebController.GetStringAsync(mf.JsonUrls[i]);
                stopWatch.Stop();
                Assert.IsNotNull(res);

                Trace.WriteLine("Url " + i + ": " + (stopWatch.ElapsedMilliseconds / 1000.0) + "s (" + mf.JsonUrls[i] + ")");
            }
        }
Esempio n. 28
0
        public bool CheckAuthentication(HttpActionContext actionContext)
        {
            WebController controller = (WebController)actionContext.ControllerContext.Controller;

            if (controller.CurrentUser == null)
            {
                return(false);
            }
            Dictionary <string, string> dClaims = AccountQueries.GetClaimsDictionaryByUser(controller.CurrentUser, controller.DbContext);
            bool result = true;

            this.Claims.ToList().ForEach(c =>
            {
                result = dClaims[c] == "true" && result;
            });
            return(result);
        }
Esempio n. 29
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            WebController defaultController = (WebController)context.Controller;

            if (defaultController.UserInfoSession == null)
            {
                return;
            }
            AppServiceFactory appServiceFactory = new AppServiceFactory(context.HttpContext.RequestServices);
            var permissionService = appServiceFactory.CreateService <IPermissionService>();

            var claims = permissionService.GetUnionPermission(defaultController.UserInfoSession);
            //页面无权限过滤
            var url  = $"/{context.RouteData.Values["Controller"].ToString()}/{context.RouteData.Values["Action"].ToString()}";
            var flag = claims.Where(x => x.Url != null).Where(x => x.Url.ToUpper() == url.ToUpper()).Count() > 0;

            if (!flag)
            {
                SesJsonResult jsonResult = new SesJsonResult(JsonResultStatus.Unauthorized, "无权限");
                context.Result = new ContentResult()
                {
                    Content = JsonConvert.SerializeObject(jsonResult)
                };
                return;
            }

            //按钮权限控制
            var btnPermission = permissionService.GetUnionBtnPermission(defaultController.UserInfoSession, url);
            Dictionary <string, string> btnPermissionDic = new Dictionary <string, string>();
            var style = "display:none;";

            foreach (var item in BtnPermission.AllBtnPms.Split(','))
            {
                if (!btnPermission.Contains(item))
                {
                    btnPermissionDic.Add(item, style);
                }
                else
                {
                    btnPermissionDic.Add(item, string.Empty);
                }
            }
            defaultController.ViewBag.BtnPermissionDic = btnPermissionDic;
            base.OnActionExecuting(context);
        }
        /// <summary>
        /// Get Controllers and its Actions of assembly
        /// </summary>
        /// <param name="executingAssembly">Reference to executing assembly</param>
        /// <returns>List of Contollers and its Actions</returns>
        private List <WebController> GetAssemblyControllers(Assembly executingAssembly)
        {
            List <WebController> webControllers = new List <WebController>();
            var controllers = executingAssembly.GetTypes()
                              .Where(type => typeof(Controller).IsAssignableFrom(type) && !type.IsDefined(typeof(NonSecurableControllerAttribute), false)).ToList();

            foreach (var controller in controllers)
            {
                WebController webController = new WebController
                {
                    Name    = controller.Name,
                    Actions = controller.GetMethods(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public)
                              .Where(method => method.IsPublic && method.IsDefined(typeof(SecurableActionAttribute), false)).Select(method => method.Name).ToArray()
                };
                webControllers.Add(webController);
            }

            return(webControllers);
        }
Esempio n. 31
0
        public RaceTimingForm()
        {
            Application.EnableVisualStyles();
            InitializeComponent();

            // Add the clock label
            clockLabel = new ClockLabel
            {
                Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                Font     = new Font("Microsoft Sans Serif", 25F, FontStyle.Regular, GraphicsUnit.Millimeter, 0),
                Location = new Point(12, 24),
                Name     = "clockLabel",
                Size     = new Size(splitContainer1.Panel1.Size.Width, 166),
            };
            splitContainer1.Panel1.Controls.Add(clockLabel);
            spaceBarLabel.Visible = false;

            Application.ThreadException += (o, e) => ShowExceptionMessageBox(e.Exception);
            AppDomain.CurrentDomain.UnhandledException += (o, e) => ShowExceptionMessageBox((Exception)e.ExceptionObject);

            appController = new ControllerFactory().AppController;
            appController.ClockTime.ClockChangeHandler  += clockLabel.ClockChangeEventListener;
            appController.ClockTime.ClockRunningHandler += ClockTimeOnClockRunningHandler;
            appController.ResultDataChange += ResultsQueueOnNewResult;
            SetTitle();

            // Setup result list view
            var listViewExtender   = new ListViewExtender(resultListView);
            var deleteResultColumn = new ListViewButtonColumn(3)
            {
                FixedWidth = true, DrawIfEmpty = false
            };

            deleteResultColumn.Click += DeleteResult;
            listViewExtender.AddColumn(deleteResultColumn);
            ListResults();

            var webController = new WebController(appController.GetRootUrl());

            webController.Start();
        }