示例#1
0
        private void Block_EntityAdded(TableObject sender, BlockEntityChangeEventArgs e)
        {
            if (e.Item.Owner != null)
            {
                // the block and its entities must belong to the same document
                if (!ReferenceEquals(e.Item.Owner.Record.Owner.Owner, this.Owner))
                {
                    throw new ArgumentException("The block and the entity must belong to the same document. Clone it instead.");
                }

                // the entity cannot belong to another block
                if (e.Item.Owner.Record.Layout == null)
                {
                    throw new ArgumentException("The entity cannot belong to another block. Clone it instead.");
                }

                // we will exchange the owner of the entity
                this.Owner.RemoveEntity(e.Item);
            }
            this.Owner.AddEntity(e.Item, true, string.IsNullOrEmpty(e.Item.Handle));
        }
    public void tableObjectSelectedByCalculator(string id, string side)
    {
        Debug.Log("id = " + id);
        for (int i = 0; i < instantiatedTableActiveGameObjects.Length; i++)
        {
            TableObject activeTableGameObject = instantiatedTableActiveGameObjects[i].GetComponent <TableObject>();

            Debug.Log(i + " " + instantiatedTableActiveGameObjects[i].GetComponent <TableObject>().id);
            if (id.Equals(activeTableGameObject.id))
            {
                Debug.Log(instantiatedTableActiveGameObjects[i].gameObject.name);

                Collected_Objects tempCollectedObject = new Collected_Objects();
                // if (side.Equals(activeTableGameObject.side))
                if (side.Equals(activeTableGameObject.objectPosition))
                {
                    Debug.Log("ATTEMPTS " + activeTableGameObject.attempts);
                    activeTableGameObject.obj_recorded_on_pad     = true;
                    activeTableGameObject.finishedRecordOnAttempt = true;
                    //dbgrabconnection.UpdateCollectedObjectOnPad(int.Parse(activeTableGameObject.id),activeTableGameObject.obj_recorded_on_pad);
                    activeTableGameObject.SetAttempts(activeTableGameObject.attempts++);
                    tempCollectedObject.SetValues(ExperimentParameters.gameplay_id, int.Parse(activeTableGameObject.id), activeTableGameObject.objectPosition, BringLevelToString(int.Parse(activeTableGameObject.level)), activeTableGameObject.obj_recorded_on_pad, false, "", activeTableGameObject.attempts);

                    Debug.Log("tempCollectedObject " + tempCollectedObject.obj_recorded_after_attempt);

                    activeTableGameObject.SetCollectedObject(tempCollectedObject);
                    //  activeTableGameObject.SetAttempts(1); //first try and succeeded

                    // dbgrabconnection.CreateCollectedObjectsRow(tempCollectedObject);
                    activeTableGameObject.canvas.GetChild(0).GetComponent <Image>().sprite             = Resources.Load <Sprite>("Textures/UiSprites/golden_star");
                    activeTableGameObject.canvas.GetChild(0).GetChild(0).GetComponent <Text>().enabled = false;
                }

                if (!activeTableGameObject.finishedRecordOnAttempt)
                {
                    activeTableGameObject.SetAttempts(activeTableGameObject.attempts++);
                }
            }
        }
    }
示例#3
0
 private void Up()
 {
     try
     {
         if (lstMainTables.Items.Count > 1)
         {
             if (lstMainTables.SelectedIndex < lstMainTables.Items.Count - 1)
             {
                 int         indx = lstMainTables.SelectedIndex;
                 TableObject tbl  = tableNames[lstMainTables.SelectedIndex];
                 tableNames[lstMainTables.SelectedIndex]     = tableNames[lstMainTables.SelectedIndex + 1];
                 tableNames[lstMainTables.SelectedIndex + 1] = tbl;
                 LoadTablesToList();
                 lstMainTables.SelectedIndex = indx + 1;
             }
         }
     }
     catch (Exception ex)
     {
         LogError(ex);
     }
 }
示例#4
0
        private EntityObject ExportBlock(GeoObject.Block blk)
        {
            List <EntityObject> entities = new List <EntityObject>();

            for (int i = 0; i < blk.Children.Count; i++)
            {
                EntityObject entity = GeoObjectToEntity(blk.Child(i));
                if (entity != null)
                {
                    entities.Add(entity);
                }
            }
            string name = blk.Name;

            if (name == null || doc.Blocks.Contains(name) || !TableObject.IsValidName(name))
            {
                name = GetNextAnonymousBlockName();
            }
            netDxf.Blocks.Block block = new netDxf.Blocks.Block(name, entities);
            doc.Blocks.Add(block);
            return(new netDxf.Entities.Insert(block));
        }
        public async Task SetPropertyValuesShouldCreateNewPropertiesAndSaveThemInTheDatabase()
        {
            // Arrange
            Guid uuid                = Guid.NewGuid();
            var  tableId             = 4;
            var  firstPropertyName   = "page1";
            var  secondPropertyName  = "page2";
            var  firstPropertyValue  = "test";
            var  secondPropertyValue = "blablabla";

            var tableObject = await TableObject.CreateAsync(uuid, tableId);

            Dictionary <string, string> newProperties = new Dictionary <string, string>
            {
                { firstPropertyName, firstPropertyValue },
                { secondPropertyName, secondPropertyValue }
            };

            // Act
            await tableObject.SetPropertyValuesAsync(newProperties);

            // Assert
            Assert.AreEqual(firstPropertyValue, tableObject.GetPropertyValue(firstPropertyName));
            Assert.AreEqual(secondPropertyValue, tableObject.GetPropertyValue(secondPropertyName));

            // Make sure the properties have ids
            Assert.AreNotEqual(0, tableObject.Properties[0].Id);
            Assert.AreNotEqual(0, tableObject.Properties[1].Id);

            var tableObjectFromDatabase = await Dav.Database.GetTableObjectAsync(uuid);

            Assert.IsNotNull(tableObjectFromDatabase);
            Assert.AreEqual(2, tableObjectFromDatabase.Properties.Count);
            Assert.AreEqual(firstPropertyName, tableObjectFromDatabase.Properties[0].Name);
            Assert.AreEqual(firstPropertyValue, tableObjectFromDatabase.Properties[0].Value);
            Assert.AreEqual(secondPropertyName, tableObjectFromDatabase.Properties[1].Name);
            Assert.AreEqual(secondPropertyValue, tableObjectFromDatabase.Properties[1].Value);
        }
        public async Task SetPropertyValueShouldCreateANewPropertyAndSaveItInTheDatabase()
        {
            // Arrange
            int    tableId       = 4;
            string propertyName  = "page1";
            string propertyValue = "Hello World";
            var    tableObject   = await TableObject.CreateAsync(tableId);

            // Act
            await tableObject.SetPropertyValueAsync(propertyName, propertyValue);

            // Assert
            Assert.AreEqual(tableObject.Properties.Count, 1);
            Assert.AreEqual(tableObject.Properties[0].Name, propertyName);
            Assert.AreEqual(tableObject.Properties[0].Value, propertyValue);

            var tableObject2 = await Dav.Database.GetTableObjectAsync(tableObject.Uuid);

            Assert.NotNull(tableObject2);
            Assert.AreEqual(tableObject2.Properties.Count, 1);
            Assert.AreEqual(tableObject2.Properties[0].Name, propertyName);
            Assert.AreEqual(tableObject2.Properties[0].Value, propertyValue);
        }
        public async Task SetFileShouldCopyTheFileAndSaveTheExtInTheDatabase()
        {
            // Arrange
            int      tableId = 3;
            Guid     uuid    = Guid.NewGuid();
            FileInfo oldFile = new FileInfo(Path.Combine(Utils.GetProjectDirectory(), "Assets", "image.jpg"));
            FileInfo newFile = new FileInfo(Path.Combine(Utils.GetProjectDirectory(), "Assets", "icon.ico"));

            var tableObject = await TableObject.CreateAsync(uuid, tableId, oldFile);

            // Act
            await tableObject.SetFileAsync(newFile);

            // Assert
            Assert.AreNotEqual(oldFile, tableObject.File);
            Assert.AreEqual(newFile.Length, tableObject.File.Length);

            var tableObject2 = await Dav.Database.GetTableObjectAsync(uuid);

            Assert.NotNull(tableObject2);
            Assert.AreEqual(newFile.Length, tableObject2.File.Length);
            Assert.AreEqual(tableObject2.Properties.Find(prop => prop.Name == "ext").Value, newFile.Extension.Replace(".", ""));
        }
示例#8
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
            }
            else
            {
                if (e.ColumnIndex == 1)
                {
                    DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

                    TableObject obj = (TableObject)row.DataBoundItem;

                    if (obj != null)
                    {
                        TableEditForm form = new TableEditForm();
                        form.Table    = obj;
                        form.Settings = this.Settings;
                        form.ShowDialog(this);
                    }
                }
            }
        }
示例#9
0
        //public void Copy(TableObject table)
        //{
        //	// Delete data
        //	if (CopySettings.DeleteRows) this.Delete(table);


        //	using (IDataReader dr = this.Select(table))
        //	{
        //		using (OracleBulkCopy copy = new OracleBulkCopy(CopySettings.Destination, this.Options))
        //		{
        //			copy.BulkCopyTimeout = CopySettings.BulkCopyTimeout;
        //			copy.BatchSize = CopySettings.BatchSize;
        //			copy.DestinationTableName = this.FullTableName(table);
        //			copy.NotifyAfter = CopySettings.NotifyAfter;
        //			copy.OracleRowsCopied += copy_OracleRowsCopied;
        //			copy.WriteToServer(dr);
        //		}
        //	}
        //}

        // Copy from source to destination this
        public void Copy(TableObject table, IDbData source)
        {
            // Delete data from destination (this)
            if (CopySettings.DeleteRows)
            {
                this.Delete(table);
            }

            // read from source
            using (IDataReader dr = source.Select(table))
            {
                // copy to destination (this)
                using (OracleBulkCopy copy = new OracleBulkCopy(this.ConnectionString, this.Options))
                {
                    copy.BulkCopyTimeout      = CopySettings.BulkCopyTimeout;
                    copy.BatchSize            = CopySettings.BatchSize;
                    copy.DestinationTableName = this.FullTableName(table);
                    copy.NotifyAfter          = CopySettings.NotifyAfter;
                    //copy.OracleRowsCopied += copy_OracleRowsCopied;
                    copy.WriteToServer(dr);
                }
            }
        }
示例#10
0
    private string GetQuestions(string testSys)
    {
        string    querstiongs = "";
        DataTable dtItem      = new TableObject("t_test_day_item").Util_GetList("Questions", "testsysnumber='" + tesSys + "'");

        if (dtItem.Rows.Count > 0)
        {
            foreach (DataRow row in dtItem.Rows)
            {
                querstiongs += row["Questions"].ToString() + ",";
            }
        }
        else
        {
            DataTable dt = new BllTestday().GetList("sysnumber='" + tesSys + "'").Tables[0];
            if (dt.Rows.Count > 0)
            {
                querstiongs = dt.Rows[0]["Questions"].ToString();
            }
        }
        querstiongs = this.hidRndQuestions.Value + querstiongs.Replace(",,", ",");
        return(querstiongs.Replace(",", "','"));
    }
示例#11
0
 public void TablesAndViews(StringBuilder str)
 {
     using (List <TableObject> .Enumerator enumerator = T4Base.MyDb.GetTableView().GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             TableObject table = enumerator.Current;
             if ((this.OnlyTable.Count == 0 || this.OnlyTable.Contains(table.name)) && !this.NoTable.Contains(table.name))
             {
                 foreach (FieldObject arg_85_0 in table.Columns)
                 {
                 }
                 IEnumerable <ProObject> enumerable =
                     from z in T4Base.MyDb.Procedures
                     where z.text.IndexOf(table.name) >= 0
                     select z;
                 foreach (ProObject arg_D1_0 in enumerable)
                 {
                 }
             }
         }
     }
 }
示例#12
0
        public static async Task AddPlayingSoundAsync(Guid uuid, List <string> soundIds, int current, int repetitions, bool randomly, double volume)
        {
            var properties = new List <Property>
            {
                new Property {
                    Name = FileManager.PlayingSoundTableSoundIdsPropertyName, Value = string.Join(",", soundIds)
                },
                new Property {
                    Name = FileManager.PlayingSoundTableCurrentPropertyName, Value = current.ToString()
                },
                new Property {
                    Name = FileManager.PlayingSoundTableRepetitionsPropertyName, Value = repetitions.ToString()
                },
                new Property {
                    Name = FileManager.PlayingSoundTableRandomlyPropertyName, Value = randomly.ToString()
                },
                new Property {
                    Name = FileManager.PlayingSoundTableVolumePropertyName, Value = volume.ToString()
                }
            };

            await TableObject.CreateAsync(uuid, FileManager.PlayingSoundTableId, properties);
        }
        public async Task DeleteTableObjectWithTableObjectShouldDeleteTheTableObjectAndItsPropertiesIfTheUploadStatusIsDeleted()
        {
            // Arrange
            int             tableId        = 6;
            Guid            uuid           = Guid.NewGuid();
            List <Property> propertiesList = new List <Property>
            {
                new Property {
                    Name = "page1", Value = "Good day"
                },
                new Property {
                    Name = "page2", Value = "Guten Tag"
                }
            };
            var tableObject = await TableObject.CreateAsync(uuid, tableId, propertiesList);

            await tableObject.SetUploadStatusAsync(TableObjectUploadStatus.Deleted);

            int firstPropertyId  = tableObject.Properties[0].Id;
            int secondPropertyId = tableObject.Properties[1].Id;

            // Act
            await Dav.Database.DeleteTableObjectAsync(tableObject);

            // Assert
            var tableObjectFromDatabase = await Dav.Database.GetTableObjectAsync(uuid);

            Assert.IsNull(tableObjectFromDatabase);

            var firstPropertyFromDatabase = await Dav.Database.GetPropertyAsync(firstPropertyId);

            Assert.IsNull(firstPropertyFromDatabase);

            var secondPropertyFromDatabase = await Dav.Database.GetPropertyAsync(secondPropertyId);

            Assert.IsNull(secondPropertyFromDatabase);
        }
        /// <summary>
        /// 设置 单元格样式 及 文字样式
        /// </summary>
        private void TableAddRows(TableObject table, int rowNums)
        {
            int uniteStart   = table.Rows.Count;
            int tableColumns = table.Columns.Count;

            if (rowNums > 0)
            {
                for (int i = 0; i < rowNums; i++)
                {
                    TableRow row = new TableRow();
                    table.Rows.Add(row);
                    row.Height = 28f;
                    for (int j = 0; j < table.ColumnCount; j++)
                    {
                        SetCellStyles(row[j]);
                    }
                }

                #region 合并单元格
                table.Rows[uniteStart][0].RowSpan = rowNums;
                table.Rows[uniteStart][tableColumns - 1].RowSpan = rowNums;
                #endregion
            }
        }
示例#15
0
 private void Block_EntityRemoved(TableObject sender, BlockEntityChangeEventArgs e)
 {
     this.Owner.RemoveEntityFromDocument(e.Item);
 }
示例#16
0
 private void Block_EntityAdded(TableObject sender, BlockEntityChangeEventArgs e)
 {
     this.Owner.AddEntityToDocument(e.Item, (Block)sender, string.IsNullOrEmpty(e.Item.Handle));
 }
示例#17
0
        public List <Asset> GetList(TableObject table)
        {
            string CustomerLink = ConfigurationManager.AppSettings["CustomerLink"];
            string CacheEnable  = ConfigurationManager.AppSettings["CacheEnable"];
            string key          = CacheUtility.GetKey(table);
            object obj          = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <Asset>)obj);
            }
            string sqlStr = "";
            string sqlAdd = "";

            if (table.IsValid == 1)
            {
                sqlAdd = " AND (TotalCourseAmount>0 OR CommonCourseAmount>0 OR SpecialCourseAmount>0) ";
            }
            byte[] TimeStamp = new byte[8];
            if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(TimeStamp))
            {
                sqlStr = @"select * from Asset where SubCompanyID=@BranchID and SchoolID=@SchoolID and LastModified>@LastModified 
and [OwnerID]
in(
select CustomerID  FROM " + CustomerLink + @"[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID " + sqlAdd + ")";
                //AND (SS.TotalCourseAmount>0 OR SS.CommonCourseAmount>0 OR SS.SpecialCourseAmount>0)
            }
            else
            {
                sqlStr = @"select * from Asset where SubCompanyID=@BranchID and SchoolID=@SchoolID and LastModified>@LastModified";
            }
            //[CLOUDCUSTOMER]为链接服务器
//            string sqlStr = @"select * from Asset where SubCompanyID=@BranchID and SchoolID=@SchoolID and LastModified>@LastModified
//and [OwnerID]
//in(
//select CustomerID  FROM [CLOUDCUSTOMER].[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID
//  AND (SS.TotalCourseAmount>0 OR SS.CommonCourseAmount>0 OR SS.SpecialCourseAmount>0)
//  )";

            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("BranchID", table.BranchID));
            pms.Add(new SqlParameter("SchoolID", table.SchoolID));
            pms.Add(new SqlParameter("LastModified", table.LastModified));
            //if (!string.IsNullOrEmpty(table.StartDate))
            //{
            //    sqlStr += " and OperateTime>@StartDate";
            //    pms.Add(new SqlParameter("StartDate", table.StartDate));
            //}
            //if (!string.IsNullOrEmpty(table.EndDate))
            //{
            //    sqlStr += " and OperateTime<@EndDate";
            //    pms.Add(new SqlParameter("EndDate", table.EndDate));
            //}
            List <Asset> list = AssetBLL.Search(sqlStr, pms.ToArray());

            if (list.Count > 0)
            {
                byte[] b = new byte[8];
                if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(b))
                {
                    CacheUtility.Insert(key, list);
                }
                else
                {
                    if (CacheEnable == "true")
                    {
                        CacheUtility.Insert(key, list);
                    }
                }
            }
            return(list);
        }
示例#18
0
        public List <Period> GetList(TableObject table)
        {
            string CacheEnable  = ConfigurationManager.AppSettings["CacheEnable"];
            string CustomerLink = ConfigurationManager.AppSettings["CustomerLink"];
            string key          = CacheUtility.GetKey(table);
            object obj          = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <Period>)obj);
            }
            string sqlStr = "";
            string sqlAdd = "";

            if (table.IsValid == 1)
            {
                sqlAdd = " AND (TotalCourseAmount>0 OR CommonCourseAmount>0 OR SpecialCourseAmount>0) ";
            }
            byte[] TimeStamp = new byte[8];
            if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(TimeStamp))
            {
                sqlStr = @"select * from [CloudAsset].[dbo].[Period]  where LastModified>@LastModified and AssetID in
(
select AssetID from [CloudAsset].[dbo].[Asset] where [OwnerID]
in(
select CustomerID  FROM " + CustomerLink + @"[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID " + sqlAdd + "))";
                //  AND (SS.TotalCourseAmount>0 OR SS.CommonCourseAmount>0 OR SS.SpecialCourseAmount>0)
            }
            else
            {
                sqlStr = @"  select a.* from [CloudAsset].[dbo].[Period] a 
                  join [dbo].[Asset] b on a.AssetID=b.AssetID where b.SubCompanyID=@BranchID and b.SchoolID=@SchoolID and a.LastModified>@LastModified";
            }


            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("BranchID", table.BranchID));
            pms.Add(new SqlParameter("SchoolID", table.SchoolID));
            pms.Add(new SqlParameter("LastModified", table.LastModified));
            //if (!string.IsNullOrEmpty(table.StartDate))
            //{
            //    sqlStr += " and AssetCreateDate>@StartDate";
            //    pms.Add(new SqlParameter("StartDate", table.StartDate));
            //}
            //if (!string.IsNullOrEmpty(table.EndDate))
            //{
            //    sqlStr += " and AssetCreateDate<@EndDate";
            //    pms.Add(new SqlParameter("EndDate", table.EndDate));
            //}
            List <Period> list = PeriodBLL.Search(sqlStr, pms.ToArray());

            if (list.Count > 0)
            {
                byte[] b = new byte[8];
                if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(b))
                {
                    CacheUtility.Insert(key, list);
                }
                else
                {
                    if (CacheEnable == "true")
                    {
                        CacheUtility.Insert(key, list);
                    }
                }
            }
            return(list);
        }
示例#19
0
 public IDataReader Select(TableObject table)
 {
     return(this.ExecuteReader(string.Format(CopySettings.SelectSql, this.FullTableName(table))));
 }
        public DbObject BuildDbObject(string connectionString)
        {
            DbObject dbObj = new DbObject();

            try
            {
                List <TableObject> tables       = new List <TableObject>();
                DataTable          dtAllObjects = GetTable(connectionString, Crud.GetSchema_Table_Columns_DataTypes_IdentityCol());
                TableObject        tblObj       = null;
                foreach (DataRow row in dtAllObjects.Rows)
                {
                    tblObj = null;
                    tblObj = new TableObject {
                        Name = string.Format("{0}", row["TABLE_NAME"]), Schema = string.Format("{0}", row["TABLE_SCHEMA"])
                    };
                    if (tables.Contains(tblObj) == false)
                    {
                        tables.Add(tblObj);
                    }
                }
                tblObj = null;
                DataRow[]           rows = null;
                ColumnObject        colObj;
                List <ColumnObject> Columns = null;

                for (int tableCounter = 0; tableCounter < tables.Count; tableCounter++)
                {
                    tblObj  = null;
                    tblObj  = tables[tableCounter];
                    Columns = new List <ColumnObject>();
                    rows    = null;
                    rows    = dtAllObjects.Select(string.Format("TABLE_NAME='{0}' AND TABLE_SCHEMA='{1}'", tblObj.Name, tblObj.Schema));

                    foreach (DataRow rw in rows)
                    {
                        colObj = new ColumnObject()
                        {
                            ColumnName = string.Format("{0}", rw["COLUMN_NAME"]), ColumnDataType = string.Format("{0}", rw["DATA_TYPE"])
                        };
                        if (Columns.Contains(colObj) == false)
                        {
                            Columns.Add(colObj);
                        }
                    }

                    tblObj.Columns = Columns;

                    rows = null;
                    rows = dtAllObjects.Select(string.Format("TABLE_NAME='{0}' AND TABLE_SCHEMA='{1}' AND IS_IDENTITY=1", tblObj.Name, tblObj.Schema));

                    foreach (DataRow rw in rows)
                    {
                        tblObj.IdColumn = string.Format("{0}", rw["COLUMN_NAME"]).Replace(" ", "");
                    }

                    tables[tableCounter] = tblObj;
                }
                dbObj.Tables = tables;
            }
            catch (Exception)
            {
                throw;
            }

            return(dbObj);
        }
示例#21
0
 public static async Task AddImageFileAsync(Guid uuid, StorageFile imageFile)
 {
     await TableObject.CreateAsync(uuid, FileManager.ImageFileTableId, new FileInfo(imageFile.Path));
 }
示例#22
0
 public static async Task AddSoundFileAsync(Guid uuid, StorageFile audioFile)
 {
     await TableObject.CreateAsync(uuid, FileManager.SoundFileTableId, new FileInfo(audioFile.Path));
 }
示例#23
0
 private void Block_EntityRemoved(TableObject sender, BlockEntityChangeEventArgs e)
 {
     this.Owner.RemoveEntity(e.Item, true);
 }
示例#24
0
        static void Main(string[] args)
        {
            WindowExitSignal       = new WindowExitSignal();
            WindowExitSignal.Exit += () =>
            {
                QuitEvent.Set();
            };

            Console.WriteLine("Hello World!");
            System.Collections.Generic.List <int> i;
            string server   = "127.0.0.1";
            string username = "******";
            string password = "";
            string database = "mysql";

            /* Connect to Database */
            MySQL.MySQLConnection connection = new MySQL.MySQLConnection(server, username, password, database);
            connection.Connect();
            //MySql.Data.MySqlClient.MySqlCommand command = new MySql.Data.MySqlClient.MySqlCommand();
            //command.Connection = connection.connection;

            //command.CommandText = "SELECT * FROM global_priv";
            Database db = new Database(connection);

            Console.WriteLine("[TestDatabase] - database include: " + db.Tables.Count);

            foreach (var entry in db.Tables)
            {
                Console.WriteLine(entry.Key);
            }
            /* -Connect to Database */

            /* Insert into a table */
            TableObject table = new TableObject();

            table.Name       = "servers";
            table.Connection = connection;


            RowObject row = new RowObject();

            row.Fields.Add("Server_name", "testinsert");
            row.Fields.Add("Host", "localhost");
            row.Fields.Add("Port", 3000);

            table.Insert(row);
            /* -Insert into a table */

            /* Select a row */
            row = new RowObject();
            row.Fields.Add("Server_name", "testinsert");
            var rows = table.Select(row);

            foreach (var item in rows)
            {
                Console.WriteLine("[" + table.Name + "]" + " - " + item);
            }
            /* -Select a row */

            /* Deserilize a row from SELECT */
            row = new RowObject();
            row.Fields.Add("host", "localhost");

            IEnumerable <TestRow> t = table.Select <TestRow>(row);

            foreach (var item in t)
            {
                Console.WriteLine("[TestDeserialize] - " + item);
            }
            /* -Deserilize a row from SELECT */

            /* Update a table row */
            RowObject original = new RowObject();

            //row.Fields.Add("Server_name", "123");
            original.Fields.Add("Host", "localhost");
            original.Fields.Add("Port", 3000);

            RowObject current = (RowObject)original.Clone();

            current.Fields.Add("Server_name", "123");

            int affected = table.Update(original, current);

            Console.WriteLine("[" + table.Name + "]" + " - " + affected + " Row(s) is affected");
            /* -Update a table row */

            /* Delete a table row */
            row = new RowObject();
            row.Fields.Add("Server_name", "123");

            affected = table.Delete(row);
            Console.WriteLine("[" + table.Name + "]" + " - " + affected + " Row(s) is affected");
            /* -Delete a table row */

            /* Deserilize a row */
            row = new RowObject();
            row.Fields.Add("Server_name", "123");
            row.Fields.Add("Host", "localhost");
            row.Fields.Add("Port", 1900);

            TestRow deserialized = row.Deserialize <TestRow>();

            Console.WriteLine("[TestRow] - " + deserialized);
            /* -Deserilize a row */

            /* Disconnect */
            connection.Disconnect();
            /* -Disconnect */

            //table.TestInsert(connection);
            //table.TestUpdate(connection);
            //table.TestDelete(connection);
            //table.TestSelect(connection);
            //table.TestDeserialize(connection);
            //row.name = "abc";
            //row.host = "local";
            //row.port = 3000;
            //row.Update();
            QuitEvent.WaitOne();
        }
示例#25
0
        // use the TableObject to represent the contents. It's easier to export it later.
        private TableObject GetTable(bool autoRows)
        {
            TableObject table = new TableObject();

            table.SetPrinting(IsPrinting);
            table.SetReport(Report);

            float cellWidth  = CellWidth;
            float cellHeight = CellHeight;

            // calculate cellWidth, cellHeight automatically
            if (cellWidth == 0 || cellHeight == 0)
            {
                float fontHeight = Font.GetHeight() * 96f / DrawUtils.ScreenDpi;
                cellWidth  = (int)Math.Round((fontHeight + 10) / Page.SnapSize.Width) * Page.SnapSize.Width;
                cellHeight = cellWidth;
            }

            int colCount = (int)((Width + HorzSpacing + 1) / (cellWidth + HorzSpacing));

            if (colCount == 0)
            {
                colCount = 1;
            }
            int rowCount = (int)((Height + VertSpacing + 1) / (cellHeight + VertSpacing));

            if (rowCount == 0 || autoRows)
            {
                rowCount = 1;
            }

            table.ColumnCount = colCount;
            table.RowCount    = rowCount;

            // process the text
            int    row       = 0;
            int    lineBegin = 0;
            int    lastSpace = 0;
            string text      = Text.Replace("\r\n", "\n");

            for (int i = 0; i < text.Length; i++)
            {
                bool isCRLF = text[i] == '\n';
                if (text[i] == ' ' || isCRLF)
                {
                    lastSpace = i;
                }

                if (i - lineBegin + 1 > colCount || isCRLF)
                {
                    if (WordWrap && lastSpace > lineBegin)
                    {
                        AddText(table, row, text.Substring(lineBegin, lastSpace - lineBegin));
                        lineBegin = lastSpace + 1;
                    }
                    else if (i - lineBegin > 0)
                    {
                        AddText(table, row, text.Substring(lineBegin, i - lineBegin));
                        lineBegin = i;
                    }
                    else
                    {
                        lineBegin = i + 1;
                    }

                    lastSpace = lineBegin;
                    row++;
                    if (autoRows && row >= rowCount)
                    {
                        rowCount++;
                        table.RowCount++;
                    }
                }
            }

            // finish the last line
            if (lineBegin < text.Length)
            {
                AddText(table, row, text.Substring(lineBegin, text.Length - lineBegin));
            }

            // set up cells appearance
            for (int i = 0; i < colCount; i++)
            {
                for (int j = 0; j < rowCount; j++)
                {
                    TableCell cell = table[i, j];
                    cell.Border    = Border.Clone();
                    cell.Fill      = Fill.Clone();
                    cell.Font      = Font;
                    cell.TextFill  = TextFill.Clone();
                    cell.HorzAlign = HorzAlign.Center;
                    cell.VertAlign = VertAlign.Center;
                }
            }

            // set cell's width and height
            for (int i = 0; i < colCount; i++)
            {
                table.Columns[i].Width = cellWidth;
            }

            for (int i = 0; i < rowCount; i++)
            {
                table.Rows[i].Height = cellHeight;
            }

            // insert spacing between cells
            if (HorzSpacing > 0)
            {
                for (int i = 0; i < colCount - 1; i++)
                {
                    TableColumn newColumn = new TableColumn();
                    newColumn.Width = HorzSpacing;
                    table.Columns.Insert(i * 2 + 1, newColumn);
                }
            }

            if (VertSpacing > 0)
            {
                for (int i = 0; i < rowCount - 1; i++)
                {
                    TableRow newRow = new TableRow();
                    newRow.Height = VertSpacing;
                    table.Rows.Insert(i * 2 + 1, newRow);
                }
            }

            table.Left   = AbsLeft;
            table.Top    = AbsTop;
            table.Width  = table.Columns[table.ColumnCount - 1].Right;
            table.Height = table.Rows[table.RowCount - 1].Bottom;
            return(table);
        }
示例#26
0
 public void Delete(TableObject table)
 {
     this.ExecuteNonQuery(string.Format(CopySettings.DeleteSql, this.FullTableName(table)));
 }
示例#27
0
        public static async Task SetSoundOrderAsync(Guid categoryUuid, bool favourite, List <Guid> uuids)
        {
            // Check if the order object already exists
            List <TableObject> tableObjects = await GetAllOrdersAsync();

            TableObject tableObject = tableObjects.Find((TableObject obj) => {
                // Check if the object is of type Sound
                if (obj.GetPropertyValue(FileManager.OrderTableTypePropertyName) != FileManager.SoundOrderType)
                {
                    return(false);
                }

                // Check if the object has the right category uuid
                string categoryUuidString = obj.GetPropertyValue(FileManager.OrderTableCategoryPropertyName);
                Guid?cUuid = FileManager.ConvertStringToGuid(categoryUuidString);
                if (!cUuid.HasValue)
                {
                    return(false);
                }

                string favString = obj.GetPropertyValue(FileManager.OrderTableFavouritePropertyName);
                bool.TryParse(favString, out bool fav);

                return(Equals(categoryUuid, cUuid) && favourite == fav);
            });

            if (tableObject == null)
            {
                // Create a new table object
                List <Property> properties = new List <Property>
                {
                    // Set the type property
                    new Property {
                        Name = FileManager.OrderTableTypePropertyName, Value = FileManager.SoundOrderType
                    },
                    // Set the category property
                    new Property {
                        Name = FileManager.OrderTableCategoryPropertyName, Value = categoryUuid.ToString()
                    },
                    // Set the favourite property
                    new Property {
                        Name = FileManager.OrderTableFavouritePropertyName, Value = favourite.ToString()
                    }
                };

                int i = 0;
                foreach (var uuid in uuids)
                {
                    properties.Add(new Property {
                        Name = i.ToString(), Value = uuid.ToString()
                    });
                    i++;
                }

                await TableObject.CreateAsync(Guid.NewGuid(), FileManager.OrderTableId, properties);
            }
            else
            {
                // Update the existing object
                int i = 0;
                Dictionary <string, string> newProperties = new Dictionary <string, string>();
                foreach (var uuid in uuids)
                {
                    newProperties.Add(i.ToString(), uuid.ToString());
                    i++;
                }
                await tableObject.SetPropertyValuesAsync(newProperties);

                bool removeNonExistentSounds = FileManager.itemViewHolder.User == null || !FileManager.itemViewHolder.User.IsLoggedIn ||
                                               (FileManager.itemViewHolder.User.IsLoggedIn && FileManager.syncFinished);

                if (removeNonExistentSounds)
                {
                    // Remove the properties that are outside of the uuids range
                    List <string> removedProperties = new List <string>();
                    foreach (var property in tableObject.Properties)
                    {
                        if (int.TryParse(property.Name, out int propertyIndex) && propertyIndex >= uuids.Count)
                        {
                            removedProperties.Add(property.Name);
                        }
                    }

                    for (int j = 0; j < removedProperties.Count; j++)
                    {
                        await tableObject.RemovePropertyAsync(removedProperties[j]);
                    }
                }
            }
        }
示例#28
0
 public long Count(TableObject table)
 {
     return((long)this.ExecuteScalar(string.Format(CopySettings.CountSql, this.FullTableName(table))));
 }
示例#29
0
 private void DimensionStyleLinetypeChanged(TableObject sender, TableObjectChangedEventArgs <Linetype> e)
 {
     this.Owner.Linetypes.References[e.OldValue.Name].Remove(sender);
     e.NewValue = this.Owner.Linetypes.Add(e.NewValue);
     this.Owner.Linetypes.References[e.NewValue.Name].Add(sender);
 }
示例#30
0
        public List <OrderStatistics> GetList(TableObject table)
        {
            string CustomerLink = ConfigurationManager.AppSettings["CustomerLink"];
            string CacheEnable  = ConfigurationManager.AppSettings["CacheEnable"];
            string key          = CacheUtility.GetKey(table);
            object obj          = CacheUtility.Get(key);

            if (obj != null)
            {
                return((List <OrderStatistics>)obj);
            }

            string sqlStr = "";
            string sqlAdd = "";

            if (table.IsValid == 1)
            {
                sqlAdd = " AND (TotalCourseAmount>0 OR CommonCourseAmount>0 OR SpecialCourseAmount>0) ";
            }
            sqlStr = @"select * from OrderStatistics where LastModified>@LastModified 
and CustomerID
in(
select CustomerID  FROM " + CustomerLink + @"[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID " + sqlAdd + ")";

//            byte[] TimeStamp = new byte[8];
//            if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(TimeStamp))
//            {
//                sqlStr = @"select * from OrderStatistics where LastModified>@LastModified
//and CustomerID
//in(
//select CustomerID  FROM " + CustomerLink + @"[CloudCustomer].[dbo].[CustomerSearch] ss where ss.XDSchoolID=@SchoolID
//
//  )";
//                //AND (SS.TotalCourseAmount>0 OR SS.CommonCourseAmount>0 OR SS.SpecialCourseAmount>0)
//            }
//            else
//            {
//                sqlStr = @"select * from OrderStatistics where LastModified>@LastModified";
//            }

            //string sqlStr = "select * from OrderStatistics where LastModified>@LastModified";

            List <SqlParameter> pms = new List <SqlParameter>();

            pms.Add(new SqlParameter("LastModified", table.LastModified));
            pms.Add(new SqlParameter("SchoolID", table.SchoolID));

            List <OrderStatistics> list = OrderStatisticsBLL.Search(sqlStr, pms.ToArray());

            if (list.Count > 0)
            {
                byte[] b = new byte[8];
                if (CacheUtility.GetCollectionKey(table.LastModified) == CacheUtility.GetCollectionKey(b))
                {
                    CacheUtility.Insert(key, list);
                }
                else
                {
                    if (CacheEnable == "true")
                    {
                        CacheUtility.Insert(key, list);
                    }
                }
            }
            return(list);
        }