///<summary>Only makes a call to the database on startup. After that, just uses cached data. ///Does not validate that the path exists except if the main one is used. ONLY used from Client layer or S class methods that have ///"No need to check RemotingRole; no call to db" and which also make sure PrefC.AtoZfolderUsed. ///Returns Cloud AtoZ path if CloudStorage.IsCloudStorage</summary> public static string GetPreferredAtoZpath() { if (PrefC.AtoZfolderUsed == DataStorageType.InDatabase) { return(null); } else if (PrefC.AtoZfolderUsed == DataStorageType.LocalAtoZ) { if (LocalAtoZpath == null) //on startup { try { LocalAtoZpath = ComputerPrefs.LocalComputer.AtoZpath; } catch { //fails when loading plugins after switching to version 15.1 because of schema change. LocalAtoZpath = ""; } } //Override path. Because it overrides all other paths, we evaluate it first. if (!string.IsNullOrEmpty(LocalAtoZpath)) { return(LocalAtoZpath.Trim()); } string replicationAtoZ = ReplicationServers.GetAtoZpath(); if (!string.IsNullOrEmpty(replicationAtoZ)) { return(replicationAtoZ.Trim()); } //use this to handle possible multiple paths separated by semicolons. return(GetValidPathFromString(PrefC.GetString(PrefName.DocPath))?.Trim()); } //If you got here you are using a cloud storage method. return(CloudStorage.AtoZPath?.Trim()); }
/* * ///<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 FormPath_Load(object sender, System.EventArgs e) { if (IsStartingUp) //and failed to find path //if(Security.IsAuthorized(Permissions.Setup,true)) {//suppress the regular message//can't do this because we don't have access to security yet. // MsgBox.Show(this,"Could not find the path for the AtoZ folder"); //} //else{//not authorized for security { MsgBox.Show(this, "Could not find the path for the AtoZ folder."); //butOK.Enabled=false; //} } else if (!Security.IsAuthorized(Permissions.Setup)) { butOK.Enabled = false; } textDocPath.Text = PrefC.GetString(PrefName.DocPath); //ComputerPref compPref=ComputerPrefs.GetForLocalComputer(); if (ReplicationServers.Server_id == 0) { labelServerPath.Visible = false; textServerPath.Visible = false; butBrowseServer.Visible = false; } else { labelServerPath.Text = "Path override for this server. Server id = " + ReplicationServers.Server_id.ToString(); textServerPath.Text = ReplicationServers.GetAtoZpath(); } textLocalPath.Text = ImageStore.LocalAtoZpath; //This was set on startup. //compPref.AtoZpath; textExportPath.Text = PrefC.GetString(PrefName.ExportPath); textLetterMergePath.Text = PrefC.GetString(PrefName.LetterMergePath); if (PrefC.GetBool(PrefName.AtoZfolderUsed)) { radioUseFolder.Checked = true; } else { radioAtoZfolderNotRequired.Checked = true; } // The opt***_checked event will enable/disable the appropriate UI elements. checkMultiplePaths.Checked = (textDocPath.Text.LastIndexOf(';') != -1); //Also set the "multiple paths" checkbox at startup based on the current image folder list format. No need to store this info in the db. }