OBJECT Table 50060 Interface Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:42:17;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Interface Setup;
  }
  FIELDS
  {
    { 1   ;   ;Interface Name      ;Text200       ;CaptionML=ENU=Interface Name;
                                                   Editable=No }
    { 2   ;   ;Module Name         ;Text200       ;CaptionML=ENU=Module Name }
    { 3   ;   ;Configuration Page ID;Integer       }
  }
  KEYS
  {
    {    ;Interface Name                          ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    PROCEDURE RegisterInterface@3(InterfaceName@1000 : Text);
    VAR
      Setup@1001 : Record 50060;
    BEGIN
      Setup."Interface Name" := InterfaceName;
      IF Setup.FIND THEN
        EXIT
      ELSE
        Setup.INSERT;
    END;

    [Integration]
    PROCEDURE OnRegisterInterface@1(InterfaceSetup@1000 : Record 50060);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Table 50061 Interface Module
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:46:14;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Interface Setup;
  }
  FIELDS
  {
    { 1   ;   ;Interface Name      ;Text200       ;CaptionML=ENU=Interface Name }
    { 2   ;   ;Module Name         ;Text200       ;CaptionML=ENU=Module Name }
    { 3   ;   ;Configuration Page ID;Integer       }
  }
  KEYS
  {
    {    ;Interface Name,Module Name              ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    PROCEDURE RegisterModule@2(InterfaceName@1000 : Text;ModuleName@1001 : Text;PageID@1002 : Integer);
    BEGIN
      "Interface Name" := InterfaceName;
      "Module Name" := ModuleName;
      "Configuration Page ID" := PageID;
      IF NOT FIND THEN
        INSERT;
    END;

    [Integration]
    PROCEDURE OnRegisterModule@4(InterfaceName@1001 : Text;VAR InterfaceModule@1000 : Record 50061);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Table 50082 Event Log - File Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:52:28;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Event Log - File Setup;
  }
  FIELDS
  {
    { 1   ;   ;Primary Key         ;Code10        ;CaptionML=ENU=Primary Key }
    { 2   ;   ;Log File Path       ;Text250       ;CaptionML=ENU=Log File Path }
  }
  KEYS
  {
    {    ;Primary Key                             ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Table 50084 Event Log - Twitter Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:13:04;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    CaptionML=ENU=Event Log - Twitter Setup;
  }
  FIELDS
  {
    { 1   ;   ;Primary Key         ;Code10        ;CaptionML=ENU=Primary Key }
    { 2   ;   ;Consumer Key        ;Text200       ;CaptionML=ENU=Consumer Key }
    { 3   ;   ;Consumer Key Secret ;Text200       ;ExtendedDatatype=Masked;
                                                   CaptionML=ENU=Consumer Key Secret }
    { 4   ;   ;Access Token        ;Text200       ;CaptionML=ENU=Access Token }
    { 5   ;   ;Access Token Secret ;Text200       ;ExtendedDatatype=Masked;
                                                   CaptionML=ENU=Access Token Secret }
  }
  KEYS
  {
    {    ;Primary Key                             ;Clustered=Yes }
  }
  FIELDGROUPS
  {
  }
  CODE
  {

    BEGIN
    END.
  }
}

OBJECT Codeunit 50060 Module Management
{
  OBJECT-PROPERTIES
  {
    Date=14.10.16;
    Time=18:43:59;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ErrorManualSubscription@1000 : TextConst 'ENU=Event subscriptions to codeunit %1 must be manual. At least one codeunit (%2 %3) was detected with static subscription. Codeunit %1 does not allow static subscriptions.';
      ErrorNoSubscriber@1001 : TextConst 'ENU=There is no event subscriber currently listening on the %1 event from codeunit %2.';
      ErrorNoSetup@1002 : TextConst 'ENU=Interface %1 is not configured with a module that implements it. Please run the %2 page.';

    PROCEDURE BindInterface@6(InterfaceName@1000 : Text;WithError@1002 : Boolean);
    VAR
      Setup@1001 : Record 50060;
      SetupPage@1003 : Page 50060;
      Notification@1004 : Notification;
    BEGIN
      IF NOT Setup.GET(InterfaceName) THEN BEGIN
        IF WithError THEN
          ERROR(ErrorNoSetup,InterfaceName,SetupPage.CAPTION);
        MESSAGE(ErrorNoSetup,InterfaceName,SetupPage.CAPTION);
        EXIT;
      END;

      OnBindModule(InterfaceName,Setup."Module Name");
    END;

    PROCEDURE UnbindInterface@7(InterfaceName@1000 : Text);
    VAR
      Setup@1001 : Record 50060;
    BEGIN
      IF NOT Setup.GET(InterfaceName) THEN
        EXIT;

      OnUnbindModule(InterfaceName,Setup."Module Name");
    END;

    [TryFunction]
    PROCEDURE MakeSureSubscriptionsAreManual@4(CodeunitID@1000 : Integer);
    VAR
      Subscription@1001 : Record 2000000140;
      AllObj@1002 : Record 2000000058;
    BEGIN
      WITH Subscription DO BEGIN
        SETRANGE("Publisher Object Type","Publisher Object Type"::Codeunit);
        SETRANGE("Publisher Object ID",CodeunitID);
        SETRANGE("Subscriber Instance",'Static-Automatic');
        IF FINDFIRST THEN BEGIN
          AllObj.GET(AllObj."Object Type"::Codeunit,"Subscriber Codeunit ID");
          ERROR(ErrorManualSubscription,CodeunitID,"Subscriber Codeunit ID",AllObj."Object Caption");
        END;
      END;
    END;

    [TryFunction]
    PROCEDURE MakeSureSubscriberExists@5(CodeunitID@1002 : Integer;FunctionName@1003 : Text);
    VAR
      Subscription@1001 : Record 2000000140;
    BEGIN
      WITH Subscription DO BEGIN
        SETRANGE("Publisher Object Type","Publisher Object Type"::Codeunit);
        SETRANGE("Publisher Object ID",CodeunitID);
        SETRANGE("Published Function",FunctionName);
        SETRANGE("Subscriber Instance",'Manual');
        SETRANGE(Active,TRUE);
        SETFILTER("Active Manual Instances",'>=%1',1);
        IF ISEMPTY THEN
          ERROR(ErrorNoSubscriber,FunctionName,CodeunitID);
      END;
    END;

    [Integration]
    PROCEDURE OnBindModule@1(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
    END;

    [Integration]
    PROCEDURE OnUnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50070 Event Log Interface
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:28:28];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Event Logging';

    PROCEDURE LogEvent@2(VAR EventLogArgs@1000 : Record 50010);
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Event Log Interface",'OnLogEvent') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnLogEvent(EventLogArgs);
    END;

    [Integration]
    PROCEDURE OnLogEvent@5(VAR EventLogArgs@1003 : Record 50010);
    BEGIN
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Event Log Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50072 Address Formatter Interface
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=22:48:34;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Address Formatter';

    PROCEDURE FormatAddress@2();
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Address Formatter Interface",'OnFormatAddress') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnFormatAddress();
    END;

    [Integration]
    PROCEDURE OnFormatAddress@5();
    BEGIN
      // This is just for demonstration purposes, and intentionally does nothing.
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Address Formatter Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50073 Currency Exchange Interface
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=22:49:50;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Currency Exchange';

    PROCEDURE ExchangeCurrency@2();
    BEGIN
      IF NOT ModuleMgt.MakeSureSubscriberExists(CODEUNIT::"Currency Exchange Interface",'OnExchangeCurrency') THEN BEGIN
        MESSAGE(GETLASTERRORTEXT);
        EXIT;
      END;

      OnExchangeCurrency();
    END;

    [Integration]
    PROCEDURE OnExchangeCurrency@5();
    BEGIN
      // This is just for demonstration purposes, and intentionally does nothing.
    END;

    [EventSubscriber(Codeunit,1,OnAfterCompanyOpen)]
    LOCAL PROCEDURE OnCompanyOpen@1();
    BEGIN
      ModuleMgt.MakeSureSubscriptionsAreManual(CODEUNIT::"Currency Exchange Interface");
    END;

    [EventSubscriber(Table,50060,OnRegisterInterface)]
    LOCAL PROCEDURE OnRegisterInterface@3(InterfaceSetup@1000 : Record 50060);
    BEGIN
      InterfaceSetup.RegisterInterface(InterfaceName);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50080 Event Log Binder - Windows
{
  OBJECT-PROPERTIES
  {
    Date=14.10.16;
    Time=18:53:34;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50081;
      Name@1001 : TextConst 'ENU=Windows Event Log';
      ImplementsInterface@1003 : TextConst 'ENU=Event Logging';
      Bound@1002 : Boolean;

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
      Bound := TRUE;
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      IF Bound THEN
        UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
      Bound := FALSE;
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,0);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50081 Event Log - Windows
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:21:52];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@2(VAR EventLogArgs@1007 : Record 50010);
    VAR
      EventLog@1003 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLog";
      EntryType@1004 : DotNet "'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Diagnostics.EventLogEntryType";
      EventEntryText@1006 : TextConst 'ENU=Source: %1\Message: %2';
      EventLogSource@1005 : TextConst 'ENU=MicrosoftDynamicsNavServer';
    BEGIN
      EntryType := EntryType.Information;

      CASE EventLogArgs.Type OF
        EventLogArgs.Type::Warning: EntryType := EntryType.Warning;
        EventLogArgs.Type::Error:   EntryType := EntryType.Error;
      END;
      EventLog := EventLog.EventLog();
      EventLog.WriteEntry(
        EventLogSource,
        GetLogMessage(STRSUBSTNO(EventEntryText,EventLogArgs.Source,EventLogArgs.Message)),
        EntryType);
    END;

    LOCAL PROCEDURE GetLogMessage@18(Text@1000 : Text) : Text;
    VAR
      Env@1001 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      String@1002 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.String";
    BEGIN
      String := Text;
      EXIT(String.Replace('\',Env.NewLine));
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50082 Event Log Binder - File
{
  OBJECT-PROPERTIES
  {
    Date=14.10.16;
    Time=18:53:12;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50083;
      Name@1001 : TextConst 'ENU=File System Event Log';
      ImplementsInterface@1002 : TextConst 'ENU=Event Logging';
      Bound@1003 : Boolean;

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
      Bound := TRUE;
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      IF Bound THEN
        UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
      Bound := FALSE;
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,PAGE::"Event Log - File Setup");
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50083 Event Log - File
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:22:41];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@2(VAR EventLogArgs@1007 : Record 50010);
    VAR
      Setup@1003 : Record 50082;
      File@1004 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
      Environment@1005 : DotNet "'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Environment";
      EntryLine@1006 : TextConst 'ENU=%1 %2 %3%4';
    BEGIN
      IF NOT Setup.GET OR (Setup."Log File Path" = '') THEN
        EXIT;

      File.AppendAllText(
        Setup."Log File Path",
        STRSUBSTNO(
          EntryLine,
          CURRENTDATETIME,
          PADSTR(EventLogArgs.Source,20),
          EventLogArgs.Message,
          Environment.NewLine));
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50084 Event Log Binder - Twitter
{
  OBJECT-PROPERTIES
  {
    Date=14.10.16;
    Time=18:53:56;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SingleInstance=Yes;
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      Module@1000 : Codeunit 50085;
      Name@1001 : TextConst 'ENU=Twitter Event Log';
      ImplementsInterface@1002 : TextConst 'ENU=Event Logging';
      Bound@1003 : Boolean;

    [EventSubscriber(Codeunit,50060,OnBindModule)]
    LOCAL PROCEDURE BindModule@1(InterfaceName@1002 : Text;ModuleName@1001 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      CLEAR(Module);
      BINDSUBSCRIPTION(Module);
      Bound := TRUE;
    END;

    [EventSubscriber(Codeunit,50060,OnUnbindModule)]
    LOCAL PROCEDURE UnbindModule@2(InterfaceName@1001 : Text;ModuleName@1000 : Text);
    BEGIN
      IF (ModuleName <> Name) OR (InterfaceName <> ImplementsInterface) THEN
        EXIT;

      IF Bound THEN
        UNBINDSUBSCRIPTION(Module);
      CLEAR(Module);
      Bound := FALSE;
    END;

    [EventSubscriber(Table,50061,OnRegisterModule)]
    LOCAL PROCEDURE OnRegisterModule@3(InterfaceName@1000 : Text;VAR InterfaceModule@1001 : Record 50061);
    BEGIN
      IF InterfaceName = ImplementsInterface THEN
        InterfaceModule.RegisterModule(InterfaceName,Name,PAGE::"Event Log - Twitter Setup");
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50085 Event Log - Twitter
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:23:26];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    EventSubscriberInstance=Manual;
    OnRun=BEGIN
          END;

  }
  CODE
  {

    [EventSubscriber(Codeunit,50070,OnLogEvent)]
    LOCAL PROCEDURE LogEvent@1(VAR EventLogArgs@1004 : Record 50010);
    VAR
      Setup@1005 : Record 50084;
      Twitter@1003 : DotNet "'Twitter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.Twitter.TwitterApi";
    BEGIN
      IF (NOT Setup.GET) OR (Setup."Consumer Key" = '') OR (Setup."Consumer Key Secret" = '')
        OR (Setup."Access Token" = '') OR (Setup."Access Token Secret" = '')
      THEN
        EXIT;

      Twitter := Twitter.TwitterApi(
        Setup."Consumer Key",
        Setup."Consumer Key Secret",
        Setup."Access Token",
        Setup."Access Token Secret");

      Twitter.Tweet(
        GetEventMessage(
          EventLogArgs.Type,
          EventLogArgs.Source,
          EventLogArgs.Message));
    END;

    LOCAL PROCEDURE GetEventMessage@5(EventType@1002 : 'Info,Warning,Error';EventSource@1001 : Text;EventMessage@1000 : Text) : Text;
    VAR
      HashTags@1003 : Text;
    BEGIN
      HashTags := GetHashTags(EventType,EventSource);
      EXIT(COPYSTR(EventMessage,1,139 - STRLEN(HashTags)) + ' ' + HashTags);
    END;

    LOCAL PROCEDURE GetHashTags@2(EventType@1001 : 'Info,Warning,Error';EventSource@1000 : Text) HashTags : Text;
    VAR
      HashTagsText@1002 : TextConst 'ENU=#FromNAV #Demo #%1';
    BEGIN
      HashTags := STRSUBSTNO(HashTagsText,EventSource);
      IF EventType <> EventType::Info THEN
        HashTags += STRSUBSTNO(' #%1',EventType);
    END;

    BEGIN
    END.
  }
}

OBJECT Codeunit 50099 Event Log Customizations
{
  OBJECT-PROPERTIES
  {
    Date=27.09.16;
    Time=[ 3:20:28];
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    OnRun=BEGIN
          END;

  }
  CODE
  {
    VAR
      ModuleMgt@1000 : Codeunit 50060;
      InterfaceName@1001 : TextConst 'ENU=Event Logging';
      Log@1002 : Codeunit 50070;
      SourceSales@1003 : TextConst 'ENU=Sales';
      EventReleased@1004 : TextConst 'ENU=Sales %1 %2 has just been released.';
      EventReopened@1005 : TextConst 'ENU=Sales %1 %2 has just been reopened.';

    [EventSubscriber(Page,42,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrder_Open@2(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,42,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrder_Close@3(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Page,9305,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrderList_Open@4(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,9305,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrderList_Close@1(VAR Rec@1000 : Record 36);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Page,48,OnOpenPageEvent)]
    LOCAL PROCEDURE SalesOrders_Open@8(VAR Rec@1000 : Record 37);
    BEGIN
      ModuleMgt.BindInterface(InterfaceName,FALSE);
    END;

    [EventSubscriber(Page,48,OnClosePageEvent)]
    LOCAL PROCEDURE SalesOrders_Close@7(VAR Rec@1000 : Record 37);
    BEGIN
      ModuleMgt.UnbindInterface(InterfaceName);
    END;

    [EventSubscriber(Codeunit,414,OnAfterReleaseSalesDoc)]
    LOCAL PROCEDURE SalesOrder_Released@5(VAR SalesHeader@1000 : Record 36);
    VAR
      Args@1001 : Record 50010;
    BEGIN
      CreateEventArgs(Args,0,SourceSales,STRSUBSTNO(EventReleased,SalesHeader."Document Type",SalesHeader."No."));
      Log.LogEvent(Args);
    END;

    [EventSubscriber(Codeunit,414,OnAfterReopenSalesDoc)]
    LOCAL PROCEDURE SalesOrder_Reopened@6(VAR SalesHeader@1000 : Record 36);
    VAR
      Args@1001 : Record 50010;
    BEGIN
      CreateEventArgs(Args,0,SourceSales,STRSUBSTNO(EventReopened,SalesHeader."Document Type",SalesHeader."No."));
      Log.LogEvent(Args);
    END;

    LOCAL PROCEDURE CreateEventArgs@9(VAR EventArgs@1000 : Record 50010;Type@1001 : Option;Source@1002 : Text;Msg@1003 : Text);
    BEGIN
      CLEAR(EventArgs);
      EventArgs.Type := Type;
      EventArgs.Source := Source;
      EventArgs.Message := Msg;
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50060 Interface Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:00:11;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50060;
    PageType=List;
    OnOpenPage=BEGIN
                 OnRegisterInterface(Rec);
               END;

    OnAfterGetCurrRecord=BEGIN
                           SetupActive := "Configuration Page ID" <> 0;
                         END;

    ActionList=ACTIONS
    {
      { 8       ;    ;ActionContainer;
                      ActionContainerType=ActionItems }
      { 9       ;1   ;Action    ;
                      Ellipsis=Yes;
                      CaptionML=ENU=Setup;
                      Promoted=Yes;
                      Enabled=SetupActive;
                      PromotedIsBig=Yes;
                      Image=Setup;
                      PromotedCategory=Process;
                      OnAction=BEGIN
                                 Setup();
                               END;
                                }
    }
  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=Group;
                GroupType=Repeater }

    { 3   ;2   ;Field     ;
                SourceExpr="Interface Name" }

    { 4   ;2   ;Field     ;
                SourceExpr="Module Name";
                OnLookup=VAR
                           Lookup@1000 : Page 50061;
                         BEGIN
                           TESTFIELD("Interface Name");
                           Lookup.SetInterface("Interface Name");
                           Lookup.LOOKUPMODE := TRUE;
                           IF Lookup.RUNMODAL = ACTION::LookupOK THEN BEGIN
                             Lookup.GetModuleInfo("Module Name","Configuration Page ID");
                             CurrPage.UPDATE(TRUE);
                           END;
                         END;
                          }

    { 5   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 7   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=RecordLinks }

    { 6   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {
    VAR
      SetupActive@1000 : Boolean;

    LOCAL PROCEDURE Setup@2();
    BEGIN
      PAGE.RUNMODAL("Configuration Page ID");
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50061 Interface Module Lookup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=20:47:07;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    SourceTable=Table50061;
    PageType=List;
    SourceTableTemporary=Yes;
    OnOpenPage=BEGIN
                 OnRegisterModule(InterfaceName,Rec);
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=Group;
                GroupType=Repeater }

    { 3   ;2   ;Field     ;
                SourceExpr="Module Name" }

  }
  CODE
  {
    VAR
      InterfaceName@1000 : Text;

    PROCEDURE SetInterface@1(InterfaceNameIn@1000 : Text);
    BEGIN
      InterfaceName := InterfaceNameIn;
    END;

    PROCEDURE GetModuleInfo@3(VAR ModuleName@1000 : Text;VAR PageID@1001 : Integer);
    BEGIN
      ModuleName := "Module Name";
      PageID := "Configuration Page ID";
    END;

    BEGIN
    END.
  }
}

OBJECT Page 50082 Event Log - File Setup
{
  OBJECT-PROPERTIES
  {
    Date=26.09.16;
    Time=21:40:02;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50082;
    PageType=Card;
    OnOpenPage=BEGIN
                 IF NOT GET THEN
                   INSERT;
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=General;
                GroupType=Group }

    { 3   ;2   ;Field     ;
                AssistEdit=Yes;
                SourceExpr="Log File Path";
                OnAssistEdit=VAR
                               Dlg@1000 : Codeunit 419;
                             BEGIN
                               "Log File Path" := Dlg.SaveFileDialog(DialogTitle,'EventLog.txt',Filter);
                             END;
                              }

    { 6   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 5   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=RecordLinks }

    { 4   ;1   ;Part      ;
                Visible=FALSE;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {
    VAR
      DialogTitle@1000 : TextConst 'ENU=Event Log File';
      Filter@1001 : TextConst 'ENU=Text files (*.txt)|*.txt';

    BEGIN
    END.
  }
}

OBJECT Page 50084 Event Log - Twitter Setup
{
  OBJECT-PROPERTIES
  {
    Date=28.09.16;
    Time=22:01:04;
    Modified=Yes;
    Version List=Directions.2017,#RealStuff;
  }
  PROPERTIES
  {
    InsertAllowed=No;
    DeleteAllowed=No;
    SourceTable=Table50084;
    PageType=Card;
    OnOpenPage=BEGIN
                 IF NOT GET THEN
                   INSERT;
               END;

  }
  CONTROLS
  {
    { 1   ;0   ;Container ;
                ContainerType=ContentArea }

    { 2   ;1   ;Group     ;
                Name=General;
                GroupType=Group }

    { 3   ;2   ;Field     ;
                SourceExpr="Consumer Key" }

    { 4   ;2   ;Field     ;
                SourceExpr="Consumer Key Secret" }

    { 5   ;2   ;Field     ;
                SourceExpr="Access Token" }

    { 6   ;2   ;Field     ;
                SourceExpr="Access Token Secret" }

    { 7   ;0   ;Container ;
                ContainerType=FactBoxArea }

    { 8   ;1   ;Part      ;
                PartType=System;
                SystemPartID=RecordLinks }

    { 9   ;1   ;Part      ;
                PartType=System;
                SystemPartID=Notes }

  }
  CODE
  {

    BEGIN
    END.
  }
}

