<%@ Page Title="Licensing" Language="C#" MasterPageFile="~/2ColMaster.Master" AutoEventWireup="true" CodeBehind="Licensing.aspx.cs" Inherits="ProcessDefinition.SiteAdmin.Licensing" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="server">

<asp:ObjectDataSource ID="odsLicenses" runat="server"
    OldValuesParameterFormatString="original_{0}" SelectMethod="GetLicenses"
    TypeName="DevProcess.ProcessDefinitionService.ProcessDefinitionManager">
</asp:ObjectDataSource>
    
<asp:ListView ID="listLicenses" runat="server" ItemPlaceholderID="itemList"
        EnableViewState="False" DataSourceID="odsLicenses" >

    <LayoutTemplate>
    <h2>Installed Licenses</h2>
    <ul class="projSumAssign">
        <asp:PlaceHolder id="itemList" runat="server"/>
    </ul>
    </LayoutTemplate>

    <ItemTemplate>
    <li>
    
    <%#DevProcess.Common.Utils.StringHelper.Format("<b>{0}</b>, {1} {2} licenses. Expires {3:shortdate}{4}.", Eval("Info"), GetLicenseFeature(Eval("Feature")), Eval("Count"), Eval("ValidTo"), GetLicenseDefault(Eval("IsDefault")))%>

    </li>
    </ItemTemplate>

    <EmptyDataTemplate>
        <p>You do not have any licenses installed.</p>
    </EmptyDataTemplate>
</asp:ListView>

<asp:Label runat="server" ID="Label5" Text="Set default license:" />
<asp:DropDownList runat="server" ID="ddDefaultLicense" />

<asp:Button runat="server" ID="btnSetDefault" Text="Set Default" OnClick="btnSetDefault_Click" /><br />

<h2>License User Assignment</h2>

<p class="hBlurb ui-state-highlight">Select the users from the table below and assign them a license by choosing the correct license and pressing the assign button.</p>


<asp:ObjectDataSource ID="odsLicensedUsers" runat="server"
    OldValuesParameterFormatString="original_{0}" SelectMethod="GetLicensedUsers"
    TypeName="DevProcess.ProcessDefinitionService.ProcessDefinitionManager">
</asp:ObjectDataSource>


<dp:DpGridView ID="gvUsersSel" CheckSelectAll="true" runat="server" AutoGenerateColumns="False" AllowGroupedSorting="False" 
    DoneSorting="False" RowHighlightCssClass="" SortImageAscending="" SortImageDescending=""
    SortType="Ascending" SortElement="DisplayName" 
    DataSourceID="odsLicensedUsers" DataKeyNames="UserId" EmptyDataText="You have not added any users to any process libraries yet.">
    <Columns>
        <asp:TemplateField ShowHeader="false">
            <ItemTemplate>
                <asp:CheckBox ID="chkSelected" runat="server" />
            </ItemTemplate>
        </asp:TemplateField>
        
        <dp:TextBoxFilterBoundField DataField="DisplayName" HeaderText="Name" SortExpression="DisplayName" Columns="10" FilterExpression="DisplayName"
            FilterMatchAnyPart="true" />
        
        <dp:TextBoxFilterBoundField DataField="MemberEmailAddress" HeaderText="Email" SortExpression="MemberEmailAddress" Columns="20" FilterExpression="MemberEmailAddress" 
            FilterMatchAnyPart="true" />
        
        <dp:DropDownFilterBoundField DataField="Info" HeaderText="License" SortExpression="Info" FilterExpression="Info" />
        
        <dp:DateBoundField DataField="ValidTo" HeaderText="Expiry" SortExpression="ValidTo" CustomFormatString="{0:shortdate}"  />


        <dp:DropDownFilterBoundField DataField="CurrentLicenseInfo" HeaderText="Current Session" SortExpression="CurrentLicenseInfo" FilterExpression="CurrentLicenseInfo" />
        
        <dp:DateBoundField DataField="CurrentLicenseExpiry" HeaderText="Current Session Expiry" SortExpression="CurrentLicenseExpiry" />


    </Columns>
</dp:DpGridView>

<asp:Label runat="server" ID="lblAssignLicense" Text="Assign license:" />
<asp:DropDownList runat="server" ID="ddAssignLicense" 
        ondatabound="ddAssignLicense_DataBound"  />

<asp:Button runat="server" ID="btnAssignLicense" Text="Assign" OnClick="btnAssignLicense_Click" />
    <dp:ConfirmButton runat="server" ID="btnRemoveUsers" Text="Delete user accounts" OnClick="btnRemoveUsers_Click" ConfirmTitle="Delete user accounts" ConfirmMessage="Are you sure you want to delete the selected user accounts from all repositories?" /><br />
<dp:DpGridViewToCsv runat="server" ID="btnDownloadCsv" OutputFilename="Licenses.csv" Text="Download" CausesValidation="false" SkipFirstColumn="true"  />



    <asp:Panel runat="server" ID="pnlRequestLicense">
    
        
            <h2>Request License</h2>
                <p class="hBlurb ui-state-highlight">Complete the fields below then press the request license button.  Email the license request output to 'license@atego.com' with the subject 'PTC Integrity Process Director License Request' to receive a license key.</p>
            
            
            <asp:Label ID="lblInfo" runat="server" Text="Company name:" AssociatedControlID="txtInfo" />
            <asp:TextBox ID="txtInfo" runat="server" Columns="80" />
            <br />

            <asp:Label ID="Label2" runat="server" Text="Feature:" AssociatedControlID="ddFeature" />
            <asp:DropDownList  ID="ddFeature" runat="server">
                <asp:ListItem Text="PTC Integrity Process Director" Value="0x100" />
                <asp:ListItem Text="PTC Integrity Process Consumer" Value="0x110" />
                <asp:ListItem Text="PTC Integrity Process Director API" Value="0x150" />            
            </asp:DropDownList>
            
            <br />

            <asp:Label ID="Label1" runat="server" Text="License count:" AssociatedControlID="txtCount" />
            <dp:IntTextBox ID="txtCount" runat="server" Columns="10" ValidationGroup="Request" />
            <br />

            <asp:Panel runat="server" ID="pnlLicenseRequest" Visible="false">
            <asp:Label ID="Label3" runat="server" Text="License request:" AssociatedControlID="txtYourRequest" />
            <asp:TextBox runat="server" ID="txtYourRequest" TextMode="MultiLine" Rows="5" Columns="80" ReadOnly="true" />    
            </asp:Panel>
            <br />
            
            <asp:Button ID="btnGenerateRequest" runat="server" Text="Generate Request" CssClass="dpButton"
                OnClick="btnGenerateRequest_Click" ValidationGroup="Request" />
                
            <br />
            <h2>Add New License</h2>
                <p class="hBlurb ui-state-highlight">Enter the request license key response in the text area below then press the add license button.</p>
            
            <asp:Label ID="Label4" runat="server" Text="License response:" AssociatedControlID="txtAddLicense" />
            <asp:TextBox runat="server" ID="txtAddLicense" TextMode="MultiLine" Rows="5" Columns="80"  />    
            <br />
            
            <asp:Button ID="btnAddLicense" runat="server" Text="Add License" CssClass="dpButton" OnClick="btnAddLicense_Click" CausesValidation="false" />
            <asp:Label runat="server" ID="lblAddResult" />
            
    
    </asp:Panel>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentOptions" runat="server">
    <ul class='ui-widget-content'>
        <li class="btn"><span class="ui-icon ui-icon-arrowreturnthick-1-w"></span><a href="..">
            Back to libraries</a></li>
    </ul>
    
   <ul class='ui-widget-content ui-corner-all'>
        <li class="btn"><span class="ui-icon ui-icon-note"></span><a href="../Admin/Report/LicenseUsage">License Usage</a></li>
    </ul>
 
</asp:Content>
