private IBinaryBuffer GetFileData(string file) { IBinaryBuffer bb = new BinaryBuffer(); FileStream fs = null; bool b = false; try { fs = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] buf = new byte[fs.Length]; fs.Read(buf, 0, (int)fs.Length); b = bb.FromByteArray(buf); } catch (Exception ex) { } finally { fs.Close(); } if (b) { return(bb); } else { return(null); } }
private bool CreateLCRecordOfFDS(IDataSource ds, String fdsname) { ITable table = null; IFdeCursor cursor = null; try { String lcguid = System.Guid.NewGuid().ToString(); byte[] lcbuf = CreateLogicTree("LogicTree", lcguid); if (!GetQueryResults(String.Format("groupid='{0}'", lcguid), "cm_logictree", ds)) { table = ds.OpenTable("cm_logictree"); cursor = table.Insert(); RowBufferFactory rbf = new RowBufferFactory(); IRowBuffer rb = rbf.CreateRowBuffer(table.GetFields()); rb.SetValue(1, lcguid); //groupid rb.SetValue(2, fdsname); //name rb.SetValue(3, fdsname); //founder IBinaryBuffer bb = new BinaryBuffer(); bb.FromByteArray(lcbuf); rb.SetValue(4, bb); //content cursor.InsertRow(rb); } table = ds.OpenTable("cm_group"); cursor = table.Insert(); RowBufferFactory rbf1 = new RowBufferFactory(); IRowBuffer rb1 = rbf1.CreateRowBuffer(table.GetFields()); rb1.SetValue(1, lcguid); //groupuid rb1.SetValue(2, fdsname); //DataSet cursor.InsertRow(rb1); return(true); } catch (COMException comEx) { System.Diagnostics.Trace.WriteLine(comEx.Message); return(false); } catch (System.Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); return(false); } finally { if (cursor != null) { //Marshal.ReleaseComObject(cursor); cursor = null; } if (table != null) { //Marshal.ReleaseComObject(table); table = null; } } }