<%@ Page Language="c#" CodeBehind="List.aspx.cs" AutoEventWireup="True" Inherits="eDocument.Server.Administrator.AbortedProcessListItem.List" MasterPageFile="~/Site.Master" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">

<%--    <p class="mb-4">
        Denne siden viser deg de avbrutte prosess-instansene for en prosess. 
        Du kan gjenoppta, restarte og kansellere en avbrutt prosess-instans.
    </p>--%>

    <asp:DataGrid 
        ID="dgAbortedProcess" 
        runat="server" 
        OnItemDataBound="dgAbortedProcess_OnItemDataBound" 
        CssClass="skjema-admin__table"
        Border="0"
        AutoGenerateColumns="False">

        <Columns>
            <asp:BoundColumn Visible="False" DataField="AbortedProcessID"></asp:BoundColumn>
            <asp:BoundColumn Visible="False" DataField="eDocumentInstanceID"></asp:BoundColumn>
            <asp:BoundColumn Visible="False" DataField="eDocumentInstanceID"></asp:BoundColumn>
            <asp:BoundColumn Visible="False" DataField="SubscriptionID"></asp:BoundColumn>
            <asp:BoundColumn Visible="False" DataField="eDocumentTemplateID"></asp:BoundColumn>
            <asp:HyperLinkColumn DataTextField="eDocumentTemplateName" HeaderText="Skjema" DataNavigateUrlField="DetailsUrl" DataNavigateUrlFormatString="{0}" />
            <asp:BoundColumn Visible="True" DataField="eDocumentTemplateVersionVersion" HeaderText="Versjon"></asp:BoundColumn>
            <asp:BoundColumn Visible="True" DataField="EventLogItemDescription" HeaderText="Feilmelding"></asp:BoundColumn>
            <asp:BoundColumn Visible="True" DataField="eDocumentInstanceCreatedOn" HeaderText="Opprettet"></asp:BoundColumn>
            <asp:BoundColumn Visible="True" DataField="eDocumentInstanceSubmittedOn" HeaderText="Innsendt"></asp:BoundColumn>
            <asp:BoundColumn Visible="True" DataField="AbortedProcessAbortedOn" HeaderText="Avbrutt"></asp:BoundColumn>
            <asp:BoundColumn Visible="True" DataField="eDocumentInstanceReferenceNumber" HeaderText="Referansenummer"></asp:BoundColumn>
            <asp:HyperLinkColumn Visible="False" DataTextField="ConsumerName" HeaderText="Kundenavn" DataNavigateUrlField="AbortedProcessInvokerConsumerID" DataNavigateUrlFormatString="../Consumer/Update.aspx?ConsumerID={0}" />
            <asp:BoundColumn Visible="True" DataField="EventLogItemStackTrace" HeaderText="Stacktrace"></asp:BoundColumn>
            <asp:ButtonColumn Text="Gjenoppta" CommandName="Resume"></asp:ButtonColumn>
            <asp:ButtonColumn Text="Restart" CommandName="Restart"></asp:ButtonColumn>
            <asp:ButtonColumn Text="Kanseler" CommandName="Cancel"></asp:ButtonColumn>
            <asp:ButtonColumn Text="Kanseler og kjør isteden..." CommandName="CancelAndExecuteOther"></asp:ButtonColumn>

            <asp:TemplateColumn HeaderText="" Visible="False">
                <ItemTemplate>
                    <asp:HyperLink Target="_blank" ID="lnkShowXml" runat="server" Text='Vis XML' NavigateUrl='<%# "~/eDocumentInstance/DownloadXmlResponse.aspx?eDocumentInstanceID=" + DataBinder.Eval(Container.DataItem, "eDocumentInstanceID") + "&SubscriberConsumerID=" + DataBinder.Eval(Container.DataItem, "AbortedProcessInvokerConsumerID") %>' />
                </ItemTemplate>
            </asp:TemplateColumn>

            <asp:TemplateColumn HeaderText="" Visible="False">
                <ItemTemplate>
                    <asp:HyperLink Target="_blank" ID="lnkShowTransformedXml" runat="server" Text='Vis trans. XML' NavigateUrl='<%# "~/eDocumentInstance/DownloadTransformedXmlResponse.aspx?eDocumentInstanceID=" + DataBinder.Eval(Container.DataItem, "eDocumentInstanceID") + "&SubscriberConsumerID=" + DataBinder.Eval(Container.DataItem, "AbortedProcessInvokerConsumerID") + "&ProcessID=" + DataBinder.Eval(Container.DataItem, "ProcessID") %>' />
                </ItemTemplate>
            </asp:TemplateColumn>

            <asp:HyperLinkColumn Visible="False" Target="_blank" DataNavigateUrlFormatString="~/eDocumentInstance/DownloadPdfResponse.aspx?eDocumentInstanceID={0}"
                DataNavigateUrlField="eDocumentInstanceID" Text="Vis PDF" />
        </Columns>
    </asp:DataGrid>

    <div class="mb-5">
        <asp:Button 
            ID="btnRefresh" 
            CssClass="skjema-admin__button skjema-admin__button--primary"
            runat="server" 
            Text="Oppdater" 
            OnClick="btnRefresh_Click">
        </asp:Button>
    </div>
   
    <h2 class="skjema-admin__section-title">
        Oppgaver
    </h2>

    <div class="mb-4">
        <asp:Button 
            ID="btnResumeAll" 
            CssClass="skjema-admin__button skjema-admin__button--primary mr-2"
            runat="server" 
            Text="Gjenoppta alle" 
            OnClick="btnResumeAll_Click">
        </asp:Button>

        <asp:Button 
            ID="btnRestartAll" 
            CssClass="skjema-admin__button skjema-admin__button--primary mr-2"
            runat="server" 
            Text="Restart alle" 
            OnClick="btnRestartAll_Click">
        </asp:Button>

        <asp:Button 
            ID="btnCancelAll" 
            CssClass="skjema-admin__button mr-2"
            runat="server" 
            Text="Kanseler alle" 
            OnClick="btnCancelAll_Click">
        </asp:Button>

        <asp:Button 
            ID="btnCancelAndExecuteOtherForAll" 
            CssClass="skjema-admin__button"
            runat="server" 
            Text="Kanseler og kjør isteden for alle..." 
            OnClick="btnCancelAndExecuteOtherForAll_Click">
        </asp:Button>
    </div>
   
    <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>
</asp:Content>
