2015年6月24日 星期三

IIS 7連結網路分享目錄

IIS 無法直接存取已建立網路磁碟机,作法如下 

  1. 建立 本機(server) 使用者,  在另外一台要作分享目錄的電腦也建立相同帳號、密碼,並把分享目錄指定給這個帳號,給予 read write權限
  2. 設定本機(server)目錄權限 因為使用 aps.net mvc5 且 64位元,建議下面兩個目錄都要設定        C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files 
                 C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files   
  3. 至 iis 7,其應用程式上新增一個虛擬目錄,指定分享目錄並輸入帳號、密碼
  4. 修改 Web.config檔   <web.system>內加入
             <identity impersonate=" true" userName="*****" password=" ******" />
  5. 程式取得目錄名稱   string default_root = Server.MapPath("../虛擬目錄名稱" );
         
    之前也寫過的文章

IIS 7以上如何執行執行檔 exe, bat

參考文件:Foo.cmd won't output lines in process (on website)
                    System.Diagnostics.Process does not work on IIS 7

目前有個需求需要在 Asp.net MVC網頁上按個連結就可以直接把標籤列印出來,所以要使用 Process這個類別

寫法大同小異,如下
                      string command = string .Format("tscgin.exe {0} {1}", "mo_print.ini", fileName);
                   
                    Process p = new Process();
                    // Redirect the output stream of the child process.
                    p.StartInfo.UseShellExecute = false;
                    p.StartInfo.RedirectStandardOutput = true;
                   p.StartInfo.WorkingDirectory = "c:\somewhere"
                    p.StartInfo.FileName =  "cmd.exe";
                    p.StartInfo.Arguments = "/c " + command;
                    p.Start();
                   string output = p.StandardOutput.ReadToEnd();

                    p.WaitForExit();


但在 IIS和本機(或 Server)目錄需要設定權限的動作,如下
  1. 建一個新目錄存放 exe or bat file,並設定權限 NetworkService或建立一個帳號具有執行、寫入、讀取
  2. 至 IIS 找出應用程式的 Application Pool後點選"進階應用",找到 "識別"選項,使用者選擇 NetworkService或你自己建立的新帳號即可

2015年6月16日 星期二

使用 moment處理 asp.net MVC回傳的 json string

參考文件:Serializing Dates in JSON 
                    momentjs

在 asp.net MVC Controller or WebAPI回傳 json時,一般會使用 json.NET的 JsonConvert.SerializeObject作處理,如果欄位有日期的話,在 json.NET 4.5的版本就會自動轉成  ISO 8601 standard 的格式,而非微軟那個格式,除非有指定 TimeConverter

JsonConvert.SerializeObject(System.DateTime.Now) ISO格式如右 "2015-06-17T00:00:00Z"
而在前端 javascript在接到時就可以用 moment所提供的功能作轉換如下所示即可

moment(event.start).format( 'YYYY-MM-DD HH:mm:ss' )



Fullcalendar popover

參考文章: "Singleton" Bootstrap Popover with Close Button - JSFiddle,
                     How to close previous popovers in fullCalendar?

目前我的日曆希望能點選事件 (event)時可以有 bootstrap popover功能出現且規則如下

  1. 一次只能有一個 popover出現
  2. 點選  event時,只顯示該 event popover
  3. 點選 day時要把顯示的 popover關閉,如果有 more視窗存在,也要一併關閉
  4. 因為有設定 eventLimt,所以在點選 more時,要把 popover關閉

參考的文章是使用 fn.extend方式 (jquery extend比較像合併(merge)觀念,並非物件導向的繼承), 先作一個 function內有 popover template,然後再合併原本的 event element,這樣就可以作出我想要的功能囉,可以參考看看



Fullcalendar 常用到的參數分享


相關的說明都可以在官網文件找的到 FullCalendar Documentation
目前有用到的參數如下:

//表頭的顯示,依照需求可以作訂定
 header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },

defaultDate: new Date() //一開始的啟始日期,都會一般用 new Date當天日期
         
businessHours: false // 是否顯示工作區間,預設是6:00~ 10:00, 也可以制定
         
eventLimit: true //  如果有太多事件 (event)在同一天在 View month,可以用 more來代表

 //View 是 week or day時,畫面啟始時間會移到所指定的 scrollTime
scrollTime: 'HH;mm:ss'

2015年6月15日 星期一

CSS 色彩配置 for fullcalendar event

因為要找 fullcalendar event的顏色配色,下面這些可以提供參考,像我這種沒有美學的工程師,要試著開始了解怎麼排版、配色,讓自己的專案能有加分的效果

25 Examples of Perfect Color Combinations in Web Design


Best Color Tools And Articles For Designers

wufoo gallerydesign

看起來不會太亂,配色也不錯

2015年6月2日 星期二

Bootstrap Typeahead處理 json格式資料,並更新另一個 input的值


參考文件: Bootstrap typeahead ajax result format - Example

因為 Bootstrap Typeahead的 source是一個字串陣列 (string array),如果使用者希望可以 source可以是 json string array而且在 typeahead選擇時可以更新另一個 input的值,這一篇文章就可以幫助你,作法如下

  1. source 接回的是 json string array
  2. 實作 matcher, sorter, highlighter
  3. 實作 updater,在這邊就可以用 JSON.parse 處理 obj,再把某個 attribute值指定給特定的input