2016年2月1日

提早 Timeout

客戶反應未到四小時就被登出
檢查 Web程式的 web.config
Session Timeout和 Form Auth Timeout都是設定 240(分)
Log紀錄也有正常的 Timeout紀錄

可能是因為 Load Balance的 Sticky Timeout只設 60(分)

2015年11月16日

瑜珈課的體悟

同一個口令/指示 有多少人就有多少不同的動作

需要老師輔助

超越極限

個體能力不同

2015年10月28日

javascript 一個元件用兩個 class註冊同一種事件的觸發順序

<input class="A B" />

$('.A').keyup(function () {
  ...
});

$(document).delegate('.B', 'keyup', function () {
  ...
});

B會比 A先執行

2015年10月23日

開發時各項工具的選擇 要考慮後續維護使用

做台新專案的經驗
PM堅持 UML用 Astah做
但是接手的台新 IT團隊都用 Enterprise Architech

2015年8月7日

OpenXML將內容控制項替換文字

Template的內容控制項後面如果是接換行符號,不可以用 ↓(Shift+Enter),要用←┘(Enter)
不然替代文字後產生出的文件會有格式問題

2015年7月31日

Log4Net 學習紀錄

1.NuGet install log4net
2.Cerate file log4net.config
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
  </configSections>
</configuration>
<configuration>
  <!--logger: 記錄器,可自訂設定屬性(可多個)-->
    <!--appender-ref: 指定參考的Appender設定-->
    <logger name="Rolling">
      <appender-ref ref="RollingFile" />
    </logger>
    <logger name="DB">
      <appender-ref ref="LogDatabase" />
    </logger>
</configuration>
<configuration>
  <!--root logger: 根記錄器,當其他記錄器執行完後最後會執行根記錄器(唯一)-->
    <!--level: 記錄級別設定-->
    <root>
      <level value="DEBUG" />
      <appender-ref ref="RollingFile" />
    </root>
</configuration>
For File
<configuration>
  <!--appender: 內容為輸出格式的設定-->
    <!--type: 輸出類型,例如 ConsoleAppender 為主控台輸出、RollingFileAppender 為文字檔輸出-->
    <!--file: 輸出檔案的路徑位置-->
    <!--layout: 記錄的格式設定-->
    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
      <file value="C:\Log\PlayLog.txt" />
      <appendToFile value="true" />
      <maximumFileSize value="1000KB" />
      <maxSizeRollBackups value="2" />
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[Activity]%newlineActivityId: %property{GUID}%newlineTime: %date{yyyy-MM-dd HH:mm:ss}%newlineLevel: %level%newline%newline[System]%newlineSystem: %property{System}%newline%newline[IP]%newlineServerIP: %property{ServerIP}%newlineClientIP: %property{ClientIP}%newline%newline[Message]%newlineDescription: %property{Description}%newlineException: %property{Exception}%newline%newline[Properties]%newline%message%newline%newline" />
      </layout>
    </appender>
</configuration>
For DB
<configuration>
  <appender name="LogDatabase" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="100" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=4.0.0.0, Culture=Neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="Data Source={Server};Initial Catalog={DBName};User ID={UserID};Password={Password}" />
      <commandText value="INSERT INTO [dbo].[Message] (MessageId, Message) VALUES (@MessageId, @Message)" />
      <parameter>
        <parameterName value="@MessageId" />
        <dbType value="Int32" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{MessageId}" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Message" />
        <dbType value="String" />
        <size value="100" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{Message}" />
        </layout>
      </parameter>
    </appender>
</configuration>
3.Add Watch in Global.asax Application_Start()
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~/log4net.config")));


儲存GUID
log4net.ThreadContext.Properties["GUID"] = guidValue;

<parameter>
    <parameterName value="@LogId" />
    <dbType value="Guid" />
    <layout type="log4net.Layout.RawPropertyLayout">
        <key value="GUID" />
    </layout>
</parameter>

Trace log4net debug message by modify web.config
<configuration>
  <appSettings>
    <add key="log4net.Internal.Debug" value="true"/>
  </appSettings>
</configuration>
<configuration>
  <system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener"
             type="System.Diagnostics.TextWriterTraceListener"
             initializeData="C:\Log\log4net.txt"
             />
      </listeners>
    </trace>
  </system.diagnostics>
</configuration>

2015年5月14日

繳費疑雲

一個帳號前後有兩個擁有者A,B

A把帳號讓渡給B了

B去查帳單的時候,A、B的兩個時期的帳單都有
B把所有帳單都繳掉了

這時查繳費紀錄只會出現B的資料
A去查繳費紀錄時就查不到了

user卻想在繳費紀錄看到“誰產生帳單的”

2015年4月20日

Single Page

用 ajas post只更新畫面中的部分區塊&javascript

debug javascript時很麻煩 ...

2015年4月17日

foreach 物件屬性

foreach (PropertyInfo property in obj.GetType().GetProperties())
{
    if (property.GetValue(obj, null) != null)
    {
        property.SetValue(obj, "");
    }
}

2015年4月1日

前端頁面使用者操作紀錄

在遠通的專案,發生了 end-user在 CSS系統繳費,說是只繳兩筆,但是系統銷帳卻有三筆的狀況

但是因為沒有頁面元件操作紀錄,所以死無對証

解決的方法可以考慮在 checkbox綁 onclick,每按一下就紀錄下來,submit的時候一併送出,再寫入 log

2015年3月31日

.NET SqlParameter(string paraName, object value) 字串 NVarchar

最近程式再被調教中
收到一封 mail說我們的 SQL script都是用 nvarchar,效能較差
要我們改成 varchar
查了一下是因為底層的 function寫得太便利,大家都是丟 object[] 進去直接賦值 大概是像這樣子
SqlParameter sqlPara = new SqlParameter("@" + temp[0], paraValues[i]);


如果 value是 int、dobule、datetime等都沒問題,產生出來的 SqlParameter內的屬性 SqlDbType會自動轉成對應的類別
但如果是字串,不管是 string、String還是 char,一律會被轉成 nvarchar
問題就來了


因為 table schema是放 varchar,query script的 where條件被轉成 nvarchar,就會導致效能變差~

2015年3月20日

Java的 milliseconds 轉成 c#的 DateTime

long javaMilliSec = 1386862447000;

new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc).Add(new TimeSpan(javaMilliSec *TimeSpan.TicksPerMillisecond)).ToString("yyyy/MM/dd HH:mm:ss")

ref: Get c# DateTime from Java System.currentTimeMillis

2014年11月20日

Can not find "Aspose.Cells.lic"

在用 .NET MVC做 ReportViewer的 PDF/Excel 輸出浮水印時

發生 OBSR環境的 Excel產出有 error (0 byte)
查到 log是寫 Can not find "Aspose.Cells.lic" ...

看了一下 OBSR跟 SIT01的佈置
OBSR的資料夾底下有放 "Aspose.Cells.lic",SIT01沒有
但是 SIT01沒問題反而是 OBSR有問題??

最後發現是 OBSR Aspose.Cells.lic檔案的屬性 Build Action沒有改成 Embedded Resource

問題找到了,收工!

ref: