2019年11月20日 星期三

[研究][ASP.NET] 簡訊發送測試

[研究][ASP.NET] 簡訊發送測試

2019-11-20
2019-12-04 更新

WebForm 專案

先把  SnsComServer_v3.4.dll 加入參考。

Web.Config


<!--
  如需如何設定 ASP.NET 應用程式的詳細資訊,請前往
  https://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appsettings>
    <add key="SMSIP" value="簡訊主機IP1, 簡訊主機IP2," />
    <add key="SMSPort" value="8001,8001" />
    <add key="SMSAccount" value="帳號" />
    <add key="SMSPassword" value="密碼" />
</appsettings>
</configuration>


Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SMSTest.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="送出簡訊" /><br />
            <asp:Label ID="Label_Message" runat="server"></asp:Label>
        </div>
    </form>
</body>
</html>


Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SMSTest
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string phoneNumber = "0931xxxyyy";   // 手機號碼
            try
            {
                RNGCryptoServiceProvider provider = new RNGCryptoServiceProvider();

                string smsip = (string)ConfigurationManager.AppSettings["SMSIP"];
                string smsport = (string)ConfigurationManager.AppSettings["SMSPort"];
                string account = (string)ConfigurationManager.AppSettings["SMSAccount"];
                string passwd = (string)ConfigurationManager.AppSettings["SMSPassword"];

                CHT.SNSCOMSERVER.SnsComObject3 m_sns = new CHT.SNSCOMSERVER.SnsComObject3();
                m_sns.InitRemoteServer(smsip, smsport, account, passwd);
                int nResult = m_sns.Login();

                if (nResult == 0)
                {
                    //傳送手機號碼, 訊息內容
                    nResult = m_sns.SubmitMessage(null, phoneNumber, "簡訊測試", 1440);

                    //若發訊成功,則更新至狀態查詢測試的兩個欄位,以便進一步查詢發送結果。
                    if (nResult == 0)
                    {
                        Label_Message.Text = "簡訊發送成功。";
                    }
                    else
                    {
                        Label_Message.Text = "簡訊發送失敗。";
                    }
                }
                m_sns.Logout();
            }
            catch (Exception ex)
            {
                if (ex != null)
                {
                    Label_Message.Text = ex.Message.ToString();
                }
                else
                {
                    Label_Message.Text = "不明例外。";
                }
            }
         }
    }
}

上述在 Visual Studio 2019 環境可正常執行,但 Deploy 到網站後會出錯。IIS 要增加設定才能解決。

(下圖) Click 圖片可看 100% 尺寸。




(完)


2019年11月6日 星期三

[研究] SQL Server 2019 Standard 繁體中文標準版安裝

[研究] SQL Server 2019 Standard 繁體中文標準版安裝

2019-11-06

SQL Server 軟硬體需求
https://docs.microsoft.com/zh-tw/sql/sql-server/install/hardware-and-software-requirements-for-installing-sql-server?view=sql-server-ver15

SQL Server 2019 Standard/Enterprise 至少需要 1GB RAM
(加上 MS-Windows 本身,建議至少 4GB )

SQL Server 2019 (15.x) 需要 .NET Framework 4.6.2。
https://www.microsoft.com/download/details.aspx?id=53344

Windows Server 2019 Datacenter
Windows Server 2019 Standard
Windows Server 2019 Essentials
Windows Server 2016 Datacenter
Windows Server 2016 Standard
Windows Server 2016 Essentials
(似乎不支援 Windows 10,Windows 8.1 和 Windows 10似乎只能裝些 Client 端程式,x86 能安裝的更少)

以下在 Windows Server 2019 繁體中文標準版上安裝 SQL Server 2019 Standard 繁體中文標準版。(兩者目前都只有 x64 版)







(下圖)
機器學習可能需要手動安裝 Python、Java (敝人沒測試)

SQL Server Standard 安裝的 PolyBase 預設不是 Server,只是 Client,後面畫面要改設定,除非你另外有 PolyBase Server,否則可能安裝不下去 (過往經驗,這次沒測)

SQL Server Enterprise / Developer 安裝的 PolyBase 預設是 PolyBase Server。

































(完)

[研究] Windows 2019 標準版中安裝 Windows 2019標準版

[研究] Windows 2019 標準版中安裝  Windows 2019標準版

2019-11-05

因為某台 VM 有很多已經安裝的軟體不要了,想要重新從 MS Windows 安裝起,有個乾淨的環境。但因沒有 BIOS 設定權限,開機也攔不到選 Boot Device 畫面,所以嘗試看看能否相同版本直接從作業系統中安裝。

現況:Windows Server 2019 Standard 繁體中文標準版,已經裝一些目前不想要的軟體
目標:Windows Server 2019 Standard 繁體中文標準版 (乾淨環境)

(下圖) 把 .iso 掛到虛擬機器的虛擬光碟上









測到目前,確認可以安裝,最後實際上也安裝成功。

C:\Windows.Old 是原有的,安裝後可以刪除,實測可以刪除乾淨。(某些情況下,此目錄下某些檔案可能因不明原因被鎖住,無法刪除乾淨)。

另外這種安裝方式,一定要有序號才行。

(完)

[研究] IIS 程序無法存取檔案,因為檔案正由另一個程序使用。(發生例外狀況於 HRESULT: 0x80070020)

[研究][IIS] 程序無法存取檔案,因為檔案正由另一個程序使用。(發生例外狀況於 HRESULT: 0x80070020)

2019-11-06

Windows Server 2019
Internet Information Services (IIS) 管理員


(下圖)
程序無法存取檔案,因為檔案正由另一個程序使用。(發生例外狀況於 HRESULT: 0x80070020)

(下圖) 存取 https://localhost 的要求遭到拒絕您未獲得授權,無法瀏覽這個網頁。
HTTP ERROR 403

 使用 netstat  -ano 檢查使用那個 Process 在用 Port 443,Process ID  ( PID) 為多少?






(下圖) 再次啟動網站


這次可以了。

(完)