private void Fill_ImbaseTable(long newSelectedID, DataTable dt)
        {
            using (SessionKeeper keeper = new SessionKeeper())
            {
                DataSet   ds;
                DataTable tb2;
                DataRow   row1;
                try
                {
                    ds = TableLoadHelper.GetTables(keeper.Session, newSelectedID, true);

                    tb2 = ds.Tables[Intermech.Imbase.Consts.IMS_DATA];
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Таблицы с tableID = " + newSelectedID.ToString() + " не найдено");
                    throw ex;
                }

                Dictionary <string, Guid> columnNamesAndGuids = new Dictionary <string, Guid>();

                byte          columnsCount       = Convert.ToByte(dt.Columns.Count); // количество колонок в табллице
                List <string> columnNamesinExcel = new List <string>(columnsCount);
                for (byte i = 0; i < columnsCount; i++)
                {
                    columnNamesinExcel.Add(dt.Columns[i].ColumnName);                                                                       // создали список наименований колонок в таблице
                    columnNamesAndGuids.Add(dt.Columns[i].ColumnName, MetaDataHelper.GetAttributeByTypeNameGuid(dt.Columns[i].ColumnName)); // имя аттрибута и его Guid
                }

                string tempGuid;
                string tempName;
                foreach (var item in dt.AsEnumerable()) // по всем рядкам
                {
                    row1 = tb2.NewRow();

                    for (byte i = 0; i < columnsCount; i++) // по каждой колонке
                    {
                        tempName = columnNamesinExcel[i];
                        tempGuid = "" + columnNamesAndGuids[tempName] + "";

                        row1.SetField(tempGuid, item[tempName].ToString());
                    }
                    tb2.Rows.Add(row1);
                    tb2.AcceptChanges();
                }

                TableLoadHelper.StoreData(keeper.Session, newSelectedID, ds, keeper.Session.GetCustomService(typeof(Intermech.Interfaces.Imbase.ITablesIndexer)) as Intermech.Interfaces.Imbase.ITablesIndexer);
            }
        }
 public void GetTags()
 {
     using (SessionKeeper keeper = new SessionKeeper())
     {
         long tableID = TableLoadHelper.GetTableReference(keeper.Session, newSelectedID);
         MessageBox.Show("tableID  " + tableID.ToString());
         DataTable dt       = TableLoadHelper.GetTableRefIDsByTableID(keeper.Session, tableID);
         string    columnns = "";
         foreach (var item in dt.Columns)
         {
             columnns += item.ToString() + Environment.NewLine;
         }
         foreach (var item in dt.Rows)
         {
             string values = ((DataRow)item)[0].ToString() + "  " + ((DataRow)item)[1].ToString();
             MessageBox.Show("Rows  " + values);
         }
         MessageBox.Show(columnns);
     }
 }
Пример #3
0
        //private void ReadBlob()
        //{
        //    using (SessionKeeper sk = new SessionKeeper())
        //    {
        //        IDBObject iDBObject = sk.Session.GetObject(1962223);
        //        IDBAttributable iDBAttributable = iDBObject as IDBAttributable;
        //        IDBAttribute[] iDBAttributeCollection = iDBAttributable.Attributes.GetAttributesByType(FieldTypes.ftFile);//получили аттрибут File

        //        if (iDBAttributeCollection != null)

        //            foreach (IDBAttribute fileAtr in iDBAttributeCollection)
        //            {
        //                if (fileAtr.ValuesCount < 2)
        //                {
        //                    MemoryStream m = new MemoryStream();
        //                    BlobProcReader reader = new BlobProcReader(fileAtr, (int)fileAtr.AsInteger, m, null, null);
        //                    MessageBox.Show("ElementID" + reader.ElementID.ToString() + "DataBlockSize =  " + reader.DataBlockSize.ToString() + "fileAtr.AsInteger  " + fileAtr.AsInteger.ToString() + "  fileAtr.AsDouble  " + fileAtr.AsDouble.ToString());
        //                    BlobInformation info = reader.BlobInformation;
        //                    reader.ReadData();
        //                    byte[] @byte = m.GetBuffer();
        //                    MessageBox.Show(@byte.Length.ToString());
        //                    //BlobProcReader reader = new BlobProcReader((long)info.BlobID, (int)AttributableElements.Object, fileAtr.AttributeID, 0, 0, 0);



        //                    //try
        //                    //{
        //                    //    IVaultFileReaderService serv = sk.Session.GetCustomService(typeof( IVaultFileReaderService)) as IVaultFileReaderService;
        //                    //    IVaultFileReader fileReader = serv.GetVaultFileReader(sk.Session.SessionID);
        //                    //    if (fileReader != null) MessageBox.Show("file reader exist       RealFileSize:" + info.RealFileSize.ToString() + Environment.NewLine + "PackedFileSize:" + info.PackedFileSize.ToString() + Environment.NewLine + iDBObject.ObjectID.ToString() + Environment.NewLine + fileAtr.AsInteger.ToString());

        //                    //    BlobInformation item = fileReader.OpenBlob(0, 1962223, 0, 8);
        //                    //    MessageBox.Show("Blob is open");

        //                    //    byte[] @byt = fileReader.ReadDataBlock((int)item.PackedFileSize);
        //                    //    MessageBox.Show(@byt.GetLength(@byt.Rank).ToString());
        //                    //}
        //                    //catch { MessageBox.Show("No service found"); }
        //                    //return;
        //                }
        //            }
        //    }
        //}

        public DataTable GetIMBASETable(long tableID, out DataSet ds, out Dictionary <string, string> dictionary)
        {
            using (SessionKeeper keeper = new SessionKeeper())
            {
                ds = TableLoadHelper.GetTables(keeper.Session, tableID, true);
                DataTable tb1     = ds.Tables[0];
                DataTable tb2     = ds.Tables[1];
                string    colName = "";
                dictionary = new Dictionary <string, string>();
                for (int i = 0; i < tb1.Columns.Count; i++)
                {
                    try
                    {
                        colName = MetaDataHelper.GetAttributeTypeName(new Guid(tb1.Columns[i].ToString()));
                        dictionary.Add(colName, tb1.Columns[i].ToString());
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("There is no such attribute:  " + colName.ToString() + "  " + tableID.ToString());
                    }
                }
                return(tb1);
            }
        }