1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
| using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlServerCe;
using System.Data.Common;
namespace BuyerApp
{
/// <summary>
/// Summary description for syncronize.
/// </summary>
public class syncronize : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox txtPublisher;
private System.Windows.Forms.TextBox txtUserID;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.TextBox txtPublication;
private System.Windows.Forms.TextBox txtDataBase;
private System.Windows.Forms.TextBox txtInternetURL;
private System.Windows.Forms.TextBox txtInternetID;
private System.Windows.Forms.TextBox txtSubscription;
private System.Windows.Forms.TextBox txtFileName;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox txtInternetPassword;
private System.Windows.Forms.Button button1;
public syncronize()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
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()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.txtPublisher = new System.Windows.Forms.TextBox();
this.txtUserID = new System.Windows.Forms.TextBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.txtPublication = new System.Windows.Forms.TextBox();
this.txtDataBase = new System.Windows.Forms.TextBox();
this.txtInternetURL = new System.Windows.Forms.TextBox();
this.txtInternetID = new System.Windows.Forms.TextBox();
this.txtSubscription = new System.Windows.Forms.TextBox();
this.txtFileName = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.txtInternetPassword = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
//
// label1
//
this.label1.Location = new System.Drawing.Point(0, 4);
this.label1.Size = new System.Drawing.Size(60, 16);
this.label1.Text = "Publisher :";
//
// label2
//
this.label2.Location = new System.Drawing.Point(0, 24);
this.label2.Size = new System.Drawing.Size(72, 16);
this.label2.Text = "Publisher Id :";
//
// label3
//
this.label3.Location = new System.Drawing.Point(0, 44);
this.label3.Size = new System.Drawing.Size(112, 16);
this.label3.Text = "Publisher Password :";
//
// label4
//
this.label4.Location = new System.Drawing.Point(0, 64);
this.label4.Size = new System.Drawing.Size(100, 16);
this.label4.Text = "Publication Name :";
//
// label5
//
this.label5.Location = new System.Drawing.Point(0, 84);
this.label5.Size = new System.Drawing.Size(100, 16);
this.label5.Text = "DataBase Name :";
//
// label6
//
this.label6.Location = new System.Drawing.Point(0, 104);
this.label6.Size = new System.Drawing.Size(76, 16);
this.label6.Text = "Internet URL :";
//
// label7
//
this.label7.Location = new System.Drawing.Point(0, 124);
this.label7.Size = new System.Drawing.Size(104, 16);
this.label7.Text = "Internet Id :";
//
// label8
//
this.label8.Location = new System.Drawing.Point(0, 164);
this.label8.Size = new System.Drawing.Size(108, 16);
this.label8.Text = "Subscription Name :";
//
// label9
//
this.label9.Location = new System.Drawing.Point(0, 184);
this.label9.Size = new System.Drawing.Size(100, 16);
this.label9.Text = "Local File Name :";
//
// txtPublisher
//
this.txtPublisher.Location = new System.Drawing.Point(104, 0);
this.txtPublisher.Size = new System.Drawing.Size(136, 20);
this.txtPublisher.Text = "server1";
//
// txtUserID
//
this.txtUserID.Location = new System.Drawing.Point(104, 20);
this.txtUserID.Size = new System.Drawing.Size(136, 20);
this.txtUserID.Text = "server1\\\\infoUserRep1";
//
// txtPassword
//
this.txtPassword.Location = new System.Drawing.Point(104, 40);
this.txtPassword.Size = new System.Drawing.Size(136, 20);
this.txtPassword.Text = "";
//
// txtPublication
//
this.txtPublication.Location = new System.Drawing.Point(104, 60);
this.txtPublication.Size = new System.Drawing.Size(136, 20);
this.txtPublication.Text = "infosalvage";
//
// txtDataBase
//
this.txtDataBase.Location = new System.Drawing.Point(104, 80);
this.txtDataBase.Size = new System.Drawing.Size(136, 20);
this.txtDataBase.Text = "infosalvage";
//
// txtInternetURL
//
this.txtInternetURL.Location = new System.Drawing.Point(104, 100);
this.txtInternetURL.Size = new System.Drawing.Size(136, 20);
this.txtInternetURL.Text = "http://10.10.10.56/infosalvage/sscesa20.dll";
//
// txtInternetID
//
this.txtInternetID.Location = new System.Drawing.Point(104, 120);
this.txtInternetID.Size = new System.Drawing.Size(136, 20);
this.txtInternetID.Text = "server1\\\\infoUserRep1";
//
// txtSubscription
//
this.txtSubscription.Location = new System.Drawing.Point(104, 160);
this.txtSubscription.Size = new System.Drawing.Size(136, 20);
this.txtSubscription.Text = "Pocket_PC";
//
// txtFileName
//
this.txtFileName.Location = new System.Drawing.Point(104, 180);
this.txtFileName.Size = new System.Drawing.Size(136, 20);
this.txtFileName.Text = "vehcopart.sdf";
//
// button1
//
this.button1.Location = new System.Drawing.Point(104, 204);
this.button1.Size = new System.Drawing.Size(136, 24);
this.button1.Text = "Syncronize Data";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// txtInternetPassword
//
this.txtInternetPassword.Location = new System.Drawing.Point(104, 140);
this.txtInternetPassword.Size = new System.Drawing.Size(136, 20);
this.txtInternetPassword.Text = "radiation";
//
// label10
//
this.label10.Location = new System.Drawing.Point(0, 144);
this.label10.Size = new System.Drawing.Size(104, 16);
this.label10.Text = "Internet Pass :";
//
// syncronize
//
this.Controls.Add(this.label10);
this.Controls.Add(this.txtInternetPassword);
this.Controls.Add(this.button1);
this.Controls.Add(this.txtFileName);
this.Controls.Add(this.txtSubscription);
this.Controls.Add(this.txtInternetID);
this.Controls.Add(this.txtInternetURL);
this.Controls.Add(this.txtDataBase);
this.Controls.Add(this.txtPublication);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUserID);
this.Controls.Add(this.txtPublisher);
this.Controls.Add(this.label9);
this.Controls.Add(this.label8);
this.Controls.Add(this.label7);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Text = "Syncronize Data";
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
SqlCeReplication repl = null;
try
{
repl = new SqlCeReplication();
repl.Publisher = txtPublisher.Text;
repl.PublisherLogin = txtUserID.Text;
repl.PublisherPassword = txtPassword.Text;
repl.PublisherSecurityMode = SecurityType.NTAuthentication;
repl.Publication = txtPublication.Text;
repl.PublisherDatabase = txtDataBase.Text;
repl.InternetUrl = txtInternetURL.Text;
repl.InternetLogin = txtInternetID.Text;
repl.InternetPassword = txtInternetPassword.Text;
repl.Subscriber = txtSubscription.Text;
string strDataSource = txtFileName.Text;
repl.SubscriberConnectionString = "Data Source="+strDataSource;
while (System.IO.File.Exists(strDataSource) == false)
{
// Demande de confirmation
if(MessageBox.Show("Le fichier n'existe pas ! Voulez-vous le créer ?","Fusion", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk,MessageBoxDefaultButton.Button1) == DialogResult.Yes)
{
// Création de la base locale
repl.AddSubscription(AddOption.CreateDatabase);
this.Refresh();
}
else
{
return;
}
}
Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
repl.Synchronize();
MessageBox.Show("Syncronisation done !");
}
catch(SqlCeException err)
{
MessageBox.Show(err.Message);
}
finally
{
repl.Dispose();
Cursor.Current = System.Windows.Forms.Cursors.Default;
}
}
}
} |
Partager