星期一, 4月 18, 2011

[MSSQL] 安裝錯誤解決方法

問題:升級到 SQL Server 2005 失敗,並出現「安裝程式無法連接到資料庫服務進行伺服器組態。」錯誤訊息。

問題:如果在升級到 SQL Server 2005 期間無法使用通訊埠 1433,則 SQL Server 安裝程式會傳回下列錯誤:

SQL Server 安裝程式無法連接到資料庫服務進行伺服器組態。

解決方案:若要繼續,請終止使用通訊埠 1433 的處理序,並繼續進行 SQL Server 2005 安裝程式:

從命令提示字元執行 netstat -o。
識別使用通訊埠 1433 的應用程式或處理序。
使用 [工作管理員] 來關閉應用程式或終止處理序以釋放通訊埠 1433。
繼續 SQL Server 2005 安裝程式。
如果使用上述步驟仍無法釋放通訊埠 1433,請使用下列其他步驟:

開啟 [控制台] 的 [新增或移除程式]。
選取 [Microsoft SQL Server 2005],再按一下 [變更]。
在 [元件選擇] 頁面上,按一下要升級的 SQL Server 執行個體的選項按鈕,然後按 [下一步]。
在 [功能維護] 頁面上,按一下 [Database Engine],然後按 [下一步]。
按一下 [繼續] 來繼續 SQL Server 2005 的升級作業。

Reference:
對 SQL Server Database Engine 的安裝進行疑難排解

星期四, 4月 14, 2011

md5 image file

string ImageFileName = null;
string StrImageName = null;
string UploadImageFolderPath = Server.MapPath("../Upload/Images/");
string ImageFileExtension;

if (ImageUpload.HasFile)
{
StrImageName = ImageUpload.FileName.ToString();
ImageFileExtension = System.IO.Path.GetExtension(StrImageName);

// GIVE A UNIQUE FILENAME(MD5) TO THE UPLOADED FILE:

MD5CryptoServiceProvider objMD5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bs = System.Text.Encoding.UTF8.GetBytes(StrImageName);
bs = objMD5.ComputeHash(bs);
System.Text.StringBuilder s = new System.Text.StringBuilder();

foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToLower());
}

StrImageName = s.ToString();

ImageFileName = StrImageName + ImageFileExtension;

// As long as the Image-File-Name is exists in the folder then we are MD5ing again the imgage-file-name:

while (System.IO.File.Exists(UploadImageFolderPath + ImageFileName))
{
MD5CryptoServiceProvider objMD5While = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] bsWhile = System.Text.Encoding.UTF8.GetBytes(StrImageName);
bsWhile = objMD5.ComputeHash(bsWhile);
System.Text.StringBuilder sWhile = new System.Text.StringBuilder();

foreach (byte bWhile in bsWhile)
{
sWhile.Append(bWhile.ToString("x2").ToLower());
}

StrImageName = sWhile.ToString();
ImageFileName = StrImageName + ImageFileExtension;
}

ImageUpload.PostedFile.SaveAs(UploadImageFolderPath + ImageFileName);
}

星期三, 4月 13, 2011

圖片檔案hash

string hash = null;
                using (System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider())
                {
                    System.Drawing.Imaging.ImageFormat format = System.Drawing.Imaging.ImageFormat.Jpeg;
                    System.Drawing.Image myImage = System.Drawing.Image.FromFile(path + f.ToString());
                    myImage.Save(ms, format);

                    hash = Convert.ToBase64String(sha1.ComputeHash(ms.ToArray()));
                }

星期四, 4月 07, 2011

[ZK] Image setContent using Stream

Aimage stream設定範例
    
URL url = new URL(avatar);
            AImage aimg = new AImage("avatar",url.openStream());
            myPhoto.setContent(aimg);

[Alfresco] upload user avatar using resetful api

Build a uploadavatar.jsp page to test uploadavatar restful api.
The page content is shown as the below:

<form id="avatar" enctype="multipart/form-data"
action="http://ideas-cosa.dyndns.org/alfresco/service/slingshot/profile/uploadavatar?alf_ticket=TICKET_32178fa17bcf3b975e76129dccb78d646466e88d" method="post">
<input type="text" name="username" value="ken"/>
Select a file:
<input type="file" name="filedata" />
<input type="submit" name="button" value="upload" />
</form>

星期二, 4月 05, 2011

HTTP 檔案上傳機制解析 [精華]

HTTP 檔案上傳機制解析 [精華]

[Asp.Net] 重新註冊IIS .NET Framework

以下程式碼為簡單的範例:請自已修正安裝的.net framework路徑

REM This batch file addresses "Server unavailable" error
@echo off

REM "Changing to the Framework install directory"
cd /d C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727

echo "Stopping IIS"
iisreset /stop
echo "----------------------"

echo "Stopping the ASP.NET state service if it is running"
net stop aspnet_state
echo "----------------------"

echo "Re-registering ASP.NET"
aspnet_regiis -i
echo "----------------------"

echo "Restarting IIS"
iisreset /start
echo "----------------------"

星期日, 3月 27, 2011

[ZK] How to download file in ZK

 public void onClick$downloadAgent(Event event){
  
  try {
   Filedownload.save("download/xxx.xls", "application/octet-stream");
  } catch (FileNotFoundException e) {
   System.out.println("FileNotFoundException:" + e.getMessage());
  }
  
 }

[Asp.Net] zip and unzip in asp.net using DotNetZip Library

If you want to create a zip in your asp.net.I suggests that you can use DotNetZip Libriay that is very easy to use.You can get more details in the following link :
DotNetZip Library


Create a downloadable zip within ASP.NET. This example creates a zip dynamically within an ASP.NET postback method, then downloads that zipfile to the requesting browser through Response.OutputStream. No zip archive is ever created on disk.

public void btnGo_Click (Object sender, EventArgs e)
{
  Response.Clear();
  Response.BufferOutput= false;  // for large files
  String ReadmeText= "This is a zip file dynamically generated at " + System.DateTime.Now.ToString("G");
  string filename = System.IO.Path.GetFileName(ListOfFiles.SelectedItem.Text) + ".zip";
  Response.ContentType = "application/zip";
  Response.AddHeader("content-disposition", "filename=" + filename);
  
  using (ZipFile zip = new ZipFile()) 
  {
    zip.AddFile(ListOfFiles.SelectedItem.Text, "files");
    zip.AddEntry("Readme.txt", "", ReadmeText);
    zip.Save(Response.OutputStream);
  }
  Response.Close();
}

星期二, 3月 22, 2011

[Alfresco] Create your first web script

if you want to create customize web script in Alfresco.
You will need to understand:
  • XML for expressing the Web Script description
    • <basename>.<httpmethod>.desc.xml
  • Optionally, JavaScript for writing Web Script behaviour
    • <basename>.<httpmethod>.js
  • Freemarker for rendering a Web Script response
    • <basename>.<httpmethod>.<format>.ftl

星期日, 3月 20, 2011

[XSLT] XSLT Note

XSLT(Extensible StyleSheet Language Transformations)
XSLT是一種把XML文件轉換成XHTML文件或是其他的XML文件的語言。
XPath則是可以操控XML文件的語言,XSLT大量的使用此技術。
XSLT文件是利用stylesheet當作root element的XML文件

Reference:
XSLT Tutorial

星期三, 3月 16, 2011

[ZK] How to pass parameter to another zul page

Today i want to pass parameter to another zul page so i find the solution for using "Executions.createComponents".



arg - java.util.Map(Refer to ZK:The User Guide)
The arg argument passed to the createComponents method in the
org.zkoss.zk.ui.Executions class. It might be null, depending on how
createComponents is called.

It is the same as self.desktop.execution.arg.
params.put("name", "John");
Executions.createComponents("/my.zul", null, params);

Then, in my.zul,

...

Notice that arg is available only when creating the components for the included page, say
my.zul. On the other hand, all events, including onCreate, are processed later. Thus, if you
want to access arg in the onCreate's listener, use the getArg method of the
org.zkoss.zk.ui.event.CreateEvent class.


Testing code is the below:
In the a.zul composer.
final Map<String, Object> map = new HashMap<String, Object>(0);
    map.put("userid",detailsUser.getUserName() );

    Window changepasswordWin = null; 
    changepasswordWin = (Window) Executions.createComponents(
      "/admin/change_password.zul", 
      null,
      map);

In teh b.zul composer.(change_password.zul)
Map<String, Object> args = null;
public void onCreate$changePasswordWin(Event e) throws Exception {
  System.out.println("--ChangePassword changePasswordWin--");
 
  CreateEvent ce = (CreateEvent) ((ForwardEvent) e).getOrigin();
  this.args = ce.getArg();
  System.out.println("pass userid:" + this.args.get("userid"));
  
  //do something
  //....

  System.out.println("--/ChangePassword changePasswordWin--");
 }

星期二, 3月 15, 2011

[ZK] Dynamic to add button and listen event

  Button btnModify = new Button("Modify Password");
                //parent is cell of row
  btnModify.setParent(cell);
  btnModify.setImage("/admin/images/btn/modify_key.png");
  btnModify.addEventListener("onClick", new EventListener() {
         public void onEvent(Event event) throws Exception {
          
           //to do something
          
          } 
   });

[ZK] Messagebox EventListener

捕捉Question Messagebox的事件

//popup messagebox
Messagebox.show("Are you sure?",
      "Question", Messagebox.OK | Messagebox.CANCEL,
      Messagebox.QUESTION, new EventListener() {
       public void onEvent(Event event) throws Exception {
        //if clicks ok to do something
        if (((Integer) event.getData()).intValue() == Messagebox.OK) {
         //to do something
        }
       }
      });

星期五, 3月 04, 2011

PHP ZEND Framwork

http://blog.corausir.org/website-design/ausir-1219
http://www.jaceju.net/blog/archives/category/web-development/php/zend-framework/page/2
http://blog.wu-boy.com/2009/03/24/1060

星期二, 3月 01, 2011

[ZK] ZK Eclipse Setting

From: ZK Essentials/Working with the Sample Applications/Setting Up the Applications Using Eclipse

In the fifth step:
"Once the download is complete, go to Window > Preferences > ZK > ZK Packages, click Add File/Directory to add the ZK package downloaded"

The default ZK Package versioin is 3.6.3, so downloaded the latest one which is zk-bin-5.0.5.zip from zk downloads. Then keep following the fifth step to select the downloaded file and then the latest version could be displayed as an option.

其他你感興趣的文章

Related Posts with Thumbnails