private void butSetRanges_Click(object sender, EventArgs e) { if (ReplicationServers.Listt.Count == 0) { MessageBox.Show(Lan.g(this, "Please add at least one replication server to the list first")); return; } //long serverCount=ReplicationServers.Listt.Count; long offset = 10000; long span = (long.MaxValue - offset) / (long)ReplicationServers.Listt.Count; //rounds down long counter = offset; for (int i = 0; i < ReplicationServers.Listt.Count; i++) { ReplicationServers.Listt[i].RangeStart = counter; counter += span - 1; if (i == ReplicationServers.Listt.Count - 1) { ReplicationServers.Listt[i].RangeEnd = long.MaxValue; } else { ReplicationServers.Listt[i].RangeEnd = counter; counter += 1; } ReplicationServers.Update(ReplicationServers.Listt[i]); } changed = true; FillGrid(); }
private void butSetRanges_Click(object sender, EventArgs e) { if (_listReplicationServers.Count == 0) { MessageBox.Show(Lan.g(this, "Please add at least one replication server to the list first")); return; } //long serverCount=ReplicationServers.Listt.Count; long offset = 10000; long maxValue = 9000000000000000000; //use 9 quintillion instead of max long to ensure a buffer for the ranges. long span = (maxValue - offset) / (long)_listReplicationServers.Count; //rounds down long counter = offset; for (int i = 0; i < _listReplicationServers.Count; i++) { _listReplicationServers[i].RangeStart = counter; counter += span - 1; if (i == _listReplicationServers.Count - 1) { _listReplicationServers[i].RangeEnd = maxValue; } else { _listReplicationServers[i].RangeEnd = counter; counter += 1; } ReplicationServers.Update(_listReplicationServers[i]); } changed = true; FillGrid(); }
/* * ///<summary>Returns true if the given path is part of the image paths stored in the database list, false otherwise.</summary> * public static bool IsImagePath(string path){ * string imagePaths=PrefC.GetString(PrefName.DocPath"); * return IsImagePath(path,imagePaths); * }*/ private void butOK_Click(object sender, System.EventArgs e) { //remember that user might be using a website or a linux box to store images, therefore must allow forward slashes. if (radioUseFolder.Checked) { if (textLocalPath.Text != "") { if (ImageStore.GetValidPathFromString(textLocalPath.Text) == null) { MsgBox.Show(this, "The path override for this computer is invalid. The folder must exist and must contain all 26 A through Z folders."); return; } } else if (textServerPath.Text != "") { if (ImageStore.GetValidPathFromString(textServerPath.Text) == null) { MsgBox.Show(this, "The path override for this server is invalid. The folder must exist and must contain all 26 A through Z folders."); return; } } else { if (ImageStore.GetValidPathFromString(textDocPath.Text) == null) { MsgBox.Show(this, "The path is invalid. The folder must exist and must contain all 26 A through Z folders."); return; } } } if (Prefs.UpdateBool(PrefName.AtoZfolderUsed, radioUseFolder.Checked) | Prefs.UpdateString(PrefName.DocPath, textDocPath.Text) | Prefs.UpdateString(PrefName.ExportPath, textExportPath.Text) | Prefs.UpdateString(PrefName.LetterMergePath, textLetterMergePath.Text)) { DataValid.SetInvalid(InvalidType.Prefs); } if (ImageStore.LocalAtoZpath != textLocalPath.Text) //if local path changed { ImageStore.LocalAtoZpath = textLocalPath.Text; //ComputerPref compPref=ComputerPrefs.GetForLocalComputer(); ComputerPrefs.LocalComputer.AtoZpath = ImageStore.LocalAtoZpath; ComputerPrefs.Update(ComputerPrefs.LocalComputer); } if (ReplicationServers.GetAtoZpath() != textServerPath.Text) { ReplicationServer server = ReplicationServers.GetForLocalComputer(); server.AtoZpath = textServerPath.Text; ReplicationServers.Update(server); DataValid.SetInvalid(InvalidType.ReplicationServers); } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (textDescript.Text == "") { //I guess we don't need to force descript to have a value } if (textServerId.errorProvider1.GetError(textServerId) != "") { MsgBox.Show(this, "Please fix server_id."); return; } int serverid = PIn.Int(textServerId.Text); if (serverid == 0) { MsgBox.Show(this, "Please enter a server_id number greater than zero."); return; } long rangeStart = 0; if (textRangeStart.Text != "") { try { rangeStart = long.Parse(textRangeStart.Text); } catch { MsgBox.Show(this, "Please fix range start."); return; } } long rangeEnd = 0; if (textRangeEnd.Text != "") { try { rangeEnd = long.Parse(textRangeEnd.Text); } catch { MsgBox.Show(this, "Please fix range end."); return; } } if ((textRangeStart.Text != "" || textRangeEnd.Text != "") && rangeEnd - rangeStart < 999999) { MsgBox.Show(this, "The end of the range must be at least 999,999 greater than the start of the range."); return; } //Disallow a range that ends after 9 quintillion. This is because the max value of a long is 9,223,372,036,854,775,807 //and we want to leave room for the convert script, which doesn't implement our random primary key logic. //It will instead use the auto-increment number for the table. //If the table had a primary key of 9,223,372,036,854,775,807, the auto-increment would be out of bounds and give an error. //So now the largest random primary key value for any table will be 9 quintillion, which leaves the convert script 200 quadrillion entries //before going out of bounds. if (rangeEnd > 9000000000000000000) { MsgBox.Show(this, "The end of the range must be less than or equal to nine quintillion."); return; } RepServ.Descript = textDescript.Text; RepServ.ServerId = serverid; //will be valid and greater than 0. RepServ.RangeStart = rangeStart; RepServ.RangeEnd = rangeEnd; RepServ.AtoZpath = textAtoZpath.Text; RepServ.UpdateBlocked = checkUpdateBlocked.Checked; RepServ.SlaveMonitor = textSlaveMonitor.Text; if (RepServ.IsNew) { ReplicationServers.Insert(RepServ); } else { ReplicationServers.Update(RepServ); } //Update the ReplicationUserQueryServer preference as needed. if (checkReportServer.Checked) { if (Prefs.UpdateLong(PrefName.ReplicationUserQueryServer, RepServ.ReplicationServerNum)) { DataValid.SetInvalid(InvalidType.Prefs); } } else if (RepServ.ReplicationServerNum == PrefC.GetLong(PrefName.ReplicationUserQueryServer)) //If this replication server was the original report server, set the current server to 0. { if (Prefs.UpdateLong(PrefName.ReplicationUserQueryServer, 0)) { DataValid.SetInvalid(InvalidType.Prefs); } } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, EventArgs e) { if (textDescript.Text == "") { //I guess we don't need to force descript to have a value } if (textServerId.errorProvider1.GetError(textServerId) != "") { MsgBox.Show(this, "Please fix server_id."); return; } int serverid = PIn.Int(textServerId.Text); if (serverid == 0) { MsgBox.Show(this, "Please enter a server_id number greater than zero."); return; } long rangeStart = 0; if (textRangeStart.Text != "") { try { rangeStart = long.Parse(textRangeStart.Text); } catch { MsgBox.Show(this, "Please fix range start."); return; } } long rangeEnd = 0; if (textRangeEnd.Text != "") { try { rangeEnd = long.Parse(textRangeEnd.Text); } catch { MsgBox.Show(this, "Please fix range end."); return; } } if ((textRangeStart.Text != "" || textRangeEnd.Text != "") && rangeEnd - rangeStart < 999999) { MsgBox.Show(this, "The end of the range must be at least 999,999 greater than the start of the range."); return; } RepServ.Descript = textDescript.Text; RepServ.ServerId = serverid; //will be valid and greater than 0. RepServ.RangeStart = rangeStart; RepServ.RangeEnd = rangeEnd; RepServ.AtoZpath = textAtoZpath.Text; RepServ.UpdateBlocked = checkUpdateBlocked.Checked; RepServ.SlaveMonitor = textSlaveMonitor.Text; if (RepServ.IsNew) { ReplicationServers.Insert(RepServ); } else { ReplicationServers.Update(RepServ); } DialogResult = DialogResult.OK; }