UWInfo Blog
發表新文章
[Join] | [忘記密碼] | [Login]
搜尋

搜尋意見
文章分類-Doug
[所有文章分類]
  • ASP.NET (0)
  • ASP.NET2.0 (0)
  • ASP.NET4.0 (0)
  • JavaScript (5)
  • jQuery (3)
  • FireFox (0)
  • UW系統設定 (0)
  • SQL (0)
  • SQL 2008 (0)
  • mirror (0)
  • SVN (0)
  • IE (0)
  • IIS (0)
  • IIS6 (0)
  • 閒聊 (0)
  • W3C (0)
  • 作業系統 (0)
  • C# (0)
  • CSS (0)
  • FileServer (0)
  • HTML 5 (0)
  • CKEditor (0)
  • UW.dll (1)
  • Visual Studio (0)
  • Browser (0)
  • SEO (0)
  • Google Apps (0)
  • 網站輔助系統 (0)
  • DNS (0)
  • SMTP (0)
  • 網管 (0)
  • 社群API (0)
  • SSL (0)
  • App_Inventor (0)
  • URLRewrite (0)
  • 開發工具 (0)
  • JSON (0)
  • Excel2007 (0)
  • 試題 (0)
  • LINQ (0)
  • bootstrap (0)
  • Vue (0)
  • IIS7 (0)
  • foodpanda (0)
  • 編碼 (0)
  • 資安 (0)
  • Sourcetree (0)
  • MAUI (0)
  • CMD (0)
  • my sql (0)
所有文章分類
[Doug的分類]
  • ASP.NET (48)
  • ASP.NET2.0 (15)
  • ASP.NET4.0 (34)
  • JavaScript (49)
  • jQuery (26)
  • FireFox (4)
  • UW系統設定 (3)
  • SQL (39)
  • SQL 2008 (25)
  • mirror (4)
  • SVN (4)
  • IE (9)
  • IIS (20)
  • IIS6 (1)
  • 閒聊 (7)
  • W3C (6)
  • 作業系統 (9)
  • C# (24)
  • CSS (12)
  • FileServer (1)
  • HTML 5 (11)
  • CKEditor (3)
  • UW.dll (13)
  • Visual Studio (16)
  • Browser (8)
  • SEO (1)
  • Google Apps (3)
  • 網站輔助系統 (4)
  • DNS (5)
  • SMTP (4)
  • 網管 (11)
  • 社群API (3)
  • SSL (4)
  • App_Inventor (1)
  • URLRewrite (2)
  • 開發工具 (6)
  • JSON (1)
  • Excel2007 (1)
  • 試題 (3)
  • LINQ (1)
  • bootstrap (0)
  • Vue (3)
  • IIS7 (3)
  • foodpanda (2)
  • 編碼 (2)
  • 資安 (3)
  • Sourcetree (1)
  • MAUI (1)
  • CMD (1)
  • my sql (1)
最新回應
  • 尋找 Aspnet_regsql.exe 的正確版本
    1. 對資料庫建立相對應的cache tableaspnet_regsql.exe -ed -d E...more
  • 新增Common.popUp2,傳物件丟到Common.popUp
    把 12 個參數的名稱和預設值寫一下吧。...more
  • [程式提醒][VB.net]
    將此文章分類在 UW.dll...more
  • [程式提醒][VB.net]
    當進行"玩"物件Update指令之後 --> 玩 ??...more
  • [程式提醒][Ajax][html] jQuery 做 HTML本文做取代時要注意 Javascript
    "HAML" ?...more
  • [程式片段][前台]VB預設
    這一段是做什麼用的 ?...more
標籤
  • Su
  • ti
  • web
  • CK
  • 114
  • 522
  • 958
  • 710
  • net
  • timeout
  • 922
  • 136
  • Block
  • extension
  • a
  • Xml
  • 140
  • [t]
  • asp,
  • json
  • encrypt
  • IE
  • 12
  • 字串
  • tim
  • dbcontext
  • C
  • code
  • 錯誤 cs0241:
  • cache啟用
  • 4Arpq52S
  • 186
  • .net
  • 48
  • SSL
  • 878
  • feed
  • 44
  • sysconfig,
  • config
  • [U2]
  • jq
  • 580
  • 追
  • GN
  • background
  • be downlo
  • 1
  • orm
  • 834
頁數 1 / 3 下一頁
.net Core環境變數加密方式
簡易執行方式
1. 確定Program.cs有加上Su.Encryption.AesEncryptor.InitAesPaddingEncryptor(secret , iv , encKey , dataRoot)
2. 確定appsettings.json有設定變數,DataRoot、EnvironmentEncKey
3. 先執行一次,會報錯誤,在dataRoot位置會產生一組$"{encKey}.ps1,裡面會放設定環境變數的指令
4. 設定完,記得把 $"{encKey}.ps1檔案刪除
===以上,設定完環境變數===
1. 確定Program.cs有加上Dictionary<string, string> encSetting = Su.Encryption.GetDecryptedSetting
2. 確定appsettings.json有設定變數,DataRoot、EnvironmentEncKey , ShowEncSetting 設定為 false
3. 在 $"{dataRoot}\Config\XXXX_dec.json"設定DBC連線,要注意連線字串要加上  "TrustServerCertificate=true;",因為.net Core一定要藥用SSL連線
4. 設定完之後,在執行一次,會自動產生XXXX.json
5. 刪除XXXX_dec.json
===以上,產生完加密DBC連線
備註,要取回解密連線字串,appsettings.json有設定變數 , ShowEncSetting 設定為 true

概念解說
原本  >> config大多是明文,駭客可以藉由偷到config來知道變數設定,例如  dbc連線資訊、某個APP Key
之後  >> 將重要資訊分成兩段,
appsettings.json  >>  放可公開資訊的設定,例如 DataRoot、EnvironmentEncKey

在環境變數加上一個 由本機產生的隨機變數
讓本機的所有


原理說明
1. .Net Core 啟動時最先執行檔案 Program.cs,在一開頭先檢查本機是否有設定環境變數
緯中用的function Su.Encryption.AesEncryptor.InitAesPaddingEncryptor(secret , iv , encKey , dataRoot)
進階加密標準(英語:Advanced Encryption Standard,縮寫:AES)

沒有的話,會在 dataRoot 這邊產生一個 encKey.ps1的檔案,裡面放有環境變數設定的指令
(encSecretAndIv = Su.Encryption.AesEncryptor.Encrypt(envSecret, envIv, Su.TextFns.GetRandomString(48));
var command = $"[Environment]::SetEnvironmentVariable('{variableName}', '{encSecretAndIv}', 'Machine')";)
(隨機產生48碼亂數,(前32碼為本機專用Secret、後16碼為iv),進行aes加密)




 
More...
Doug, 2023/6/17 下午 12:04:28
mssql 開啟127.0.0.1
 開啟TCPIP
 

重啟SQL Server
 
注意連線可能有port要記得設定
 



 
More...
Doug, 2023/5/3 下午 12:44:41
找不到 .NETFramework,Version=v5.0 的參考組件。
跑.net core 程式的時候遇到
錯誤    MSB3644    找不到 .NETFramework,Version=v5.0 的參考組件。若要解決此問題,請安裝此架構版本的開發人員套件 (SDK/目標套件) 或重定應用程式。您可以在 https://aka.ms/msbuild/developerpacks 下載 .NET Framework 開發人員套件    KOKOxMMBApi    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets    1175        

遇到此問題時先去
https://dotnet.microsoft.com/download/dotnet/5.0
下載64版本

但另一個原因有可能是vs2019版本過低,建議升到 16.6 版以上
https://visualstudio.microsoft.com/zh-hant/downloads/

接著~很可能遇到無法更新
請參考這篇
https://www.dotblogs.com.tw/Eyelash/2021/01/09/151544

刪除C:\Program Files (x86)\Microsoft Visual Studio\Installer\
Installer刪掉這個資料夾

回到VS 說明 > 檢查版本
就能更新了

 
More...
Doug, 2021/10/5 上午 11:53:20
前端處理網址組網址工具
在後端部分,因為有uw元件,在處理url時已經很好處理了
但是在JavaScript因為我們沒有固定js在使用,
因此提供一套簡易使用網址處理工具
thisPage.ParameterByName(key) //取得網址上特定參數
thisPage.OriUrl(key) //中間一段提供修改變數的功能


    <script>
        var thisPage = {
            Init: function () {
                thisPage.InitPageInput();

                $("body")
                    ;
                thisPage.ChangeEvent();
            },
            ParameterByName: function (targetKey) {
                var res = null;
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                for (const [key, value] of Object.entries(params)) {
                    if (targetKey.trim().toLocaleLowerCase() === key) {
                        res = value;
                    }
                }
                return res;
            },
            OriUrl: function () {
                var arrayUrl = [];
                arrayUrl.push(window.location.protocol);//https:
                arrayUrl.push("//");
                arrayUrl.push(window.location.hostname);//blog.uwinfo.com.tw
                if (window.location.port.length > 0) {
                    //大多情況,不用特別指定port
                    arrayUrl.push(":");
                    arrayUrl.push(window.location.port);//80
                }
                arrayUrl.push(window.location.pathname);//post/Edit.aspx
                //換一套寫法
                //arrayUrl.push(window.location.search);//?Id=321
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                var ayyarQueryString = [];
                //這邊可以加工增加額外的key值
                for (const [key, value] of Object.entries(params)) {
                    if (value.trim().length > 0) {
                        //這邊要注意中文需要encode
                        ayyarQueryString.push(key + "=" + encodeURIComponent(value));
                    }
                }
                if (ayyarQueryString.length > 0) {
                    arrayUrl.push("?");
                    arrayUrl.push(ayyarQueryString.join('&'));
                }
                return arrayUrl.length > 0 ? arrayUrl.join('') : '';
            },
            InitPageInput: function () {
                const urlSearchParams = new URLSearchParams(window.location.search);
                const params = Object.fromEntries(urlSearchParams.entries());
                for (const [key, value] of Object.entries(params)) {
                    $('input[name=' + key + ']').val(value);
                    //這邊因為input有多種不同輸入方式,可以自行編輯
                    //$('select[name=' + key + ']').val(value);
                    //$('textarea[name=' + key + ']').html(value);
                }
            },
            ChangeEvent: function () {

            },
        }
        $(function () {
            thisPage.Init();
        });
    </script>
More...
Doug, 2021/10/1 下午 12:19:30
deferred jQuery 從 1.5 開始引進了 Deferred Object(延遲物件),可以更簡便地處理非同步程式在不同狀態的 callback。
http://blog.zhusee.in/post/48857667691/jquery-deferred-object

deferred.done(callback)  #=> 成功時執行
deferred.fail(callback)  #=> 失敗時執行
deferred.progress(callback)  #=> 還在跑,但是裡面的程式使用 `.notify` 方法通知進度
deferred.always(callback)  #=> 無論成功或失敗都會執行
deferred.when(filters)  #=> 在呼叫 callback 前先處理資料,後面解釋

當所有 Deferred 都完成後,註冊在 $.when() 下面的 callback 會拿到第一個 Deferred 物件傳給 callback 的參數

var d1 = $.Deferred(), d2 = $.Deferred(),
     w = $.when(d1, d2);

  w.done(function(msg) { console.log(msg) });

  d1.resolve("Part A done");
  d2.resolve("Part B done");

  #=> "Part A done"

 
More...
Doug, 2015/10/15 下午 12:23:54
[JS]innerHTML、outerHTML
​

有的時候jquery會用到取代標籤的方式
<div id="testId">我是原本文字</div>



以下兩個都是innerHTML
document.getElementById('testId').innerHTML = "我是之後文字";
$('#testId').html("我是之後文字");





以下兩個都是outerHTML
document.getElementById('testId').outerHTML = "<div id="我是原本Id">我是原本文字</div>";
$('#testId').replaceWith("<div id="我是原本Id">我是原本文字</div>");






但是有時候~我們並不是要取代~而是想單純得到html含標籤的內容~
$('#testId').clone().wrap('<div>').parent().html()



 

More...
Doug, 2014/8/11 上午 10:50:29
訂單明細
小計:Format(Order_Main.Total_訂單層級的購物原始金額_包括產品單價的折價, "#,###,##0")
Order_Main.Total_訂單層級的購物原始金額_包括產品單價的折價 = Me.Total + Me.Deduct_Amt + Me.CouponAdd
Order_Main.Total = 當下所付的現金
Order_Main.Deduct_Amt = 當下U幣使用多少(已經除以30成為台幣了)
Order_Main.CouponAdd = 某些CouponCode會讓商品變貴,例如Global的自由選。

U幣折抵金額:Format(Order_Main.Deduct_Amt, "#,###,##0")
Order_Main.Deduct_Amt = 當下U幣使用多少(已經除以30成為台幣了)

GetE_coupon折抵金額:Format(Order_Main.CouponDiscount, "#,###,##0")
Order_Main.CouponDiscount是指訂單成立當下所有coupon加起來的金額~
如果想要知道細項,只能反查V_UsedCoupon,查看當下有哪些Couponcode有被使用。
也因為是後來才法查的,因此若是coupon設定與當下不符合,數字很可能就會對不起來了~
couponcode.IsExtraInput AndAlso oUC.CouponCode.Length > 0 
可用來判別是否需要手動輸入couponcode

折讓:Order_Main.Amount_Shortage - (Order_Main.TotalDiscount_訂單層級的折抵_不包括子訂單的折價 - Order_Main.Deduct_Amt - Order_Main.CouponDiscount)
Order_Main.TotalDiscount_訂單層級的折抵_不包括子訂單的折價 = Me.Discount + Me.Loyalty_Reward_Used + Me.Welcome_Reward_Used + Me.Deduct_Amt
折讓 = Order_Main.Amount_Shortage - (Me.Discount + Me.Loyalty_Reward_Used + Me.Welcome_Reward_Used + Me.Deduct_Amt + Me.CouponDiscount) + Order_Main.Deduct_Amt - Order_Main.CouponDiscount
折讓 = Order_Main.Amount_Shortage + Me.Discount + Me.Loyalty_Reward_Used + Me.Welcome_Reward_Used
有可能是正的~也可能是負的~
'訂單管管理頁面可以填寫 補差額 折讓 兩個欄位 http://zxp09.dev.shopunt.com.tw/Admin/Order/OrderEdit.aspx?page=1&Id=163761
'補差額是一個品項 想像成一個不會出的商品 用來讓整筆訂單變貴的方式~
 
More...
Doug, 2014/4/24 上午 11:52:57
LazyLoad設定問題
Lazy本身載入不是太大問題~
但是因為本身是使用網頁設計上架構會互相牽連~某些圖會出不來~
例如:
1. 原本要顯示的區塊是display:none,Lazyload為了效能問題,因此不顯示的圖片不會讀取。
2. 事件觸發是寫在Srcoll上面~因此某些圖片是用display切換的時候,不會出發Srcoll事件。
3. 大KV縮小的時候~不會觸發Scroll事件,因此圖片也不會讀出來~

因此在我們的 windowload事件
設定要加上一些參數
skip_invisible: false,                 display:none的圖片要讀;圖片若是到大視窗可視畫面時會觸發~
failure_limit: $("img.lazy").length,   容納錯誤次數,
threshold: 250                         圖片預讀高度,


參考連結:
http://www.appelsiini.net/projects/lazyload
http://localhost:2874/WWW20/scripts/Merge/lazyload.js
More...
Doug, 2014/4/9 上午 11:25:56
tch刪除購物車裡的東西
一般而言~
加入購物車切未購矮的東西會在14天後進行刪除~
但是在測試的情況可能會加入有誤的商品~造成購物車出錯~
因此需要手動區資料庫清除某些項目~
http://www.shopunt.com/tch/shopping/CancelTempCart.aspx
上面這隻程式是刪除的參考程式~
內容是刪除
TempCart   MemberId 對到的資料 以及 ComputerId 對到的資料
More...
Doug, 2014/4/1 下午 04:59:28
前台:具有潛在危險 request.querystring (validateRequest="false")
假如你現在在ASP.NET 4.0 的環境下的話,就算進行上述的設定,可能仍會出現驗證失敗的訊息(潛在危險Request.QueryString的錯誤訊息)
因為ASP.NET4.0與2.0版本在請求驗證的定義上已經有所不同:

這時為了避免這樣的問題,一樣在Web.Config中 <system.web>下加入下列語句
<httpRuntime requestValidationMode="2.0" />

http://www.dotblogs.com.tw/pin0513/archive/2010/10/22/18522.aspx
More...
Doug, 2014/3/28 下午 05:35:11
|< 123 >|
頁數 1 / 3 下一頁
~ Uwinfo ~