1.Except
譯:二陣列中,前有,後者沒有的
Ex:
var a=[1,2,3];
var b=[2,3];
a.Except(b); Result=1;
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
2.Zip
譯:二個相同長度陣列串連成一個;如不同長度,以最短長度為準
Ex:
var a=[1,2,3];
var b=[2,3,4];
a.Zip(b,(f,s)=>f+s); Result=[3,5,7]
參考資訊:http://msdn.microsoft.com/zh-tw/library/dd267698(v=vs.100).aspx
http://www.cnblogs.com/fox23/archive/2009/12/14/zip-operator-in-csharp4-vs-python3.html
2014年4月21日 星期一
{LInQ} 做Dictionary、Distinct ... 多屬性為Key 比對其Class覆寫方法
如需要將多個屬性做為Key供判斷,需要另外覆寫 Equals()與 GetHashCode() 才能達到判斷是否相同的結果....
public class InventoryWODetail
{
public int SOItemId { set; get; }
public string CPSPN { set; get; }
public string WONo { set; get; }
public int WOTotalQty { set; get; }
public int WOCloseQty { set; get; }
public int WOOpenQty { set; get; }
public string CPSSONo { set; get; }
public string CPSSOPlannedShipDate { set; get; }
public string WOPlannedClose { set; get; }
public override bool Equals(object obj)
{
if (!(obj is InventoryWODetail))
return false;
else
{
InventoryWODetail other = obj as InventoryWODetail;
return (other.SOItemId == this.SOItemId && other.CPSPN == this.CPSPN && other.WONo == this.WONo && other.WOTotalQty == this.WOTotalQty
&& other.WOCloseQty == this.WOCloseQty && other.WOOpenQty == this.WOOpenQty && other.CPSSONo == this.CPSSONo && other.CPSSOPlannedShipDate == this.CPSSOPlannedShipDate
&& other.WOPlannedClose == this.WOPlannedClose);
}
}
public override int GetHashCode()
{
return string.Format("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} ", this.SOItemId, this.CPSPN, this.WONo, this.WOTotalQty, this.WOCloseQty, this.WOOpenQty, this.CPSSONo, this.CPSSOPlannedShipDate, this.WOPlannedClose).GetHashCode();
}
}
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
public class InventoryWODetail
{
public int SOItemId { set; get; }
public string CPSPN { set; get; }
public string WONo { set; get; }
public int WOTotalQty { set; get; }
public int WOCloseQty { set; get; }
public int WOOpenQty { set; get; }
public string CPSSONo { set; get; }
public string CPSSOPlannedShipDate { set; get; }
public string WOPlannedClose { set; get; }
public override bool Equals(object obj)
{
if (!(obj is InventoryWODetail))
return false;
else
{
InventoryWODetail other = obj as InventoryWODetail;
return (other.SOItemId == this.SOItemId && other.CPSPN == this.CPSPN && other.WONo == this.WONo && other.WOTotalQty == this.WOTotalQty
&& other.WOCloseQty == this.WOCloseQty && other.WOOpenQty == this.WOOpenQty && other.CPSSONo == this.CPSSONo && other.CPSSOPlannedShipDate == this.CPSSOPlannedShipDate
&& other.WOPlannedClose == this.WOPlannedClose);
}
}
public override int GetHashCode()
{
return string.Format("{0} | {1} | {2} | {3} | {4} | {5} | {6} | {7} | {8} ", this.SOItemId, this.CPSPN, this.WONo, this.WOTotalQty, this.WOCloseQty, this.WOOpenQty, this.CPSSONo, this.CPSSOPlannedShipDate, this.WOPlannedClose).GetHashCode();
}
}
參考資訊:http://www.cnblogs.com/626498301/archive/2011/02/24/1963413.html
2014年4月9日 星期三
{CSS} !important 用法
加上!important 有最高有優先權
.ui-state-disabled { cursor: default !important; }
.ui-state-disabled { cursor: }
同時在page 的Css 相同命名下,有!important則有較高的被用權利
參考資料:
http://note.tc.edu.tw/598.html
.ui-state-disabled { cursor: default !important; }
.ui-state-disabled { cursor: }
同時在page 的Css 相同命名下,有!important則有較高的被用權利
參考資料:
http://note.tc.edu.tw/598.html
{Javascript} 從檔案路徑取檔案名稱
var type=url.match(/[^\/.]+$/gi);
g 比對多次
i 忽略字元的大小寫
m 多行(^與$能比對行末字元)
參考資料:
http://carlos-studio.com/2013/09/12/%E6%AD%A3%E8%A6%8F%E9%81%8B%E7%AE%97%E5%BC%8Fregular-expression/
g 比對多次
i 忽略字元的大小寫
m 多行(^與$能比對行末字元)
參考資料:
http://carlos-studio.com/2013/09/12/%E6%AD%A3%E8%A6%8F%E9%81%8B%E7%AE%97%E5%BC%8Fregular-expression/
{JQuery} 圖片上傳前先預覽--連結
http://sundoctor.iteye.com/blog/1943278
http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20100429165520ZQ2.html
http://www.cnblogs.com/sooj/archive/2013/04/25/3041862.html
http://support.microsoft.com/kb/294714/zh-tw
http://avnpc.com/pages/single-file-upload-component-by-jquery-file-upload
http://www.dotblogs.com.tw/cross/archive/2010/09/21/17840.aspx
Funcion 回傳 <img> Tag Html
http://www.blueshop.com.tw/board/FUM20041006152641OLG/BRD20100429165520ZQ2.html
http://www.cnblogs.com/sooj/archive/2013/04/25/3041862.html
http://support.microsoft.com/kb/294714/zh-tw
http://avnpc.com/pages/single-file-upload-component-by-jquery-file-upload
http://www.dotblogs.com.tw/cross/archive/2010/09/21/17840.aspx
Funcion 回傳 <img> Tag Html
imgdiv=$('<div id="imgDiv"> </div>')
imgScaling(fileuploadControl,imgdiv);
function imgScaling(slave, imgDiv) {
var maxsize = 4096;
var version = parseInt($.browser.version, 10);
var returnValue = '';
if (slave.value) {
if ($.browser.msie && version < 10) {
if (version == 6) {
var image = new Image();
image.onload = function () {
if ((image.fileSize / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
}
image.src = 'file:///' + slave.value;
imgDiv = createImg(imgDiv);
imgDiv.attr('src', image.src);
returnValue= imgDiv[0].outerHTML;
// imgDiv = autoScaling(imgDiv);
} else {
//IE8版本 用DXImageTransform.Microsoft.AlphaImageLoader 一直失敗
imgDiv.html('');
slave.select();
var img = document.selection.createRange().text;
var image = new Image();
image.onload = function () {
if ((image.fileSize / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
}
image.src = img;
try {
var v = String(slave.value || '');
var temp = v.match(/[^\/\\]+$/gi);
imgDiv.append(temp[0]);
returnValue=temp[0];
//imgDiv.css({ "-ms-filter": "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image,src=" + img + ")" });
// imgDiv.get(0).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").sizingMethod = "image";
// imgDiv.get(0).filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = img;
// var aa = imgDiv;
} catch (e) {
alert("無效的圖片文件!");
return false;
}
}
}
else {
try {
var file = null;
var size = 0;
if (slave.files && slave.files[0]) {
file = slave.files[0];
size = file.size;
} else if (slave.files && slave.files.item(0)) {
file = slave.files.item(0);
size = file.fileSize;
}
if ((size / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
imgDiv = createImg(imgDiv);
//Firefox 因安全性問題已無法直接通過input[file].value 獲取完整的文件路徑
try {
//Firefox7.0 以下
imgDiv.attr('src', file.getAsDataURL());
} catch (e) {
//Firefox8.0以上
imgDiv.attr('src', window.URL.createObjectURL(file));
}
imgDiv.css({ "vertical-align": "middle" });
returnValue=imgDiv[0].outerHTML;
} catch (e) {
//支持html5的瀏覽器,比如高版本的firefox、chrome、ie10
if (slave.files && slave.files[0]) {
if ((slave.files[0].size / 1024) > maxsize) {
alert('圖片大小不能超過' + maxsize + 'K');
return false;
}
var reader = new FileReader();
reader.onload = function (e) {
imgDiv.attr('src', e.target.result);
};
reader.readAsDataURL(slave.files[0]);
returnValue=imgDiv[0].outerHTML;
}
};
}
}
return returnValue;
}
function createImg(imgDiv) {
imgDiv.html('');
var img = $("<img />");
imgDiv.replaceWith(img);
imgDiv = img;
imgDiv.width(90);
imgDiv.height(110);
return imgDiv;
}
訂閱:
文章 (Atom)