ZoomReplication
# ライブラリ読み込み | |
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Data") | |
# DB接続 | |
$connectionString = "DSN=CData API Zoom;" | |
$odbcCon = New-Object System.Data.Odbc.OdbcConnection($connectionString) | |
$odbcCon.Open() | |
# コマンドオブジェクト作成 | |
$odbcCmd = New-Object System.Data.Odbc.OdbcCommand | |
$odbcCmd.Connection = $odbcCon | |
$users = @() | |
$meetings = @() | |
# ユーザーの取得 | |
$odbcCmd.CommandText = "SELECT * FROM Users" # User一覧を取得 | |
$odbcReader = $odbcCmd.ExecuteReader() | |
while ($odbcReader.Read()) { | |
$users += $odbcReader["Id"].ToString() | |
} | |
$odbcReader.Dispose() | |
# ミーティングの取得 | |
foreach($user in $users){ | |
$odbcCmd.CommandText = "SELECT * FROM Meetings WHERE UserId = '" + $user + "' AND StartTime < TODAY()" # 過去のミーティング一覧を取得 | |
$odbcReader = $odbcCmd.ExecuteReader() | |
while ($odbcReader.Read()) { | |
$meetings += $odbcReader["Id"].ToString() | |
} | |
$odbcReader.Dispose() | |
} | |
# Meetingのレプリケーション | |
foreach($meeting in $meetings){ | |
$odbcCmd.CommandText = "CACHE SELECT * FROM Meeting WHERE Id = '" + $meeting + "';" | |
$odbcCmd.ExecuteNonQuery() | |
$odbcReader.Dispose() | |
} | |
# PastMeeting のレプリケーション | |
foreach($meeting in $meetings){ | |
$odbcCmd.CommandText = "CACHE SELECT * FROM PastMeetings WHERE Id = '" + $meeting + "';" | |
$odbcCmd.ExecuteNonQuery() | |
$odbcReader.Dispose() | |
} | |
# コマンドオブジェクト破棄 | |
$odbcCmd.Dispose() | |
# DB切断 | |
$odbcCon.Close() | |
$odbcCon.Dispose() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment