未分類

Web Form Note

PostBack保持Scroll位置

<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”report01.aspx.cs” Inherits=”report01″ MaintainScrollPositionOnPostback=”true” %>

MaintainScrollPositionOnPostback="true"

#簡潔select

<asp:SqlDataSource ID="SqlDataSource_L01" runat="server" ConnectionString="<%$ ConnectionStrings:BPMConnectionString %>" SelectCommand="SELECT distinct oSupplierName FROM [AFoodGo_Order] WHERE sw='Y' AND oDate='2023-10-09'"></asp:SqlDataSource>
foreach (System.Data.DataRowView rowView in SqlDataSource_L01.Select(DataSourceSelectArguments.Empty))
{
    string dayItem = rowView["oSupplierName"].ToString();
}

#send Line Notify

private void sendLineNotify(string message)
{
    message = "\r\n" + message;
    string token = "9x57xj1Qgy5EVfRBd6KZYWJ2ltxn9birdJ2OLyk18pn";

    using (WebClient client = new WebClient())
    {
        NameValueCollection data = new NameValueCollection
        {
            { "message", message }
        };
        client.Headers.Add("Authorization", $"Bearer {token}");
        try
        {
            byte[] response = client.UploadValues("https://notify-api.line.me/api/notify", "POST", data);
            string result = System.Text.Encoding.UTF8.GetString(response);
            Console.WriteLine(result);
        }
        catch (WebException ex)
        {
            Console.WriteLine("errMsg:" + ex.Message);
        }
    }

}

#send Line Notify 圖片版

string token = "mOhPIFK2NBPZaxIHn8CXwAb2auU8hYGsqbLkeL2UG1c";

HttpClientHandler handler = new HttpClientHandler();
HttpClient Client = new HttpClient(handler);
Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
MultipartFormDataContent content = new MultipartFormDataContent();

//圖片訊息
var file = @"C:\BPM\L01D092.jpeg";
var upfilebytes = File.ReadAllBytes(file);
ByteArrayContent baContent = new ByteArrayContent(upfilebytes);
content.Add(baContent, "imageFile", "qq168.jpg");

//文字訊息
var messageContent = new StringContent("這是一張圖片123!!!");
content.Add(messageContent, "message");

var response = Client.PostAsync(@"https://notify-api.line.me/api/notify", content).Result;