ASP.Net Restore Data


 

Ref: ASP.Net Backup Data

Ref: LINQ to File and Directory

Download:

http://cid-7d608959d854cb28.skydrive.live.com/embedrowdetail.aspx/SourcesCode/WebBackData|_19-09-2008.zip

รูปที่ 1

ออกแบบหน้าจอ:

รูปที่ 2

รูปที่ 3 รูปที่ 4

รูปที่ 5 รูปที่ 6

รูปที่ 7

รูปที่ 8

รูปที่ 9

รูปที่ 10

 

Ref: ASP.Net Backup Data

Ref: LINQ to File and Directory

     private void getListBackupFiles()
   
{
       
var f = from fs in new System.IO.DirectoryInfo(Server.MapPath("BackData")).GetFiles()
               
select new
               
{
                   
Name = "BackData\" + fs.Name,
                   
fs.CreationTime,
                   
fs.Extension,
                   
fs.Length
               
};

        GridView1.DataSource = f;
       
GridView1.DataBind();
   
}

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
   
{
       
if (e.CommandName == "Select")
       
{
           
int xrow =int.Parse(e.CommandArgument.ToString());
           
HyperLink hyperLink2 = GridView1.Rows[xrow].Cells[1].FindControl("HyperLink2") as HyperLink;
           
RestaoreDB(hyperLink2.Text);
       
}
   
}

    private void RestaoreDB(string backFile)
   
{   

        ServerConnection connection = 
           
new ServerConnection(this.Session["Server"].ToString (),

                                   
this.Session["User"].ToString(),
                                   
this.Session["Password"].ToString());
       
Server svr = new Server(connection);

        Restore res = new Restore();
       
res.Database = txtDBname.Text.Trim();
       
res.Action = RestoreActionType.Database;

        res.Devices.AddDevice(Server.MapPath(backFile), DeviceType.File);
       
res.PercentCompleteNotification = 10;
       
res.ReplaceDatabase = true;
       
res.PercentComplete += new PercentCompleteEventHandler(res_PercentComplete);

        svr.KillAllProcesses(txtDBname.Text.Trim());

        res.Wait();
       
res.SqlRestore(svr);
   
}

    void res_PercentComplete(object sender, PercentCompleteEventArgs e)
   
{
       
//throw new NotImplementedException();
        Label1.Text = e.Percent.ToString() + e.Percent.ToString() + "% Restored up";

    }

    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
   
{
       
if (e.Row.RowType == DataControlRowType.DataRow)
       
{
           
Button button1 =  e.Row.Cells[0].FindControl("Button1") as Button ;
           
button1.CommandArgument = e.Row.RowIndex.ToString();
       
}
   
}


 

Download:

http://cid-7d608959d854cb28.skydrive.live.com/embedrowdetail.aspx/SourcesCode/WebBackData|_19-09-2008.zip

 

Ref: ASP.Net Backup Data

Ref: LINQ to File and Directory

 

เกี่ยวกับ

Nuchit Atjanawat is a Microsoft MVP, GreatFriends Community Leader, WindowsITPro Columnist(Mr.Nano), Silverlight Business Application Instructor, Speaker in various Microsoft events, Author, passionate Blogger and a Software Engineer by profession. He has a very good skill over Silverlight, LightSwitch, C#, XAML & Blend. He shares his technical findings, tutorials in his technical blog. Follow his Blog and Facebook page to be updated on latest articles. - Technical Blog: https://janawat.wordpress.com - WindowsITPro Columnist(Mr.Nano): http://windowsitpro.net - The GreatFriends.Biz Community Discussion Board (nano): http://greatfriends.biz - witter: https://twitter.com/janawat - Facebook Page: https://www.facebook.com/nuchit - Instructor: http://bit.ly/GF250-01, http://bit.ly/GF150-02

เขียนใน Web Application

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

In Archive
%d bloggers like this: