2016年3月15日 星期二

EF6,exception: The data reader returned by the store data provider does not have enough columns for the query requested.

「The data reader returned by the store data provider does not have enough columns for the query requested.」
解法
在原來的stored procedure中,應該是以 Return @result做傳回值的動作,
 改為select @result的方式傳回即可解決這個問題
參考這裡

2016年3月10日 星期四

for javascript,模擬F11將目前頁面開為全螢幕模式或是關閉全螢幕模式

=============================================================
function cancelFullScreen(el) {
           var requestMethod = el.cancelFullScreen || el.webkitCancelFullScreen || el.mozCancelFullScreen || el.exitFullscreen;
           if (requestMethod) { // cancel full screen.
               requestMethod.call(el);
           } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
               var wscript = new ActiveXObject("WScript.Shell");
               if (wscript !== null) {
                   wscript.SendKeys("{F11}");
               }
           }
       }

       function requestFullScreen(el) {
           // Supports most browsers and their versions.
           var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;

           if (requestMethod) { // Native full screen.
               requestMethod.call(el);
           } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
               var wscript = new ActiveXObject("WScript.Shell");
               if (wscript !== null) {
                   wscript.SendKeys("{F11}");
               }
           }
           return false
       }

       function toggleFull() {
           var elem = document.body; // Make the body go full screen.
           var isInFullScreen = (document.fullScreenElement && document.fullScreenElement !== null) || (document.mozFullScreen || document.webkitIsFullScreen);

           if (isInFullScreen) {
               cancelFullScreen(document);
           } else {
               requestFullScreen(elem);
           }
           return false;
       }
=============================================
參考來源在此
但,注意,如果你已經在Chrome的設定中指定全螢幕模式的話(如下圖)


上述的語法是會沒動作的,請小心






2016年1月11日 星期一

for Xamarin :您必須加入組件 'System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 的參考。

錯誤 CS0012 類型 'Task<>' 定義在未參考的組件中。您必須加入組件
'System.Threading.Tasks, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 的參考。
TabHostWalkthrough C:\Users\John\Documents\TabHostWalkthrough\TabHostWalkthrough\DlgEditAccount.cs 78

Solution:
參考:
http://stackoverflow.com/questions/19439564/method-error-cannot-await-system-threading-tasks-task-from-await-and-async-pr
,中間那段:
What a Nightmare! I have found the problem.
Microsoft.Bcl
It appears in my case that the Microsoft.Bcl and Microsoft.Bcl.Async are in conflict. I removed the Microsoft.Bcl and Microsoft.Bcl.Async with the following commands:
uninstall-package Microsoft.Bcl.Async -force
then:
uninstall-package Microsoft.Bcl -force
and then install again:
install-package Microsoft.Bcl.Async
....

















for Xamarin: 加入了Layout檔(axml),卻在complie時找不到 !?

照理說設計好了axml檔,重建後,在cs檔輸入Resouse.Layout. 時,會自動帶出layout檔以供選擇
可是就算是自己輸入layout檔重建時,還是遇到找不到這個layout file 的錯誤訊息

 這時,請到該amxl的屬性視窗那裡,找一下「建置動作」欄位,設定為「AndroidResource」
如附圖:
問題出在「建置動作」
這樣再重建就可以用了
參考這裡
以上,大家加油了

2015年12月18日 星期五

專案移轉到他平台時,complie時遇到「此專案參考這部電腦上所缺少的 NuGet 封裝。請啟用 NuGet 封裝還原,以下載該封裝。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的檔案是....」

移轉到他台pc的vs2015開發時,
如果只有copy一些source & html檔就編譯重建
就會遇到package 缺漏的訊息:
ex:
===================================
此專案參考這部電腦上所缺少的 NuGet 封裝。請啟用 NuGet 封裝還原,以下載該封裝。如需詳細資訊,請參閱 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的檔案是
..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props....
==================================
此時,除了用nuget把既有的package升級之外
最直接的方式是....從你copy過來的來源平台中,把package資料夾拿過來全數覆蓋
再重建之
就可以了
參考 相關案例

以上,加油了

2015年12月11日 星期五

for Extjs4 大一點的combobox下拉按鈕

一樣都是pos的單元,所以連帶combobox也要大一點
最麻煩的就是combobox旁邊的下拉鍵,怎麼做?
1.準備一個下拉要用的按鈕圖,本例是30x30
2.準備一個css class
========================================
            /*--for bigger combobox--arrow_down.png*/
            .bigTriggerArrow   {
                background-image: url('/FTW/Images/arrow_down.png') !important;
                height:30px!important;
                width:30px!important;
            }

======上述的「!important」真的是很important,省不得!!================
其中長與高,真的就是照圖的大小,別留白了
3.設定combobox的trigger css對應
================combobox==================
                                        {
                                            xtype: 'combobox',
                                            width: 155,
                                            height:32,
                                            fieldLabel: '業務人員',
                                            labelSeparator: '   ',
                                            labelWidth: 52,
                                            name: 'SO_sales',
                                            //triggerCls: 'bigTriggerArrow',
                                            triggerBaseCls: 'bigTriggerArrow',
                                            //triggerWrapCls: 'bigTriggerArrow',

                                            id: 'MainPanelTextInvoiceSEQ',
                                            allowBlank: false,
                                            queryMode: 'local',
                                            matchFieldWidth: false,
                                            store: new Ext.data.ArrayStore({
                                                fields: ['text', 'value'],
                                                data: [['李四', 'F'], ['張三', 'M']]
                                            }),
                                            valueField: 'value',
                                            displayField: 'text',
                                            listeners: {
                                                select: function (cbx, records, eOpts) {
                                                    var recOfCbx = records[0];
;

                                                }
                                            },
                                            listConfig: {
                                                width: 250,
                                                getInnerTpl: function () {
                                                    return '<h4>{value}</h4>{text}'
                                                }
                                            }
                                        }

============================================
以上

2015年11月20日 星期五

連結SignalR卻遇到「You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3.」 錯誤

server push 在多人系統中是可能會遇到的課題
在這次我們試著用SignalR來實做
大家應該都拿到範例了
如果是要從server的control去呼叫已經存在的SignalR去送訊息,
參考以下的程式碼:(caller project要先安裝siganlR client 套件) 
========先決條件是你已經做好一個SignalR with hub "ChatHub"================
 public ActionResult callSignalR() {
            var hubConnection = new HubConnection("http://localhost/SignalRChat");
            IHubProxy myproxy = hubConnection.CreateHubProxy("ChatHub");
            hubConnection.Start().Wait();
            myproxy.Invoke("Send", "From backend", "Attention!!");
            return new EmptyResult();
        }
===========================================
可是執生起來(hubConnection.start.Wait()那段),居然出現exception:
「You are using a version of the client that isn't compatible with the server. Client version 1.4, server version 1.3.」
翻遍所有的套件,好像都沒有1.4/1.3的代號
是的,問題不出在caller/control,而是出在signalR,
回到SignalR的專案,用nuget把用到的相關的套件做update,這個問題就解決了
就是這麼單純

以上,大家加油吧

2015年11月17日 星期二

for MSSQL2012 由查詢的結果產出insert 語法

「由查詢的結果產出insert 語法」(就某單一table查詢而言)
在toad 這樣的工具早就有這功能了,
在MSSQL 2008也有,叫 sp_generate_inserts
example:
EXEC sp_generate_inserts 'titles', @From = "from titles where title like '%Computer%'"
但是在MSSQL 2012 SQL 居然沒這麼好用的工具
放心,
這行就是這樣--很多事已經有人替你踢過鐵板了,你需要的,別人也有需要
以下就是這個產生insert語法的stored procedure:
===================================================================
/*
Authore : neeraj prasad sharma (please dont remove this :))
Example (1) Exec [dbo].[INS]  'Dbo.test where 1=1'
        (2) Exec [dbo].[INS]  'Dbo.test where name =''neeraj''' * for string

here Dbo is schema and test is tablename and 1=1 is condition

*/


CREATE procedure  [dbo].[INS]                              
(                                                          
   @Query  Varchar(MAX)                                                          
)                              

AS                              

       Set nocount ON                  

DEclare @WithStrINdex as INT                            
DEclare @WhereStrINdex as INT                            
DEclare @INDExtouse as INT                            

Declare @SchemaAndTAble VArchar(270)                            
Declare @Schema_name  varchar(30)                            
Declare @Table_name  varchar(240)                            
declare @Condition  Varchar(MAX)                             

SET @WithStrINdex=0                            

SELECT @WithStrINdex=CHARINDEX('With',@Query )                            
, @WhereStrINdex=CHARINDEX('WHERE', @Query)                            

IF(@WithStrINdex!=0)                            
Select @INDExtouse=@WithStrINdex                            
ELSE                            
Select @INDExtouse=@WhereStrINdex                            

Select @SchemaAndTAble=Left (@Query,@INDExtouse-1)                                                     
select @SchemaAndTAble=Ltrim (Rtrim( @SchemaAndTAble))                            

Select @Schema_name= Left (@SchemaAndTAble, CharIndex('.',@SchemaAndTAble )-1)                            
,      @Table_name = SUBSTRING(  @SchemaAndTAble , CharIndex('.',@SchemaAndTAble )+1,LEN(@SchemaAndTAble) )                            

,      @CONDITION=SUBSTRING(@Query,@WhereStrINdex+6,LEN(@Query))--27+6                            


Declare   @COLUMNS  table (Row_number SmallINT , Column_Name VArchar(Max) )                              
Declare @CONDITIONS as varchar(MAX)                              
Declare @Total_Rows as SmallINT                              
Declare @Counter as SmallINT              

declare @ComaCol as varchar(max)            
select @ComaCol=''                   

Set @Counter=1                              
set @CONDITIONS=''                              

INsert INTO @COLUMNS                              
Select  Row_number()Over (Order by ORDINAL_POSITION ) [Count] ,Column_Name FRom INformation_schema.columns Where Table_schema=@Schema_name                              
And table_name=@Table_name         


select @Total_Rows= Count(1) FRom  @COLUMNS                              

             Select @Table_name= '['+@Table_name+']'                      

             Select @Schema_name='['+@Schema_name+']'                      

While (@Counter<=@Total_Rows )                              
begin                               
--PRINT @Counter                              

    select @ComaCol= @ComaCol+'['+Column_Name+'],'            
    FROM @COLUMNS                              
Where [Row_number]=@Counter                          

select @CONDITIONS=@CONDITIONS+ ' +Case When ['+Column_Name+'] is null then ''Null'' Else ''''''''+                              

 Replace( Convert(varchar(Max),['+Column_Name+']  ) ,'''''''',''''  )                              

  +'''''''' end+'+''','''                              

FROM @COLUMNS                              
Where [Row_number]=@Counter                              

SET @Counter=@Counter+1                              

End                              

select @CONDITIONS=Right(@CONDITIONS,LEN(@CONDITIONS)-2)                              

select @CONDITIONS=LEFT(@CONDITIONS,LEN(@CONDITIONS)-4)              
select @ComaCol= substring (@ComaCol,0,  len(@ComaCol) )                            

select @CONDITIONS= '''INSERT INTO '+@Schema_name+'.'+@Table_name+ '('+@ComaCol+')' +' Values( '+'''' + '+'+@CONDITIONS                              

select @CONDITIONS=@CONDITIONS+'+'+ ''')'''                              

Select @CONDITIONS= 'Select  '+@CONDITIONS +'FRom  ' +@Schema_name+'.'+@Table_name+' With(NOLOCK) ' + ' Where '+@Condition                              
print(@CONDITIONS)                              
Exec(@CONDITIONS)  
=============================================================
出處在此
以上,大家加油吧



2015年11月10日 星期二

for Extjs4 ,如何在文字欄位離焦前做點事--找出被誰橫刀「奪焦」去了

找出同一個頁面中,是讓什麼其他元件取走focus
(這種需求多半是在輸入時要用輔助單元做輸入,而動作完之後,仍要再度取回焦點,)
我想,你一定想當然爾是在blur事件時做善後的,
example:
==================================
  { xtype:'textfield',
     ...
     ...
     listeners:{
          ...
          ...
          blur: function (textfield, e, o) {
               //test if the target is helper control,and take back focus latter.
             if(e.getTarget().id!=.......){
                //if target id is not help control,forget it
             }else{
                 //if target id is helper control, set the flag, wait for it
             }
 
          }
     
    }
   }
=====================================
但,不幸的,上例所取得的id,永遠是這個textfield.inputEl.dom.id,而不是取得焦點的extjs control id
,怎麼辦?
事實上,上面的例子,只要加個defer的動作,就差不多了,如:
==============================
   Ext.Function.defer(function () {
        if(e.getTarget().id!=.......){
        }
  },500);
=============================
是的,既言之,差不多,就是還是會有漏勾的地方,沒錯,在Chrome是很正常,但在IE & 火狐就掛了
就這樣放棄了嗎?
   那就改一下xtype吧,用別的文字方塊類別,,把上述的程式碼改一下
==================================
  { xtype:'numberfield',
     ...
     ...
     listeners:{
          ...
          ...
          blur: function (textfield, e, o) {
               //test if the target is helper control,and take back focus latter.
             if(e.getTarget().id!=.......){
                //if target id is not help control,forget it
             }else{
                 //if target id is helper control, set the flag, wait for it
             }
 
          }
     
    }
   }
========不要問我為什麼,反正我就是試出了===================
這樣在firefox & IE就正常了
以上,大家加油囉


2015年10月31日 星期六

Extjs4.2.2 pagingtoolbar 的按鍵怎麼修改 ?

最近很不幸的又是臨危受命去改版別人的東西,這次是POS
POS的東西有一項很重要的特性就是所有的按鍵都要大
其中Grid的列要如何加大,加高,這請自己去查
今天要講的是pagingtoolbar的問題
pagingtoolbar的「重新整理」這按鈕要怎麼查出來?
先看「錯誤示範」  
=============================================
 var grid = Ext.create('Ext.grid.Panel', {
   ...
   ...
   ...
  //這裡先不做dockedItems設定
  }
 var otherButton={.....} //定義一個要在pagingToolBar加入的其他功能按鈕
//在gird外面宣告一個paging Tool bar
        var pgToolbar = {
            xtype: 'pagingtoolbar',
            store: store,
            dock: 'bottom',
            displayInfo: true,
            height:40,
            items:[ otherButton ]
        }
 //放進 gird中
 grid.addDocked(pgToolbar);
 //這樣看起來看正常,是吧?
 //接著,我們要把「重新整理」按鍵隱藏起來,不讓user去按
pgToolbar.down('#refresh').hide(); <--注意,這裡就會出現pgToolbar error:沒有「.down」方法函數
                                                            //這下子,志明跟春嬌的故事就演不下去了!!
================================================
要怎麼做才是正確的呢?
以下才是正確的方法:
=============================================
 var grid = Ext.create('Ext.grid.Panel', {
   ...
   ...
   ...,
            width: 735,
            minHeight: 300,
           //這時就要先放進grid中了
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: store,
                displayInfo: true,
                dock: 'bottom',
                height:40,
                items: [
                     //在paging tool bar加上其他我們要用的動作鈕
                    {
                        xtype: 'button',
                        margin: '0 0 0 30',
                        text: '關閉',
                        handler: function () {
                            .....
                        }
                    }
                ]
            }]
  }
  //宣告完了,現在,就可以找出「重新整理 」按鍵做隱藏動作了
  grid.down('#refresh').hide(); <---這樣,就達成我們要的目的了
======================================================
其他的修改icon的動作也是如此,舉例吧
===================================
        var btnNext = grid.down('#next');
        btnNext.minWidth = 32;
        btnNext.minHeight = 32;
        btnNext.setText('');
        btnNext.setIcon('');
        btnNext.iconCls = null;
        btnNext.cls = 'pagingToolBarBtnNext';
================================
(上例是你已定義一個css  pagingToolBarBtnNext class,像是以下的玩意
           .pagingToolBarBtnNext {
                background-image: url('......../ToNext.png') !important;
            }
)

以上,大家加油吧