OSDN Git Service

ここまで来たのでコミット
authoryamat0jp <terukohietori@gmail.com>
Fri, 6 Mar 2020 06:16:14 +0000 (15:16 +0900)
committeryamat0jp <terukohietori@gmail.com>
Fri, 6 Mar 2020 06:16:14 +0000 (15:16 +0900)
FormUnit1.dfm [new file with mode: 0644]
FormUnit1.pas [new file with mode: 0644]
Unit1.dfm [new file with mode: 0644]
Unit1.pas [new file with mode: 0644]
WebModuleUnit1.dfm [new file with mode: 0644]
WebModuleUnit1.pas [new file with mode: 0644]
newstable.dpr [new file with mode: 0644]
newstable.dproj [new file with mode: 0644]
newstable.res [new file with mode: 0644]

diff --git a/FormUnit1.dfm b/FormUnit1.dfm
new file mode 100644 (file)
index 0000000..cee6ca0
--- /dev/null
@@ -0,0 +1,64 @@
+object Form1: TForm1
+  Left = 271
+  Top = 114
+  Caption = 'Form1'
+  ClientHeight = 235
+  ClientWidth = 399
+  Color = clBtnFace
+  Font.Charset = DEFAULT_CHARSET
+  Font.Color = clWindowText
+  Font.Height = -11
+  Font.Name = 'Tahoma'
+  Font.Style = []
+  OldCreateOrder = False
+  OnCreate = FormCreate
+  PixelsPerInch = 96
+  TextHeight = 13
+  object Label1: TLabel
+    Left = 24
+    Top = 48
+    Width = 28
+    Height = 13
+    Caption = #12509#12540#12488
+  end
+  object ButtonStart: TButton
+    Left = 24
+    Top = 8
+    Width = 75
+    Height = 25
+    Caption = #36215#21205
+    TabOrder = 0
+    OnClick = ButtonStartClick
+  end
+  object ButtonStop: TButton
+    Left = 105
+    Top = 8
+    Width = 75
+    Height = 25
+    Caption = #20572#27490
+    TabOrder = 1
+    OnClick = ButtonStopClick
+  end
+  object EditPort: TEdit
+    Left = 24
+    Top = 67
+    Width = 121
+    Height = 21
+    TabOrder = 2
+    Text = '8080'
+  end
+  object ButtonOpenBrowser: TButton
+    Left = 24
+    Top = 112
+    Width = 107
+    Height = 25
+    Caption = #12502#12521#12454#12470#12434#38283#12367
+    TabOrder = 3
+    OnClick = ButtonOpenBrowserClick
+  end
+  object ApplicationEvents1: TApplicationEvents
+    OnIdle = ApplicationEvents1Idle
+    Left = 288
+    Top = 24
+  end
+end
diff --git a/FormUnit1.pas b/FormUnit1.pas
new file mode 100644 (file)
index 0000000..82c00a9
--- /dev/null
@@ -0,0 +1,85 @@
+unit FormUnit1;
+
+interface
+
+uses
+  Winapi.Messages, System.SysUtils, System.Variants,
+  System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
+  Vcl.AppEvnts, Vcl.StdCtrls, IdHTTPWebBrokerBridge, Web.HTTPApp;
+
+type
+  TForm1 = class(TForm)
+    ButtonStart: TButton;
+    ButtonStop: TButton;
+    EditPort: TEdit;
+    Label1: TLabel;
+    ApplicationEvents1: TApplicationEvents;
+    ButtonOpenBrowser: TButton;
+    procedure FormCreate(Sender: TObject);
+    procedure ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
+    procedure ButtonStartClick(Sender: TObject);
+    procedure ButtonStopClick(Sender: TObject);
+    procedure ButtonOpenBrowserClick(Sender: TObject);
+  private
+    FServer: TIdHTTPWebBrokerBridge;
+    procedure StartServer;
+    { private \90é\8c¾ }
+  public
+    { public \90é\8c¾ }
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.dfm}
+
+uses
+  WinApi.Windows, Winapi.ShellApi;
+
+procedure TForm1.ApplicationEvents1Idle(Sender: TObject; var Done: Boolean);
+begin
+  ButtonStart.Enabled := not FServer.Active;
+  ButtonStop.Enabled := FServer.Active;
+  EditPort.Enabled := not FServer.Active;
+end;
+
+procedure TForm1.ButtonOpenBrowserClick(Sender: TObject);
+var
+  LURL: string;
+begin
+  StartServer;
+  LURL := Format('http://localhost:%s', [EditPort.Text]);
+  ShellExecute(0,
+        nil,
+        PChar(LURL), nil, nil, SW_SHOWNOACTIVATE);
+end;
+
+procedure TForm1.ButtonStartClick(Sender: TObject);
+begin
+  StartServer;
+end;
+
+procedure TForm1.ButtonStopClick(Sender: TObject);
+begin
+  FServer.Active := False;
+  FServer.Bindings.Clear;
+end;
+
+procedure TForm1.FormCreate(Sender: TObject);
+begin
+  FServer := TIdHTTPWebBrokerBridge.Create(Self);
+end;
+
+procedure TForm1.StartServer;
+begin
+  if not FServer.Active then
+  begin
+    FServer.Bindings.Clear;
+    FServer.DefaultPort := StrToInt(EditPort.Text);
+    FServer.Active := True;
+  end;
+end;
+
+end.
diff --git a/Unit1.dfm b/Unit1.dfm
new file mode 100644 (file)
index 0000000..55a234a
--- /dev/null
+++ b/Unit1.dfm
@@ -0,0 +1,210 @@
+object DataModule1: TDataModule1
+  OldCreateOrder = False
+  OnCreate = DataModuleCreate
+  Height = 257
+  Width = 299
+  object index: TFDTable
+    IndexFieldNames = 'no'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'index'
+    TableName = 'index'
+    Left = 48
+    Top = 136
+  end
+  object FDTable2: TFDTable
+    Connection = MagazineConnection
+    Left = 48
+    Top = 184
+  end
+  object indexTable: TFDTable
+    IndexFieldNames = 'readerId;magId'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'indexTable'
+    TableName = 'indexTable'
+    Left = 208
+    Top = 80
+    object indexTablereaderId: TIntegerField
+      FieldName = 'readerId'
+      Origin = 'readerId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object indexTablemagId: TIntegerField
+      AutoGenerateValue = arDefault
+      FieldName = 'magId'
+      Origin = 'magId'
+    end
+  end
+  object reader: TFDTable
+    IndexFieldNames = 'readerId'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'reader'
+    TableName = 'reader'
+    Left = 208
+    Top = 32
+    object readerreaderId: TIntegerField
+      FieldName = 'readerId'
+      Origin = 'readerId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object readerreader: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'reader'
+      Origin = 'reader'
+    end
+    object readermail: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'mail'
+      Origin = 'mail'
+    end
+    object readerpassword: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'password'
+      Origin = '`password`'
+    end
+  end
+  object magList: TFDTable
+    IndexFieldNames = 'writerId;magId'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'magList'
+    TableName = 'magList'
+    Left = 128
+    Top = 128
+    object magListwriterId: TIntegerField
+      FieldName = 'writerId'
+      Origin = 'writerId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object magListmagId: TIntegerField
+      AutoGenerateValue = arDefault
+      FieldName = 'magId'
+      Origin = 'magId'
+    end
+  end
+  object MagazineConnection: TFDConnection
+    Params.Strings = (
+      'ConnectionDef=newstable')
+    Connected = True
+    LoginPrompt = False
+    Left = 52
+    Top = 29
+  end
+  object FDQuery1: TFDQuery
+    Connection = MagazineConnection
+    SQL.Strings = (
+      '')
+    Left = 48
+    Top = 80
+  end
+  object news: TFDTable
+    IndexFieldNames = 'magId;no'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'news'
+    TableName = 'news'
+    Left = 128
+    Top = 184
+    object newsmagId: TIntegerField
+      FieldName = 'magId'
+      Origin = 'magId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object newsno: TIntegerField
+      FieldName = 'no'
+      Origin = 'no'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object newsday: TDateField
+      AutoGenerateValue = arDefault
+      FieldName = 'day'
+      Origin = '`day`'
+    end
+    object newschanged: TBooleanField
+      AutoGenerateValue = arDefault
+      FieldName = 'changed'
+      Origin = 'changed'
+    end
+    object newsenabled: TBooleanField
+      AutoGenerateValue = arDefault
+      FieldName = 'enabled'
+      Origin = 'enabled'
+    end
+  end
+  object FDGUIxWaitCursor1: TFDGUIxWaitCursor
+    Provider = 'Forms'
+    Left = 208
+    Top = 184
+  end
+  object writer: TFDTable
+    IndexFieldNames = 'writerId'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'writer'
+    TableName = 'writer'
+    Left = 128
+    Top = 80
+    object writerwriterId: TIntegerField
+      FieldName = 'writerId'
+      Origin = 'writerId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object writerwriter: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'writer'
+      Origin = 'writer'
+    end
+    object writermail: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'mail'
+      Origin = 'mail'
+    end
+    object writerpassword: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'password'
+      Origin = '`password`'
+    end
+  end
+  object mag: TFDTable
+    IndexFieldNames = 'magId'
+    Connection = MagazineConnection
+    UpdateOptions.UpdateTableName = 'mag'
+    TableName = 'mag'
+    Left = 128
+    Top = 32
+    object magmagId: TIntegerField
+      FieldName = 'magId'
+      Origin = 'magId'
+      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
+      Required = True
+    end
+    object magmagName: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'magName'
+      Origin = 'magName'
+    end
+    object magcomment: TWideStringField
+      AutoGenerateValue = arDefault
+      FieldName = 'comment'
+      Origin = 'comment'
+      Size = 50
+    end
+    object magday: TDateField
+      AutoGenerateValue = arDefault
+      FieldName = 'day'
+      Origin = '`day`'
+    end
+    object maglastDay: TDateField
+      AutoGenerateValue = arDefault
+      FieldName = 'lastDay'
+      Origin = 'lastDay'
+    end
+    object magenable: TBooleanField
+      AutoGenerateValue = arDefault
+      FieldName = 'enable'
+      Origin = '`enable`'
+    end
+  end
+end
diff --git a/Unit1.pas b/Unit1.pas
new file mode 100644 (file)
index 0000000..e155ffc
--- /dev/null
+++ b/Unit1.pas
@@ -0,0 +1,525 @@
+unit Unit1;
+
+interface
+
+uses
+  System.SysUtils, System.Classes, System.JSON, FireDAC.Comp.Client, Data.DB,
+  FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param,
+  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf,
+  FireDAC.Stan.Async, FireDAC.DApt, FireDAC.UI.Intf, FireDAC.Stan.Def,
+  FireDAC.Stan.Pool, FireDAC.Phys, FireDAC.Phys.MySQL, FireDAC.Phys.MySQLDef,
+  FireDAC.Comp.DataSet, FireDAC.VCLUI.Wait, FireDAC.Comp.UI, FireDAC.Phys.FB,
+  FireDAC.Phys.FBDef;
+
+type
+  TDataModule1 = class(TDataModule)
+    index: TFDTable;
+    FDTable2: TFDTable;
+    indexTable: TFDTable;
+    reader: TFDTable;
+    magList: TFDTable;
+    MagazineConnection: TFDConnection;
+    FDQuery1: TFDQuery;
+    news: TFDTable;
+    FDGUIxWaitCursor1: TFDGUIxWaitCursor;
+    writer: TFDTable;
+    writerwriterId: TIntegerField;
+    writerwriter: TWideStringField;
+    writermail: TWideStringField;
+    writerpassword: TWideStringField;
+    magListwriterId: TIntegerField;
+    magListmagId: TIntegerField;
+    newsmagId: TIntegerField;
+    newsno: TIntegerField;
+    newsday: TDateField;
+    newschanged: TBooleanField;
+    newsenabled: TBooleanField;
+    readerreaderId: TIntegerField;
+    readerreader: TWideStringField;
+    readermail: TWideStringField;
+    readerpassword: TWideStringField;
+    indexTablereaderId: TIntegerField;
+    indexTablemagId: TIntegerField;
+    mag: TFDTable;
+    magmagId: TIntegerField;
+    magmagName: TWideStringField;
+    magcomment: TWideStringField;
+    magday: TDateField;
+    maglastDay: TDateField;
+    magenable: TBooleanField;
+    procedure DataModuleCreate(Sender: TObject);
+  private
+    { Private \90é\8c¾ }
+    function makeTable(Sender: TObject): TJSONObject;
+  public
+    { Public \90é\8c¾ }
+    procedure AddMagazine(id: integer; out Data: TJSONObject);
+    procedure backNumber(id: integer; out Data: TJSONObject);
+    function checkUserPassword(id: integer; password: string): Boolean;
+    procedure createReaderId(Data: TJSONObject);
+    procedure custData(id: integer; data: TJSONObject);
+    procedure custView(id: integer; out Data: TJSONObject);
+    procedure deleteMagazine(id: integer);
+    procedure deleteNumber(id, num: integer);
+    procedure deleteUser(id: integer);
+    procedure getView(id, num: integer; out Data: TJSONObject); overload;
+    procedure getView(id: integer; out Data: TJSONObject); overload;
+    procedure magazines(id: integer; out Data: TJSONObject);
+    procedure magListAll(out data: TJSONObject);
+    procedure magData(id: integer; out Data: TJSONObject);
+    function magid(name: string): integer;
+    procedure magIdOff(id, magid: integer);
+    procedure magIdOn(id, magid: integer);
+    procedure createMagId(id: integer; out data: TJSONObject);
+    procedure postMessage(id: integer; Data: TJSONObject);
+    procedure createWriterId(Data: TJSONObject);
+    procedure readuserData(id: integer; out Data: TJSONObject);
+    procedure titleView(id: integer; Data: TJSONObject);
+    procedure updateWriterId(id: integer; Data: TJSONObject);
+    procedure userView(id: integer; out Data: TJSONObject);
+  end;
+
+var
+  DataModule1: TDataModule1;
+
+implementation
+
+uses System.Variants, System.Generics.Collections;
+
+{%CLASSGROUP 'Vcl.Controls.TControl'}
+
+{$R *.dfm}
+
+procedure TDataModule1.AddMagazine(id: integer; out Data: TJSONObject);
+var
+  i: integer;
+  na, com: string;
+begin
+  FDQuery1.Open('select MAX(magId) as id from mag;');
+  i := FDQuery1.FieldByName('id').AsInteger + 1;
+  na := Data.Values['magName'].Value;
+  com := Data.Values['comment'].Value;
+  mag.AppendRecord([i, na, com, Date, Date, true]);
+  magList.AppendRecord([id, i]);
+end;
+
+procedure TDataModule1.backNumber(id: integer; out Data: TJSONObject);
+const
+  con = '\82±\82Ì\8bL\8e\96\82Í\8cö\8aJ\90§\8cÀ\82ª\82 \82è\82Ü\82·.';
+var
+  d: TJSONObject;
+  mem: TStringList;
+  blob: TStream;
+begin
+  with FDQuery1.Params do
+  begin
+    Clear;
+    ParamByName('id').AsInteger := id;
+  end;
+  Data := TJSONObject.Create;
+  d := Data;
+  mem := TStringList.Create;
+  with FDQuery1 do
+  begin
+    Open('select file,enabled from news where magId = :id order by day;');
+    First;
+    while Eof = false do
+    begin
+      blob := CreateBlobStream(FieldByName('text'), bmRead);
+      mem.LoadFromStream(blob);
+      if FieldByName('enabled').AsBoolean = true then
+        d.AddPair('text', mem.Text)
+      else
+        d.AddPair('text', con);
+      blob.Free;
+      Next;
+    end;
+  end;
+  mem.Free;
+end;
+
+function TDataModule1.checkUserPassword(id: integer; password: string): Boolean;
+begin
+  result := writer.Lookup('id', id, 'password') = password;
+end;
+
+procedure TDataModule1.createMagId(id: integer; out data: TJSONObject);
+var
+  i: integer;
+begin
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select MAX(magId) as count from mag;');
+  FDQuery1.Open;
+  i:=FDQuery1.FieldByName('count').AsInteger+1;
+  mag.Append;
+  mag.FieldByName('magId').AsInteger:=i;
+  mag.FieldByName('day').AsDateTime:=Date;
+  mag.FieldByName('lastDay').AsDateTime:=Date;
+  mag.FieldByName('magName').AsString:=data.Values['magName'].Value;
+  mag.FieldByName('comment').AsString:=data.Values['comment'].Value;
+  mag.FieldByName('enable').AsString:=data.Values['enable'].Value;
+  mag.Post;
+  magList.AppendRecord([id,i]);
+end;
+
+procedure TDataModule1.createReaderId(Data: TJSONObject);
+var
+  i: integer;
+  na, ma, pa: string;
+begin
+  FDQuery1.Open('select MAX(readerid) as id from reader;');
+  i := FDQuery1.FieldByName('id').AsInteger + 1;
+  na := Data.Values['name'].Value;
+  ma := Data.Values['mail'].Value;
+  pa := Data.Values['password'].Value;
+  reader.AppendRecord([i, na, ma, pa]);
+end;
+
+procedure TDataModule1.DataModuleCreate(Sender: TObject);
+const
+  tmp = 'create table if not exists ';
+begin
+//  FDQuery1.ExecSQL(tmp+'index(no int primary key, magId int, readerId int, writeId int);');
+  FDQuery1.ExecSQL(tmp+'mag(magId int primary key, magName varchar(20), comment varchar(50), day date, lastDay date, enable bool);');
+  FDQuery1.ExecSQL(tmp+'writer(writerId int primary key, writer varchar(20), mail varchar(20), password varchar(20));');
+  FDQuery1.ExecSQL(tmp+'reader(readerId int primary key, reader varchar(20), mail varchar(20), password varchar(20));');
+  FDQuery1.ExecSQL(tmp+'news(magId int, no int, day date, changed bool, enabled bool, primary key (magId,no));');
+  FDQuery1.ExecSQL(tmp+'indexTable(readerId int, magId int, primary key (readerId,magId));');
+  FDQuery1.ExecSQL(tmp+'magList(writerId int, magId int, primary key (writerId,magId));');
+//  index.Open;
+  mag.Open;
+  writer.Open;
+  reader.Open;
+  news.Open;
+  indexTable.Open;
+  magList.Open;
+end;
+
+procedure TDataModule1.deleteMagazine(id: integer);
+  procedure main(DB: string);
+  begin
+    FDQuery1.Open(Format('select * from %s where magId = :id;', [DB]));
+    FDQuery1.First;
+    while FDQuery1.Eof = false do
+      FDQuery1.Delete;
+  end;
+
+begin
+  if mag.Locate('magId', id) = true then
+  begin
+    mag.Delete;
+    FDQuery1.Params.Clear;
+    FDQuery1.Params.ParamByName('id').AsInteger := id;
+    main('news');
+    main('database');
+    main('indexTable');
+  end;
+end;
+
+procedure TDataModule1.deleteNumber(id, num: integer);
+begin
+  if news.Locate('magId;newsId', VarArrayOf([id, num])) = true then
+    news.Delete;
+end;
+
+procedure TDataModule1.deleteUser(id: integer);
+var
+  i: integer;
+  list: TList<integer>;
+begin
+  FDQuery1.Params.Clear;
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open('select * from maglist where userid = :id;');
+  list := TList<integer>.Create;
+  while FDQuery1.Eof = false do
+  begin
+    list.Add(FDQuery1.FieldByName('magid').AsInteger);
+    FDQuery1.Delete;
+  end;
+  for i in list do
+    deleteMagazine(i);
+  list.Free;
+end;
+
+procedure TDataModule1.readuserData(id: integer; out Data: TJSONObject);
+var
+  i: Integer;
+begin
+  if reader.Locate('readerid', id) = true then
+  begin
+    Data := TJSONObject.Create;
+    for i := 1 to reader.Fields.Count-1 do
+      Data.AddPair(reader.Fields[i].FieldName, reader.Fields[i].AsString);
+  end;
+end;
+
+procedure TDataModule1.userView(id: integer; out Data: TJSONObject);
+var
+  i: integer;
+  list: TList<integer>;
+begin
+  Data := TJSONObject.Create;
+  list := TList<integer>.Create;
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select * from indexTable where readerid = :id;');
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  while FDQuery1.Eof = false do
+    list.Add(FDQuery1.FieldByName('magid').AsInteger);
+  for i in list do
+    titleView(i, Data);
+  list.Free;
+end;
+
+procedure TDataModule1.custData(id: integer; data: TJSONObject);
+var
+  i: Integer;
+begin
+  if writer.Locate('writerid',id) = true then
+  begin
+    data.AddPair('name',writer.FieldByName('writer').AsString);
+    data.AddPair('mail',writer.FieldByName('mail').AsString);
+  end;
+end;
+
+procedure TDataModule1.custView(id: integer; out Data: TJSONObject);
+var
+  i: integer;
+  list: TList<integer>;
+begin
+  Data := TJSONObject.Create;
+  list := TList<integer>.Create;
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select * from maglist where readerid = :id;');
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  while FDQuery1.Eof = false do
+  begin
+    list.Add(FDQuery1.FieldByName('magid').AsInteger);
+    FDQuery1.Next;
+  end;
+  for i in list do
+    titleView(i, Data);
+  list.Free;
+end;
+
+procedure TDataModule1.getView(id, num: integer; out Data: TJSONObject);
+begin
+  with FDQuery1.SQL do
+  begin
+    Clear;
+    Add('select updated,day,file from news');
+    Add(' where magId = :id and newsId = :num');
+    Add(' order by day;');
+  end;
+  with FDQuery1.Params do
+  begin
+    ParamByName('id').AsInteger := id;
+    ParamByName('num').AsInteger := num;
+  end;
+  FDQuery1.Open;
+  Data := makeTable(FDQuery1);
+end;
+
+procedure TDataModule1.getView(id: integer; out Data: TJSONObject);
+begin
+  with FDQuery1.SQL do
+  begin
+    Clear;
+    Add('select updated,day,file from indexTable,news');
+    Add(' where readerId = :id and indexTable.magId = news.magId');
+    Add(' and enabled = true order by day;');
+  end;
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  Data := makeTable(FDQuery1);
+end;
+
+procedure TDataModule1.magData(id: integer; out Data: TJSONObject);
+begin
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select * from mag where magid = :id;');
+  FDQuery1.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  if FDQuery1.FieldByName('enable').AsBoolean = true then
+  begin
+    Data := TJSONObject.Create;
+    Data.AddPair('name', FDQuery1.FieldByName('magName').AsString);
+    Data.AddPair('comment', FDQuery1.FieldByName('comment').AsString);
+    Data.AddPair('day', FDQuery1.FieldByName('day').AsString);
+    Data.AddPair('last', FDQuery1.FieldByName('lastDay').AsString);
+    FDQuery1.Open('select COUNT(*) as count do mag where magid = :id;');
+    Data.AddPair('count', FDQuery1.FieldByName('count').AsString);
+  end;
+end;
+
+function TDataModule1.magid(name: string): integer;
+begin
+  result := mag.Lookup('magname', name, 'magid');
+end;
+
+procedure TDataModule1.magIdOff(id, magid: integer);
+begin
+  if indexTable.Locate('readerId;magId', VarArrayOf([id, magid])) = true then
+    indexTable.Delete;
+end;
+
+procedure TDataModule1.magIdOn(id, magid: integer);
+begin
+  if (writer.Locate('readerid', id) = true) and (mag.Locate('magid', magid) = true)
+  then
+    indexTable.AppendRecord([id, magid]);
+end;
+
+procedure TDataModule1.magListAll(out data: TJSONObject);
+var
+  i: Integer;
+  js: TJSONObject;
+  ar: TJSONArray;
+  val: TJSONValue;
+begin
+  mag.First;
+  ar:=TJSONArray.Create;
+  while mag.Eof = false do
+  begin
+      js:=TJSONObject.Create;
+      js.AddPair('magName',mag.FieldByName('magName').AsString);
+      js.AddPair('comment',mag.FieldByName('comment').AsString);
+      js.AddPair('day',mag.FieldByName('day').AsString);
+      js.AddPair('lastDay',mag.FieldByName('lastDay').AsString);
+      ar.Add(js);
+    mag.Next;
+  end;
+  data:=TJSONObject.Create;
+  if ar.Count > 0 then
+    data.AddPair('items',ar)
+  else
+    data.AddPair('items',TJSONFalse.Create);
+  if mag.FieldByName('enable').AsBoolean = true then
+    val:=TJSONTrue.Create
+  else
+    val:=TJSONFalse.Create;
+  data.AddPair('enable',val);
+end;
+
+procedure TDataModule1.magazines(id: integer; out Data: TJSONObject);
+var
+  d: TJSONObject;
+  val: TJSONValue;
+  ar: TJSONArray;
+begin
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select * from maglist where writerid = :id;');
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  ar:=TJSONArray.Create;
+  while FDQuery1.Eof = false do
+  begin
+    magData(FDQuery1.FieldByName('magId').AsInteger, d);
+    ar.Add(d);
+    FDQuery1.Next;
+  end;
+  if ar.Count = 0 then
+  begin
+    ar.Free;
+    val:=TJSONFalse.Create;
+  end
+  else
+    val:=ar;
+  Data := TJSONObject.Create;
+  data.AddPair('mag',val);
+end;
+
+function TDataModule1.makeTable(Sender: TObject): TJSONObject;
+var
+  blob: TStream;
+  mem: TStringList;
+begin
+  result := TJSONObject.Create;
+  mem := TStringList.Create;
+  with Sender as TFDQuery do
+  begin
+    First;
+    while Eof = false do
+    begin
+      if FieldByName('updated').AsBoolean = true then
+        result.AddPair('hint', Format('\82±\82Ì\8bL\8e\96\82Í\8dX\90V\82³\82ê\82Ü\82µ\82½:(%s)\93ú.',
+          [FieldByName('day').AsString]));
+      blob := CreateBlobStream(FieldByName('file'), bmRead);
+      mem.LoadFromStream(blob);
+      blob.Free;
+      result.AddPair('text', mem.Text);
+      Next;
+    end;
+  end;
+  mem.Free;
+end;
+
+procedure TDataModule1.postMessage(id: integer; Data: TJSONObject);
+var
+  i: integer;
+begin
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select MAX(newsId) as id from news where magId = :id;');
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  if FDQuery1.RecordCount > 0 then
+  begin
+    i := FDQuery1.FieldByName('id').AsInteger + 1;
+    news.AppendRecord([id, i, false, Date, Data.Values['file'], true]);
+  end;
+end;
+
+procedure TDataModule1.createWriterId(Data: TJSONObject);
+var
+  i: integer;
+  na, ma, pa: string;
+begin
+  ma := Data.Values['mail'].Value;
+  if writer.Locate('mail', ma) = false then
+  begin
+    FDQuery1.Open('select MAX(writerId) as id from writer;');
+    i := FDQuery1.FieldByName('id').AsInteger+1;
+    na := Data.Values['name'].Value;
+    ma := Data.Values['mail'].Value;
+    pa := Data.Values['password'].Value;
+    writer.AppendRecord([i, na, ma, pa]);
+  end;
+end;
+
+procedure TDataModule1.titleView(id: integer; Data: TJSONObject);
+var
+  d: TJSONObject;
+  i: integer;
+begin
+  d := Data;
+  FDQuery1.SQL.Clear;
+  FDQuery1.SQL.Add('select * from mag where magid = :id;');
+  FDQuery1.Params.ParamByName('id').AsInteger := id;
+  FDQuery1.Open;
+  with FDQuery1 do
+    while Eof = false do
+    begin
+      for i := 0 to Fields.Count - 1 do
+        d.AddPair(Fields[i].FieldName, Fields[i].AsString);
+      Next;
+    end;
+end;
+
+procedure TDataModule1.updateWriterId(id: integer; Data: TJSONObject);
+var
+  na, ma, pa: string;
+begin
+  na := Data.ParseJSONValue('writer').Value;
+  ma := Data.ParseJSONValue('mail').Value;
+  pa := Data.ParseJSONValue('password').Value;
+  with DataModule1.writer do
+  begin
+    FieldByName('writerId').AsInteger := id;
+    FieldByName('writer').AsString := na;
+    FieldByName('mail').AsString := ma;
+    FieldByName('password').AsString := pa;
+  end;
+end;
+
+end.
diff --git a/WebModuleUnit1.dfm b/WebModuleUnit1.dfm
new file mode 100644 (file)
index 0000000..610c9e3
--- /dev/null
@@ -0,0 +1,184 @@
+object WebModule1: TWebModule1
+  OldCreateOrder = False
+  OnCreate = WebModuleCreate
+  Actions = <
+    item
+      Default = True
+      MethodType = mtGet
+      Name = 'top'
+      PathInfo = '/top'
+      OnAction = WebModule1DefaultHandlerAction
+    end
+    item
+      MethodType = mtGet
+      Name = 'help'
+      PathInfo = '/help'
+    end
+    item
+      Name = 'regist'
+      PathInfo = '/regist'
+      OnAction = WebModule1registAction
+    end
+    item
+      MethodType = mtGet
+      Name = 'detail'
+      PathInfo = '/data'
+    end
+    item
+      MethodType = mtGet
+      Name = 'readerTop'
+      PathInfo = '/reader/top'
+      OnAction = WebModule1readerTopAction
+    end
+    item
+      MethodType = mtPut
+      Name = 'readerData'
+      PathInfo = '/reader/data'
+    end
+    item
+      Name = 'selection'
+      PathInfo = '/reader/select'
+      OnAction = WebModule1selectionAction
+    end
+    item
+      MethodType = mtGet
+      Name = 'writerTop'
+      PathInfo = '/writer/top'
+      OnAction = WebModule1writerTopAction
+    end
+    item
+      Name = 'writerData'
+      PathInfo = '/writer/data'
+      OnAction = WebModule1writerDataAction
+    end
+    item
+      MethodType = mtPost
+      Name = 'writeMag'
+      PathInfo = '/writer/regist'
+      OnAction = WebModule1writeMagAction
+    end>
+  Height = 225
+  Width = 415
+  object readerTop: TPageProducer
+    HTMLDoc.Strings = (
+      '<!DOCTYPE html>'
+      '<html lang="en">'
+      '<head>'
+      '    <meta charset="UTF-8">'
+      
+        '    <meta name="viewport" content="width=device-width, initial-s' +
+        'cale=1.0">'
+      '    <title>Document</title>'
+      '</head>'
+      '<body>'
+      '        <p>'#12354#12394#12383#12398#26412#26842#12391#12377
+      '    {{#mag}}'
+      '        <table border=1>'
+      '        <th>{{name}}<ht>'
+      '        <tr><td>{{day}}</td></tr>'
+      '        <tr><td>{{lastDay}}</td></tr>'
+      '        </table>'
+      '    {{/mag}}'
+      '    <p><a href=/top>'#12488#12483#12503'</a>'#12506#12540#12472#12408#25147#12387#12390#36861#21152#12375#12414#12375#12423#12358
+      '</body>'
+      '</html>')
+    Left = 48
+    Top = 24
+  end
+  object top: TPageProducer
+    HTMLDoc.Strings = (
+      '<!DOCTYPE html>'
+      '<html lang="en">'
+      '<head>'
+      '    <title>Document'
+      '</title>'
+      '    <meta charset="UTF-8">'
+      
+        '    <meta name="viewport" content="width=device-width, initial-s' +
+        'cale=1.0">'
+      '</head>'
+      '<body>'
+      '    {{#items}}'
+      '        {{#enable}}'
+      '                <table border=1>'
+      '                <th>{{magName}}</th>'
+      '                <tr><td>{{comment}}</td></tr>'
+      '                <tr><td>{{day}}</td></tr>'
+      '                <tr><td>{{lastDay}}</td></tr>'
+      '                </table>'
+      '        {{/enable}}'
+      '    {{/items}}'
+      '    <form method="post" action="/regist">'
+      '        <input type="text" name="reader">'
+      '        <input type="text" name="mail">'
+      '        <input type="password" name="password">'
+      '        <input type="submit" name="regReader" value="send">'
+      '    </form>'
+      '    <form method=post action=/writer/data>'
+      '        <input type=text name=writer>'
+      '        <input type=text name=mail>'
+      '        <input type=password name=password>'
+      '        <input type=submit name=regWriter value=send>'
+      '    </form>'
+      '</body>'
+      '</html>')
+    Left = 112
+    Top = 24
+  end
+  object writerTop: TPageProducer
+    HTMLDoc.Strings = (
+      '<!DOCTYPE html>'
+      '<html lang="ja">'
+      '<head>'
+      '    <meta charset="UTF-8">'
+      
+        '    <meta name="viewport" content="width=device-width, initial-s' +
+        'cale=1.0">'
+      '    <title>Document</title>'
+      '</head>'
+      '<body>'
+      '        <p>'#26032#35215#30331#37682
+      '        <form method=post action=/writer/regist>'
+      '                <input type=text name=name>'
+      '                <input type=text name=comment>'
+      '                <input type=text name=day>'
+      '                <input type=submit>'
+      '        </form>'
+      '        <p>'#30331#37682#20013#12398#12510#12460#12472#12531#12391#12377
+      '        {{#mag}}'
+      '                <p>{{magName}}'
+      '                <p>{{comment}}'
+      '                <p>{{day}}'
+      '                <p>{{lastDay}}'
+      '                <p>{{enable}}'
+      '                <p>{{count}}'
+      '        {{/mag}}'
+      '</body>'
+      '</html')
+    Left = 168
+    Top = 24
+  end
+  object writerData: TPageProducer
+    HTMLDoc.Strings = (
+      '<!DOCTYPE html>'
+      '<html lang="en">'
+      '<head>'
+      '    <meta charset="UTF-8">'
+      
+        '    <meta name="viewport" content="width=device-width, initial-s' +
+        'cale=1.0">'
+      '    <title>Document</title>'
+      '</head>'
+      '<body>'
+      '        <form method=put action=/writer/data>'
+      '        <p>name : {{name}}<input type=text name=name>'
+      '        <p>mail : {{mail}}<input type=text name=mail>'
+      '        <p>password : ***<input type=password name=password>'
+      '        <input type=submit>'
+      '        </form>'
+      '</body>'
+      '</html>')
+    Left = 168
+    Top = 80
+  end
+end
diff --git a/WebModuleUnit1.pas b/WebModuleUnit1.pas
new file mode 100644 (file)
index 0000000..403d2d1
--- /dev/null
@@ -0,0 +1,194 @@
+unit WebModuleUnit1;
+
+interface
+
+uses System.SysUtils, System.Classes, Web.HTTPApp, Web.HTTPProd;
+
+type
+  TWebModule1 = class(TWebModule)
+    readerTop: TPageProducer;
+    top: TPageProducer;
+    writerTop: TPageProducer;
+    writerData: TPageProducer;
+    procedure WebModule1DefaultHandlerAction(Sender: TObject;
+      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+    procedure WebModule1readerTopAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+    procedure WebModule1registAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+    procedure WebModule1writerTopAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+    procedure WebModuleCreate(Sender: TObject);
+    procedure WebModule1writeMagAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+    procedure WebModule1selectionAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+    procedure WebModule1writerDataAction(Sender: TObject; Request: TWebRequest;
+      Response: TWebResponse; var Handled: Boolean);
+  private
+    { private \90é\8c¾ }
+    writerId: integer;
+    userId: integer;
+  public
+    { public \90é\8c¾ }
+  end;
+
+var
+  WebModuleClass: TComponentClass = TWebModule1;
+
+implementation
+
+uses SynMustache, SynCommons, System.JSON, Unit1;
+
+{ %CLASSGROUP 'Vcl.Controls.TControl' }
+
+{$R *.dfm}
+
+var
+  mustache: TSynMustache;
+
+procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  DataModule1.magListAll(data);
+  mustache := TSynMustache.Parse(top.Content);
+  Response.ContentType := 'text/html;charset=utf-8';
+  Response.Content := mustache.RenderJSON(data.ToJSON);
+  data.Free;
+end;
+
+procedure TWebModule1.WebModule1readerTopAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  if userId = 0 then
+  begin
+    Handled := false;
+    Exit;
+  end;
+  Response.ContentType := 'text/html;charset=utf-8';
+  DataModule1.userView(userId, data);
+  mustache := TSynMustache.Parse(readerTop.Content);
+  Response.Content := mustache.RenderJSON(data.ToJSON);
+end;
+
+procedure TWebModule1.WebModule1registAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  case Request.MethodType of
+    mtPOST:
+      with Request.ContentFields do
+      begin
+        data := TJSONObject.Create;
+        data.AddPair('mail', Values['mail']);
+        data.AddPair('password', Values['password']);
+        data.AddPair('name', Values['reader']);
+        DataModule1.createReaderId(data);
+        data.Free;
+        Response.SendRedirect('/reader/top');
+      end;
+  end;
+end;
+
+procedure TWebModule1.WebModule1selectionAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  id: integer;
+begin
+  id := DataModule1.magid(Request.ContentFields.Values['name']);
+  case Request.MethodType of
+    mtGet:
+      Handled := false;
+    mtPOST:
+      DataModule1.magIdOn(userId, id);
+    mtDelete:
+      DataModule1.magIdOff(userId, id);
+  end;
+end;
+
+procedure TWebModule1.WebModule1writeMagAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  data := TJSONObject.Create;
+  data.AddPair('magName', Request.ContentFields.Values['name']);
+  data.AddPair('comment', Request.ContentFields.Values['comment']);
+  data.AddPair('day', Request.ContentFields.Values['day']);
+  data.AddPair('enable', TJSONTrue.Create);
+  DataModule1.createMagId(writerId, data);
+  data.Free;
+  WebModule1writerTopAction(Sender, Request, Response, Handled);
+end;
+
+procedure TWebModule1.WebModule1writerDataAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  if writerId > 0 then
+  begin
+    case Request.MethodType of
+      mtPOST:
+        with Request.ContentFields do
+        begin
+          data := TJSONObject.Create;
+          data.AddPair('mail', Values['mail']);
+          data.AddPair('password', Values['password']);
+          data.AddPair('name', Values['writer']);
+          DataModule1.createWriterId(data);
+          data.Free;
+        end;
+      mtPut:
+        begin
+          data := TJSONObject.Create;
+          with Request.ContentFields do
+          begin
+            data.AddPair('writer', Values['name']);
+            data.AddPair('mail', Values['mail']);
+            data.AddPair('password', Values['password']);
+          end;
+          DataModule1.updateWriterId(writerId, data);
+          data.Free;
+        end;
+    end;
+    data:=TJSONObject.Create;
+    DataModule1.custData(writerId,data);
+    Response.ContentType := 'text/html;charset=utf-8';
+    mustache:=TSynMustache.Parse(writerData.Content);
+    Response.Content := mustache.RenderJSON(data.ToString);
+    data.Free;
+  end
+  else
+    Handled := false;
+end;
+
+procedure TWebModule1.WebModule1writerTopAction(Sender: TObject;
+  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
+var
+  data: TJSONObject;
+begin
+  if writerId = 0 then
+  begin
+    Handled := false;
+    Exit;
+  end;
+  DataModule1.magazines(writerId, data);
+  Response.ContentType := 'text/html;charset=utf-8';
+  mustache := TSynMustache.Parse(writerTop.Content);
+  Response.Content := mustache.RenderJSON(data.Value);
+  data.Free;
+end;
+
+procedure TWebModule1.WebModuleCreate(Sender: TObject);
+begin
+  userId := 1;
+  writerId := 1;
+end;
+
+end.
diff --git a/newstable.dpr b/newstable.dpr
new file mode 100644 (file)
index 0000000..d55bfe9
--- /dev/null
@@ -0,0 +1,21 @@
+program newstable;
+{$APPTYPE GUI}
+
+uses
+  Vcl.Forms,
+  Web.WebReq,
+  IdHTTPWebBrokerBridge,
+  FormUnit1 in 'FormUnit1.pas' {Form1},
+  WebModuleUnit1 in 'WebModuleUnit1.pas' {WebModule1: TWebModule},
+  Unit1 in 'Unit1.pas' {DataModule1: TDataModule};
+
+{$R *.res}
+
+begin
+  if WebRequestHandler <> nil then
+    WebRequestHandler.WebModuleClass := WebModuleClass;
+  Application.Initialize;
+  Application.CreateForm(TForm1, Form1);
+  Application.CreateForm(TDataModule1, DataModule1);
+  Application.Run;
+end.
diff --git a/newstable.dproj b/newstable.dproj
new file mode 100644 (file)
index 0000000..68024b6
--- /dev/null
@@ -0,0 +1,513 @@
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <ProjectGuid>{CDEFD041-368E-4737-A9FC-79D4D3BAE0CC}</ProjectGuid>
+        <ProjectVersion>16.1</ProjectVersion>
+        <FrameworkType>VCL</FrameworkType>
+        <MainSource>newstable.dpr</MainSource>
+        <Base>True</Base>
+        <Config Condition="'$(Config)'==''">Debug</Config>
+        <Platform Condition="'$(Platform)'==''">Win32</Platform>
+        <TargetedPlatforms>1</TargetedPlatforms>
+        <AppType>Application</AppType>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Base)'=='true') or '$(Base_Win32)'!=''">
+        <Base_Win32>true</Base_Win32>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win64' and '$(Base)'=='true') or '$(Base_Win64)'!=''">
+        <Base_Win64>true</Base_Win64>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
+        <Cfg_1>true</Cfg_1>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
+        <Cfg_1_Win32>true</Cfg_1_Win32>
+        <CfgParent>Cfg_1</CfgParent>
+        <Cfg_1>true</Cfg_1>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
+        <Cfg_2>true</Cfg_2>
+        <CfgParent>Base</CfgParent>
+        <Base>true</Base>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base)'!=''">
+        <Icon_MainIcon>$(BDS)\bin\delphi_PROJECTICON.ico</Icon_MainIcon>
+        <SanitizedProjectName>newstable</SanitizedProjectName>
+        <Icns_MainIcns>$(BDS)\bin\delphi_PROJECTICNS.icns</Icns_MainIcns>
+        <DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace)</DCC_Namespace>
+        <DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
+        <DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
+        <DCC_E>false</DCC_E>
+        <DCC_N>false</DCC_N>
+        <DCC_S>false</DCC_S>
+        <DCC_F>false</DCC_F>
+        <DCC_K>false</DCC_K>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base_Win32)'!=''">
+        <VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
+        <VerInfo_Locale>1033</VerInfo_Locale>
+        <DCC_UsePackage>FireDACSqliteDriver;FireDACDSDriver;DBXSqliteDriver;FireDACPgDriver;fmx;IndySystem;tethering;vclib;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DataSnapProviderClient;DBXSybaseASEDriver;DbxCommonDriver;vclimg;dbxcds;DatasnapConnectorsFreePascal;MetropolisUILiveTile;vcldb;vcldsnap;fmxFireDAC;DBXDb2Driver;DBXOracleDriver;CustomIPTransport;vclribbon;dsnap;IndyIPServer;fmxase;vcl;IndyCore;DBXMSSQLDriver;IndyIPCommon;CloudService;CodeSiteExpressPkg;FireDACIBDriver;DataSnapFireDAC;FireDACDBXDriver;soapserver;inetdbxpress;dsnapxml;FireDACInfxDriver;FireDACDb2Driver;adortl;FireDACASADriver;bindcompfmx;RaudusD210;FireDACODBCDriver;RESTBackendComponents;emsclientfiredac;rtl;dbrtl;DbxClientDriver;FireDACCommon;bindcomp;inetdb;DBXOdbcDriver;vclFireDAC;xmlrtl;DataSnapNativeClient;svnui;ibxpress;IndyProtocols;DBXMySQLDriver;FireDACCommonDriver;bindengine;vclactnband;bindcompdbx;soaprtl;bindcompvcl;vclie;FireDACADSDriver;vcltouch;emsclient;VCLRESTComponents;FireDACMSSQLDriver;FireDAC;VclSmp;DBXInformixDriver;DataSnapConnectors;DataSnapServerMidas;dsnapcon;DBXFirebirdDriver;inet;fmxobj;FireDACMySQLDriver;soapmidas;vclx;svn;DBXSybaseASADriver;FireDACOracleDriver;fmxdae;RESTComponents;dmvcframeworkDT;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
+        <Manifest_File>$(BDS)\bin\default_app.manifest</Manifest_File>
+        <DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
+        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Base_Win64)'!=''">
+        <DCC_UsePackage>FireDACSqliteDriver;FireDACDSDriver;DBXSqliteDriver;FireDACPgDriver;fmx;IndySystem;tethering;vclib;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DataSnapProviderClient;DBXSybaseASEDriver;DbxCommonDriver;vclimg;dbxcds;DatasnapConnectorsFreePascal;MetropolisUILiveTile;vcldb;vcldsnap;fmxFireDAC;DBXDb2Driver;DBXOracleDriver;CustomIPTransport;vclribbon;dsnap;IndyIPServer;fmxase;vcl;IndyCore;DBXMSSQLDriver;IndyIPCommon;CloudService;FireDACIBDriver;DataSnapFireDAC;FireDACDBXDriver;soapserver;inetdbxpress;dsnapxml;FireDACInfxDriver;FireDACDb2Driver;adortl;FireDACASADriver;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;emsclientfiredac;rtl;dbrtl;DbxClientDriver;FireDACCommon;bindcomp;inetdb;DBXOdbcDriver;vclFireDAC;xmlrtl;DataSnapNativeClient;ibxpress;IndyProtocols;DBXMySQLDriver;FireDACCommonDriver;bindengine;vclactnband;bindcompdbx;soaprtl;bindcompvcl;vclie;FireDACADSDriver;vcltouch;emsclient;VCLRESTComponents;FireDACMSSQLDriver;FireDAC;VclSmp;DBXInformixDriver;DataSnapConnectors;DataSnapServerMidas;dsnapcon;DBXFirebirdDriver;inet;fmxobj;FireDACMySQLDriver;soapmidas;vclx;DBXSybaseASADriver;FireDACOracleDriver;fmxdae;RESTComponents;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1)'!=''">
+        <DCC_Define>DEBUG;$(DCC_Define)</DCC_Define>
+        <DCC_DebugDCUs>true</DCC_DebugDCUs>
+        <DCC_Optimize>false</DCC_Optimize>
+        <DCC_GenerateStackFrames>true</DCC_GenerateStackFrames>
+        <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
+        <DCC_RemoteDebug>true</DCC_RemoteDebug>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
+        <DCC_RemoteDebug>false</DCC_RemoteDebug>
+    </PropertyGroup>
+    <PropertyGroup Condition="'$(Cfg_2)'!=''">
+        <DCC_LocalDebugSymbols>false</DCC_LocalDebugSymbols>
+        <DCC_Define>RELEASE;$(DCC_Define)</DCC_Define>
+        <DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
+        <DCC_DebugInformation>0</DCC_DebugInformation>
+    </PropertyGroup>
+    <ItemGroup>
+        <DelphiCompile Include="$(MainSource)">
+            <MainSource>MainSource</MainSource>
+        </DelphiCompile>
+        <DCCReference Include="FormUnit1.pas">
+            <Form>Form1</Form>
+            <FormType>dfm</FormType>
+        </DCCReference>
+        <DCCReference Include="WebModuleUnit1.pas">
+            <Form>WebModule1</Form>
+            <FormType>dfm</FormType>
+            <DesignClass>TWebModule</DesignClass>
+        </DCCReference>
+        <DCCReference Include="Unit1.pas">
+            <Form>DataModule1</Form>
+            <FormType>dfm</FormType>
+            <DesignClass>TDataModule</DesignClass>
+        </DCCReference>
+        <None Include="ModelSupport_newstable\default.txaPackage"/>
+        <None Include="ModelSupport_newstable\default.txvpck"/>
+        <None Include="ModelSupport_newstable\Unit1\default.txvpck"/>
+        <None Include="ModelSupport_newstable\WebModuleUnit1\default.txvpck"/>
+        <None Include="ModelSupport_newstable\newstable\default.txvpck"/>
+        <None Include="ModelSupport_newstable\FormUnit1\default.txvpck"/>
+        <BuildConfiguration Include="Release">
+            <Key>Cfg_2</Key>
+            <CfgParent>Base</CfgParent>
+        </BuildConfiguration>
+        <BuildConfiguration Include="Base">
+            <Key>Base</Key>
+        </BuildConfiguration>
+        <BuildConfiguration Include="Debug">
+            <Key>Cfg_1</Key>
+            <CfgParent>Base</CfgParent>
+        </BuildConfiguration>
+    </ItemGroup>
+    <ProjectExtensions>
+        <Borland.Personality>Delphi.Personality.12</Borland.Personality>
+        <Borland.ProjectType>Application</Borland.ProjectType>
+        <BorlandProject>
+            <Delphi.Personality>
+                <Source>
+                    <Source Name="MainSource">newstable.dpr</Source>
+                </Source>
+            </Delphi.Personality>
+            <Deployment>
+                <DeployFile LocalName="ModelSupport_newstable\FormUnit1\default.txvpck" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="Win32\Debug\newstable.exe" Configuration="Debug" Class="ProjectOutput">
+                    <Platform Name="Win32">
+                        <RemoteName>newstable.exe</RemoteName>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="ModelSupport_newstable\default.txvpck" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="ModelSupport_newstable\default.txaPackage" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="ModelSupport_newstable\newstable\default.txvpck" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="ModelSupport_newstable\WebModuleUnit1\default.txvpck" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployFile LocalName="ModelSupport_newstable\Unit1\default.txvpck" Configuration="Debug" Class="ProjectFile">
+                    <Platform Name="Win32">
+                        <RemoteDir>.\</RemoteDir>
+                        <Overwrite>true</Overwrite>
+                    </Platform>
+                </DeployFile>
+                <DeployClass Required="true" Name="DependencyPackage">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                        <Extensions>.bpl</Extensions>
+                    </Platform>
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="DependencyModule">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                        <Extensions>.dll;.bpl</Extensions>
+                    </Platform>
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                        <Extensions>.dylib</Extensions>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPad_Launch2048">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectOSXInfoPList">
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectiOSDeviceDebug">
+                    <Platform Name="iOSDevice">
+                        <RemoteDir>..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_SplashImage470">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-normal</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidLibnativeX86File">
+                    <Platform Name="Android">
+                        <RemoteDir>library\lib\x86</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectiOSResource">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectOSXEntitlements">
+                    <Platform Name="OSX32">
+                        <RemoteDir>../</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidGDBServer">
+                    <Platform Name="Android">
+                        <RemoteDir>library\lib\armeabi-v7a</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPhone_Launch640">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_SplashImage960">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-xlarge</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_LauncherIcon96">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-xhdpi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPhone_Launch320">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_LauncherIcon144">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-xxhdpi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidLibnativeMipsFile">
+                    <Platform Name="Android">
+                        <RemoteDir>library\lib\mips</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidSplashImageDef">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="DebugSymbols">
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="DependencyFramework">
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                        <Extensions>.framework</Extensions>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_SplashImage426">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-small</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectiOSEntitlements">
+                    <Platform Name="iOSDevice">
+                        <RemoteDir>../</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AdditionalDebugSymbols">
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>0</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidClassesDexFile">
+                    <Platform Name="Android">
+                        <RemoteDir>classes</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectiOSInfoPList">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPad_Launch1024">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_DefaultAppIcon">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectOSXResource">
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\Resources</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectiOSDeviceResourceRules">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPad_Launch768">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Required="true" Name="ProjectOutput">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="Android">
+                        <RemoteDir>library\lib\armeabi-v7a</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                    </Platform>
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidLibnativeArmeabiFile">
+                    <Platform Name="Android">
+                        <RemoteDir>library\lib\armeabi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_SplashImage640">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-large</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="File">
+                    <Platform Name="iOSDevice">
+                        <Operation>0</Operation>
+                    </Platform>
+                    <Platform Name="Android">
+                        <Operation>0</Operation>
+                    </Platform>
+                    <Platform Name="Win32">
+                        <Operation>0</Operation>
+                    </Platform>
+                    <Platform Name="OSX32">
+                        <RemoteDir>Contents\MacOS</RemoteDir>
+                        <Operation>0</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>0</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPhone_Launch640x1136">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_LauncherIcon36">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-ldpi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="AndroidSplashStyles">
+                    <Platform Name="Android">
+                        <RemoteDir>res\values</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="iPad_Launch1536">
+                    <Platform Name="iOSDevice">
+                        <Operation>1</Operation>
+                    </Platform>
+                    <Platform Name="iOSSimulator">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_LauncherIcon48">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-mdpi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="Android_LauncherIcon72">
+                    <Platform Name="Android">
+                        <RemoteDir>res\drawable-hdpi</RemoteDir>
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <DeployClass Name="ProjectAndroidManifest">
+                    <Platform Name="Android">
+                        <Operation>1</Operation>
+                    </Platform>
+                </DeployClass>
+                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="iOSDevice" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
+            </Deployment>
+            <Platforms>
+                <Platform value="Win32">True</Platform>
+                <Platform value="Win64">False</Platform>
+            </Platforms>
+            <ModelSupport>True</ModelSupport>
+        </BorlandProject>
+        <ProjectFileVersion>12</ProjectFileVersion>
+    </ProjectExtensions>
+    <Import Project="$(BDS)\Bin\CodeGear.Delphi.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Delphi.Targets')"/>
+    <Import Project="$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj" Condition="Exists('$(APPDATA)\Embarcadero\$(BDSAPPDATABASEDIR)\$(PRODUCTVERSION)\UserTools.proj')"/>
+    <Import Project="$(MSBuildProjectName).deployproj" Condition="Exists('$(MSBuildProjectName).deployproj')"/>
+</Project>
diff --git a/newstable.res b/newstable.res
new file mode 100644 (file)
index 0000000..d6cf632
Binary files /dev/null and b/newstable.res differ