Exemplo n.º 1
0
        /// <summary>
        /// Downloads the table of the configuration database.
        /// </summary>
        public bool DownloadBaseTable(IBaseTable baseTable)
        {
            if (baseTable == null)
            {
                throw new ArgumentNullException(nameof(baseTable));
            }

            DownloadFile(
                new RelativePath(TopFolder.Base, AppFolder.Root, baseTable.FileNameDat),
                0, 0, false, DateTime.MinValue, () => { return(new MemoryStream()); },
                out _, out FileReadingResult readingResult, out Stream stream);

            try
            {
                if (readingResult == FileReadingResult.EndOfFile && stream != null)
                {
                    stream.Position = 0;
                    BaseTableAdapter adapter = new BaseTableAdapter()
                    {
                        Stream = stream
                    };
                    adapter.Fill(baseTable);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally
            {
                stream?.Dispose();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens an existing file for reading.
        /// </summary>
        protected override BinaryReader OpenRead(ConnectedClient client, RelativePath path)
        {
            switch (path.TopFolder)
            {
            case TopFolder.Base:
                if (coreLogic.ConfigDatabase.TableMap.TryGetValue(path.Path, out IBaseTable baseTable))
                {
                    BaseTableAdapter adapter = new BaseTableAdapter {
                        Stream = new MemoryStream()
                    };
                    adapter.Update(baseTable);
                    adapter.Stream.Position = 0;
                    return(new BinaryReader(adapter.Stream, Encoding.UTF8, false));
                }
                else
                {
                    throw new ScadaException(CommonPhrases.NamedFileNotFound, path);
                }

            case TopFolder.View:
                return(coreLogic.Storage.OpenBinary(DataCategory.View, path.Path));

            default:
                throw new ProtocolException(ErrorCode.IllegalFunctionArguments, CommonPhrases.PathNotSupported);
            }
        }
Exemplo n.º 3
0
        public void Execute(DataTable table, string storageProc, params SqlParameter[] parameters)
        {
            BaseTableAdapter baseTableAdapter = TableAdapterFactory.AdapterFactory(table.TableName);

            baseTableAdapter.Connection  = _transaction.Connection;
            baseTableAdapter.Transaction = this._transaction;
            baseTableAdapter.Execute(table, storageProc, parameters);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Reads the table of the configuration database.
        /// </summary>
        public override void ReadBaseTable(IBaseTable baseTable)
        {
            BaseTableAdapter adapter = new BaseTableAdapter
            {
                FileName = Path.Combine(baseDir, baseTable.FileNameDat)
            };

            adapter.Fill(baseTable);
        }
Exemplo n.º 5
0
        public void ReadData(DataTable table)
        {
            BaseTableAdapter baseTableAdapter = TableAdapterFactory.AdapterFactory(table.TableName);

            if (baseTableAdapter != null)
            {
                baseTableAdapter.Connection  = _transaction.Connection;
                baseTableAdapter.Transaction = _transaction;
                baseTableAdapter.Fill(table);
            }
        }
Exemplo n.º 6
0
        public void UpdateData(DataTable table)
        {
            BaseTableAdapter baseTableAdapter = TableAdapterFactory.AdapterFactory(table.TableName);

            if (baseTableAdapter is UpdateBaseTableAdapter)

            {
                baseTableAdapter.Connection = _transaction.Connection;

                baseTableAdapter.Transaction = _transaction;

                ((UpdateBaseTableAdapter)baseTableAdapter).Update(table);
            }
        }
        public void FillTablesFromDbForCustomerDataTest()
        {
            BaseTableAdapter table = null;

            foreach (string name in _glossariesName)
            {
                table = GetGlossary(name);
            }

            if (table != null)
            {
                int count = table.Fill(new DataTable(""));
                Assert.IsTrue(count > 0);
            }
        }
Exemplo n.º 8
0
 public void GetManyManyConnectionTableAdaptersTestMethod1()
 {
     Accounting.DAL.ConnectionManager.ConnectionManager.SetConnection(UserSettings.UserName, UserSettings.Password);
     //Accounting.DAL.ConnectionManager.ConnectionManager.Connection;
     BaseTableAdapter[] adapters = new BaseTableAdapter[10];
     for (int i = 0; i < adapters.Length; i++)
     {
         adapters[i] = new GenderTableAdapter
         {
             Connection = Accounting.DAL.ConnectionManager.ConnectionManager.Connection
         };
         adapters[i].Fill(new DataTable());
     }
     Assert.AreEqual(adapters[0].Connection, adapters[1].Connection);
 }
        protected BaseTableAdapter GetGlossary(string name)
        {
            BaseTableAdapter table = null;

            switch (name)
            {
            case "Address":
                table = new AddressTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Customer":
                table = new Accounting.DAL.TableAdapters.CustomerTableAdapter.CustomerTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Invalid":
                table = new InvalidBenefitsCategoryTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Register":
                table = new RegisterTableAdapter()
                {
                    Connection = _conn
                };
                break;
            }

            return(table);
        }
Exemplo n.º 10
0
        protected BaseTableAdapter GetGlossary(string name)
        {
            BaseTableAdapter table = null;

            switch (name)
            {
            case "AdminDivision":
                table = new AdminDivisionTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Gender":
                table = new GenderTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "ApppTpr":
                table = new ApppTprTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Benefits":
                table = new BenefitsCategoryTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "ChiperRecept":
                table = new ChiperReceptTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Disability":
                table = new DisabilityGroupTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Land":
                table = new LandTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "Register":
                table = new RegisterTypeTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "TypeStreet":
                table = new TypeStreetTableAdapter()
                {
                    Connection = _conn
                };
                break;

            case "WhyDeReg":
                table = new WhyDeRegisterTableAdapter()
                {
                    Connection = _conn
                };
                break;
            }

            return(table);
        }