public bool MakeRootAppSchema(string docKey, SchemaRootAppData raData, int QtySubSchema) { if (raData == null || docKey == null || QtySubSchema == 0) { return(false); } scList.AddNew(docKey, QtySubSchema); Schema schema = null; try { SchemaBuilder sb = new SchemaBuilder(Guid.NewGuid()); makeSchemaDef(ref sb, raData.GetValue <string>(SchemaRootAppKey.RAK_NAME), raData.GetValue <string>(SchemaRootAppKey.RAK_DESCRIPTION)); makeSchemaFields(ref sb, raData.Fields); makeSchemaSubSchemaFields(docKey, ref sb, raData); schema = sb.Finish(); } catch (Exception e) { string ex = e.Message; string iex = e?.InnerException.Message ?? "none"; } scList[docKey].Schema = schema; return(true); }
public void ShowRootAppData(SchemaRootAppFields rootFields, SchemaRootAppData rootData) { W.WriteLineAligned("this is| ", "CSToolsDelux"); W.WriteLineAligned("this is| ", $"{documentName}"); W.WriteLineAligned("Show Root-App data| ", "type 1"); W.WriteAligned("\n"); string name; string type; string value; foreach (SchemaRootAppKey key in rootFields.KeyOrder) { name = rootData[key].FieldDef.Name; value = rootData[key].ValueString; type = rootData[key].ValueType.Name; W.WriteLineAligned($"key| {key}| ", formatFieldInfo(name, type, value)); } W.WriteAligned("\n"); W.WriteLineAligned("Show Root-App data| ", "finished"); W.WriteAligned("\n"); W.ShowMsg(); }
public void Config(string docKey, DataStorage ds) { reset(); DocKey = docKey; DataStorage = ds; RootAppData = new SchemaRootAppData(); CellData = new SchemaCellData(); }
public ExStoreRtnCodes WriteRootAppData(SchemaRootAppData raData, SchemaCellData cData, DataStorage ds) { Transaction t = null; string docKey = exData.DocKey; ExStoreRtnCodes result = ExStoreRtnCodes.XRC_FAIL; raData.SetValue(SchemaRootAppKey.RAK_NAME, docKey); try { bool answer = scMgr.MakeRootAppSchema(docKey, raData, cData.DataList.Count); if (!answer) { return(ExStoreRtnCodes.XRC_FAIL); } Schema schema = scMgr.SchemaList[docKey].Schema; Entity e = new Entity(schema); scMgr.MakeSubSchemasFields(e, schema, cData); writeData(e, schema, raData.Data); writeCellData(e, schema, cData); // using (t = new Transaction(AppRibbon.Doc, "Save Cells Default Config Info")) // { // t.Start(); ds.SetEntity(e); // t.Commit(); // } } catch (InvalidOperationException ex) { if (t != null && t.HasStarted()) { t.RollBack(); t.Dispose(); } if (ex.HResult == -2146233088) { return(ExStoreRtnCodes.XRC_DUPLICATE); } return(ExStoreRtnCodes.XRC_FAIL); } return(ExStoreRtnCodes.XRC_GOOD); }
private void makeSchemaSubSchemaFields(string docKey, ref SchemaBuilder sb, SchemaRootAppData raData) { int qty = scList[docKey].QtySubSchema; for (int i = 0; i < qty; i++) { Tuple <string, Guid> subS = raData.AppFields.SubSchemaField(); FieldBuilder fb = sb.AddSimpleField(subS.Item1, typeof(Entity)); fb.SetDocumentation(raData.GetValue <string>(SchemaRootAppKey.RAK_DESCRIPTION)); fb.SetSubSchemaGUID(subS.Item2); scList[docKey].SubSchemaFields.Add(subS.Item1, subS.Item2); } }
public FieldsManager(AWindow w) { W = w; show = new ShowInfo(w); rData = new SchemaRootData(); rData.Configure(SchemaGuidManager.GetNewAppGuidString()); aData = new SchemaAppData(); aData.Configure("App Data Name", "App Data Description"); raData = new SchemaRootAppData(); raData.Configure("Root-App Data Name", "Root-App Data Description"); cData = new SchemaCellData(); cData.Configure("new name", "A1", UpdateRules.UR_AS_NEEDED, "cell Family", false, "xl file path", "worksheet name"); cData.Configure("Another new name", "B2", UpdateRules.UR_AS_NEEDED, "second cell Family", false, "second xl file path", "second worksheet name"); }
public ExStoreRtnCodes WriteRootApp(SchemaRootAppData raData, SchemaCellData cData) { Transaction T; ExStoreRtnCodes result; using (T = new Transaction(AppRibbon.Doc, "fields")) { T.Start(); result = exMgr.WriteRootAppData(raData, cData, exData.DataStorage); if (result == ExStoreRtnCodes.XRC_GOOD) { T.Commit(); } else { T.RollBack(); } } return(result); }
public FieldsManager(AWindow w, Document doc) { this.doc = doc; W = w; scMgr = SchemaManager.Instance; exMgr = new ExStoreMgr(w, doc); dsMgr = new DataStoreManager(doc); show = new ShowInfo(w); exData = ExStorData.Instance; rData = new SchemaRootData(); rData.Configure(SchemaGuidManager.GetNewAppGuidString()); aData = new SchemaAppData(); aData.Configure("App Data Name", "App Data Description"); raData = new SchemaRootAppData(); raData.Configure("Root-App Data Name", "Root-App Data Description"); cData = new SchemaCellData(); cData.Configure("new name", "A1", UpdateRules.UR_AS_NEEDED, "cell Family", false, "xl file path", "worksheet name"); }