Пример #1
0
        private void btnUnmergedChanges_Click(object sender, RoutedEventArgs e)
        {
            long startTicks = XlHlp.DisplayInWatchWindow("Begin");

            try
            {
                RequestHandlers.SpeedUpStart();

                MergeCandidate[] mergeCandidates = AzureDevOpsExplorer.Presentation.Views.Server.VersionControlServer.GetMergeCandidates("$/Development", "$/Release", RecursionType.Full);

                foreach (var mergeCandidate in mergeCandidates)
                {
                    if (mergeCandidate.Changeset.Owner == @"DOMAIN\ChuckNorris")
                    {
                        //This is an unmerged changeset commited by Chuck
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                RequestHandlers.SpeedUpEnd();
            }

            XlHlp.DisplayInWatchWindow("End", startTicks);
        }
Пример #2
0
        private void GetTestCaseInfo(TestCaseRequest request)
        {
            long startTicks = Log.EVENT_HANDLER("Enter", Common.PROJECT_NAME);

            try
            {
                RequestHandlers.SpeedUpStart();

                char[] splitChars = { ',' };

                int testCaseId = 0;

                Options_AZDO_TFS options = GetOptions();

                foreach (string testCase in request.TestID.Split(splitChars, StringSplitOptions.None))
                {
                    if (int.TryParse(testCase, out testCaseId))
                    {
                        CreateWS_TM_TestCaseInfo(testCaseId, request.TestSections, options);
                    }

                    AZDOHelper.ProcessLoopDelay(options);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                RequestHandlers.SpeedUpEnd();
            }

            Log.EVENT_HANDLER("Exit", Common.PROJECT_NAME, startTicks);
        }
Пример #3
0
        private void btnCodeChurn_Click(object sender, RoutedEventArgs e)
        {
            long startTicks = XlHlp.DisplayInWatchWindow("Start");

            Options_AZDO_TFS options = GetOptions();

            try
            {
                RequestHandlers.SpeedUpStart();
                //TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("http://WhateverServerUrl");
                //IBuildServer buildServer = (IBuildServer)tfs.GetService(typeof(IBuildServer));
                //VersionControlServer VsServer = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
                //IBuildDetail build = buildServer.GetAllBuildDetails(new Uri("http://WhateverBuildUrl"));

                //List<IChangesetsummary> associatedChangesets = InformationNodeConverters.GetAssociatedChangesets(build);

                //foreach (IChangesetsummary changeSetData in associatedChangesets)
                //{
                //    Changeset changeSet = VsServer.GetChangeset(changeSetData.ChangesetId);
                //    foreach (Change change in changeSet.Changes)
                //    {
                //        bool a = change.Item.IsContentDestroyed;
                //        long b = change.Item.ContentLength;
                //    }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                RequestHandlers.SpeedUpEnd();
            }
        }
Пример #4
0
        private void Get_TPC_Info()
        {
            long startTicks = XlHlp.DisplayInWatchWindow("Begin");

            Options_AZDO_TFS options = GetOptions();

            try
            {
                RequestHandlers.SpeedUpStart();

                //// Get the Team Project Collections

                //ReadOnlyCollection<CatalogNode> projectCollectionNodes = VNCTFS.Helper.Get_TeamProjectCollectionNodes(AzureDevOpsExplorer.Presentation.Views.Server.ConfigurationServer);

                var tpcCatalogNode = AzureDevOpsExplorer.Presentation.Views.Server.TfsTeamProjectCollection.CatalogNode;

                CreateWS_TPC_Info(tpcCatalogNode, AzureDevOpsExplorer.Presentation.Views.Server.TfsTeamProjectCollection, false, options);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                RequestHandlers.SpeedUpEnd();
            }

            XlHlp.DisplayInWatchWindow("End", startTicks);
        }
            public void CreateStreamingRequestHandler(WebSocket socket, Activity activity, string audience = null)
            {
                var srh = new StreamingRequestHandler(ConnectedBot, this, socket, audience, Logger);

                // Prepare StreamingRequestHandler for BotFrameworkHttpAdapterBase.ProcessStreamingActivityAsync()
                // Add ConversationId to StreamingRequestHandler's conversations cache
                var cacheField = typeof(StreamingRequestHandler).GetField("_conversations", BindingFlags.NonPublic | BindingFlags.Instance);
                var cache      = (ConcurrentDictionary <string, DateTime>)cacheField.GetValue(srh);

                cache.TryAdd(activity.Conversation.Id, DateTime.Now);

                // Add ServiceUrl to StreamingRequestHandler
                var serviceUrlProp = typeof(StreamingRequestHandler).GetProperty("ServiceUrl");

                serviceUrlProp.DeclaringType.GetProperty("ServiceUrl");
                serviceUrlProp.GetSetMethod(true).Invoke(srh, new object[] { activity.ServiceUrl });

                if (RequestHandlers != null)
                {
                    RequestHandlers.Add(srh);
                    return;
                }

                RequestHandlers = new List <StreamingRequestHandler> {
                    srh
                };
            }
        public AlexaResponse AlexaStarterSkill(AlexaRequest request)
        {
            //if (request.Session.Application.ApplicationId != ApplicationId)
            //    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));

            //var totalSeconds = (DateTime.UtcNow - request.Request.Timestamp).TotalSeconds;
            //if (totalSeconds <= 0 || totalSeconds > 150)
            //    throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));

            AlexaResponse response = null;

            if (request != null)
            {
                switch (request.Request.Type)
                {
                case "LaunchRequest":
                    response = RequestHandlers.LaunchRequestHandler(request);
                    break;

                case "IntentRequest":
                    response = RequestHandlers.IntentRequestHandler(request);
                    break;

                case "SessionEndedRequest":
                    response = RequestHandlers.SessionEndedRequestHandler(request);
                    break;
                }
            }

            return(response);
        }
Пример #7
0
        /// <summary>
        /// Process the initial request to establish a long lived connection via a streaming server.
        /// </summary>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="httpRequest">The connection request.</param>
        /// <param name="httpResponse">The response sent on error or connection termination.</param>
        /// <returns>Returns on task completion.</returns>
        private async Task ConnectWebSocketAsync(IBot bot, HttpRequest httpRequest, HttpResponse httpResponse)
        {
            if (httpRequest == null)
            {
                throw new ArgumentNullException(nameof(httpRequest));
            }

            if (httpResponse == null)
            {
                throw new ArgumentNullException(nameof(httpResponse));
            }

            ConnectedBot = bot ?? throw new ArgumentNullException(nameof(bot));

            if (!httpRequest.HttpContext.WebSockets.IsWebSocketRequest)
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                await httpRequest.HttpContext.Response.WriteAsync("Upgrade to WebSocket is required.").ConfigureAwait(false);

                return;
            }

            var claimsIdentity = await AuthenticateRequestAsync(httpRequest).ConfigureAwait(false);

            if (claimsIdentity == null)
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                await httpRequest.HttpContext.Response.WriteAsync("Request authentication failed.").ConfigureAwait(false);

                return;
            }

            try
            {
                var socket = await httpRequest.HttpContext.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);

                // Set ClaimsIdentity on Adapter to enable Skills and User OAuth in WebSocket-based streaming scenarios.
                var audience = GetAudience(claimsIdentity);

                var requestHandler = CreateStreamingRequestHandler(bot, socket, audience);

                if (RequestHandlers == null)
                {
                    RequestHandlers = new List <StreamingRequestHandler>();
                }

                RequestHandlers.Add(requestHandler);

                await requestHandler.ListenAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await httpRequest.HttpContext.Response.WriteAsync($"Unable to create transport server. Error: {ex.ToString()}").ConfigureAwait(false);

                throw;
            }
        }
Пример #8
0
        private IRequestHandlers CreateRequestHandlers()
        {
            var handlers = new RequestHandlers();

            handlers.TryAdd(MessageMethod.Initialize, this);
            handlers.TryAdd(MessageMethod.GetOperationClaims, this);

            return(handlers);
        }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, getActionsHandler, runActionHandler) in handlers
              .OfType <Mef.IRequestHandler <GetCodeActionsRequest, GetCodeActionsResponse>,
                       Mef.IRequestHandler <RunCodeActionRequest, RunCodeActionResponse> >())
     {
         yield return(new OmniSharpCodeActionHandler(getActionsHandler, runActionHandler, selector));
     }
 }
Пример #10
0
            /// <summary>
            /// Returns the class-path for the 404 pages in their invoke order ascending.
            /// </summary>
            /// <param name="conn"></param>
            /// <returns></returns>
            public static RequestHandlers getRequest404s(Connector conn)
            {
                RequestHandlers handlers = new RequestHandlers();

                foreach (ResultRow handler in conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_404='1' ORDER BY invoke_order ASC"))
                {
                    handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
                }
                return(handlers);
            }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, membersAsTreeHandler, findUsagesHandler) in handlers
              .OfType <
                  Mef.IRequestHandler <MembersTreeRequest, FileMemberTree>,
                  Mef.IRequestHandler <FindUsagesRequest, QuickFixResponse> >())
     {
         yield return(new OmniSharpCodeLensHandler(membersAsTreeHandler, findUsagesHandler, selector));
     }
 }
Пример #12
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers.OfType <Mef.IRequestHandler <GotoDefinitionRequest, GotoDefinitionResponse> >())
     {
         if (handler != null)
         {
             yield return(new DefinitionHandler(handler, selector));
         }
     }
 }
Пример #13
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <AutoCompleteRequest, IEnumerable <AutoCompleteResponse> > >())
     {
         if (handler != null)
         {
             yield return(new OmniSharpCompletionHandler(handler, selector));
         }
     }
 }
Пример #14
0
        /// <summary>
        /// Process the initial request to establish a long lived connection via a streaming server.
        /// </summary>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="httpRequest">The connection request.</param>
        /// <param name="httpResponse">The response sent on error or connection termination.</param>
        /// <returns>Returns on task completion.</returns>
        private async Task ConnectWebSocketAsync(IBot bot, HttpRequestMessage httpRequest, HttpResponseMessage httpResponse)
        {
            if (httpRequest == null)
            {
                throw new ArgumentNullException(nameof(httpRequest));
            }

            if (httpResponse == null)
            {
                throw new ArgumentNullException(nameof(httpResponse));
            }

            ConnectedBot = bot ?? throw new ArgumentNullException(nameof(bot));

            if (HttpContext.Current.IsWebSocketRequest || HttpContext.Current.IsWebSocketRequestUpgrading)
            {
                httpResponse.StatusCode = HttpStatusCode.BadRequest;
                httpResponse.Content    = new StringContent("Upgrade to WebSocket is required.");

                return;
            }

            if (!await AuthenticateRequestAsync(httpRequest, httpResponse).ConfigureAwait(false))
            {
                httpResponse.StatusCode = HttpStatusCode.Unauthorized;
                httpResponse.Content    = new StringContent("Request authentication failed.");

                return;
            }

            try
            {
                HttpContext.Current.AcceptWebSocketRequest(async context =>
                {
                    var requestHandler = new StreamingRequestHandler(bot, this, context.WebSocket, Logger);

                    if (RequestHandlers == null)
                    {
                        RequestHandlers = new List <StreamingRequestHandler>();
                    }

                    RequestHandlers.Add(requestHandler);

                    await requestHandler.ListenAsync().ConfigureAwait(false);
                });
            }
            catch (Exception ex)
            {
                httpResponse.StatusCode = HttpStatusCode.InternalServerError;
                httpResponse.Content    = new StringContent($"Unable to create transport server. Error: {ex.ToString()}");

                throw ex;
            }
        }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <FormatAfterKeystrokeRequest, FormatRangeResponse> >())
     {
         if (handler != null)
         {
             yield return(new OmniSharpDocumentOnTypeFormattingHandler(handler, selector));
         }
     }
 }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <TypeLookupRequest, TypeLookupResponse> >())
     {
         if (handler != null)
         {
             yield return(new OmniSharpHoverHandler(handler, selector));
         }
     }
 }
Пример #17
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <SignatureHelpRequest, SignatureHelpResponse> >())
     {
         if (handler != null)
         {
             yield return(new SignatureHelpHandler(handler, selector));
         }
     }
 }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <FindImplementationsRequest, QuickFixResponse> >())
     {
         if (handler != null)
         {
             yield return(new OmniSharpImplementationHandler(handler, selector));
         }
     }
 }
Пример #19
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <FindUsagesRequest, QuickFixResponse> >())
     {
         if (handler != null)
         {
             yield return(new ReferencesHandler(handler, selector));
         }
     }
 }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <MembersTreeRequest, FileMemberTree> >())
     {
         if (handler != null)
         {
             yield return(new DocumentSymbolHandler(handler, selector));
         }
     }
 }
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     foreach (var(selector, handler) in handlers
              .OfType <Mef.IRequestHandler <CodeStructureRequest, CodeStructureResponse> >())
     {
         if (handler != null)
         {
             yield return(new OmniSharpDocumentSymbolHandler(handler, selector));
         }
     }
 }
Пример #22
0
        /// <summary>
        /// Process the initial request to establish a long lived connection via a streaming server.
        /// </summary>
        /// <param name="bot">The <see cref="IBot"/> instance.</param>
        /// <param name="httpRequest">The connection request.</param>
        /// <param name="httpResponse">The response sent on error or connection termination.</param>
        /// <returns>Returns on task completion.</returns>
        private async Task ConnectWebSocketAsync(IBot bot, HttpRequest httpRequest, HttpResponse httpResponse)
        {
            if (httpRequest == null)
            {
                throw new ArgumentNullException(nameof(httpRequest));
            }

            if (httpResponse == null)
            {
                throw new ArgumentNullException(nameof(httpResponse));
            }

            ConnectedBot = bot ?? throw new ArgumentNullException(nameof(bot));

            if (!httpRequest.HttpContext.WebSockets.IsWebSocketRequest)
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
                await httpRequest.HttpContext.Response.WriteAsync("Upgrade to WebSocket is required.").ConfigureAwait(false);

                return;
            }

            if (!await AuthenticateRequestAsync(httpRequest).ConfigureAwait(false))
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
                await httpRequest.HttpContext.Response.WriteAsync("Request authentication failed.").ConfigureAwait(false);

                return;
            }

            try
            {
                var socket = await httpRequest.HttpContext.WebSockets.AcceptWebSocketAsync().ConfigureAwait(false);

                var requestHandler = new StreamingRequestHandler(bot, this, socket, Logger);

                if (RequestHandlers == null)
                {
                    RequestHandlers = new List <StreamingRequestHandler>();
                }

                RequestHandlers.Add(requestHandler);

                await requestHandler.ListenAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                httpRequest.HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await httpRequest.HttpContext.Response.WriteAsync($"Unable to create transport server. Error: {ex.ToString()}").ConfigureAwait(false);

                throw ex;
            }
        }
Пример #23
0
        private void GetTeamProjectInfo(TeamProjectActionRequest request)
        {
            long startTicks = Log.EVENT_HANDLER("Enter", Common.PROJECT_NAME);

            Options_AZDO_TFS options = GetOptions();

            var priorStatusBar = Globals.ThisAddIn.Application.StatusBar;

            try
            {
                Globals.ThisAddIn.Application.DisplayStatusBar = true;

                RequestHandlers.SpeedUpStart();

                if (options.TeamProjects is null)
                {
                    MessageBox.Show("No Team Project(s) selected, aborting");
                }
                else
                {
                    options.TeamProjects.Reverse();

                    foreach (string teamProjectName in options.TeamProjects)
                    {
                        try
                        {
                            Globals.ThisAddIn.Application.StatusBar = "Processing " + teamProjectName;

                            CreateWS_TP(teamProjectName, request, options);

                            Globals.ThisAddIn.Application.ActiveWorkbook.Save();

                            AZDOHelper.ProcessLoopDelay(options);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Globals.ThisAddIn.Application.StatusBar = priorStatusBar;
                RequestHandlers.SpeedUpEnd();
            }

            Log.EVENT_HANDLER("Exit", Common.PROJECT_NAME, startTicks);
        }
Пример #24
0
            /// <summary>
            /// Returns the classpath of the plugin responsible for the passed request.
            ///
            /// If a 404 occurs, this method will return a method able to handle the error;
            /// if no plugin is able to handle a 404, the returned collection will be empty.
            /// </summary>
            /// <param name="request"></param>
            /// <returns></returns>
            public static RequestHandlers getRequestPlugin(Connector conn, HttpRequest request)
            {
                // If no page is provided, we'll check for a default page in the setting, else we'll just use home
                string          page     = request.QueryString["page"] ?? (Core.settings.contains("core", "default_page") ? Core.settings["core"]["default_page"] : "home");
                RequestHandlers handlers = new RequestHandlers();

                foreach (ResultRow handler in conn.Query_Read("SELECT p.pluginid, p.classpath FROM urlrewriting AS u LEFT OUTER JOIN plugins AS p ON p.pluginid=u.pluginid WHERE u.parent IS NULL AND u.title LIKE '" + Utils.Escape(page.Replace("%", "")) + "' AND p.state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' ORDER BY p.invoke_order ASC LIMIT 1"))
                {
                    handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
                }
                return(handlers);
            }
 public static IEnumerable <IJsonRpcHandler> Enumerate(
     RequestHandlers handlers,
     ISerializer serializer,
     ILanguageServer mediator,
     DocumentVersions versions)
 {
     foreach (var(selector, getActionsHandler, runActionHandler) in handlers
              .OfType <Mef.IRequestHandler <GetCodeActionsRequest, GetCodeActionsResponse>,
                       Mef.IRequestHandler <RunCodeActionRequest, RunCodeActionResponse> >())
     {
         yield return(new OmniSharpCodeActionHandler(getActionsHandler, runActionHandler, selector, serializer, mediator, versions));
     }
 }
Пример #26
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(RequestHandlers handlers)
 {
     //
     // TODO: remove the conditional when we upgrade to v0.16.0 of Omnisharp.Extensions.LSP
     //
     // we have no WorkspaceSymbolRegistrationOptions/DocumentSelector until version 0.16.0 of Omnisharp.Extensions.LSP
     // thus we artificially limit the handler to C# language for now
     // (as Cake version of <FindSymbolsRequest,QuickFixResponse> would get selected otherwise)
     //
     yield return(new OmniSharpWorkspaceSymbolsHandler(handlers
                                                       .OfType <Mef.IRequestHandler <FindSymbolsRequest, QuickFixResponse> >()
                                                       .Select(z => z.handler)));
 }
Пример #27
0
 public static IEnumerable <IJsonRpcHandler> Enumerate(
     RequestHandlers handlers,
     OmniSharpWorkspace workspace)
 {
     foreach (var(selector, openHandler, closeHandler, bufferHandler) in handlers
              .OfType <
                  Mef.IRequestHandler <FileOpenRequest, FileOpenResponse>,
                  Mef.IRequestHandler <FileCloseRequest, FileCloseResponse>,
                  Mef.IRequestHandler <UpdateBufferRequest, object> >())
     {
         // TODO: Fix once cake has working support for incremental
         var documentSyncKind = TextDocumentSyncKind.Incremental;
         // if (selector.ToString().IndexOf(".cake") > -1) documentSyncKind = TextDocumentSyncKind.Full;
         yield return(new TextDocumentSyncHandler(openHandler, closeHandler, bufferHandler, selector, documentSyncKind, workspace));
     }
 }
Пример #28
0
        internal virtual void OnFinalUnsubscribe()
        {
            if (_log.IsDebugEnabled)
            {
                _log.DebugFormat("Final unsubscribe");
            }

            StopPolling(true);
            lock (SynchLock)
            {
                if (RequestHandlers.Count > 0)
                {
                    RequestHandlers.Clear();
                }
            }
        }
Пример #29
0
        private void GetTeamProjectXML(TeamProjectActionRequest request)
        {
            long startTicks = Log.EVENT_HANDLER("Enter", Common.PROJECT_NAME);

            Options_AZDO_TFS options = GetOptions();

            var priorStatusBar = Globals.ThisAddIn.Application.StatusBar;

            try
            {
                Globals.ThisAddIn.Application.DisplayStatusBar = true;

                RequestHandlers.SpeedUpStart();

                foreach (string teamProjectName in options.TeamProjects)
                {
                    try
                    {
                        Globals.ThisAddIn.Application.StatusBar = "Processing " + teamProjectName;

                        Project project = AzureDevOpsExplorer.Presentation.Views.Server.WorkItemStore.Projects[teamProjectName];

                        Body_WorkItemStore.Get_TP_WorkItemTypesXML(options, project);

                        //Globals.ThisAddIn.Application.ActiveWorkbook.Save();

                        AZDOHelper.ProcessLoopDelay(options);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Globals.ThisAddIn.Application.StatusBar = priorStatusBar;
                RequestHandlers.SpeedUpEnd();
            }

            Log.EVENT_HANDLER("Exit", Common.PROJECT_NAME, startTicks);
        }
Пример #30
0
        public JsonResult Register([FromBody] UserRegistrationModel model)
        {
            return(RequestHandlers.Handle(() =>
            {
                Mapper mapper = new Mapper();

                User mappedUser = mapper.ParseUser(model);

                DbProvider provider = new DbProvider(ctx);

                if (provider.GetUserByEmail(mappedUser.Email) != null)
                {
                    throw new ArgumentOutOfRangeException(nameof(model.Email), "Email already exists");
                }

                provider.AddUser(mappedUser);
            }));
        }
Пример #31
0
 /// <summary>
 /// Returns the class-path for the 404 pages in their invoke order ascending.
 /// </summary>
 /// <param name="conn"></param>
 /// <returns></returns>
 public static RequestHandlers getRequest404s(Connector conn)
 {
     RequestHandlers handlers = new RequestHandlers();
     foreach (ResultRow handler in conn.Query_Read("SELECT pluginid, classpath FROM plugins WHERE state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' AND handles_404='1' ORDER BY invoke_order ASC"))
         handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
     return handlers;
 }
Пример #32
0
 /// <summary>
 /// Returns the classpath of the plugin responsible for the passed request.
 /// 
 /// If a 404 occurs, this method will return a method able to handle the error;
 /// if no plugin is able to handle a 404, the returned collection will be empty.
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public static RequestHandlers getRequestPlugin(Connector conn, HttpRequest request)
 {
     // If no page is provided, we'll check for a default page in the setting, else we'll just use home
     string page = request.QueryString["page"] ?? (Core.settings.contains("core", "default_page") ? Core.settings["core"]["default_page"] : "home");
     RequestHandlers handlers = new RequestHandlers();
     foreach (ResultRow handler in conn.Query_Read("SELECT p.pluginid, p.classpath FROM urlrewriting AS u LEFT OUTER JOIN plugins AS p ON p.pluginid=u.pluginid WHERE u.parent IS NULL AND u.title LIKE '" + Utils.Escape(page.Replace("%", "")) + "' AND p.state='" + (int)UberCMS.Plugins.Base.State.Enabled + "' ORDER BY p.invoke_order ASC LIMIT 1"))
         handlers.add(new RequestHandler(handler["pluginid"], handler["classpath"]));
     return handlers;
 }