コード例 #1
0
        public override void Run(object context)
        {
            DbController dbc = null;
            try
            {
                Log(DbDefault.GetCreateViewStatement(Relation.CUSTOMER_ADDRESS));

                dbc = new DbController(Connection);
                dbc.CreateView(Relation.CUSTOMER_ADDRESS);

                DataTable table = Connection.GetSchema("Views");

                if (table.Rows.Count <= 0)
                    Fail("GetSchema('Views') did not return information.");


                table.Clear();
                Command.CommandText = "SELECT * FROM " + Relation.CUSTOMER_ADDRESS.ToString();
                DataAdapter.Fill(table);
                                
                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                dbc.DropView(Relation.CUSTOMER_ADDRESS.ToString());
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Product product = dbc.GetRandomProduct();                
                DataTable table = new DataTable();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { product.ProductId });
                                
                DataAdapter.Fill(table);

                if (table.Columns.Count != (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                    + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                    Fail("Number of returned columns is incorrect");

                ParseDataTable(table);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        private void UpdateRow(object param)
        {
            GFXDClientConnection conn = null;
            Product product = (Product)ObjectFactory.Create(ObjectType.Product);
            product.ProductId = Convert.ToInt64(param);

            try
            {
                conn = new GFXDClientConnection(ConnectionString);
                conn.Open();
                conn.BeginGFXDTransaction();

                DbController dbc = new DbController(conn);
                dbc.UpdateProduct(product);

                Product updatedProd = dbc.GetProduct(product.ProductId);

                conn.Commit();

                if (!product.Validate(updatedProd))
                    Fail("Product update validation failed.");
            }
            catch(GFXDException se)
            {
                if(!se.State.Equals("X0Z02"))
                    Fail(se);
                
                conn.Rollback();
            }
            catch (Exception e)
            {                
                Fail(e);
                conn.Rollback();
            }
        }
        public override void Run(object context)
        {
            int numTrans = 2;
            DbController dbc = new DbController(Connection);

            try
            {
                Customer customer = dbc.GetRandomCustomer();
                Log(String.Format("Original customer data. [{0}]{1}", 
                    Thread.CurrentThread.ManagedThreadId, customer.ToString()));

                Thread[] ts = new Thread[numTrans];

                for (int i = 0; i < numTrans; i++)
                {                    
                    ts[i] = new Thread(new ParameterizedThreadStart(UpdateRow));

                    Log(String.Format("Start customer update thread. TID: [{0}]", ts[i].ManagedThreadId));
                    ts[i].Start(customer.CustomerId);
                    Thread.Sleep(10);
                }
                for (int i = 0; i < numTrans; i++)
                    ts[i].Join();
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            int numThreads = 10;
            DbController dbc = new DbController(Connection);
            
            try
            {
                long rowCount = dbc.GetProductCount();
                Thread[] ts = new Thread[numThreads];

                for (int i = 0; i < numThreads; i++)
                {
                    ts[i] = new Thread(new ParameterizedThreadStart(SelectRows));
                    ts[i].Start(rowCount);
                }
                for (int i = 0; i < numThreads; i++)
                {
                    ts[i].Join();
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = dbc.GetRandomCategory();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { category.CategoryId });

                DataReader = Command.ExecuteReader();

                if (DataReader.FieldCount != (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                    + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                    Fail("Number of data fields returned is incorrect");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #7
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            try
            {
                String schemaName = DbHelper.GetRandomString(10);
                DbDefault.CreateDB(schemaName, DbCreateType.PKPartition);

                foreach (TableName tname in Enum.GetValues(typeof(TableName)))
                {
                    Command.CommandText = DbDefault.GetSelectCountStatement(schemaName, tname);
                    if (Convert.ToInt32(Command.ExecuteScalar()) < 1)
                        Fail(String.Format("Failed to create table {0}.{1}", schemaName, tname.ToString()));
                }

                DbDefault.DropDB(schemaName);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #8
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            DataTable table = new DataTable();

            try
            {
                Command.CommandText = String.Format(
                    "SELECT * FROM {0}", TableName.PRODUCT.ToString());

                DataReader = Command.ExecuteReader();
                table.Load(DataReader, LoadOption.OverwriteChanges);

                if (table.Rows.Count != dbc.GetProductCount())
                    Fail("DataTable failed to load all rows from Product table");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                try
                {                    
                    Command.Close();
                }
                catch (Exception e)
                {
                    Fail(e);
                }

                base.Run(context);
            }
        }        
        public override void Run(object context)
        {
            int numThreads = 3;
            DbController dbc = new DbController(Connection);

            try
            {
                IList<Product> products = dbc.GetRandomProducts(numThreads);
                Thread[] ts = new Thread[numThreads];

                for (int i = 0; i < numThreads; i++)
                {
                    ts[i] = new Thread(new ParameterizedThreadStart(UpdateRow));
                    ts[i].Start(products[i].ProductId);
                }
                for (int i = 0; i < numThreads; i++)
                {
                    ts[i].Join();
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #10
0
        public override void Run(object context)
        {
            DbController dbc = null;
            Relation relation = Relation.ORDERDETAIL_ORDER;

            try
            {
                dbc = new DbController(Connection);
                dbc.CreateView(relation);

                DataTable dt = dbc.GetView(relation.ToString());

                if (dt.Rows.Count <= 0)
                    Fail("Failed to create database view");
                else
                    ParseDataTable(dt);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                dbc.DropView(relation.ToString());
                base.Run(context);
            }
        }
コード例 #11
0
        private MainController()
        {
            _dbController = new SqlLiteController();
            //_dataController = new TestDataController();
            _dataController = new WiiController();
            _personController = new PersonController(_dbController);

            _dataController.AddSensorDataListener(new MovementRecognitionController());

            List<Person> persons = _personController.getPersons();
            try
            {
                _personController.CurrentPerson = persons[0];
            }
            catch (Exception)
            {
                string testDataScript = @"db\DbData.sql";
                string sql = File.ReadAllText(testDataScript);
                _dbController.Execute(sql);
                persons = _personController.getPersons();
                _personController.CurrentPerson = persons[0];
            }

            _notifyMessageMgr = new NotifyMessageManager
                (
                    Screen.Width,
                    Screen.Height,
                    200,
                    150
                );
            //_notifyMessageMgr.Start();
        }
コード例 #12
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Address address = (Address)ObjectFactory.Create(ObjectType.Address);
                Category category = (Category)ObjectFactory.Create(ObjectType.Category);

                dbc.AddAddress(address);
                dbc.AddCategory(category);                

                if (dbc.GetAddress(address.AddressId) != null)
                    Fail("Failed to delete address that has no FK constraint");
                if (dbc.GetCategory(category.CategoryId) != null)
                    Fail("Failed to delete category that has no FK constraint");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #13
0
        public override void Run(object context)
        {
            IList<BusinessObject> bObjects = new List<BusinessObject>();
            DbController dbc = new DbController(Connection);

            try
            {
                Connection.AutoCommit = false;
                Connection.BeginGFXDTransaction();

                Address addr1 = (Address)ObjectFactory.Create(ObjectType.Address);
                bObjects.Add(addr1);

                Supplier supp = (Supplier)ObjectFactory.Create(ObjectType.Supplier);
                supp.Address = addr1;
                bObjects.Add(supp);

                Category cate = (Category)ObjectFactory.Create(ObjectType.Category);
                bObjects.Add(cate);

                Product prod = (Product)ObjectFactory.Create(ObjectType.Product);
                prod.Category = cate;
                bObjects.Add(prod);

                Address addr2 = (Address)ObjectFactory.Create(ObjectType.Address);
                addr2.AddressId = addr1.AddressId + 1;
                bObjects.Add(addr2);

                Customer cust = (Customer)ObjectFactory.Create(ObjectType.Customer);
                cust.Address = addr2;
                bObjects.Add(cust);

                Order order = (Order)ObjectFactory.Create(ObjectType.Order);
                order.Customer = cust;
                bObjects.Add(order);

                OrderDetail ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId = order.OrderId;
                ordDetail.ProductId = prod.ProductId;
                bObjects.Add(ordDetail);

                dbc.ProcessNewCustomerOrder(bObjects);

                Connection.Commit();

                if (!dbc.ValidateTransaction(bObjects))
                    Fail(dbc.GetValidationErrors(bObjects));
            }
            catch (Exception e)
            {
                Connection.Rollback();
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #14
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Customer customer = dbc.GetRandomCustomer();

                Log(customer.ToString());

                Order order = (Order)ObjectFactory.Create(ObjectType.Order);
                order.Customer = customer;

                Log(order.ToString());

                dbc.AddOrder(order);

                Order result = dbc.GetOrder(order.OrderId);
                if (result == null)
                {
                    Fail("Failed to insert new Order record");
                    return;
                }
                else if (!order.Equals(result))
                {
                    Fail("Inserted Order record having inconsistent data");
                    return;
                }

                order = (Order)ObjectFactory.Create(ObjectType.Order);
                order.OrderId = result.OrderId;
                order.Customer = customer;
                dbc.UpdateOrder(order);

                result = dbc.GetOrder(order.OrderId);
                if (!order.Equals(result))
                {
                    Fail("Failed to update Order record");
                    return;
                }

                dbc.DeleteOrder(order.OrderId);
                if (dbc.GetOrder(order.OrderId) != null)
                    Fail("Failed to delete Order record");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #15
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            DataSet ds = new DataSet();

            StringBuilder sql = new StringBuilder();
            sql.AppendFormat("SELECT * FROM {0} ", TableName.PRODUCT.ToString());
            sql.AppendFormat("SELECT * FROM {0} ", TableName.CATEGORY.ToString());
            sql.AppendFormat("SELECT * FROM {0} ", TableName.SUPPLIER.ToString());

            DataTable[] tables = new DataTable[]{ 
                new DataTable(TableName.PRODUCT.ToString()),
                new DataTable(TableName.CATEGORY.ToString()),
                new DataTable(TableName.SUPPLIER.ToString())};
            
            try
            {
                ds.Tables.Add(tables[0]);
                ds.Tables.Add(tables[1]);
                ds.Tables.Add(tables[2]);

                Command.CommandText = sql.ToString();
                DataReader = Command.ExecuteReader();
                
                ds.Load(DataReader, LoadOption.OverwriteChanges, tables);

                if (ds.Tables[TableName.PRODUCT.ToString()].Rows.Count != dbc.GetProductCount())
                    Fail("DataSet failed to load all rows in Product table");
                if (ds.Tables[TableName.CATEGORY.ToString()].Rows.Count != dbc.GetCategoryCount())
                    Fail("DataSet failed to load all rows in Category table");
                if (ds.Tables[TableName.SUPPLIER.ToString()].Rows.Count != dbc.GetSupplierCount())
                    Fail("DataSet failed to load all rows in Supplier table");                
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                try
                {                    
                    Command.Close();
                }
                catch (Exception e)
                {
                    Fail(e);
                }

                base.Run(context);
            }
        }        
コード例 #16
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Order order = dbc.GetRandomOrder();
                Product product = dbc.GetRandomProduct();

                OrderDetail ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId = order.OrderId;
                ordDetail.ProductId = product.ProductId;
                dbc.AddOrderDetail(ordDetail);

                OrderDetail result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new OrderDetail record");
                    return;
                }
                else if (!ordDetail.Equals(result))
                {
                    Fail("Inserted OrderDetail record having inconsistent data");
                    return;
                }

                ordDetail = (OrderDetail)ObjectFactory.Create(ObjectType.OrderDetail);
                ordDetail.OrderId = result.OrderId;
                ordDetail.ProductId = result.ProductId;
                dbc.UpdateOrderDetail(ordDetail);

                result = dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (!ordDetail.Equals(result))
                {
                    Fail("Failed to update OrderDetail record");
                    return;
                }

                dbc.DeleteOrderDetail(ordDetail.OrderId, ordDetail.ProductId);
                if (dbc.GetOrderDetail(ordDetail.OrderId, ordDetail.ProductId) != null)
                    Fail("Failed to delete OrderDetail record");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #17
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            IList<BusinessObject> bObjects = new List<BusinessObject>();

            try
            {
                Connection.AutoCommit = false;
                Connection.BeginGFXDTransaction();

                Order order = (Order)ObjectFactory.Create(ObjectType.Order);
                order.Customer = dbc.GetRandomCustomer();
                dbc.AddOrder(order);
                
                IList<Product> products = dbc.GetRandomProducts(5);
                foreach (Product product in products)
                {
                    OrderDetail ordDetail = new OrderDetail();
                    ordDetail.OrderId = order.OrderId;
                    ordDetail.ProductId = product.ProductId;
                    ordDetail.UnitPrice = product.RetailPrice;
                    ordDetail.Quantity = DbHelper.GetRandomNumber(1);
                    ordDetail.Discount = 0;

                    dbc.AddOrderDetail(ordDetail);
                    bObjects.Add(ordDetail);

                    product.UnitsInStock -= ordDetail.Quantity;
                    dbc.UpdateProduct(product);

                    order.SubTotal += (ordDetail.UnitPrice * ordDetail.Quantity);
                }

                dbc.UpdateOrder(order);
                bObjects.Add(order);

                Connection.Commit();

                if (!dbc.ValidateTransaction(bObjects))
                    Fail(dbc.GetValidationErrors(bObjects));
            }
            catch (Exception e)
            {
                Connection.Rollback();
                Fail(e);
            }
            finally
            {                
                base.Run(context);
            }
        }
コード例 #18
0
        //
        //====================================================================================================
        /// <summary>
        /// Process the active editor form
        /// </summary>
        /// <param name="core"></param>
        public static void processActiveEditor(CoreController core)
        {
            //
            string Button      = null;
            int    ContentID   = 0;
            string ContentName = null;
            int    RecordID    = 0;
            string FieldName   = null;
            string ContentCopy = null;

            //
            Button = core.docProperties.getText("Button");
            switch (Button)
            {
            case ButtonCancel:
                //
                // ----- Do nothing, the form will reload with the previous contents
                //
                break;

            case ButtonSave:
                //
                // ----- read the form fields
                //
                ContentID   = core.docProperties.getInteger("cid");
                RecordID    = core.docProperties.getInteger("id");
                FieldName   = core.docProperties.getText("fn");
                ContentCopy = core.docProperties.getText("ContentCopy");
                //
                // ----- convert editor active edit icons
                //
                ContentCopy = ActiveContentController.processWysiwygResponseForSave(core, ContentCopy);
                //
                // ----- save the content
                //
                ContentName = MetadataController.getContentNameByID(core, ContentID);
                if (!string.IsNullOrEmpty(ContentName))
                {
                    using (var csData = new CsModel(core)) {
                        csData.open(ContentName, "ID=" + DbController.encodeSQLNumber(RecordID), "", false);
                        if (csData.ok())
                        {
                            csData.set(FieldName, ContentCopy);
                        }
                        csData.close();
                    }
                }
                break;
            }
        }
コード例 #19
0
 private void ProcessActions(Microsoft.Cognitive.LUIS.Action[] actions, Activity activity)
 {
     foreach (var action in actions)
     {
         if (action.Triggered)
         {
             ExecuteAction(action.Name, action.Parameters, activity);
         }
         else
         {
             AddToReplyQueue(DbController.GetFailureMessage(action.Name));
         }
     }
 }
コード例 #20
0
        /// <summary>
        /// Shfaq te gjitha njesite matese te regjistruara
        /// </summary>
        /// <returns></returns>
        public DataSet ShfaqNjesiteMatese()
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqNjesiteMatese");

            if (!Convert.IsDBNull(ds))
            {
                ds.Tables[0].Columns.Add("CHECKED", typeof(Boolean));
                ds.AcceptChanges();
                ds.Tables[0].Columns["CHECKED"].DefaultValue = false;
                ds.AcceptChanges();
            }
            return(ds);
        }
コード例 #21
0
        /// <summary>
        /// Kthe kategorite e artikujve qe jane te dukshem ne menu
        /// </summary>
        /// <returns></returns>
        public DataSet ShfaqKategoriteArtikujPerMenu()
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqKategoriteEArtikujvePerMenu");

            if (!Convert.IsDBNull(ds))
            {
                ds.Tables[0].Columns.Add("CHECKED", typeof(Boolean));
                ds.AcceptChanges();
                ds.Tables[0].Columns["CHECKED"].DefaultValue = false;
                ds.AcceptChanges();
            }
            return(ds);
        }
コード例 #22
0
        public DataSet KtheFaturatSipasKerkimit(string strSql)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("KtheFaturatSipasKerkimit", strSql);

            if (ds == null)
            {
                return(null);
            }

            DataSet dsFatura = new DataSet();

            dsFatura.Tables.Add();

            dsFatura.Tables[0].Columns.Add("ID_FATURA", typeof(Int32));
            dsFatura.Tables[0].Columns.Add("DATA_ORA", typeof(string));
            dsFatura.Tables[0].Columns.Add("NR_FATURE", typeof(string));
            dsFatura.Tables[0].Columns.Add("TAVOLINA", typeof(string));
            dsFatura.Tables[0].Columns.Add("KAMARIERI", typeof(string));
            dsFatura.Tables[0].Columns.Add("VLERA", typeof(float));
            dsFatura.Tables[0].Columns.Add("SKONTO", typeof(float));
            dsFatura.Tables[0].Columns.Add("TOTALI", typeof(float));
            dsFatura.Tables[0].Columns.Add("FORMA_PAGESA", typeof(string));
            dsFatura.Tables[0].Columns.Add("ANULLUAR", typeof(bool));

            dsFatura.Tables[0].AcceptChanges();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                DataRow drFatura = dsFatura.Tables[0].NewRow();

                drFatura["ID_FATURA"]    = dr["ID_FATURA"];
                drFatura["DATA_ORA"]     = Convert.ToDateTime(dr["DATA_ORA"]).ToString("dd.MM.yyyy HH:mm");
                drFatura["NR_FATURE"]    = dr["NR_FATURE"];
                drFatura["TAVOLINA"]     = dr["TAVOLINA"];
                drFatura["KAMARIERI"]    = dr["KAMARIERI"];
                drFatura["VLERA"]        = dr["TOTALI"];
                drFatura["SKONTO"]       = dr["SKONTO"];
                drFatura["TOTALI"]       = Convert.ToDouble(dr["TOTALI"]) - Convert.ToDouble(dr["SKONTO"]);
                drFatura["FORMA_PAGESA"] = dr["FORMA_PAGESA"];
                drFatura["ANULLUAR"]     = dr["ANULLUAR"];

                dsFatura.Tables[0].Rows.Add(drFatura);
            }

            dsFatura.Tables[0].AcceptChanges();

            return(dsFatura);
        }
コード例 #23
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Address address = (Address)ObjectFactory.Create(ObjectType.Address);
                dbc.AddAddress(address);

                Customer customer = (Customer)ObjectFactory.Create(ObjectType.Customer);
                customer.Address = address;
                dbc.AddCustomer(customer);

                Customer result = dbc.GetCustomer(customer.CustomerId);
                if (result == null)
                {
                    Fail("Failed to insert new Customer record");
                    return;
                }
                else if (!customer.Equals(result))
                {
                    Fail("Inserted Customer record having inconsistent data");
                    return;
                }

                customer = (Customer)ObjectFactory.Create(ObjectType.Customer);
                customer.CustomerId = result.CustomerId;
                dbc.UpdateCustomer(customer);

                result = dbc.GetCustomer(customer.CustomerId);
                if (!customer.Equals(result))
                {
                    Fail("Failed to update Customer record");
                    return;
                }

                dbc.DeleteCustomer(customer.CustomerId);
                if (dbc.GetCustomer(customer.CustomerId) != null)
                    Fail("Failed to delete Customer record");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #24
0
ファイル: Receta.cs プロジェクト: koson/ResManagerAdmin
        /// <summary>
        /// Ndryshon disponibilitetin e recetave ne menu
        /// </summary>
        /// <param name="disponueshem"></param>
        /// <param name="dsId"></param>
        /// <returns></returns>
        public int NdryshoDisponibilitet(int disponueshem, DataSet dsId)
        {
            DbController db = new DbController();
            int          b  = db.Update("NdryshoDisponibilitet", disponueshem, dsId);

            if (b == 0)
            {
                if (disponueshem == 0)
                {
                    b = db.Delete("FshiRecetatNgaFavoritet", dsId);
                }
            }

            return(b);
        }
コード例 #25
0
        /// <summary>
        /// When overridden in the derived class, gets the items to add to the list.
        /// </summary>
        /// <returns>The items to add to the list.</returns>
        protected override IEnumerable <IItemTemplateTable> GetListItems()
        {
            var ids = DbController.GetQuery <SelectItemTemplateIDsQuery>().Execute();

            var ret           = new List <IItemTemplateTable>();
            var templateQuery = DbController.GetQuery <SelectItemTemplateQuery>();

            foreach (var id in ids)
            {
                var template = templateQuery.Execute(id);
                ret.Add(template);
            }

            return(ret.OrderBy(x => x.ID));
        }
コード例 #26
0
 private void OnClosed(object sender, EventArgs args)
 {
     if (_Documents != null)
     {
         Picker dp = new Picker(_Documents);
         dp.ShowDialog();
         if (Picker.PickedDocument != null)
         {
             ProjectName = string.Format("{0}: {1}", Picker.PickedDocument.Project.Name, Picker.PickedDocument.Name);
             KPLNDataBase.Collections.DbDocument pickedDocument = Picker.PickedDocument;
             OutputDB form = new OutputDB(ProjectName, DbController.GetRows(pickedDocument.Id.ToString()), _Documents);
             form.Show();
         }
     }
 }
コード例 #27
0
        public DataSet ShfaqVetemDetyrimePerDhomen(int idDhoma)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("dbShfaqVetemDetyrimetPerKlienteteDhomes", idDhoma);

            ds.Tables[0].Columns.Add("DATA_STR", typeof(String));
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                DateTime data = Convert.ToDateTime(dr[6]);
                dr[12] = this.konverto(data);
            }
            ds.AcceptChanges();

            return(ds);
        }
コード例 #28
0
ファイル: LocalStorage.cs プロジェクト: sbs20/syncotron
        public IEnumerable <SyncAction> ActionSelect()
        {
            string sql = "select * from action";

            return(this.dbController
                   .ExecuteAsEnumerableRows(sql)
                   .Select(r =>
            {
                return new SyncAction
                {
                    Type = DbController.ToString(r["Type"]).ToEnum <SyncActionType>(),
                    CommonPath = DbController.ToString(r["Path"])
                };
            }));
        }
コード例 #29
0
        //
        //========================================================================
        /// <summary>
        /// Encode a value for a sql
        /// </summary>
        /// <param name="expression"></param>
        /// <param name="fieldType"></param>
        /// <returns></returns>
        public static string encodeSQL(object expression, CPContentBaseClass.FieldTypeIdEnum fieldType = CPContentBaseClass.FieldTypeIdEnum.Text)
        {
            try {
                switch (fieldType)
                {
                case CPContentBaseClass.FieldTypeIdEnum.Boolean:
                    return(DbController.encodeSQLBoolean(GenericController.encodeBoolean(expression)));

                case CPContentBaseClass.FieldTypeIdEnum.Currency:
                case CPContentBaseClass.FieldTypeIdEnum.Float:
                    return(DbController.encodeSQLNumber(GenericController.encodeNumber(expression)));

                case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement:
                case CPContentBaseClass.FieldTypeIdEnum.Integer:
                case CPContentBaseClass.FieldTypeIdEnum.Lookup:
                case CPContentBaseClass.FieldTypeIdEnum.MemberSelect:
                    return(DbController.encodeSQLNumber(GenericController.encodeInteger(expression)));

                case CPContentBaseClass.FieldTypeIdEnum.Date:
                    return(DbController.encodeSQLDate(GenericController.encodeDate(expression)));

                case CPContentBaseClass.FieldTypeIdEnum.LongText:
                case CPContentBaseClass.FieldTypeIdEnum.HTML:
                case CPContentBaseClass.FieldTypeIdEnum.HTMLCode:
                    return(DbController.encodeSQLText(GenericController.encodeText(expression)));

                case CPContentBaseClass.FieldTypeIdEnum.File:
                case CPContentBaseClass.FieldTypeIdEnum.FileImage:
                case CPContentBaseClass.FieldTypeIdEnum.Link:
                case CPContentBaseClass.FieldTypeIdEnum.ResourceLink:
                case CPContentBaseClass.FieldTypeIdEnum.Redirect:
                case CPContentBaseClass.FieldTypeIdEnum.ManyToMany:
                case CPContentBaseClass.FieldTypeIdEnum.Text:
                case CPContentBaseClass.FieldTypeIdEnum.FileText:
                case CPContentBaseClass.FieldTypeIdEnum.FileJavascript:
                case CPContentBaseClass.FieldTypeIdEnum.FileXML:
                case CPContentBaseClass.FieldTypeIdEnum.FileCSS:
                case CPContentBaseClass.FieldTypeIdEnum.FileHTML:
                case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode:
                    return(DbController.encodeSQLText(GenericController.encodeText(expression)));

                default:
                    throw new GenericException("Unknown Field Type [" + fieldType + "");
                }
            } catch (Exception) {
                throw;
            }
        }
コード例 #30
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = dbc.GetRandomCategory();
                Supplier supplier = dbc.GetRandomSupplier();

                Product product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.Category = category;
                product.Supplier = supplier;
                dbc.AddProduct(product);

                Product result = dbc.GetProduct(product.ProductId);
                if (result == null)
                {
                    Fail("Failed to insert new Product record");
                    return;
                }
                else if (!product.Equals(result))
                {
                    Fail("Inserted Product record having inconsistent data");
                    return;
                }

                product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.ProductId = result.ProductId;
                dbc.UpdateProduct(product);

                result = dbc.GetProduct(product.ProductId);
                if (!product.Equals(result))
                    Fail("Failed to update Product record");

                dbc.DeleteProduct(product.ProductId);
                if (dbc.GetProduct(product.ProductId) != null)
                    Fail("Failed to delete Product record");
                
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #31
0
 //
 //
 //
 //========================================================================
 /// <summary>
 /// Set a site property
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="Value"></param>
 public void setProperty(string propertyName, string Value)
 {
     try {
         if (dbNotReady)
         {
             //
             // -- cannot set property
             throw new GenericException("Cannot set site property before Db is ready.");
         }
         else
         {
             if (!string.IsNullOrEmpty(propertyName.Trim()))
             {
                 if (propertyName.ToLowerInvariant().Equals("adminurl"))
                 {
                     //
                     // -- intercept adminUrl for compatibility, always use admin route instead
                 }
                 else
                 {
                     //
                     // -- set value in Db
                     string SQLNow          = DbController.encodeSQLDate(core.dateTimeNowMockable);
                     string SQL             = "UPDATE ccSetup Set FieldValue=" + DbController.encodeSQLText(Value) + ",ModifiedDate=" + SQLNow + " WHERE name=" + DbController.encodeSQLText(propertyName);
                     int    recordsAffected = 0;
                     core.db.executeNonQuery(SQL, ref recordsAffected);
                     if (recordsAffected == 0)
                     {
                         SQL = "INSERT INTO ccSetup (ACTIVE,CONTENTCONTROLID,NAME,FIELDVALUE,ModifiedDate,DateAdded)VALUES("
                               + DbController.SQLTrue + "," + DbController.encodeSQLNumber(ContentMetadataModel.getContentId(core, "site properties")) + "," + DbController.encodeSQLText(propertyName.ToUpper()) + "," + DbController.encodeSQLText(Value) + "," + SQLNow + "," + SQLNow + ");";
                         core.db.executeNonQuery(SQL);
                     }
                     //
                     // -- set simple lazy cache
                     string cacheName = getNameValueDictKey(propertyName);
                     if (nameValueDict.ContainsKey(cacheName))
                     {
                         nameValueDict.Remove(cacheName);
                     }
                     nameValueDict.Add(cacheName, Value);
                 }
             }
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
コード例 #32
0
ファイル: BanningManager.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// When overridden in the derived class, gets the ID of an account from the account's name.
        /// </summary>
        /// <param name="accountName">The name of the account.</param>
        /// <param name="accountID">When this method returns true, contains the ID of the account for the given
        /// <paramref name="accountName"/>.</param>
        /// <returns>True if the ID of the account for the given <paramref name="accountName"/> was found; otherwise false.</returns>
        protected override bool TryGetAccountIDFromAccountName(string accountName, out AccountID accountID)
        {
            var query = DbController.GetQuery <SelectAccountIDFromNameQuery>();
            var acc   = query.Execute(accountName);

            if (!acc.HasValue)
            {
                accountID = new AccountID(0);
                return(false);
            }
            else
            {
                accountID = acc.Value;
                return(true);
            }
        }
コード例 #33
0
ファイル: BanningManager.cs プロジェクト: wtfcolt/game
        /// <summary>
        /// When overridden in the derived class, gets the ID of an account from the user's name.
        /// </summary>
        /// <param name="userName">The name of the user to get the account of.</param>
        /// <param name="accountID">When this method returns true, contains the ID of the account for the given
        /// <paramref name="userName"/>.</param>
        /// <returns>True if the ID of the account for the given <paramref name="userName"/> was found; otherwise false.</returns>
        protected override bool TryGetAccountIDFromUserName(string userName, out AccountID accountID)
        {
            var query = DbController.GetQuery <SelectAccountIDFromUserNameQuery>();
            var id    = query.Execute(userName);

            if (!id.HasValue)
            {
                accountID = new AccountID(0);
                return(false);
            }
            else
            {
                accountID = id.Value;
                return(true);
            }
        }
コード例 #34
0
        /// <summary>
        /// When overridden in the derived class, removes a ban from an account.
        /// </summary>
        /// <param name="accountID">The account to remove the ban from.</param>
        /// <param name="issuedBy">The name of the user or source that issued the unban.</param>
        /// <param name="failReason">When this method returns false, contains the reason why the ban failed to be removed.</param>
        /// <returns>
        /// True if the unban was successfully added; otherwise false.
        /// </returns>
        protected override bool TryRemoveBanInternal(AccountID accountID, string issuedBy, out BanManagerFailReason failReason)
        {
            var q            = DbController.GetQuery <UpdateAccountUnBanQuery>();
            var rowsAffected = q.ExecuteWithResult(accountID, issuedBy);

            if (rowsAffected == 0)
            {
                failReason = BanManagerFailReason.FailedToRemoveFromDatabase;
                return(false);
            }
            else
            {
                failReason = BanManagerFailReason.Unknown;
                return(true);
            }
        }
コード例 #35
0
        public string CountAccountCharacters(string accountName)
        {
            if (!GameData.AccountName.IsValid(accountName))
            {
                return("Invalid account name");
            }

            var accountID = DbController.GetQuery <SelectAccountIDFromNameQuery>().Execute(accountName);

            if (!accountID.HasValue)
            {
                return(string.Format("No account with the name `{0}` exists.", accountName));
            }

            return(CountAccountCharacters((int)accountID.Value));
        }
コード例 #36
0
        /// <summary>
        /// Triggers the AfterTestGroup method to dispose or clean up any resources
        /// that were held for the length of the collection test run.
        /// </summary>
        public void Dispose()
        {
            GlobalConfiguration globalConfig =
                (GlobalConfiguration)ConfigurationManager.GetSection(SectionXPath);

            // If not each class, then each collection.
            if (!globalConfig.DeployDatabasesEachClass)
            {
                // Log calls must unfortunately be discarded with xUnit as the following exception occurs:
                //
                // [Test Collection Cleanup Failure(DataAccess)]:
                // System.InvalidOperationException :
                // There is no currently active test case.
                DbController.AfterTestGroup(_type, msg => { });
            }
        }
コード例 #37
0
        /// <summary>
        /// Shton nje kategori artikulli me emrin qe merr si parameter
        /// </summary>
        /// <param name="emri"></param>
        /// <returns></returns>
        public int ShtoKategoriArtikulli(string emri, int statusi)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqKategoriteEArtikujvePerEmer", emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje kategori artikulli me kete emer nuk lejohet shtimi
                return(2);
            }
            else
            {
                int b = db.Create("ShtoKategoriArtikulli", statusi, emri);
                return(b);
            }
        }
コード例 #38
0
        public int ModifikoKostoVilaX()
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqArtikujt");

            int idArtikulli = 0;
            int b           = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                idArtikulli = Convert.ToInt32(dr[0]);
                b           = db.Update("ModifikoKostoVilaX", idArtikulli);
            }

            return(b);
        }
コード例 #39
0
        /// <summary>
        /// Ben modifikimin e njesise matese sipas parametrave
        /// </summary>
        /// <param name="idKategoria"></param>
        /// <param name="emri"></param>
        /// <returns></returns>
        public int ModifikoNjesiMatese(int idNjesia, string emri)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqNjesitePerEmerPerjashtoId", idNjesia, emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje njesi matese me kete emer nuk lejohet modifikimi
                return(2);
            }
            else
            {
                int b = db.Update("ModifikoNjesi", idNjesia, emri);
                return(b);
            }
        }
コード例 #40
0
        public int KrijoKategoriShpenzimMujor(string emri, string pershkrimi)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("KontrolloKategoriShpenzimMujor", emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje kategori shpenzimi me kete emer nuk lejohet shtimi
                return(2);
            }
            else
            {
                int b = db.Create("KrijoKategoriShpenzimMujor", emri, pershkrimi);
                return(b);
            }
        }
コード例 #41
0
        //
        public static string getDefaultValue(CoreController core, string contentName, string fieldName)
        {
            string defaultValue = "";
            int    contentId    = ContentMetadataModel.getContentId(core, contentName);
            string SQL          = "select defaultvalue from ccfields where name=" + DbController.encodeSQLText(fieldName) + " and contentid=(" + contentId + ")";

            using (var csData = new CsModel(core)) {
                csData.openSql(SQL);
                if (csData.ok())
                {
                    defaultValue = csData.getText("defaultvalue");
                }
                csData.close();
            }
            return(defaultValue);
        }
コード例 #42
0
        /// <summary>
        /// Shton nje kategori shpenzimi me emrin qe merr si parameter
        /// </summary>
        /// <param name="emri"></param>
        /// <returns></returns>
        public int ShtoKategoriShpenzimi(string emri)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqKategoriteEShpenzimevePerEmer", emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje kategori shpenzimi me kete emer nuk lejohet shtimi
                return(2);
            }
            else
            {
                int b = db.Create("ShtoKategoriShpenzimi", emri);
                return(b);
            }
        }
コード例 #43
0
        /// <summary>
        /// Shton njesi te re matese
        /// </summary>
        /// <param name="emri"></param>
        /// <returns></returns>
        public int ShtoNjesiMatese(string emri)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqNjesitePerEmer", emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje njesi matese me kete emer nuk lejohet shtimi
                return(2);
            }
            else
            {
                int b = db.Create("ShtoNjesi", emri);
                return(b);
            }
        }
コード例 #44
0
        /// <summary>
        /// Modifikon emrin e nje kategorie shpenzimi
        /// </summary>
        /// <param name="idKategoria"></param>
        /// <param name="emri"></param>
        /// <returns></returns>
        public int ModifikoKategoriShpenzimi(int idKategoria, string emri)
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("ShfaqKategoriteEShpenzimevePerEmerPerjashtoId", idKategoria, emri);

            if (ds.Tables[0].Rows.Count != 0)
            {
                //nqs ka nje kategori shpenzimi me kete emer nuk lejohet modifikimi
                return(2);
            }
            else
            {
                int b = db.Update("ModifikoKategoriShpenzimi", idKategoria, emri);
                return(b);
            }
        }
コード例 #45
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Address address = (Address)ObjectFactory.Create(ObjectType.Address);
                dbc.AddAddress(address);

                Address result = dbc.GetAddress(address.AddressId);
                if (result == null)
                {
                    Fail("Failed to insert new Address record");
                    return;
                }
                else if (!address.Equals(result))
                {
                    Fail("Inserted Address record having inconsistent data");
                    return;
                }

                address           = (Address)ObjectFactory.Create(ObjectType.Address);
                address.AddressId = result.AddressId;
                dbc.UpdateAddress(address);

                result = dbc.GetAddress(address.AddressId);
                if (!address.Equals(result))
                {
                    Fail("Failed to update Address record");
                    return;
                }

                dbc.DeleteAddress(address.AddressId);
                if (dbc.GetAddress(address.AddressId) != null)
                {
                    Fail("Failed to delete Address record");
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #46
0
 public void OnOpened(object sender, DocumentOpenedEventArgs args)
 {
     try
     {
         Document doc = args.Document;
         if (!CheckTools.AllWorksetsAreOpened(doc))
         {
             return;
         }
         if (doc.IsWorkshared && !doc.IsDetached)
         {
             string   path        = ModelPathUtils.ConvertModelPathToUserVisiblePath(doc.GetWorksharingCentralModelPath());
             FileInfo centralPath = new FileInfo(path);
             foreach (DbDocument dbDoc in KPLNDataBase.DbControll.Documents)
             {
                 FileInfo metaCentralPath = new FileInfo(dbDoc.Path);
                 if (dbDoc.Code == "NONE")
                 {
                     continue;
                 }
                 if (centralPath.FullName == metaCentralPath.FullName)
                 {
                     if (File.Exists(string.Format(@"Z:\Отдел BIM\03_Скрипты\09_Модули_KPLN_Loader\DB\BatchModelCheck\doc_id_{0}.sqlite", dbDoc.Id.ToString())))
                     {
                         List <DbRowData> rows = DbController.GetRows(dbDoc.Id.ToString());
                         if (rows.Count != 0)
                         {
                             if ((DateTime.Now.Day - rows.Last().DateTime.Day > 7 && rows.Last().DateTime.Day != DateTime.Now.Day) || rows.Last().DateTime.Month != DateTime.Now.Month || rows.Last().DateTime.Year != DateTime.Now.Year)
                             {
                                 CheckDocument(doc, dbDoc);
                             }
                         }
                         else
                         {
                             CheckDocument(doc, dbDoc);
                         }
                     }
                     else
                     {
                         CheckDocument(doc, dbDoc);
                     }
                 }
             }
         }
     }
     catch (Exception) { }
 }
コード例 #47
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = (Category)ObjectFactory.Create(ObjectType.Category);
                dbc.AddCategory(category);

                Category result = dbc.GetCategory(category.CategoryId);
                if (result == null)
                {
                    Fail("Failed to insert new Category record");
                    return;
                }
                else if (!category.Equals(result))
                {
                    Fail("Inserted Category record having inconsistent data");
                    return;
                }

                category            = (Category)ObjectFactory.Create(ObjectType.Category);
                category.CategoryId = result.CategoryId;
                dbc.UpdateCategory(category);

                result = dbc.GetCategory(category.CategoryId);
                if (!category.Equals(result))
                {
                    Fail("Failed to update Category record");
                    return;
                }

                dbc.DeleteCategory(category.CategoryId);
                if (dbc.GetCategory(category.CategoryId) != null)
                {
                    Fail("Failed to delete Category record");
                }
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #48
0
        public override void Run(object context)
        {
            String schemaName = "ADONETTEST";
            try
            {
                DbDefault.CreateDB(schemaName, DbCreateType.PKPartition);

                DbController dbc = new DbController(Connection, schemaName);

                IList<Address> objList1 = dbc.GetAddresses();
                foreach (Address obj in objList1)
                    Log(obj.ToString());

                IList<Supplier> objList2 = dbc.GetSuppliers();
                foreach (Supplier obj in objList2)
                    Log(obj.ToString());

                IList<Category> objList3 = dbc.GetCategories();
                foreach (Category obj in objList3)
                    Log(obj.ToString());

                IList<Product> objList4 = dbc.GetProducts();
                foreach (Product obj in objList4)
                    Log(obj.ToString());

                IList<Customer> objList5 = dbc.GetCustomers();
                foreach (Customer obj in objList5)
                    Log(obj.ToString());

                IList<Order> objList6 = dbc.GetOrders();
                foreach (Order obj in objList6)
                    Log(obj.ToString());

                IList<OrderDetail> objList7 = dbc.GetOrderDetails();
                foreach (OrderDetail obj in objList7)
                    Log(obj.ToString());
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                DbDefault.DropDB(schemaName);
                base.Run(context);
            }
        }
コード例 #49
0
        private string KtheNrFatura()
        {
            DbController db = new DbController();
            DataSet      ds = db.Read("KtheNrFaturaLast");

            int numri = 0;

            if (ds.Tables[0].Rows.Count != 0)
            {
                numri = Convert.ToInt32(ds.Tables[0].Rows[0][1]);
            }
            numri = numri + 1;

            string strFatura = Convert.ToString(numri);

            return(strFatura);
        }
        public override void Run(Object context)
        {
            GFXDTransaction transx = Connection.BeginTransaction();
            DbController    dbc    = new DbController(Connection);

            try
            {
                Connection.AutoCommit = false;
                Connection.BeginGFXDTransaction();

                Order order = (Order)ObjectFactory.Create(ObjectType.Order);
                order.Customer = dbc.GetRandomCustomer();
                dbc.AddOrder(order);

                IList <Product> products = dbc.GetRandomProducts(5);
                foreach (Product product in products)
                {
                    OrderDetail ordDetail = new OrderDetail();
                    ordDetail.OrderId   = order.OrderId;
                    ordDetail.ProductId = product.ProductId;
                    ordDetail.UnitPrice = product.RetailPrice;
                    ordDetail.Quantity  = DbHelper.GetRandomNumber(1);
                    ordDetail.Discount  = 0;

                    dbc.AddOrderDetail(ordDetail);

                    product.UnitsInStock -= ordDetail.Quantity;
                    dbc.UpdateProduct(product);

                    order.SubTotal += (ordDetail.UnitPrice * ordDetail.Quantity);
                }

                dbc.UpdateOrder(order);

                Connection.Commit();
            }
            catch (Exception e)
            {
                Connection.Rollback();
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #51
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Category category = (Category)ObjectFactory.Create(ObjectType.Category);
                dbc.AddCategory(category);

                Category result = dbc.GetCategory(category.CategoryId);
                if (result == null)
                {
                    Fail("Failed to insert new Category record");
                    return;
                }
                else if (!category.Equals(result))
                {
                    Fail("Inserted Category record having inconsistent data");
                    return;
                }

                category = (Category)ObjectFactory.Create(ObjectType.Category);
                category.CategoryId = result.CategoryId;
                dbc.UpdateCategory(category);

                result = dbc.GetCategory(category.CategoryId);
                if (!category.Equals(result))
                {
                    Fail("Failed to update Category record");
                    return;
                }

                dbc.DeleteCategory(category.CategoryId);
                if (dbc.GetCategory(category.CategoryId) != null)
                    Fail("Failed to delete Category record");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #52
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                dbc.DeleteCategory(dbc.GetRandomProduct().Category.CategoryId);
                Fail("Product constraint violation exception should have occurred");
            }
            catch (Exception e)
            {
                Log(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #53
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                dbc.DeleteProduct(dbc.GetRandomOrderDetail().ProductId);
                Fail("OrderDetail constraint violation exception shoudl have occurred");
            }
            catch (Exception e)
            {
                Log(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        private void ReadData()
        {
            try
            {
                DbController dbc = new DbController(Connection);
                IList<Product> products = dbc.GetProducts();
                foreach(Product product in products)
                    Log(product.ToString());

                IList<Order> orders = dbc.GetOrders();                
                foreach(Order order in orders)
                    Log(order.ToString());

            }
            catch (Exception e)
            {
                Fail(e);
            }
        }
        private void SelectRows(object param)
        {
            long rowCount = Convert.ToInt64(param);

            try
            {
                DbController dbc = new DbController(Connection);
                IList<Product> products = dbc.GetProducts();

                if(products.Count != rowCount)
                    Fail(String.Format("Query returned incorrect number or rows. "
                        + "Expected [{0}]; Actual [{1}]",
                        rowCount, products.Count));
            }
            catch (Exception e)
            {
                Fail(e);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                Order order = dbc.GetRandomOrder();
                Product product = dbc.GetRandomProduct();               

                DataSet dataset = new DataSet();

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.ORDERDETAIL_ORDER, new long[] { order.OrderId });
                Log(Command.CommandText);
                DataAdapter.Fill(dataset, "OrderDetail_Order");

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.ORDERDETAIL_PRODUCT, new long[] { product.ProductId });
                Log(Command.CommandText);
                DataAdapter.Fill(dataset, "OrderDetail_Product");

                if (dataset.Tables["OrderDetail_Order"].Columns.Count
                    != (DbDefault.GetTableStructure(TableName.ORDERDETAIL).Columns.Count
                    + DbDefault.GetTableStructure(TableName.ORDERS).Columns.Count))
                    Fail("Incorrect number of columns returned for joined OrderDetail_Order query");

                if (dataset.Tables["OrderDetail_Product"].Columns.Count
                    != (DbDefault.GetTableStructure(TableName.ORDERDETAIL).Columns.Count
                    + DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count))
                    Fail("Incorrect number of columns returned for joined OrderDetail_Product query");

                ParseDataSet(dataset);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        private void UpdateRow(object param)
        {
            try
            {
                Product product = (Product)ObjectFactory.Create(ObjectType.Product);
                product.ProductId = Convert.ToInt64(param);

                DbController dbc = new DbController(Connection);
                dbc.UpdateProduct(product);

                Product updatedProd = dbc.GetProduct(product.ProductId);

                if (!product.Validate(updatedProd))
                    Fail("Product update validation failed.");
            }
            catch (Exception e)
            {
                Fail(e);
            }
        }
コード例 #58
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            try
            {
                dbc.DeleteAddress(dbc.GetRandomCustomer().Address.AddressId);
                Fail("Customer constraint violation exception should have occurred");

                dbc.DeleteAddress(dbc.GetRandomSupplier().Address.AddressId);
                Fail("Supplier constraint violation exception should have occurred");
            }
            catch (Exception e)
            {
                Log(e);
            }
            finally
            {
                base.Run(context);
            }
        }
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);

            try
            {
                DataSet ds = new DataSet(); 

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.PRODUCT_CATEGORY, new long[] { dbc.GetRandomCategory().CategoryId });

                DataAdapter.Fill(ds, "Product_Category");

                Command.CommandText = DbDefault.GetInnerJoinSelectStatement(
                    Relation.ORDER_CUSTOMER, new long[] { dbc.GetRandomCustomer().CustomerId });

                DataAdapter.Fill(ds, "Order_Customer");

                if (ds.Tables["Product_Category"].Columns.Count != 
                    (DbDefault.GetTableStructure(TableName.PRODUCT).Columns.Count
                    + DbDefault.GetTableStructure(TableName.CATEGORY).Columns.Count))
                    Fail("Number of returned columns is incorrect");

                if (ds.Tables["Order_Customer"].Columns.Count !=
                    (DbDefault.GetTableStructure(TableName.ORDERS).Columns.Count
                    + DbDefault.GetTableStructure(TableName.CUSTOMER).Columns.Count))
                    Fail("Number of returned columns is incorrect");
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }
コード例 #60
0
        public override void Run(object context)
        {
            DbController dbc = new DbController(Connection);
            try
            {
                Customer customer = dbc.GetRandomCustomer();                
                Address address = (Address)ObjectFactory.Create(ObjectType.Address);
                address.AddressId = customer.Address.AddressId;
                dbc.UpdateAddress(address);

                Supplier supplier = dbc.GetRandomSupplier();
                address = (Address)ObjectFactory.Create(ObjectType.Address);
                address.AddressId = supplier.Address.AddressId;
                dbc.UpdateAddress(address);
            }
            catch (Exception e)
            {
                Fail(e);
            }
            finally
            {
                base.Run(context);
            }
        }