Beispiel #1
0
 public bool Equals(MasterEntry me)
 {
     return(Name == me.Name &&
            FileName == me.FileName &&
            Descr == me.Descr &&
            ConnStr == me.ConnStr &&
            Path == me.Path);
 }
Beispiel #2
0
 public void CopyFrom(MasterEntry me)
 {
     Name     = me.Name;
     FileName = me.FileName;
     Descr    = me.Descr;
     ConnStr  = me.ConnStr;
     Path     = me.Path;
 }
Beispiel #3
0
        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, "klonsA_", "fdb");
            me.FileName = Utils.GetFileNameFromURL(me.FileName);
            CreateNewDB(me);
        }
Beispiel #4
0
        public void CreateNewDB(MasterEntry me)
        {
            MasterList.ConnectionList.Add(me);
            string path    = GetBaseDBPath();
            string fnmbase = path + "\\base\\klonsA00.fdb";
            string fnmnew  = path + "\\" + me.FileName;

            if (!File.Exists(fnmbase))
            {
                throw new Exception("Fails [" + fnmbase + "] netika atrasts.");
            }
            File.Copy(fnmbase, fnmnew);
            return;
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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)
            {
                try
                {
                    Params.Save();
                    if (KlonsTableAdapterManager?.TUSERSTableAdapter?.Connection != null)
                    {
                        KlonsTableAdapterManager.TUSERSTableAdapter.Connection.StateChange -= Connection_StateChange;
                    }
                }
                catch (Exception) { }
            }

            _klonsDataSetHelper = new DataSetHelper(
                typeof(KlonsADataSet),
                typeof(KlonsAdapters.TableAdapterManager),
                typeof(KlonsAdapters.QueriesTableAdapter),
                "ConnectionString1",
                KlonsA.Properties.Settings.Default);

            _dataSetHelpers["KlonsData"] = _klonsDataSetHelper;

            _klonsRepDataSetHelper = new DataSetHelper(
                typeof(KlonsARepDataSet),
                typeof(KlonsRepAdapters.TableAdapterManager),
                null,
                "ConnectionString1",
                KlonsA.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);
        }
Beispiel #7
0
 public MasterEntry(MasterEntry me)
 {
     CopyFrom(me);
 }