You are on page 1of 16

SAMPLE CODE:

namespace parallel { partial class Home_page { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Home_page)); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.linkLabel2 = new System.Windows.Forms.LinkLabel(); this.linkLabel3 = new System.Windows.Forms.LinkLabel(); this.linkLabel4 = new System.Windows.Forms.LinkLabel(); this.SuspendLayout(); // // linkLabel1 // this.linkLabel1.AutoSize = true; this.linkLabel1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkLabel1.LinkVisited = true; this.linkLabel1.Location = new System.Drawing.Point(363, 24); this.linkLabel1.Name = "linkLabel1"; this.linkLabel1.Size = new System.Drawing.Size(190, 24); this.linkLabel1.TabIndex = 14; this.linkLabel1.TabStop = true;

this.linkLabel1.Text = "Parellel Processing\r\n"; this.linkLabel1.VisitedLinkColor = System.Drawing.Color.Blue; this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkCli cked); // // linkLabel2 // this.linkLabel2.AutoSize = true; this.linkLabel2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkLabel2.LinkVisited = true; this.linkLabel2.Location = new System.Drawing.Point(363, 93); this.linkLabel2.Name = "linkLabel2"; this.linkLabel2.Size = new System.Drawing.Size(173, 24); this.linkLabel2.TabIndex = 15; this.linkLabel2.TabStop = true; this.linkLabel2.Text = "Serial Processing\r\n"; this.linkLabel2.VisitedLinkColor = System.Drawing.Color.Blue; this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkCli cked); // // linkLabel3 // this.linkLabel3.AutoSize = true; this.linkLabel3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkLabel3.LinkVisited = true; this.linkLabel3.Location = new System.Drawing.Point(363, 209); this.linkLabel3.Name = "linkLabel3"; this.linkLabel3.Size = new System.Drawing.Size(72, 24); this.linkLabel3.TabIndex = 16; this.linkLabel3.TabStop = true; this.linkLabel3.Text = "Report\r\n"; this.linkLabel3.VisitedLinkColor = System.Drawing.Color.Blue; this.linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel3_LinkCli cked); // // linkLabel4 // this.linkLabel4.AutoSize = true; this.linkLabel4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.linkLabel4.LinkVisited = true; this.linkLabel4.Location = new System.Drawing.Point(363, 146); this.linkLabel4.Name = "linkLabel4"; this.linkLabel4.Size = new System.Drawing.Size(63, 24); this.linkLabel4.TabIndex = 17; this.linkLabel4.TabStop = true;

this.linkLabel4.Text = "Client\r\n"; this.linkLabel4.VisitedLinkColor = System.Drawing.Color.Blue; this.linkLabel4.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel4_LinkCli cked); // // Home_page // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.ControlLightLight; this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage"))); this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(565, 297); this.Controls.Add(this.linkLabel4); this.Controls.Add(this.linkLabel3); this.Controls.Add(this.linkLabel2); this.Controls.Add(this.linkLabel1); this.Name = "Home_page"; this.Text = "Home_page"; this.ResumeLayout(false); this.PerformLayout(); } #endregion private private private private } } using using using using using using using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.IO; System.Data.SqlClient; System.Net; System.Net.Sockets; System.Net.NetworkInformation; System.Net.Security; System.Windows.Forms.LinkLabel System.Windows.Forms.LinkLabel System.Windows.Forms.LinkLabel System.Windows.Forms.LinkLabel linkLabel1; linkLabel2; linkLabel3; linkLabel4;

namespace parallel { public partial class Parellel_Image_process : Form { public static string filedir, client, filesize, filename, forwarder, time;

public static TimeSpan timeduration; public static string ip, req, filename1; public static string dfil, ofile, efilename; string fileDes, cryptFile, password, fileIni, fileDir, path1; string ser1, exe, fileN; string pass, inputFile, file, ini, outputFile, name, fname; DateTime starttime1, endtime1; public Parellel_Image_process() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { pipeline1();

public void pipeline() { try { IPAddress[] ipAddress = Dns.GetHostAddresses(client); IPEndPoint ipEnd = new IPEndPoint(ipAddress[0], 5656); Socket clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP); string filePath = ""; fileDes = fileDes.Replace("\\", "/"); while (fileDes.IndexOf("/") > -1) { filePath += fileDes.Substring(0, fileDes.IndexOf("/") + 1); fileDes = fileDes.Substring(fileDes.IndexOf("/") + 1); } byte[] filedirByte = Encoding.ASCII.GetBytes(fileDes); DateTime starttime = DateTime.Now; //starttime1 = starttime; label2.Text = ""; label2.Text = "Buffering ..."; byte[] fileData = File.ReadAllBytes(filePath + fileDes); byte[] clientData = new byte[4 + filedirByte.Length + fileData.Length]; byte[] filedirLen = BitConverter.GetBytes(filedirByte.Length); filedirLen.CopyTo(clientData, 0);

filedirByte.CopyTo(clientData, 4); fileData.CopyTo(clientData, 4 + filedirByte.Length); clientSock.Connect(ipEnd); clientSock.Send(clientData); label2.Text = ""; DateTime endtime = DateTime.Now; //timeduration = starttime.Subtract(endtime);//.Subtract(dt); timeduration = endtime.Subtract(starttime); } catch (Exception ex) { DateTime dt = DateTime.Now; if (ex.Message == "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond") { label2.Text = ""; label2.Text = "No Such System Available Try other IP"; } else { if (ex.Message == "No connection could be made because the target machine actively refused it") { label2.Text = ""; label2.Text = "File Sending fail. Because server not running."; } else { label2.Text = ""; label2.Text = "File Sharing filed fail." + ex.Message; } } } } public void pipeline1() { //FileInfo fi = new FileInfo(textBox1.Text); //string toid = "\\\\" + textBox2.Text + "\\Parrallel\\" + fi.Name; //sendsharedfolder(fi.FullName, toid); DirectoryInfo di = new DirectoryInfo(textBox1.Text); foreach (FileInfo fi in di.GetFiles()) {

if(fi.Extension==".jpg"|| fi.Extension==".bmp"||fi.Extension==".gif") { //time = DateTime.Now.ToString(); string toid = "\\\\" + textBox2.Text + "\\Parrallel\\" + fi.Name; starttime1 = DateTime.Now; sendsharedfolder(fi.FullName, toid); filename = fi.Name; sqlcon(); } //sqlconnection(); //Status_lbl.Text = "File transfered"; } } public void sendsharedfolder(string from, string to) { FileInfo fi = new FileInfo(from); fi.CopyTo(to); endtime1 = DateTime.Now; //sqlcon(); time = DateTime.Now.ToString(); label3.Text = "File transfered"; } private void button1_Click(object sender, EventArgs e) { //String fileName = GetFileName("Videos (*.avi)|*.avi;*.mpe;*.mpeg"); //openFileDialog1.Filter = "Bitmaps (*.bmp)|*.bmp|JPEG (*.jpg)|*.jpg"; //openFileDialog1.ShowDialog(); //textBox1.Text = openFileDialog1.FileName; //fileDes = openFileDialog1.FileName; ////textBox2.Text = openFileDialog1.FileName; //string[] exeSplit = fileDes.Split('.'); //exe = exeSplit[1];

////exe = fileDes.Substring(fileDes.IndexOf("."), 4); ////exe = exe.Substring(1, 3); //fileIni = fileDes.Substring(fileDes.IndexOf("\\") + 1, fileDes.IndexOf(".") - 3); //fileN = fileDes.Substring(fileDes.IndexOf("\\") + 1); //fileDir = fileDes.Substring(0, fileDes.IndexOf("\\") + 1); //FileInfo name = new FileInfo(fileDes); //ofile = name.Name;

if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) textBox1.Text = folderBrowserDialog1.SelectedPath.ToString(); } private void Image_process_Load(object sender, EventArgs e) { } public void sqlcon() { SqlConnection conn = new SqlConnection("server=softxper2;database=pipeline;uid=sa;pwd=softxper;"); conn.Open(); SqlCommand cmd = new SqlCommand("insert into parellel(ip,filename,sdate,enddate)values('" + textBox2.Text + "','" + filename+ "','" + starttime1 + "','" + endtime1 + "')", conn); cmd.ExecuteNonQuery(); conn.Close(); } private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { parallel_split_trans p = new parallel_split_trans(); p.Show(); this.Hide(); } } }

You might also like