public void CopyFrom(MasterEntry me) { Name = me.Name; FileName = me.FileName; Descr = me.Descr; ConnStr = me.ConnStr; Path = me.Path; }
public bool Equals(MasterEntry me) { return Name == me.Name && FileName == me.FileName && Descr == me.Descr && ConnStr == me.ConnStr && Path == me.Path; }
public void CreateNewDB(string name, string descr) { MasterEntry me = new MasterEntry(); me.Name = name; me.Descr = descr; me.ConnStr = Settings.BaseConnStr; string path = GetBaseDBPath(); me.FileName = Utils.GetNextFile(path, "klons_", "fdb"); me.FileName = Utils.GetFileNameFromURL(me.FileName); CreateNewDB(me); }
public void CreateNewDB(MasterEntry me) { MasterList.ConnectionList.Add(me); string path = GetBaseDBPath(); string fnmbase = path + "\\base\\klons00.fdb"; string fnmnew = path + "\\" + me.FileName; if (!File.Exists(fnmbase)) { throw new Exception("Fails [" + fnmbase + "] netika atrasts."); } File.Copy(fnmbase, fnmnew); return; }
public string GetFileName(MasterEntry me) { string filename; if (string.IsNullOrEmpty(me.Path)) { filename = GetBaseDBPath(); } else { filename = me.Path; filename = filename.Replace("@", GetBaseDBPath()); } filename += "\\" + me.FileName; return(filename); }
public MasterEntry(MasterEntry me) { CopyFrom(me); }
public bool ConnectTo(MasterEntry me, string username, string userpsw) { string filename = GetFileName(me); if (!File.Exists(filename)) { throw new Exception($"Nav faila: [{filename}]"); } if (CurrentDBTag != null) { Params.Save(); } _klonsDataSetHelper = new DataSetHelper( typeof(klonsDataSet), typeof(KlonsAdapters.TableAdapterManager), typeof(KlonsAdapters.QueriesTableAdapter), "ConnectionString1", KlonsF.Properties.Settings.Default); _dataSetHelpers["KlonsData"] = _klonsDataSetHelper; _klonsRepDataSetHelper = new DataSetHelper( typeof(klonsRepDataSet), typeof(KlonsRepAdapters.TableAdapterManager), null, "ConnectionString1", KlonsF.Properties.Settings.Default); _dataSetHelpers["KlonsRep"] = _klonsRepDataSetHelper; string newconnstr = MasterList.GetTemplateByName(me.ConnStr); if (string.IsNullOrEmpty(newconnstr)) { newconnstr = "character set=UTF8;" + "data source=localhost;" + @"initial catalog={0};" + "user id=aivars;" + "password=parole"; } newconnstr = string.Format(newconnstr, filename, username); var s1 = CheckConnectionString(newconnstr); if (s1 == null) { throw new Exception($"Nekorekti pieslēguma dati:\n{newconnstr}"); } newconnstr = s1; _currentUserName = username; _klonsDataSetHelper.ConnectTo(newconnstr); _klonsRepDataSetHelper.ConnectTo(newconnstr); KlonsTableAdapterManager.TUsersTableAdapter.Connection.StateChange += Connection_StateChange; KlonsTableAdapterManager.TUsersTableAdapter.Connection.Open(); CurrentDBTag = new MasterEntry(me); return(true); }