블로그 이미지
다비도프

만나고, 고백하고, 가슴 떨리고, 설레이고, 웃고, 사랑하고, 키스하고, 함께하고..

Rss feed Tistory
WEB/AJAX 2007. 3. 14. 11:44

A Quick Guide How to start : AjaxPro

원문 : http://www.ajaxpro.info/quickguide.aspx

1. Download the latest Ajax.NET Professional files from www.schwarz-interactive.de
2. Add a reference to the AjaxPro.2.dll (for the .NET 1.1 Framework use AjaxPro.dll)
3. Add following lines to your web.config:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.web>
    <httpHandlers>
      <add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
    </httpHandlers>

  [...]

  </system.web>
</configuration>

4. Now, you have to mark your .NET methods with an AjaxMethod attribute:

[AjaxPro.AjaxMethod]
public DateTime GetServerTime()
{
  return DateTime.Now;
}

5. To use the .NET method on the client-side JavaScript you have to register the methods, this will be done to register a complete class to Ajax.NET:

namespace MyDemo
{
  public class _Default
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      AjaxPro.Utility.RegisterTypeForAjax(typeof(_Default));
    }

    [AjaxPro.AjaxMethod]
    public DateTime GetServerTime()
    {
      return DateTime.Now;
    }
  }
}

6. If you start the web page two JavaScript includes are rendered to the HTML source.
   To call a .NET method form the client-side JavaScript code you can use following syntax:

function getServerTime()
{
  MyDemo._Default.GetServerTime(getServerTime_callback);  // asynchronous call
}

// This method will be called after the method has been executed
// and the result has been sent to the client.

function getServerTime_callback(res)
{
  alert(res.value);
}

,
WEB/ASP.NET With C# 2007. 3. 13. 16:13

HttpContext.Current.Cache의 사용..

   //--> 캐쉬에서 가져오기 : 저장되어져 있는 cache가 있다면 ds에 그값을 저장한다.  
   ds = (DataSet) HttpContext.Current.Cache["cacheXXX"];

   // 만약 저장된 cache가 없다면..
    if (ds==null)
    {
         // DB에서 DataSet을 받는다.
        ds =  <-- DataSet을 실제로 받아서 넣는것임......!!!!!

        if (ds.Tables[0].Rows.Count > 0)
        {
            // DB에 데이터가 있다면 받아온 데이터를 캐쉬에 Insert!!
            HttpContext.Current.Cache.Insert("cacheXXX", ds, null, DateTime.Now.AddMinutes(10), System.Web.Caching.Cache.NoSlidingExpiration);
        }
        else
        {
            // 받아온 데이터가 없다면..
            HttpContext.Current.Cache.Remove("cacheXXX");
            //--> 데이터가 없다는 얘긴데, 말도 안되므로 캐쉬를 일단 제거해줌
            // (빈캐쉬가 오랫동안 남지 않도록)
        }
    }


    컨트롤.DataSource = ds;
    컨트롤.DataBind();
,
WEB/ASP.NET With C# 2007. 3. 13. 16:05

3Tier..?

3Tier로 개발할때 중요한 건
미리 요구사항 분석 완료, DB설계, 프로시져 제작,
그다음에 데이터 계층 설계, 그 다음에 비지니스 계층 설계, 프레젠테이션은..??
그리고 데이터 계층 코딩, 비지니스 코딩, 프레젠테이션 코딩 순서로.. 가는 거 같다..
결국 DB랑 똑같은 걸..
3 Tier, 3 Layer 헷갈리다가 찾은 문서..
물리적인 분리냐, 논리적인 분리냐에 따라 Tier인지 Layer인지 구분한다는 거!!
혼용하지 말 것!!

아래는 참고글 : http://vishwamohan.blogspot.com/2006/10/understanding-3-tier-vs-3-layer.html

Understanding 3-Tier vs. 3-Layer Architecture

The terms tier and layer are frequently used interchangeably, but actually there is a difference between them: Tiers indicate a physical separation of components, which may mean different assemblies such as DLL, EXE etc on the same server or multiple servers; but layers refers to a logical separation of components, such as having distinct namespaces and classes for the Database Access Layer (DAL), Business Logic Layer (BLL) and User Interface Layer (UIL). Therefore, tier is about physical separation and units of deployment, and layers are about logical separation and units of design.

Creating a multi tier project design is more suitable and advisable to mid to large-size projects, whereas a good multi-layered design is suitable for small to mid-size projects.

Let’s understand this difference more closely with my earlier posts on “Developing 3-Tier Application in .NET 2.0”. In reality this example is 3-layer architecture because all the layers are logically separated but stay in one code. Following are the namespaces of each layer

1. eBizzTech.Examples.Web.DAL
2. eBizzTech.Examples.Web.BLL
3. eBizzTech.Examples.Web.UIL


The final DLL contains all the above layers: eBizzTech.Examples.Web.dll

Now, let’s think how to build the same project in true 3-tier architecture. For simple understanding, each layer will be moved to a separate project and thus creating following three dlls. These dlls can stay on the same machine or different servers.

1. eBizzTech.Examples.Web.DAL.dll
2. eBizzTech.Examples.Web.BLL.dll
3. eBizzTech.Examples.Web.UIL.dll


But, by just moving the code of each layer into a separate project will not work, because first and foremost issue is: each layer depends on other layer, so you can not compile one project without other one and here you are in catch 22 situation.

So you will require changes into current design. Also, if you are not planning to keep all the layers in the same folder of your application, then another big issue- how to refer and communicate with each layer’s object. Here is some approach you can take for each layer to convert into a tier model.

  • Literally, create a separate project for each layer.
  • For Database Access Layer and Business Logic Layer ASP.NET Web Services or .NET Remoting can be used. If you can use .NET 3.0 Windows Communication Foundation (WCF) Services, that will be great, they seem to me like Web Services but more powerful, secure and flexible than Web Services.
  • User Interface Layer will stay as ASP.NET Web Site but some changes will be required for invoking or calling Business Objects. However, existing BLL and DAL layers will be removed from current project.
  • Additionally, I will recommend using Microsoft Enterprise Library - Application Blocks for .NET 2.0. This library can help you to build a robust application, it provides solutions to common development challenges such as data access, logging and user interface etc. You can find more information at http://msdn.microsoft.com/practices
  • By using (Web) Services, you will move one step towards Service Oriented Architecture (SOA), which is becoming more popular now in enterprise application development.
You must be wondering why did I use the word 3-Tier instead of 3-layer?

First of all most of the time people are searching on key words like 3-Tier rather 3-Layer. Word 3-tier architecture is most frequently used but heavily misused in IT industry. So it is easier to bring people to the information they are looking for and then educate them as what exactly it means.

Needless to say that it was easier for me to take a simple example for 3- layer architecture design and explain each layer step by step. Developing a true multi tier approach may look like over killing of the sample project. I may write one sometime in future:).
,
WEB/Java Script 2007. 3. 9. 21:01

JavaScript - Powerful Extension : Firebug

IE에서 지원되는 IE Developer Tollbar따위 쓰레기통에 버려버리고
모두 같이 Firebug를 씁시다.

http://www.getfirebug.com/
,
WEB/ASP.NET With C# 2007. 3. 9. 15:56

[개발] AJAX - Rolling List

요번 프로젝트때 만든 롤링리스트...
10초마다 ajax함수를 호출해서...
함수에 요청하는 건데.. 부하가 많이 걸려서 OTL

[aspx]

<UL id=RollListSubList>
<asp:Literal id=ltrMainRssList EnableViewState="False" Runat="server"></asp:Literal>
</UL>
<script language="javascript" type="text/javascript">
   function ReloadRollList(){Ajax.PG.ucRollListNetSub.reloadList(Reload_CallBack);}
   function Reload_CallBack(res){
        if(res != null){
              var divRss = document.getElementById('RollListSubList'); divRss.innerHTML = res.value;}}
   setInterval("ReloadRollList();", 10000);
</script>

[cs]

[AjaxPro.AjaxMethod]
  public string reloadList()
  {
   int temp = 0;
   DataSet ds = RollListNetBiz.GetListAdminRecommand(1,30, out temp);

   if(ds != null)
   {
    DataTable dt = Utility.RollingData(ds.Tables[0], 10);   
    string HTML = string.Empty;
    Random random = new Random();
   
    int boldNum1 = random.Next(0, 4);
    int boldNum2 = random.Next(5, 9);

    for(int i = dt.Rows.Count -1 ; i >= 0 ; i--)
    {
     int RollListID = (int) dt.Rows[i]["RollListID"];
     string Title = dt.Rows[i]["Title"].ToString();
     string Content = dt.Rows[i]["Content"].ToString();
     string Link = dt.Rows[i]["ContentUrl"].ToString();
     string MasterName = dt.Rows[i]["MasterName"].ToString();
     DateTime Date = (DateTime) (dt.Rows[i]["PubDate"]);

     string MasterLink = "./RollListNetMaster.aspx?MasterID=" + RollListID.ToString();

     Title = Utility.RemoveHTML(Title);
     Title = Utility.RemoveHTMLTag(Title);
     Title = Utility.GetTitles(Title, 12);

     if(i == boldNum1 || i == boldNum2)
     {
      Title = Utility.GetTitles(Title, 10);
      HTML  += "<li class='bold'><a href='" + Link + "' target='RollListViewer'>" + Title + "</a></li>";
     }
     else
     {
      Title = Utility.GetTitles(Title, 12);
      HTML  += "<li><a href='" + Link + "' target='RollListViewer'>" + Title + "</a></li>";
     }
    }
    return HTML;
   }
   else
    return null;
  }

,
WEB/Java Script 2007. 3. 9. 15:03

Flash에서의 Javascript호출 문제

[Flash에서의 Javascript호출 문제]

Form태그안에 Flash가 Object태그로 들어간 경우에는
Flash에서의 Js Function Call이 먹히지 않습니다.
현재 진행하고 있는 프로젝트에서 동영상의 주소를 클립보드로 복사하기 위해
플래시에서 Js Function을 Call하는데 Form태그안에 Object 태그로 들어가 있는
플래시의 경우 IE에서는 백이면 백 "ObjectID is undefined" 라는
Script Error가 나타납니다. 이런경우에는 어떻게 해결하느냐~
2가지 방법이 있습니다.

1. <Object>를 <Form> 바깥으로 뺀다!! -_-;;
    간단하군;;

2. undefined가 나지 않도록 IE일 경우
    window.[ObjectID] = new Object();를 추가하면 됩니다. 그럼 OK~


   [html]

<script language='javascript'>
//<![CDATA[

   if(navigator.appName.indexOf("Microsoft") != -1)
   {
      window.flvplayer = new Object();
   }

   function callFromFlash()
   {
        ....
       if(navigator.appName.indexOf("Microsoft") != -1)
      {
          window.flvplayer = document.getElementById('flvplayer');
      }
   }

//]]>
</script>
<form runat='server' method='post'>
   ...
   <object id='flvplayer' classid='dasjkfljdklal' ...> ...</object>
   ...
</form>


[참고]
http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002200.html

http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00002201.html



현재까지는 이게 최고의 해결책이랍디다;;

추가 :
불려지는 함수에
window.flvplayer = document.getElementById('flvplayer');
를 추가시켜 IE에서 보여지는 스크립트 에러를 제거~ s( ̄∇ ̄)v
,
WEB/AJAX 2007. 3. 9. 13:35

Ajax 활용시 고려해야 될 점..

1.  Ajax를 사용한 이벤트 처리시에 디자인이 깨지는 거 고려해야 되요~ [2007.01.30]

자.. 무슨 말이냐..
Ajax를 사용해서 이벤트를 처리하고 그 뒷처리까지 깨끗이 했으면!!
분명히 무언가 바꼈을끄에요.
무언가 바꼈으니 레이아웃도 조곰 변경됐을텐데!!
나머지부분은 적용이 안된다는 거~!!
그러니까 리플을 예로 들믄

      1) 리플 삭제 -> Ajax
      2) CallBack 처리 - 삭제 결과값
      3) 리플 리스트 다시 바인딩하고 -> Ajax

여기까지 하면 리플 아래에 있는 Footer 같은 거.
아님 머 이미지 네비 같은거.
아님 글 리스트 같은 건
제자리에 그대로 있다는 거~!!

그러니까 저기서 끈나는게 아니라 변경된 레이아웃까지 다시 잡아줘야 된다는 거..


2. CS단의 Ajax Method에서는 Data값이 남아있지 않아요~ [2007.01.30]
이건 조금 하믄 당근 아는거..

   [cs]

   private int aaa = 1;
   private void Page_Load(object sender, System.EventArgs e)
  {
       AjaxPro.Utility.RegisterTypeForAjax(typeof(Viewer));
     
      // 이렇게 aaa를 cs단에 박아넣어도..
      if(Request.QueryString["aa"] != null
          && Request.QueryString["aa"].ToString() != "")
       this.aaa = int.Parse(Request.QueryString["aa"]);
  }

   [AjaxPro.AjaxMethod]
   public bool Delete(int ID)
  {
        // 불러도 이건 쓰레기값~!!
        return this.aaa;
  }


3. AjaxPro.AjaxMethod는 Overload가 되지 않습니다요~ [2007. 2. 12]

cs단에 아래와 같이 이름이 같고, 파라미터가 다르게 오버로드를 하려고 해도 AjaxPro에서는
함수 Overloading을 지원하지 않기때문에 스크립트에서 정의되지 않은 / 정확한 파라미터가 아니라는 에러가 난다.

    [cs]

    [AjaxPro.AjaxMethod]
    public bool CreateContentReply(int ZMID, int ZMCID, string Name){...}

    [AjaxPro.AjaxMethod]
    public bool CreateContentReply(int ZMID, int ZMCID){...}


    [Html]
    AjaxPro.PG.Viewer.CreateContentReply(ZMID, ZMCID, Name, CallBack_proc);
    AjaxPro.PG.Viewer.CreateContentReply(ZMID, ZMCID, CallBack_proc);   Error
,
WEB/ASP.NET With C# 2007. 3. 9. 13:31

[개발] 올블로그 - 아이디 체크

간단하게 아이디체크 구현해보자..
정말 간단.. -ㅁ-;;



 올블로그에서 회원가입시 포스트백 없이 아이디 체크되는 걸.. 보고..
혹해서 만들어봤다..


[aspx]
<script type="text/javascript" src="./lib/prototype/prototype.js"></script>
 <script>
      function AjaxIDCheck(param)
      {
          PG.AjaxBoard.IDCheck.IDChecking(param, IDCheck_CallBack);
      }

      function IDCheck_CallBack(res)
      {
          var check_value = res.value;
   
          if(check_value)
              lblText.innerHTML = "사용하실 수 있는 ID 입니다.";    
          else
              lblText.innerHTML = "이미 등록된 ID 입니다.";    
      }
   
      function IDCheck()
      {
          var param = $('txtID').value;
   
          if(param.trim() == "")
              lblText.innerHTML = "ID를 입력해주세요.";    
          else
              AjaxIDCheck(param);
      }
  </script>
   ...
   <input type="text" ID="txtID" Width="200px" onkeyup="IDCheck()"/>
   <label id="lblText"></label>
   ...

   
[cs]
   private void Page_Load(object sender, System.EventArgs e)
  {
      AjaxPro.Utility.RegisterTypeForAjax(typeof(IDCheck));
  }

   [AjaxPro.AjaxMethod]
   public bool IDChecking(string strID)
   {
      bool check_value = false;

      // DB단 처리
      ...

      return check_value;
   }


생각보다 무지 간단하구나..=ㅁ=;;
올블로그랑 똑같이 하려면 onkeyup 이벤트를 onblur 이벤트로 바꿔주면 된다..

,
TOTAL TODAY