2016年7月20日 星期三

ORA-12154: TNS: 無法解析指定的連線 ID

在本機建立好連接 oracle 的表單,放入 IIS7 上執行時,竟然發生

ORA-12154: TNS: 無法解析指定的連線 ID

檢查了 TNS 和 Oracle 版本,都和本機的相同,TNS 的設定跟其的 Oralce DB 就差了 sid 的屬性,但不明白為何本機可以但 Server 上不行

後來把 connectstring 改為放入完整的 tns,竟然可以了

參考來源:
http://stackoverflow.com/questions/12571379/oracleconnection-open-is-throwing-ora-12541-tns-no-listener

主版頁面的圖片顯示路徑

今天第一次把 VS 2015 的 asp.net 網站專案放上測試區 Windows 2003 Server / IIS 7上面,結果發生了一些以前沒遇過的事情

1. 發佈時網站預設是沒有預先編譯的,要記得打勾
2. 在主版頁面有放圖片用 <img src = "~/img/....jpg" /> ,但是實際運作時看不到圖片,看了圖片的原始位置,發現圖片的網址怪怪...,又不想依各頁面來分別把路徑寫死,google 了一下找到了這一篇

http://stackoverflow.com/questions/5190769/html-img-and-asp-net-image-and-relative-paths

只要在 <img /> 內加入 runat="server " 即可
 <img src="~/App_Themes/Default/images/two.gif" runat="server" />

2016年7月6日 星期三

Visual Studio 2013 會有 JavaScript 執行階段錯誤: Syntax error...

因為要用到在  ASPXGridView 的 Batch Clone 功能,而把 Developer Express 升級到 15.2 之後,發現會出現以下的錯誤,

未處理的例外狀況 位於行 37,欄 59140 在 http://localhost:60666/dc15f9e0341a4844924fd80f41006451/browserLink 中

0x800a139e - JavaScript 執行階段錯誤: Syntax error, unrecognized expression: a#gridView_DXCBtn%DXItemIndex0%



耗了 2 天在 debug javascript 後發現問題原因不是嫩嫩我能夠解的,就算關閉了例外警告還是會出錯,後來就專心 google 這個問題

在 https://www.devexpress.com/Support/Center/Question/Details/Q571501 ,有看到類似的問題有得到了解答,詳細原因其實我看不太懂,只知道在 https://blogs.msdn.microsoft.com/webdev/2013/06/28/browser-link-feature-in-visual-studio-preview-2013/ 說的,在 web.config <appSettings> 中加入下列就可以解決

  <appSettings>
    <add key="vs:EnableBrowserLink" value="false"></add>
  </appSettings>

試了一下,果然再也不會彈出 Syntax error 了.....

2014年7月10日 星期四

使用 DirectoryInfo().Getfiles("*.xls") 會將 *.xlsx 列出來 ???


今天有朋友問我一個問題,使用 DirectoryInfo().Getfiles("*.xls") ,該目錄中若有檔案為 *.xlsx ,則連 *.xlsx 都會一起 list 出來

寫法如下,一般都是這樣子寫,看起來沒什麼異狀...
DirectoryInfo di = new DirectoryInfo(@"d:\temp");
            FileInfo[] files = di.GetFiles("*.xls");
            foreach (FileInfo fi in files)
            {
                string sfullname =  fi.FullName;
            }

後來改為以下的寫法,用 Where 下檔名的條件就可以解決了...

List<string> sfiles = Directory.GetFiles(@"d:\temp", "*.*").Where(file => file.ToLower().EndsWith("xls")).ToList();
            foreach (string file in sfiles)
            {
                FileInfo fi = new FileInfo(file);
                //(.....)
            }

舉一反三,若要取得二個以上的副檔名檔案列表呢? Where 條件中加個 || (OR) 條件就好了

List<string> sfiles = Directory.GetFiles(@"d:\temp", "*.*").Where(file => file.ToLower().EndsWith("xls")  || file.ToLower().EndsWith("html") ).ToList();


2014年5月17日 星期六

庫存不足,不允許過帳還原


在出貨單按下扣帳還原,若是網路或是Tiptop 有問題,有很大的機率會出現已扣帳還原,但庫存還未加回,造成庫存錯誤,此時若再庫存重算也仍無法解決問題
手動處理的方式是找到該料號的 icd21,把數量清除即可。





2014年5月2日 星期五

IIS7 + dotNetFramework 4.5.1 不能運行


IIS7 + dotNetFramework 4.5.1 不能運行

執行了 v4.xxx.xxx aspnet_regiis -i 仍不能運行,後來再重啟 IIS  及應用程式集區之後就可以執行了,在 Server 顯示正常,但從本機瀏覽網頁卻變成 下圖,格式都跑掉了



修改加入了以下這行後顯示就正常了
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" >
      <remove name="FormsAuthenticationModule" />
    </modules>
  </system.webServer>



2014年4月29日 星期二

[EFGP] FormScript with jQuery

今天在測試 EasyFlow GP 透過 jQuery 使用 C# 寫的 Webservice

在 VisualStudio 中用 c# 寫的程式可以正常呼叫,但是透過 EFGP 就不能
試了半天之後終於得到答案了,在這裡做個筆記

1. jQuery.noConflict(); //避免 $ 與其他 jQuery UI 的衝突 ,在這個範例上沒有設也ok
2. jQuery.support.cors = true; // 跨網域要把它設為 true , 就是這一點搞了非常久

範例如下:

FormScript :

document.write('<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>');

 
function GetInfo() {
  //jQuery.noConflict(); 
  jQuery.support.cors = true;
  //var jq = jQuery.noConflict();
       var $res;
       $.ajax({
           type: "POST",
           url: "http://10.1.10.103:8888/JsonServiceSample.asmx/GetOneUserInfo",
           contentType: "application/json; charset=utf-8",
           async: false,
           cache: false,
          dataType: 'json',
          data: "{name:'Test',age:29}",
          success: function (data) {
              if (data.hasOwnProperty("d")) {
                  $res = data.d;
              }
              else
                  $res = data;
          },
          error: function (xhr, ajaxOptions, thrownError) {
         alert('WS status = ' + xhr.status );
         alert('WS Error =' + thrownError);
        }
      });
      return $res;
  }


function btnEdit_onclick() {
    var res = GetInfo();

    alert(res.Name);
    alert(res.Age);
}



WebService




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.Services.Protocols;    //加上這個預備給 Java Call

namespace JQueryWebService
{

    public class User
    {
        public string Name { get; set; }

        public int Age { get; set; }

    }

    /// <summary>
    /// 移除 NameSpace
    /// 每一個 Methods 上面必須加上 
    /// [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    /// </summary>
    [WebService(Namespace = "", Description = "For Donma Test")]
    [System.ComponentModel.ToolboxItem(false)]
    [ScriptService]
    public class JsonServiceSample : System.Web.Services.WebService
    {
        [WebMethod]
        [SoapRpcMethod(Use = System.Web.Services.Description.SoapBindingUse.Literal)] 
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public string GetUserInfoString(string name, int age)
        {
            return name + "," + age;
        }

        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public User GetOneUserInfo(string name, int age)
        {
            return (new User { Name = name, Age = age });
        }


        [WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public User[] GetUsers(string name, int age)
        {
            List<User> res = new List<User>();
            res.Add(new User { Name = name + "1", Age = age });
            res.Add(new User { Name = name + "2", Age = age });

            return res.ToArray();
        }
    }
}