Exemplo n.º 1
0
        private void bindClientInfo()
        {
            DataSet DSClientInfo = new DataSet();

            try
            {
                DSClientInfo = rproxy.CustomerGetDetails(CustomerID, 2);
                if (
                    (DSClientInfo.Tables[0] != null) &&
                    (DSClientInfo.Tables[0].Rows.Count > 0)
                    )
                {
                    DataRow    row     = DSClientInfo.Tables[0].Rows[0];
                    RowWrapper wrapper = new RowWrapper(row);

                    wrapper.rowView.Row.Table.Columns["firstname"].ColumnName        = "Nombre";
                    wrapper.rowView.Row.Table.Columns["middlename"].ColumnName       = "Seg Nombre";
                    wrapper.rowView.Row.Table.Columns["surname1"].ColumnName         = "Apellido";
                    wrapper.rowView.Row.Table.Columns["surname2"].ColumnName         = "Seg Apellido";
                    wrapper.rowView.Row.Table.Columns["idnumber"].ColumnName         = "Identificación";
                    wrapper.rowView.Row.Table.Columns["Country"].ColumnName          = "País";
                    wrapper.rowView.Row.Table.Columns["name"].ColumnName             = "Registrante";
                    wrapper.rowView.Row.Table.Columns["registrationdate"].ColumnName = "Matrícula";
                    wrapper.rowView.Row.Table.Columns["State"].ColumnName            = "Estado";
                    wrapper.rowView.Row.Table.Columns["profilename"].ColumnName      = "Perfil";
                    wrapper.rowView.Row.Table.Columns["language"].ColumnName         = "Idioma";

                    ClientPropertyGrid.SelectedObject = wrapper;
                }
            }
            catch (Exception x)
            {
                x.Message.Trim();
            }
        }
Exemplo n.º 2
0
    static void Main()
    {
        DataTable table = new DataTable();

        table.Columns.Add("ID", typeof(int));
        table.Columns.Add("Foo", typeof(int));
        table.Columns.Add("Bar", typeof(string));
        table.Columns.Add("Audit", typeof(DateTime));

        table.Rows.Add(1, 14, "abc", DateTime.MinValue);
        DataRow row = table.Rows.Add(2, 13, "def", DateTime.MinValue);

        table.Rows.Add(3, 24, "ghi", DateTime.MinValue);

        RowWrapper wrapper = new RowWrapper(row);

        wrapper.Exclude.Add("ID");
        wrapper.Exclude.Add("Bar");

        Application.EnableVisualStyles();
        Application.Run(new Form {
            Controls =
            {
                new PropertyGrid {
                    Dock           = DockStyle.Fill,
                    SelectedObject = wrapper
                }
            }
        });
    }
Exemplo n.º 3
0
    public void GetEntity_TypeWithoutDiscriminator ()
    {
      _readerMock
          .Expect (mock => mock.GetValue (1))
          .Return ("Peter");
      _readerMock
          .Expect (mock => mock.GetValue (2))
          .Return (21);
      _reverseMappingResolverMock
          .Expect (mock => mock.GetMetaDataMembers (typeof (PersonTestClass)))
          .Return (_metaModel.GetTable (typeof (PersonTestClass)).RowType.DataMembers.Where (dataMember => !dataMember.IsAssociation).ToArray());

      var columnIDs = new[]
                      {
                          new ColumnID ("FirstName", 1),
                          new ColumnID ("Age", 2)
                      };

      var rowWrapper = new RowWrapper (_readerMock, _reverseMappingResolverMock);

      var instance = rowWrapper.GetEntity<PersonTestClass> (columnIDs);


      _readerMock.VerifyAllExpectations();
      Assert.That (new PersonTestClass ("Peter", 21), Is.EqualTo (instance));
    }
Exemplo n.º 4
0
        public void GetEntity_TypeWithoutDiscriminator()
        {
            _readerMock
            .Expect(mock => mock.GetValue(1))
            .Return("Peter");
            _readerMock
            .Expect(mock => mock.GetValue(2))
            .Return(21);
            _reverseMappingResolverMock
            .Expect(mock => mock.GetMetaDataMembers(typeof(PersonTestClass)))
            .Return(_metaModel.GetTable(typeof(PersonTestClass)).RowType.DataMembers.Where(dataMember => !dataMember.IsAssociation).ToArray());

            var columnIDs = new[]
            {
                new ColumnID("FirstName", 1),
                new ColumnID("Age", 2)
            };

            var rowWrapper = new RowWrapper(_readerMock, _reverseMappingResolverMock);

            var instance = rowWrapper.GetEntity <PersonTestClass> (columnIDs);


            _readerMock.VerifyAllExpectations();
            Assert.That(new PersonTestClass("Peter", 21), Is.EqualTo(instance));
        }
Exemplo n.º 5
0
        public void GetEntity_CreatesInstanceAccordingToDiscriminatorColumn()
        {
            _readerMock
            .Expect(mock => mock.GetValue(2))
            .Return("Customer"); //return value of discriminator column
            _reverseMappingResolverMock
            .Expect(mock => mock.GetMetaDataMembers(typeof(ContactWithInheritanceHierarchy)))
            .Return(
                _metaModel.GetTable(typeof(ContactWithInheritanceHierarchy)).RowType.DataMembers.Where(dataMember => !dataMember.IsAssociation).
                ToArray(

                    ));

            var rowWrapper = new RowWrapper(_readerMock, _reverseMappingResolverMock);

            var columnIDs = new[]
            {
                new ColumnID("ContactID", 1),
                new ColumnID("ContactType", 2)
            };

            var customer = rowWrapper.GetEntity <ContactWithInheritanceHierarchy> (columnIDs);

            _readerMock.VerifyAllExpectations();
            _reverseMappingResolverMock.VerifyAllExpectations();
            Assert.IsInstanceOf(typeof(ContactWithInheritanceHierarchy.CustomerContact), customer);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates the child element.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="parentElement">The parent element.</param>
        /// <param name="element">The element.</param>
        /// <returns>The created child element.</returns>
        protected override RowWrapper CreateChildElement(IBrowser browser, IWebElement parentElement, IWebElement element)
        {
            var rowWrapper = new RowWrapper(parentElement, this.cellLookup);

            rowWrapper.CloneNativeElement(element);

            return(rowWrapper);
        }
Exemplo n.º 7
0
    public void SimpleGetValue_ShouldReturnValue ()
    {
      var columnID = new ColumnID ("Name", 1);
      var rowWrapper = new RowWrapper (_readerMock, _reverseMappingResolverMock);
      _readerMock
          .Expect (mock => mock.GetValue (columnID.Position))
          .Return ("Peter");

      var value = rowWrapper.GetValue<string> (columnID);

      _readerMock.VerifyAllExpectations();
      Assert.That ("Peter", Is.EqualTo (value));
    }
Exemplo n.º 8
0
        public virtual void TestMoveRow()
        {
            server.setResponseBody("../../../TestSDK/resources/moveRow.json");

            RowWrapper rowWrapper = new RowWrapper();

            rowWrapper.ToTop     = true;
            rowWrapper.ParentId  = 1234L;
            rowWrapper.SiblingId = 1234L;
            IList <Row> rows = rowResourcesImpl.MoveRow(1234L, rowWrapper);

            Assert.True(rows.Count == 1);
            Assert.True(rows[0].Cells.Count == 1);
        }
Exemplo n.º 9
0
 void InitGrid()
 {
     m_grid = new List <RowWrapper> ();
     for (int j = 0; j < m_gridHeight; j++)
     {
         RowWrapper row = new RowWrapper();
         row.Index = j;
         for (int i = 0; i < m_gridWidth; i++)
         {
             row.Add(null);
         }
         m_grid.Add(row);
     }
 }
Exemplo n.º 10
0
 public void CopyTiles(RowWrapper _rowWrapperSource)
 {
     for (int i = 0; i < _rowWrapperSource.Count; i++)
     {
         if (i < list.Count)
         {
             list[i] = _rowWrapperSource [i];
         }
         else
         {
             list.Add(_rowWrapperSource[i]);
         }
     }
 }
Exemplo n.º 11
0
        public void SimpleGetValue_ShouldReturnValue()
        {
            var columnID   = new ColumnID("Name", 1);
            var rowWrapper = new RowWrapper(_readerMock, _reverseMappingResolverMock);

            _readerMock
            .Expect(mock => mock.GetValue(columnID.Position))
            .Return("Peter");

            var value = rowWrapper.GetValue <string> (columnID);

            _readerMock.VerifyAllExpectations();
            Assert.That("Peter", Is.EqualTo(value));
        }
Exemplo n.º 12
0
        public void GetEntity_ByteArraysCanBeUsed()
        {
            var encoding = new System.Text.UTF8Encoding();
            var pw       = encoding.GetBytes("passwordtext");

            var photo = encoding.GetBytes("myPhoto");

            _readerMock
            .Expect(mock => mock.GetValue(1))
            .Return(pw);
            _readerMock
            .Expect(mock => mock.GetValue(2))
            .Return(photo);
            _readerMock
            .Expect(mock => mock.GetValue(3))
            .Return(1); //return value of discriminator column
            _readerMock
            .Expect(mock => mock.GetValue(4))
            .Return("Employee");

            _reverseMappingResolverMock
            .Expect(mock => mock.GetMetaDataMembers(typeof(ContactWithInheritanceHierarchy)))
            .Return(
                _metaModel.GetMetaType(typeof(ContactWithInheritanceHierarchy.EmployeeContact)).DataMembers.ToArray()
                );

            var rowWrapper = new RowWrapper(_readerMock, _reverseMappingResolverMock);

            var columnIDs = new[]
            {
                new ColumnID("Password", 1),
                new ColumnID("Photo", 2),
                new ColumnID("ContactID", 3),
                new ColumnID("ContactType", 4)
            };

            var contact = rowWrapper.GetEntity <ContactWithInheritanceHierarchy> (columnIDs);

            var expectedContact = new ContactWithInheritanceHierarchy.EmployeeContact();

            expectedContact.ContactID   = 1;
            expectedContact.ContactType = "Employee";
            expectedContact.Password    = pw;
            expectedContact.Photo       = new Binary(photo);

            _readerMock.VerifyAllExpectations();
            _reverseMappingResolverMock.VerifyAllExpectations();

            Assert.That(contact.Equals(expectedContact), Is.True);
        }
Exemplo n.º 13
0
        public override PropertyDescriptorCollection GetProperties(
            ITypeDescriptorContext context, object value, Attribute[] attributes)
        {
            RowWrapper rw = (RowWrapper)value;
            PropertyDescriptorCollection props = TypeDescriptor.GetProperties(
                GetRowView(value), attributes);
            List <PropertyDescriptor> result = new List <PropertyDescriptor>(props.Count);

            foreach (PropertyDescriptor prop in props)
            {
                if (rw.Exclude.Contains(prop.Name))
                {
                    continue;
                }
                result.Add(new RowWrapperDescriptor(prop));
            }
            return(new PropertyDescriptorCollection(result.ToArray()));
        }
Exemplo n.º 14
0
        public virtual void TestInsertRows()
        {
            server.setResponseBody("../../../TestSDK/resources/insertRows.json");

            // Create a set of cells
            IList <Cell> cells = new List <Cell>();
            Cell         cell  = new Cell();

            cell.DisplayValue = "Testing";
            cell.ColumnId     = 8764071660021636L;
            cell.RowId        = 1234L;
            Link link = new Link();

            link.Url      = "http://google.com";
            link.Type     = LinkType.URL;
            link.SheetId  = 1234L;
            link.ColumnId = 1234L;
            link.RowId    = 1234L;
            cell.Link     = link;
            cell.Formula  = "=1+1";

            // Create a row and add the cells to it.
            IList <Row> rows = new List <Row>();
            Row         row  = new Row();

            row.Cells = cells;
            rows.Add(row);

            // Create a rowWrapper to hold the rows for inserting.
            RowWrapper rowWrapper = new RowWrapper();

            rowWrapper.ToBottom = true;
            rowWrapper.Rows     = rows;

            IList <Row> newRows = sheetRowResource.InsertRows(1234L, rowWrapper);

            Assert.NotNull(newRows);
            Assert.AreEqual(rows.Count, newRows.Count, "The number of rows created & inserted is not correct.");
            Column col = new Column();

            col.ID = 8764071660021636L;
            Assert.Null(rows[0].GetColumnByIndex(0));
            Assert.Null(rows[0].GetColumnById(8764071660021636L));
        }
Exemplo n.º 15
0
        /// <summary>
        /// <para>执行SQL,返回结果集,使用RowWrapper对每一行进行包装</para>
        /// <para>如果结果集为空,那么返回空List (List.Count=0)</para>
        /// <para>rowWrapper = null时,使用WrapRowToDictionary</para>
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="paramArr"></param>
        /// <param name="rowWrapper"></param>
        /// <returns></returns>
        public List <object> ExecuteRow(string sql, SQLiteParameter[] paramArr, RowWrapper rowWrapper)
        {
            if (sql == null)
            {
                throw new ArgumentNullException("sql=null");
            }
            this.EnsureConnection();

            SQLiteCommand cmd = new SQLiteCommand(sql, this.Connection);

            if (paramArr != null)
            {
                foreach (SQLiteParameter p in paramArr)
                {
                    cmd.Parameters.Add(p);
                }
            }

            if (rowWrapper == null)
            {
                rowWrapper = new RowWrapper(SQLLiteHepler.WrapRowToDictionary);
            }

            SQLiteDataReader reader = cmd.ExecuteReader();
            List <object>    result = new List <object>();

            if (reader.HasRows)
            {
                int rowNum = 0;
                while (reader.Read())
                {
                    object row = rowWrapper(rowNum, reader);
                    result.Add(row);
                    rowNum++;
                }
            }
            reader.Close();
            reader.Dispose();
            cmd.Dispose();
            return(result);
        }
Exemplo n.º 16
0
    void StoreTileObject(GameObject _tile, int _i, int _j, RowWrapper _rowWrapper)
    {
        GameObject rowObject = null;

        for (int i = 0; i < transform.childCount; i++)
        {
            if (transform.GetChild(i).gameObject.name == "Row" + _j.ToString("000"))
            {
                rowObject = transform.GetChild(i).gameObject;
                break;
            }
        }
        if (rowObject == null)
        {
            rowObject = new GameObject("Row" + _j.ToString("000"));
            rowObject.transform.parent = transform;
            _rowWrapper.RowObject      = rowObject;
        }
        _tile.gameObject.name  = "Tile_" + _i.ToString("000") + "_" + _j.ToString("000");
        _tile.transform.parent = rowObject.transform;
    }
Exemplo n.º 17
0
        /// <summary>
        /// Fetches the element list.
        /// </summary>
        /// <param name="parentElement">The parent element.</param>
        /// <param name="browser">The browser.</param>
        /// <returns>The created list of items.</returns>
        protected override List <RowWrapper> FetchElementList(HtmlTable parentElement, IBrowser browser)
        {
            var rows = parentElement.Rows;

            if (rows != null && rows.Count > 0)
            {
                return(rows.Cast <HtmlRow>()
                       .Where(c => c.ControlType != ControlType.RowHeader &&
                              (c.Cells != null && !c.Cells.Any(f => f is HtmlHeaderCell)))
                       .Select(r =>
                {
                    var control = new RowWrapper(parentElement);
                    control.CopyFrom(r);
                    return control;
                })
                       .OrderBy(r => r.RowIndex)
                       .ToList());
            }

            return(new List <RowWrapper>(0));
        }
Exemplo n.º 18
0
        public void GetEntity_AdditionalMappedMembersInSubTypesDontCauseException()
        {
            _readerMock
            .Expect(mock => mock.GetValue(2))
            .Return(1);
            _readerMock
            .Expect(mock => mock.GetValue(3))
            .Return("Supplier"); //return value of discriminator column
            _readerMock
            .Expect(mock => mock.GetValue(1))
            .Return("www.homepage.com");

            _reverseMappingResolverMock
            .Expect(mock => mock.GetMetaDataMembers(typeof(ContactWithInheritanceHierarchy)))
            .Return(
                _metaModel.GetMetaType(typeof(ContactWithInheritanceHierarchy.SupplierContact)).DataMembers.ToArray()
                );

            var rowWrapper = new RowWrapper(_readerMock, _reverseMappingResolverMock);

            var columnIDs = new[]
            {
                new ColumnID("HomePage", 1),
                new ColumnID("ContactID", 2),
                new ColumnID("ContactType", 3)
            };

            var contact = rowWrapper.GetEntity <ContactWithInheritanceHierarchy> (columnIDs);

            var expectedContact = new ContactWithInheritanceHierarchy.SupplierContact();

            expectedContact.ContactID   = 1;
            expectedContact.ContactType = "Supplier";
            expectedContact.HomePage    = "www.homepage.com";

            _readerMock.VerifyAllExpectations();
            _reverseMappingResolverMock.VerifyAllExpectations();

            Assert.That(contact.Equals(expectedContact), Is.True);
        }
Exemplo n.º 19
0
    /// <summary>
    /// Gets the tile.
    /// </summary>
    /// <returns>The tile.</returns>
    /// <param name="i">The index.</param>
    /// <param name="j">J.</param>
    public Tile GetTile(int i, int j)
    {
        RowWrapper row = null;

        try{
            row = m_grid [j];
        }catch (System.Exception e) {
            e.ToString();             //Avoid Warning in Console
            return(null);
        }

        Tile tileScript;

        try{
            tileScript = row[i];
        }catch (System.Exception e) {
            //Debug.LogError("No Column "+i);
            e.ToString();             //Avoid Warning in Console
            return(null);
        }

        return(tileScript);
    }
Exemplo n.º 20
0
    //called to resort the grid when its height has changed
    void ResortGridHeight(int _formerHeight)
    {
        int diff = m_gridHeight - _formerHeight;

        if (diff == 0)
        {
            return;
        }
        //keep rows in buffer
        List <GameObject> tmpRows = new List <GameObject> (m_gridHeight);

        for (int i = 0; i < m_gridHeight; i++)
        {
            //take in account the new grid height
            int newIndex = i - diff / 2;
            //Debug.Log( i + " " + newIndex );
            if (newIndex >= 0 && newIndex < m_grid.Count)
            {
                tmpRows.Add(m_grid[newIndex].RowObject);
            }
            else
            {
                tmpRows.Add(null);
            }
        }

        //the grid is shrunk
        if (diff < 0)
        {
            diff = Mathf.Abs(diff) / 2;
            //go through all rows and shift them
            for (int i = 0; i < m_grid.Count; i++)
            {
                RowWrapper row = m_grid[i];
                //whether the current row is still in the grid after the height change
                bool inGrid = (row.Index >= diff && row.Index < _formerHeight - diff);
                if (!inGrid)
                {
                    //check if a Row GameObject is instantiated in the scene
                    if (row.RowObject != null)
                    {
                        Object.DestroyImmediate(row.RowObject);
                    }
                }
                //shift index
                if (i < tmpRows.Count)
                {
                    row.RowObject = tmpRows[i];
                }
                else
                {
                    row.RowObject = null;
                }
                row.Index = i;
            }
        }
        else          //the grid is expanded
        {
            diff = diff / 2;
            //Add new rows in grid if necessary
            for (int i = m_grid.Count; i < m_gridHeight; i++)
            {
                RowWrapper row = new RowWrapper();
                row.Index = i;
                row.Add(m_gridWidth);
                m_grid.Add(row);
            }
            //shift all rows
            for (int i = 0; i < m_grid.Count; i++)
            {
                RowWrapper row = m_grid[i];
                row.RowObject = tmpRows[row.Index];
                row.Index     = i;
            }
        }
    }
Exemplo n.º 21
0
    public void GetEntity_ByteArraysCanBeUsed ()
    {
      var encoding = new System.Text.UTF8Encoding();
      var pw = encoding.GetBytes ("passwordtext");

      var photo = encoding.GetBytes ("myPhoto");

      _readerMock
          .Expect (mock => mock.GetValue (1))
          .Return (pw);
      _readerMock
          .Expect (mock => mock.GetValue (2))
          .Return (photo);
      _readerMock
          .Expect (mock => mock.GetValue (3))
          .Return (1); //return value of discriminator column
      _readerMock
          .Expect (mock => mock.GetValue (4))
          .Return ("Employee");

      _reverseMappingResolverMock
          .Expect (mock => mock.GetMetaDataMembers (typeof (ContactWithInheritanceHierarchy)))
          .Return (
              _metaModel.GetMetaType (typeof (ContactWithInheritanceHierarchy.EmployeeContact)).DataMembers.ToArray()
          );

      var rowWrapper = new RowWrapper (_readerMock, _reverseMappingResolverMock);

      var columnIDs = new[]
                      {
                          new ColumnID ("Password", 1),
                          new ColumnID ("Photo", 2),
                          new ColumnID ("ContactID", 3),
                          new ColumnID ("ContactType", 4)
                      };

      var contact = rowWrapper.GetEntity<ContactWithInheritanceHierarchy> (columnIDs);

      var expectedContact = new ContactWithInheritanceHierarchy.EmployeeContact();
      expectedContact.ContactID = 1;
      expectedContact.ContactType = "Employee";
      expectedContact.Password = pw;
      expectedContact.Photo = new Binary (photo);

      _readerMock.VerifyAllExpectations();
      _reverseMappingResolverMock.VerifyAllExpectations();

      Assert.That (contact.Equals (expectedContact), Is.True);
    }
Exemplo n.º 22
0
 /// <summary>
 /// Move a row.
 ///
 /// It mirrors To the following Smartsheet REST API method: PUT /row/{Id}
 ///
 /// Exceptions:
 ///   IllegalArgumentException : if any argument is null
 ///   InvalidRequestException : if there is any problem with the REST API request
 ///   AuthorizationException : if there is any problem with the REST API authorization(access token)
 ///   ResourceNotFoundException : if the resource can not be found
 ///   ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
 ///   SmartsheetRestException : if there is any other REST API related error occurred during the operation
 ///   SmartsheetException : if there is any other error occurred during the operation
 /// </summary>
 /// <param name="id"> the Id </param>
 /// <param name="rowWrapper"> the the RowWrapper with one of the following attributes:
 ///   - ToTop : Moves the row (and children Rows, if any) To the top of the sheet.
 ///   - ToBottom : Moves the row To the bottom of the sheet
 ///   - ParentId : Moves the row as the first child row of the parent.
 ///   - ToBottom=true can also be set To add the row as the last child of the parent.
 ///   - SiblingId : Moves the row as the next sibling of the row ID provided.
 /// </param>
 /// <returns> the Rows that have been moved by the operation </returns>
 /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
 public virtual IList <Row> MoveRow(long id, RowWrapper rowWrapper)
 {
     return(this.PutAndReceiveList <RowWrapper, Row>("row/" + id, rowWrapper, typeof(Row)));
 }
Exemplo n.º 23
0
 /// <summary>
 /// Elements the exists.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="expectedIndex">The expected index.</param>
 /// <returns><c>true</c> if the element exists.</returns>
 protected override bool ElementExists(RowWrapper element, int expectedIndex)
 {
     return(!this.ValidateElementExists || element.Exists);
 }
Exemplo n.º 24
0
    public void GetEntity_CreatesInstanceAccordingToDiscriminatorColumn ()
    {
      _readerMock
          .Expect (mock => mock.GetValue (2))
          .Return ("Customer"); //return value of discriminator column
      _reverseMappingResolverMock
          .Expect (mock => mock.GetMetaDataMembers (typeof (ContactWithInheritanceHierarchy)))
          .Return (
              _metaModel.GetTable (typeof (ContactWithInheritanceHierarchy)).RowType.DataMembers.Where (dataMember => !dataMember.IsAssociation).
                  ToArray(
                      
                  ));

      var rowWrapper = new RowWrapper (_readerMock, _reverseMappingResolverMock);

      var columnIDs = new[]
                      {
                          new ColumnID ("ContactID", 1),
                          new ColumnID ("ContactType", 2)
                      };

      var customer = rowWrapper.GetEntity<ContactWithInheritanceHierarchy> (columnIDs);

      _readerMock.VerifyAllExpectations();
      _reverseMappingResolverMock.VerifyAllExpectations();
      Assert.IsInstanceOf (typeof (ContactWithInheritanceHierarchy.CustomerContact), customer);
    }
Exemplo n.º 25
0
        /*
谢老师,下午与庄老师和张老师确定了这样一个实现方案:
         * LC类号和DDC类号都是全号精确匹配获得CLC,结果取两者对应LCC类号内容相同,并且权值和最大的项。
         * 如果权值和最大的有多项,则取LC(以后也有可能是DDC)权值最大的,如果这还有多项,则任选一项。
         * 降级取号的事情稍后再做。
         * * */
        // 自动选择事项
        // TODO: 可以只管选择 row 而不管当前的 RelationControl,等全部选择完成后,再统一刷新一次每个 Control 的 TargetText
        // parameters:
        //      strStyle shangtu
        // return:
        //      被选中的事项个数
        public int AutoSelect(string strStyle)
        {
            _disableSelectionChanged++; // 防止 control 的 TargetText 被清掉
            try
            {
                if (StringUtil.IsInList("shangtu", strStyle) == true)
                {
                    List<RowWrapper> result_rows = new List<RowWrapper>();
                    // *** 第一步,将每个列表中级次最高的加入待处理列表
                    foreach (RelationControl control in this.flowLayoutPanel_relationList.Controls)
                    {
                        ControlInfo info = (ControlInfo)control.Tag;
                        Debug.Assert(info != null, "");

                        int nFirstItemLevel = -1;
                        foreach (DpRow row in info.Rows)
                        {
                            int nCurrentLevel = Int32.Parse(row[COLUMN_LEVEL].Text);
                            if (nFirstItemLevel == -1)
                                nFirstItemLevel = nCurrentLevel;
                            else
                            {
                                // 小于最大级次的事项被舍弃
                                if (nCurrentLevel < nFirstItemLevel)
                                    break;
                            }

                            row.Selected = false;   // 先清除全部已有的选择
                            RowWrapper wrapper = new RowWrapper();
                            wrapper.Control = control;
                            wrapper.Row = row;
                            result_rows.Add(wrapper);
                        }
                    }

                    // *** 第二步,合并一些 rel 相同的事项,但要保留原始 row 便于细节分析
                    // 可能需要另一种 Item Class 来描述合并后的对象

                    // 按照 rel 列排序
                    result_rows.Sort((x, y) =>
                    {
                        return string.Compare(x.Row[COLUMN_REL].Text, y.Row[COLUMN_REL].Text);
                    });

                    // 按照 rel 列合并
                    List<Merged> merged_list = new List<Merged>();
                    Merged current = null;
                    foreach (RowWrapper wrapper in result_rows)
                    {
                        if (current != null
                            && wrapper.Row[COLUMN_REL].Text == current.Rel)
                        {
                        }
                        else
                        {
                            current = new Merged();
                            current.Rel = wrapper.Row[COLUMN_REL].Text;
                            merged_list.Add(current);
                        }

                        current.Weight += Int32.Parse(wrapper.Row[COLUMN_WEIGHT].Text);
                        current.Wrappers.Add(wrapper);

                        ControlInfo info = (ControlInfo)wrapper.Control.Tag;
                        string strType = GetSourceClassType(info.Relation.DbName);
                        if (current.SourceClassTypes.IndexOf(strType) == -1)
                            current.SourceClassTypes.Add(strType);
                    }

#if DEBUG
                    foreach(Merged item in merged_list)
                    {
                        Debug.Assert(item != null, "");
                    }
#endif
                    SetClusterWeight(merged_list);

                    // merged_list 按照 weight 排序。大在前
                    merged_list.Sort((x, y) =>
                    {
                        int nRet = x.Weight - y.Weight;
                        if (nRet != 0)
                            return -1*nRet; // 大在前
                        // 来源于 LCC 的靠前
                        bool bRet1 = x.SourceClassTypes.IndexOf("LCC") != -1;
                        bool bRet2 = y.SourceClassTypes.IndexOf("LCC") != -1;
                        if (bRet1 == true && bRet2 == false)
                            return -1;
                        if (bRet2 == true && bRet1 == false)
                            return 1;
                        Debug.Assert(bRet1 == bRet2, "");
                        double ret = x.ClusterWeight - y.ClusterWeight;
                        return -1*((int)ret);
                    });

                    // 选定第一个
                    if (merged_list.Count > 0)
                        merged_list[0].Wrappers[0].Row.Selected = true;
                }
            }
            finally
            {
                _disableSelectionChanged--;
            }

            RefreshAllTargetText();
            return 0;
        }
 public virtual IList <Row> MoveRow(long id, RowWrapper rowWrapper)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 27
0
    public void GetEntity_AdditionalMappedMembersInSubTypesDontCauseException ()
    {
      _readerMock
          .Expect (mock => mock.GetValue (2))
          .Return (1);
      _readerMock
          .Expect (mock => mock.GetValue (3))
          .Return ("Supplier"); //return value of discriminator column
      _readerMock
          .Expect (mock => mock.GetValue (1))
          .Return ("www.homepage.com");

      _reverseMappingResolverMock
          .Expect (mock => mock.GetMetaDataMembers (typeof (ContactWithInheritanceHierarchy)))
          .Return (
              _metaModel.GetMetaType (typeof (ContactWithInheritanceHierarchy.SupplierContact)).DataMembers.ToArray()
          );

      var rowWrapper = new RowWrapper (_readerMock, _reverseMappingResolverMock);

      var columnIDs = new[]
                      {
                          new ColumnID ("HomePage", 1),
                          new ColumnID ("ContactID", 2),
                          new ColumnID ("ContactType", 3)
                      };

      var contact = rowWrapper.GetEntity<ContactWithInheritanceHierarchy> (columnIDs);

      var expectedContact = new ContactWithInheritanceHierarchy.SupplierContact();
      expectedContact.ContactID = 1;
      expectedContact.ContactType = "Supplier";
      expectedContact.HomePage = "www.homepage.com";

      _readerMock.VerifyAllExpectations();
      _reverseMappingResolverMock.VerifyAllExpectations();

      Assert.That (contact.Equals (expectedContact), Is.True);
    }
Exemplo n.º 28
0
    //called to resort the grid when its height has changed
    void ResortGridWidth(int _formerWidth)
    {
        int diff = m_gridWidth - _formerWidth;

        if (diff == 0)
        {
            return;
        }

        //the grid is shrunk
        if (diff < 0)
        {
            //go through all rows and shift them
            for (int i = 0; i < m_grid.Count; i++)
            {
                RowWrapper row = m_grid[i];
                //keep tiles in buffer
                List <Tile> tmpTiles = new List <Tile> (m_gridWidth);
                for (int j = 0; j < m_gridWidth; j++)
                {
                    //take in account the new grid width
                    int newIndex = j - diff / 2;
                    //Debug.Log( j + " " + newIndex );
                    if (newIndex >= 0 && newIndex < m_grid.Count)
                    {
                        tmpTiles.Add(row[newIndex]);
                    }
                    else
                    {
                        tmpTiles.Add(null);
                    }
                }
                // destroy
                for (int j = 0; j < row.Count; j++)
                {
                    Tile t = row[j];
                    if (t != null)
                    {
                        //whether the current row is still in the grid after the height change
                        bool inGrid = (t.Column >= Mathf.Abs(diff) / 2 && t.Column < _formerWidth - Mathf.Abs(diff) / 2);
                        if (!inGrid)
                        {
                            //Debug.Log("Deleting "+ t.gameObject.name);
                            Object.DestroyImmediate(t.gameObject);
                        }
                    }
                }
                //shift all tiles
                for (int j = 0; j < row.Count; j++)
                {
                    if (j < m_gridWidth)
                    {
                        m_grid[i][j] = tmpTiles[j];
                        if (row[j] != null)
                        {
                            row[j].Column = j;      row[j].Row = i;
                            row[j].RefreshName();
                        }
                    }
                }
            }
        }
        else          //the grid is expanded
                      //Add tiles to rows and shift
        {
            for (int i = 0; i < m_grid.Count; i++)
            {
                RowWrapper row = m_grid[i];
                if (m_gridWidth > row.Count)
                {
                    row.Add(m_gridWidth);
                }
                //keep tiles in buffer
                List <Tile> tmpTiles = new List <Tile> (m_gridWidth);
                for (int j = 0; j < m_gridWidth; j++)
                {
                    //take in account the new grid width
                    int newIndex = j - diff / 2;
                    if (newIndex >= 0 && newIndex < m_grid.Count)
                    {
                        tmpTiles.Add(row[newIndex]);
                    }
                    else
                    {
                        tmpTiles.Add(null);
                    }
                }

                //shift all tiles
                for (int j = 0; j < row.Count; j++)
                {
                    if (j < m_gridWidth)
                    {
                        m_grid[i][j] = tmpTiles[j];
                        if (row[j] != null)
                        {
                            row[j].Column = j;      row[j].Row = i;
                            row[j].RefreshName();
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 29
0
    public GameObject AddTile(float x, float y)
    {
        //Debug.Log (m_currentTile);
        GameObject go = null;

        if (m_currentTile != null)
        {
            //Position in the grid
            float i = Mathf.Floor(x * m_baseUnit / m_cellSize) + Mathf.Floor(m_gridWidth * 0.5f);
            float j = Mathf.Floor(y * m_baseUnit / m_cellSize) + Mathf.Floor(m_gridHeight * 0.5f);

            //outside of grid bounds
            if (i < 0 || j < 0 || i >= m_gridWidth || j >= m_gridHeight)
            {
                return(null);
            }

            Undo.IncrementCurrentGroup();

            Tile formerTile = GetTile((int)i, (int)j);
            if (formerTile)
            {
                //if the tile we want to add is already in place
                bool sameTile = formerTile.Compare(m_currentTile.GetComponent <Tile>());
                if (sameTile)
                {
                    return(null);
                }
                Object.DestroyImmediate(formerTile.gameObject);
            }

            //Instantiate tile prefab
            go = (GameObject)PrefabUtility.InstantiatePrefab(m_currentTile.gameObject);


            //store the script in the grid
            Tile tileScript = go.GetComponent <Tile>();
            if (tileScript)
            {
                if (m_grid == null)
                {
                    InitGrid();
                }
                RowWrapper row = m_grid[(int)j];
                row[(int)i] = tileScript;
                //set variables
                tileScript.Row    = (int)j;
                tileScript.Column = (int)i;
                //Resize
                tileScript.Resize(m_cellSize);

                StoreTileObject(tileScript.gameObject, (int)i, (int)j, row);
            }


            float cellSize = m_cellSize / m_baseUnit;
            //position in the world
            float newX = -m_xRange * 0.5f + i * cellSize + cellSize * 0.5f;
            float newY = -m_yRange * 0.5f + j * cellSize + cellSize * 0.5f;

            Vector3 newPos = new Vector3(newX, newY, 0.0f);
            go.transform.position = newPos;

            Undo.RegisterCreatedObjectUndo(go, "Create" + go.name);
        }
        return(go);
    }
Exemplo n.º 30
0
 /// <summary>
 /// Insert Rows To a sheet.
 ///
 /// It mirrors To the following Smartsheet REST API method: POST /sheet/{Id}/Rows
 ///
 /// Exceptions:
 ///   - IllegalArgumentException : if any argument is null
 ///   - InvalidRequestException : if there is any problem with the REST API request
 ///   - AuthorizationException : if there is any problem with the REST API authorization(access token)
 ///   - ResourceNotFoundException : if the resource can not be found
 ///   - ServiceUnavailableException : if the REST API service is not available (possibly due To rate limiting)
 ///   - SmartsheetRestException : if there is any other REST API related error occurred during the operation
 ///   - SmartsheetException : if there is any other error occurred during the operation
 /// </summary>
 /// <param name="sheetId"> the sheet Id </param>
 /// <param name="rowWrapper"> he RowWrapper object, one of the following attributes should be specified:
 /// * ToTop : Inserts the Rows at the top of the sheet. * ToBottom : Inserts the Rows at the
 /// bottom of the sheet * ParentId : Inserts the Rows as the first child row of the parent. ToBottom=true can also be
 /// set To add the row as the last child of the parent. * SiblingId : Inserts the row as the next sibling of the row
 /// ID provided. </param>
 /// <returns> the created Rows </returns>
 /// <exception cref="SmartsheetException"> the Smartsheet exception </exception>
 public virtual IList <Row> InsertRows(long sheetId, RowWrapper rowWrapper)
 {
     return(this.PostAndReceiveList <RowWrapper, Row>("sheet/" + sheetId + "/rows", rowWrapper, typeof(Row)));
 }