예제 #1
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);
            }
        }