Private: MY Note


SQL SERVER TIP

Posted in DATABASE by dev1 on the November 29, 2007

SOA

Posted in SOA by dev1 on the November 27, 2007

เราอาจจะอธิบายได้ไม่ดีนักนะคะ จะลองดูละกัน

1. concept พื้นฐานของ SOA ก็คือมองทุกอย่างเป็น service
อย่างถ้า OOP เราจะมองทุกอย่างเป็น object ใช่มั้ยคะ แต่อันนี้เรามองเป็น service แทน
ตัวอย่างที่เขาชอบยกมาก็คือ service เช่น บริการจองโรงแรม บริการจองตั๋วเครื่องบิน บริการดูราคาหุ้น (Stock Quote)
ซึ่งเวลามองก็จะมองว่า มีบริการอย่างนี้นะ เราใส่ข้อมูลความต้องการเราลงไป แล้วเราได้บริการกลับมา
ซึ่งมันจะต่างจาก object ที่จะมองเป็น properties/behavior อะค่ะ

web service ก็เป็น implementation อย่างนึงของ SOA ทำนองเดียวกับที่ Java เป็น implementation ของ OO อะค่ะ

web service (WS) ก็จะประกอบด้วยส่วนหลักๆที่ควรรู้จัก 3 อัน ก็คือ WSDL, SOAP, UDDI (ทุกตัวเป็น XML)
ถ้าให้อธิบายคร่าวๆ

- SOAP จะเป็นส่วน transportation protocol อะค่ะ คือมันจะติดต่อกันด้วย SOAP
- WSDL จะเป็นตัวอธิบาย มองง่ายๆจะคล้ายๆ interface ก็คือจะอธิบายว่า service นี้รับ parameter อะไรบ้าง ส่งอะไรกลับคืนมา
- UDDI จะเป็นคล้ายๆสมุดหน้าเหลือง เวลาจะหา service ที่ต้องการก็เข้าไปเปิดหาในนี้

Invocation model ของ WS แบบในฝันก็คือ user ต้องการใช้บริการ เช่น อยากจองตั๋วเครื่องบิน ก็ไปดูใน UDDI ซึ่งมันก็จะมีหลายเจ้าที่ให้บริการที่เหมือนกัน ก็เลือกมาเจ้านึง (ซึ่งจะใช้เงื่อนไขอะไรนั้นก็เช่น QoS, Location, etc. )
แล้วก็จะได้ WSDL file (location) ของ service นั้นๆมาจาก UDDI
แล้วพอได้ WSDL file มาแล้วเราก็จะสามารถติดต่อกับ service นั้นๆได้แล้ว

แต่ปัจจุบัน UDDI มันยังไม่ค่อยมีคนใช้อะค่ะ หลักสำคัญก็คือต้องรู้ WSDLของ service ที่จะเรียกเป็นใช้ได้ ถ้ารู้อยู่แล้วก็ข้าม UDDI ไปได้เลย

2. อันนี้มันมีให้เลือกหลากหลายอยู่อะค่ะ ก็แล้วแต่ภาษาแล้วก็เทคโนโลยีที่ใช้ อย่างถ้าจะทำ WS ด้วย Java มันก็มีให้ใช้หลายตัวมากๆเลย อย่างเช่น JWSDP, Axis, และอื่นๆ (เราเคยใช้แค่สองตัว)
พวกตระกูล .NET ก็จะมีของมันอะค่ะ

3. ก็ต้องแล้วแต่ technology ที่ใช้ค่ะ
แต่หลักๆของมันก็คล้ายๆกัน คือถ้าจะสร้าง service ให้คนอื่นใช้ tool มันก็จะสร้าง WSDL file ออกมาให้ แต่ถ้าจะไปใช้ของเขา เราก็ต้องรู้ WSDL ของเขา แล้วเราก็สร้าง class ไฟล์มาเพื่อไปเรียกมันอีกที ปกติถ้าจะทำ web service จากโปรแกรมที่มีอยู่แล้ว ก็แค่สร้าง interface แล้วก็เอามาสร้าง wsdl ด้วย tool แล้วเอาไป deploy ก็ใช้ได้แล้ว

ref: http://www.narisa.com/forums/index.php?showtopic=15472

Notepad++ Cool Editor for Coding

Posted in .NET 2.0, ASP.NET by dev1 on the November 27, 2007

Sorting with DataView

Posted in .NET 2.0, ASP.NET by dev1 on the November 26, 2007

DataView dv = SapNewdt.DefaultView;

string sortExpr = ” Sent_SAP_Date ASC”;

//TableManager.HRTxnSAPSummary.SENT_SAP_DATE + ” , ” + TableManager.HRTxnSAPSummary.PROC_NAME + ” ASC”;

dv.Sort = sortExpr;

SapNewdt = dv.ToTable();

DataSet SapDs = new DataSet();SapDs.Tables.Add(SapNewdt);

return SapDs;

optimize data from calling webservice

Posted in .NET, .NET 2.0, ASP.NET by dev1 on the November 26, 2007

                DataTable HrDt = mHRTxnSAPData.ListDetail_OF_SentDocToSAP(comp_code, module, start_sap_date, end_sap_date
                                   , start_doc_date, end_doc_date, crem_type, Process_name, success, type);
                             
                foreach (DataRow dr in HrDt.Rows)
                {
                    //save to arrayList
                    strPin = dr[TableManager.WFCremation.PIN].ToString();
                    if (mList.IndexOf(strPin) == -1)
                    {
                        mList.Add(strPin);

                        if (type == “CR”)
                        {
                            strPin = dr[TableManager.WFCremation.HR_PIN].ToString();
                            if (mList.IndexOf(strPin) == -1)
                                mList.Add(strPin);
                        }
                    }

                    //save to hash(org info) –
                    strOrgInfo = dr[TableManager.WFCremation.NEAR_ORG_ID].ToString();
                    if (strOrgInfo != string.Empty)
                    {
                        if (!hashOrgInfo.ContainsKey(strOrgInfo))
                        {
                            OrgDs = mOMEHRService.GetOrgInfobyOrgCode(strOrgInfo);
                            if (OrgDs.Tables[0].Rows.Count > 0)
                                hashOrgInfo[strOrgInfo] = OrgDs.Tables[0].Rows[0][TableManager.Employee.ORG_DESC].ToString();
                        }
                    }

                }

                for (int a = 0; a < mList.Count; a++)
                {
                    if (strPin != string.Empty)
                        strPin = strPin + “,”;

                    strPin = strPin + mList[a].ToString();
                }

                //call ws for employee profile –
                dsProfile = mOMEHRService.ListEmployeeProfileByPIN(strPin);

———- calling  ——————

DataRow[] drProfile;

drProfile = dsProfile.Tables[0].Select(” PIN=’” + HrDr[TableManager.WFCremation.PIN].ToString() + “‘”);if (drProfile.Length != 0){

Pin_name = drProfile[0]["THFIRSTNAME"].ToString() + ” “ + drProfile[0]["THLASTNAME"].ToString();Position = drProfile[0][

TableManager.Employee.POSI_DESC].ToString();}

Display Hierarchical Data with TreeView in ASP.NET 2.0

Posted in .NET 2.0, ASP.NET by dev1 on the November 25, 2007

Keyboard short cut

Posted in OTHER by dev1 on the November 23, 2007

Here’s a simple way you can run Internet Explorer from the command line…

Create a new text file that contains the following line:

CODE

@start “” /b “C:\Program Files\Internet Explorer\iexplore.exe” %*

Rename the file e.bat

Copy this file to your profile folder

QUOTE

C:\Documents and Settings\your_account_name

Now you can open a command prompt window and type the following

CODE

e www.trap17.com

This will start Internet Explorer and open the URL for www.trap17.com 

———————————————- 

Windows Logo+E: Windows Explorer

Windows Logo+D: Minimizes all open windows and displays the desktop

Windows Logo+TAB: Cycle through taskbar buttons

Windows Logo+TAB: Cycle through taskbar buttons

Windows Logo+Break: System Properties dialog box
Dialog box keyboard commands
• TAB: Move to the next control in the dialog box

• SHIFT+TAB: Move to the previous control in the dialog box

• SPACEBAR: If the current control is a button, this clicks the button. If the current control is a check box, this toggles the check box. If the current control is an option, this selects the option.

• ENTER: Equivalent to clicking the selected button (the button with the outline)

• ESC: Equivalent to clicking the Cancel button

• ALT+underlined letter in dialog box item: Move to the corresponding item

store procedure call store procedure

Posted in DATABASE by dev1 on the November 21, 2007

<script type=”text/javascript”><!–
google_ad_client = “pub-2910472071369479″;
//728×90, created 11/20/07
google_ad_slot = “7313632958″;
google_ad_width = 728;
google_ad_height = 90;
//–></script>
<script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js“>
</script>

src=”http://pagead2.googlesyndication.com/pagead/show_ads.js” mce_src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>

set nocount on
declare @sql nvarchar(2000)
declare @comp_code nvarchar(255), @pin nvarchar(255), @LoanType nvarchar(255), @datefrom nvarchar(255)
declare @temp_id int, @n int
declare @docNo nvarchar(20)

create table #temp
(
 _id int IDENTITY,
 Company nvarchar(255),
 PIN nvarchar(255),
 LoanType nvarchar(255),
 df nvarchar(255)
)

insert into #temp
select Company, PIN, LoanType, convert(varchar,convert(datetime, DateFrom, 103),112) as df
from sheet1 where LoanType in (’01′,’02′,’03′,’04′,’05′) and convert(datetime, DateTo, 103) >= getdate()
order by pin

set @n = 0

– loop –
declare cur cursor for
select _id from #temp
open cur
fetch next from cur into @temp_id   
 while @@fetch_status=0
 begin  
  set @n = @n + 1
  
  exec get_running_number @n, @docNo out
  
  select @comp_code=Company, @pin=PIN, @LoanType=LoanType, @datefrom=df from #temp where _id=@temp_id
  
  set @sql = ‘insert into welfare.WF2_TXN_CREMATION (Comp_Code,Pin,Doc_Date,Relat_Pers_Type, Doc_No) values ‘
  set @sql = @sql + ‘(”’ + @comp_code + ”’,”’+ @pin + ”’,”’ + @datefrom + ”’,”’
+ @LoanType + ”’,”’ + @docNo + ”’)’
  print (@sql)
  
  fetch next from cur into @temp_id  
 end
 
 print ‘– total record: ‘ + cast(@n as varchar)

close cur
deallocate cur

– drop table –
drop table #temp    

set nocount off

store procedure for return value string format

Posted in DATABASE by dev1 on the November 21, 2007

CREATE PROCEDURE get_running_number
@id int,
@docNO varchar(20)  out
AS
begin
 declare @_id nvarchar(20)
 declare @i int
 set @_id = cast(@id as nvarchar)
 set @i = len(@_id)
 while (@i<5)
 begin
  set @_id = ‘0′ + @_id
  set @i = @i +1
 end
 set @_id = ‘WF0711′ + @_id
      select @docNO =  @_id
end
GO

asp.net repeater

Posted in .NET 2.0, ASP.NET by dev1 on the November 21, 2007
 <asp:Repeater id=”Repeater1″ runat=”server”>    <HeaderTemplate>       <table border=”1″>          <tr bgcolor=”#ffcc99″>             <th>ID</th>             <th>First Name</th>             <th>Last Name</th>             <th>Address</th>          </tr>    </HeaderTemplate>    <ItemTemplate>       <tr bgcolor=”#ffcccc”>         <td><%# DataBinder.Eval(Container.DataItem, “au_id”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “au_fname”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “au_lname”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “address”) %></td>       </tr>    </ItemTemplate>    <AlternatingItemTemplate>       <tr bgcolor=”#ccff99″>         <td><%# DataBinder.Eval(Container.DataItem, “au_id”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “au_fname”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “au_lname”) %></td>         <td><%# DataBinder.Eval(Container.DataItem, “address”) %></td>       </tr>    </AlternatingItemTemplate>    <FooterTemplate> 	   </table>    </FooterTemplate> </asp:Repeater> 
Next Page »