Side Project Document
  • 如果沒能一次成功,那就叫它 1.0 版吧。
  • Stock Price for LINE Notify V1
    • 前言
    • 一、申請玉山富果 API
    • 二、申請 LINE Notify Token
    • 三、環境架設與資料表設定
    • 四、SSIS 設計
      • SSIS 流程圖
      • Move to History Table & Truncate Table
      • Foreach Loop to Get API
      • Lookup File - Chart
      • Lookup File - Quote
      • Join Table to Result Set
      • Post Result Set to LINE Notify
      • Delete Over 3 days Files
      • 事件處理常式
    • 五、安裝教學
  • Stock Price for LINE Notify V2
    • 前言
    • 一、軟體架構與流程圖
    • 二、環境架設與資料表設定
    • 三、Python 程式說明
      • 主程式:Local_Stock_Main.py
      • 取得個股基本資訊:Local_Stock_Meta.py
      • 取得個股交易資訊:Local_Stock_Quote.py
      • 將折線圖發送至 LINE Notify:Local_Stock_Line_Notify.py
      • 資料解密:Local_Encryption.py
      • 排程設定
  • Stock Price for LINE Notify V3
    • 前言
    • 一、軟體架構與流程圖
    • 二、環境架設與資料表設定
    • 三、Python 程式說明
      • Local_Stock_Main.py
      • Local_Stock_Meta.py
      • Local_Stock_Quote.py
      • Local_Stock_Line_Notify.py
      • Create_RSA_Key.py
      • Encrypt_Data.py
      • Decrypt_Data.py
      • 排程設定
      • 加碼:.py 打包成 .exe 執行檔
Powered by GitBook
On this page
  1. Stock Price for LINE Notify V1
  2. 四、SSIS 設計

Post Result Set to LINE Notify

指令碼工作

Last updated 3 years ago

  • ReadOnlyVariables 屬性:User::SqlResultSet

  • Script(寫法參考 )

// ......

public void Main()
{
    // TODO: Add your code here

    DataTable dataTable = new DataTable();
    OleDbDataAdapter adapter = new OleDbDataAdapter();
    adapter.Fill(dataTable, Dts.Variables["User::SqlResultSet"].Value);

    string result = "";

    foreach (DataRow row in dataTable.Rows)
    {
        result +=   "\n"
               + "\t股票代號:" + row["StockNo"].ToString() + "\n"
               + "\t即時高點:" + row["MinAvgHighPrice"].ToString() + "\n"
               + "\t即時低點:" + row["MinAvgLowPrice"].ToString() + "\n"
               + "\t當日高點:" + row["DayHighPrice"].ToString() + "\n"
               + "\t當日高點時間:" + String.Format("{0:H:mm:ss}", Convert.ToDateTime(row["DayHighTime"])) + "\n"
               + "\t當日低點:" + row["DayLowPrice"].ToString() + "\n"
               + "\t當日低點時間:" + String.Format("{0:HH:mm:ss}", Convert.ToDateTime(row["DayLowTime"]))
               + "\n";
    }

    using (var wc = new WebClient())
    {
        var bearer = $"[Your LINE Notify Token]";

        wc.Encoding = Encoding.UTF8;
        wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
        wc.Headers.Add("Authorization", $"Bearer {bearer}");

        var nv = new NameValueCollection();
        nv["message"] = result;

        var bResult = wc.UploadValues($"https://notify-api.line.me/api/notify", nv);

        var res = Encoding.UTF8.GetString(bResult);
    }

    Dts.TaskResult = (int)ScriptResults.Success;
}

// ......
Wei 大大的文章