<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/FiniqAppMasterPage.Master" CodeBehind="FinIQ_WebSQL.aspx.vb" Inherits="FinIQWebApp.FinIQ_WebSQL"
    EnableEventValidation="false" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <script src="../ELN_DealEntry1/App_Themes/assets/js/bootstrap.min.js"></script>
    <link href="../ELN_DealEntry1/App_Themes/assets/css/bootstrap.min.css" rel="stylesheet" />
 
    <script>
        document.onkeydown = null;

        $(document).ready(function () {

            var selectedTab = $("#<%=hidtab.ClientID%>");
            var tabId = selectedTab.val() != "" ? selectedTab.val() : "tab1";
            $('#TabName a[href="#' + tabId + '"]').tab('show');
            $("#TabName a").click(function () {
                selectedTab.val($(this).attr("href").substring(1));
            });
        });

        //Start Added by shubham k on 24-Jun-2021 for UBP
        document.onkeyup = function (e) {
            if (e.ctrlKey && e.key == "r") {
                document.getElementById('<%= btnLoad.ClientID %>').click();
            } else if (e.ctrlKey && e.shiftKey && e.key == "E") {
                document.getElementById('<%= btnExport.ClientID %>').click();
            }
        }
        //End Added by shubham k on 24-Jun-2021 for UBP
    </script>

    <style>
        .TextAreaClass {
            width: 98% !important;
            margin-top: 10px !important;
        }

        .RadioButtonListClass {
            width: 800px !important;
            margin-top: 10px !important;
            text-align: center;
        }

        a {
            color: #000;
            text-decoration: none;
        }

        /*Start Added by shubham k on 24-Jun-2021 for UBP*/
        .btn_padding {
            padding-right: 10px !important;
            padding-top: 5px !important;
        }
        /*End Added by shubham k on 24-Jun-2021 for UBP*/
    </style>
    <asp:ScriptManagerProxy ID="ScriptManagerProxy11" runat="server">
    </asp:ScriptManagerProxy>
    <div id="TabName" role="tabpanel">
        <ul class="nav nav-tabs" role="tablist">
            <li class="nav-item active">
                <a href="#tab1" aria-controls="tab1" role="tab" data-toggle="tab">SQL</a>
            </li>
            <li class="nav-item">
                <a href="#tab2" aria-controls="tab2" role="tab" data-toggle="tab">LOG</a>
            </li>
            <li class="nav-item">
                <a href="#tab3" aria-controls="tab3" role="tab" data-toggle="tab">SERVICE</a>
            </li>
        </ul>
        <div class="tab-content">
            <div role="tabpanel" class="tab-pane active" id="tab1" style="padding: 5px">
                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <div style="overflow-x: auto; width: 100%;">
                            <table>
                                <tr>
                                    <td colspan="2">
                                        <%--Start Jira:-UBPINT-1153 Start Added by shubham k on 24-Jun-2021 for UBP--%>
                                        <table>
                                            <tr>

                                                <td style="width: 190px" class="btn_padding">
                                                    <asp:DropDownList ID="drpDatabases" runat="server" AutoPostBack="false" Style="height: 30px; width: 180px" OnSelectedIndexChanged="drpDatabases_SelectedIndexChanged"></asp:DropDownList>
                                                </td>
                                                <td class="btn_padding">
                                                    <asp:Button ID="btnLoad" Text="Execute" CssClass="btn" runat="server" ToolTip="Execute (ctrl + r)" OnClick="btnLoad_Click" />
                                                </td>
                                                <td class="btn_padding">
                                                    <asp:Button ID="btnExport" CssClass="Export2Excel" Text="" ToolTip="Export Excel (ctrl + shift + e)" runat="server" />
                                                </td>
                                                <td>
                                                    <asp:Button ID="btnLoadTemplateOrig" runat="server" CssClass="btn" Text="LoadTemplateOrig" Enabled="true" Style="display: none;" />
                                                </td>
                                                <td class="btn_padding">
                                                    <asp:Label ID="lblPageSize" runat="server" Text="Record(s) per page:"></asp:Label>
                                                    <asp:TextBox ID="txtPageSize" Style="text-align: center; width: 40px;" runat="server" Text="" MaxLength="2" OnTextChanged="txtPageSize_TextChanged"></asp:TextBox>
                                                </td>
                                            </tr>
                                        </table>
                                        <%--End Jira:-UBPINT-1153 Start Added by shubham k on 24-Jun-2021 for UBP--%>
                                    </td>

                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:Label ID="lblError" runat="server" Text=""></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <asp:TextBox ID="txtSQL" runat="server" TextMode="MultiLine" Rows="10" Columns="300" Wrap="true" CssClass="TextAreaClass" Text="SELECT * FROM "></asp:TextBox>
                                        <cc1:AutoCompleteExtender ServiceMethod="SearchWords" MinimumPrefixLength="14" CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
                                            TargetControlID="txtSQL" ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false">
                                        </cc1:AutoCompleteExtender>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <br />
                        <div id="gridDiv" style="overflow-x: auto; width: 100%; height: 600px;">
                            <asp:GridView ID="grdData" runat="server" OnRowDataBound="grdData_RowDataBound" CssClass="Grid" ShowHeaderWhenEmpty="true"
                                SelectedRowStyle-CssClass="GridItemSelect" AlternatingRowStyle-CssClass="AlternatItemStyle" EmptyDataText="No Data found."
                                HeaderStyle-CssClass="GridHeaderTitle" AllowPaging="true" PageSize="10" OnPageIndexChanging="grdData_PageIndexChanging">
                                <Columns>
                                    <asp:TemplateField HeaderText="" ItemStyle-Width="100">
                                        <ItemTemplate>
                                            <asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </ContentTemplate>
                    <Triggers>
                        <asp:PostBackTrigger ControlID="btnLoadTemplateOrig" />
                    </Triggers>
                </asp:UpdatePanel>
            </div>
            <div role="tabpanel" class="tab-pane" id="tab2" style="padding: 5px">
                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                        <table>
                            <tr>
                                <td>
                                    <asp:RadioButtonList ID="rblLogType" runat="server" RepeatDirection="Horizontal" CssClass="RadioButtonListClass"
                                        OnSelectedIndexChanged="rblLogType_SelectedIndexChanged" AutoPostBack="true">
                                        <asp:ListItem Value="ERROR" Selected="True">Webapp Error</asp:ListItem>
                                        <asp:ListItem Value="DEBUG">Webapp Debug</asp:ListItem>
                                        <asp:ListItem Value="INFO">Webapp Info</asp:ListItem>
                                        <asp:ListItem Value="SERVICE">Service Log</asp:ListItem>
                                        <asp:ListItem Value="SQL">SQL Log</asp:ListItem>
                                        <asp:ListItem Value="SIGNALR">Signal R Log</asp:ListItem>
                                        <asp:ListItem Value="UCP">UCP Log</asp:ListItem>
                                        <asp:ListItem Value="FIX">FIX Log</asp:ListItem>
                                        <asp:ListItem Value="STP">STP Log</asp:ListItem>
                                    </asp:RadioButtonList>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblLogError" runat="server" Text=""></asp:Label></td>
                            </tr>
                        </table>
                        <br />
                        <div id="divLogs" style="overflow-x: auto; width: 100%; height: 98% !important;">
                            <asp:GridView ID="grdLogs" runat="server" OnRowDataBound="grdData_RowDataBound" CssClass="Grid" AutoGenerateColumns="false"
                                SelectedRowStyle-CssClass="GridItemSelect" AlternatingRowStyle-CssClass="AlternatItemStyle" EmptyDataText="No Data found." Width="800"
                                HeaderStyle-CssClass="GridHeaderTitle" AllowPaging="true" PageSize="20" OnPageIndexChanging="grdLogs_PageIndexChanging" ShowHeaderWhenEmpty="true">
                                <Columns>
                                    <asp:TemplateField HeaderText="S.N." ItemStyle-Width="100">
                                        <ItemTemplate>
                                            <asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Name" ItemStyle-Width="300">
                                        <ItemTemplate>
                                            <asp:Label Text='<%# Eval("Name")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="File Size (KB)" ItemStyle-Width="100">
                                        <ItemTemplate>
                                            <asp:Label Text='<%# Eval("FileSize")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Last Access Time" ItemStyle-Width="200">
                                        <ItemTemplate>
                                            <asp:Label Text='<%# Eval("LastAccessTime")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Download">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="hidFilePath" runat="server" Value='<%#Eval("Download")%>' />
                                            <asp:Button runat="server" ID="btnDownLoad" CssClass="btn" Text="DownLoad" OnClick="DownloadFile" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
            <div role="tabpanel" class="tab-pane" id="tab3" style="padding: 5px">
                <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                    <ContentTemplate>
                        <table>
                            <tr>
                                <td>
                                    <asp:Button ID="btnLoadService" Text="Load Services" CssClass="btn" runat="server" OnClick="btnLoadService_Click" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <asp:Label ID="lblMsgService" runat="server" Text=""></asp:Label></td>
                            </tr>
                        </table>
                        <br />
                        <div id="divService" style="overflow-x: auto; width: 100%; height: 98% !important;">
                            <asp:GridView ID="grdServices" runat="server" CssClass="Grid" AutoGenerateColumns="false" EmptyDataText="No Data found." Width="800"
                                SelectedRowStyle-CssClass="GridItemSelect" AlternatingRowStyle-CssClass="AlternatItemStyle" ShowHeaderWhenEmpty="true"
                                HeaderStyle-CssClass="GridHeaderTitle" AllowPaging="true" PageSize="20" OnPageIndexChanging="grdServices_PageIndexChanging">
                                <Columns>
                                    <asp:TemplateField HeaderText="S.N." ItemStyle-Width="100">
                                        <ItemTemplate>
                                            <asp:Label ID="lblRowNumber" Text='<%# Container.DataItemIndex + 1 %>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Name" ItemStyle-Width="300">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" Text='<%# Eval("Name")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status" ItemStyle-Width="100">
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" Text='<%# Eval("Status")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Startup Type" ItemStyle-Width="200">
                                        <ItemTemplate>
                                            <asp:Label ID="Label3" Text='<%# Eval("StartupType")%>' runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Start">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="hidStartService" runat="server" Value='<%#Eval("Name")%>' />
                                            <asp:Button runat="server" ID="btnStart" Width="80" CssClass="btn" Text="Start" OnClick="StartService" Enabled='<%# If(Eval("btnStatus").ToString() = "Y", True, False)%>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Stop">
                                        <ItemTemplate>
                                            <asp:HiddenField ID="hidStopService" runat="server" Value='<%#Eval("Name")%>' />
                                            <asp:Button runat="server" ID="btnStop" Width="80" CssClass="btn" Text="Stop" OnClick="StopService" Enabled='<%# If(Eval("btnStatus").ToString() = "Y", True, False)%>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                        </div>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </div>
    </div>
    <asp:HiddenField ID="hidtab" Value="0" runat="server" />
</asp:Content>

