Пример #1
0
        public ExStoreRtnCodes ReadCellData(ref ExStoreCell xCell)
        {
            OpDescription = "Read Cells SubSchema";
            Entity          eApp;
            Schema          sApp;
            ExStoreRtnCodes result;

            List <Entity> subEntities;

            result = getAppSchemaAndEntity(out eApp, out sApp);

            if (result != ExStoreRtnCodes.XRC_GOOD)
            {
                return(result);
            }

            result = getSubEntities(eApp, sApp, out subEntities);

            if (subEntities.Count > 0)
            {
                result = readCellData(ref xCell, subEntities);

                if (result != ExStoreRtnCodes.XRC_GOOD)
                {
                    return(ExStoreRtnCodes.XRC_FAIL);
                }
            }

            return(ExStoreRtnCodes.XRC_GOOD);
        }
Пример #2
0
        public ExStoreCell Clone()
        {
            ExStoreCell copy = new ExStoreCell(/*Data.Count*/);

            copy.Data          = cloneData();
            copy.IsInitialized = IsInitialized;

            return(copy);
        }
Пример #3
0
        private Schema makeSubSchema(string guid, ExStoreCell xCell)
        {
            SchemaBuilder sb = new SchemaBuilder(new Guid(guid));

            makeSchemaDef(ref sb, xCell.Name, xCell.Description);

            makeSchemaFields(ref sb, xCell.Fields);

            return(sb.Finish());
        }
Пример #4
0
        private void makeSubSchemasFields(Entity entity, Schema schema, ExStoreCell xCell)
        {
            foreach (KeyValuePair <string, string> kvp in xCell.SubSchemaFields)
            {
                Field f = schema.GetField(kvp.Key);

                Schema subSchema = makeSubSchema(kvp.Value, xCell);

                Entity subE = new Entity(subSchema);

                entity.Set(f, subE);
            }
        }
Пример #5
0
        public ExStoreRtnCodes WriteAppAndCellsData(ExStoreApp xApp, ExStoreCell xCell, DataStorage ds)
        {
            Transaction t = null;

            try
            {
                // SchemaBuilder sb = new SchemaBuilder(xApp.ExStoreGuid);
                //
                // makeSchemaDef(sb, xApp.Name, xApp.Description);
                //
                // makeSchemaFields(sb, xApp.Data);
                //
                // makeSchemaSubSchemaFields(sb, xCell);

                // Schema schema = sb.Finish();
                Schema schema =
                    MakeAppSchema(xApp, xCell);
                // GetAppSchemaCurr();

                Entity e = new Entity(schema);

                makeSubSchemasFields(e, schema, xCell);

                writeData(e, schema, xApp.Data);
                writeCellData(e, schema, xCell);

                // 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);
        }
Пример #6
0
        private void writeCellData(Entity entity, Schema schema, ExStoreCell xCell)
        {
            int j = 0;

            foreach (KeyValuePair <string, string> kvp in xCell.SubSchemaFields)
            {
                Field f = schema.GetField(kvp.Key);

                Entity subE = entity.Get <Entity>(kvp.Key);

                writeData(subE, subE.Schema, xCell.Data[j++]);

                entity.Set(f, subE);
            }
        }
Пример #7
0
        private ExStoreRtnCodes readCellData(ref ExStoreCell xCell, List <Entity> subE)
        {
            ExStoreRtnCodes result;

            xCell = ExStoreCell.Instance();

            for (var i = 0; i < subE.Count; i++)
            {
                // xCell.Data[i] = xCell.DefaultValues();
                xCell.AddDefault();

                foreach (KeyValuePair <SchemaCellKey, SchemaFieldDef <SchemaCellKey> > kvp in xCell.Fields)
                {
                    SchemaCellKey key       = kvp.Value.Key;
                    string        fieldName = kvp.Value.Name;
                    Field         f         = subE[i].Schema.GetField(fieldName);
                    if (f == null)
                    {
                        return(ExStoreRtnCodes.XRC_FAIL);
                    }

                    Type t = f.ValueType;
                    if (t == null)
                    {
                        return(ExStoreRtnCodes.XRC_FAIL);
                    }


                    if (t?.Equals(typeof(string)) ?? false)
                    {
                        xCell.Data[i][key].Value = subE[i].Get <string>(fieldName);
                    }
                    else if (t?.Equals(typeof(double)) ?? false)
                    {
                        // int i1 = subE[i].Get<int>(fieldName);
                        double d2 = subE[i].Get <double>(fieldName, DisplayUnitType.DUT_GENERAL);

                        xCell.Data[i][key].Value = subE[i].Get <double>(fieldName, DisplayUnitType.DUT_GENERAL);
                    }
                    else if (t?.Equals(typeof(bool)) ?? false)
                    {
                        xCell.Data[i][key].Value = subE[i].Get <bool>(fieldName);
                    }
                }
            }

            return(ExStoreRtnCodes.XRC_GOOD);
        }
Пример #8
0
        public bool GetAppEntity(ExStoreApp xApp, ExStoreCell xCell, out Entity e, out DataStorage ds)
        {
            ExStorageTests.location = 260;
            e  = null;
            ds = null;

            Schema schema =
                MakeAppSchema(xApp, xCell);

            if (schema == null)
            {
                return(false);
            }

            ExStorageTests.location = 265;
            return(DsMgr.GetDataStorage(schema, out e, out ds));
        }
Пример #9
0
        /*
         * update method
         * get new data
         * erase schema
         * save new data
         */

        public ExStoreRtnCodes UpdateCellData(ExStoreApp xApp, ExStoreCell xCell, DataStorage ds)
        {
            ExStoreRtnCodes result;

            result = DeleteAppSchema();

            if (result != ExStoreRtnCodes.XRC_GOOD)
            {
                return(result);
            }

            result = WriteAppAndCellsData(xApp, xCell, ds);

            if (result != ExStoreRtnCodes.XRC_GOOD)
            {
                return(result);
            }

            return(ExStoreRtnCodes.XRC_GOOD);
        }
Пример #10
0
        public Schema MakeAppSchema(ExStoreApp xApp, ExStoreCell xCell)
        {
            ExStorageTests.location = 270;
            Schema schema = null;

            try
            {
                // schema = Schema.Lookup(xApp.ExStoreGuid);
                //
                // if (schema != null) return schema;

                SchemaBuilder sb = new SchemaBuilder(xApp.ExStoreGuid);

                ExStorageTests.location = 273;
                makeSchemaDef(ref sb, xApp.Name, xApp.Description);

                ExStorageTests.location = 275;
                makeSchemaFields(ref sb, xApp.Data);

                if (xCell != null)
                {
                    ExStorageTests.location = 277;
                    makeSchemaSubSchemaFields(ref sb, xCell);
                }

                ExStorageTests.location = 278;
                schema = sb.Finish();
            }
            catch (Exception e)
            {
                string ex  = e.Message;
                string iex = e?.InnerException.Message ?? "none";

                return(null);
            }

            ExStorageTests.location = 279;
            return(schema);
        }
Пример #11
0
        private void makeSchemaSubSchemaFields(ref SchemaBuilder sb, ExStoreCell xCell)
        {
            xCell.SubSchemaFields = new Dictionary <string, string>();

            int count = xCell.Data.Count;

            count = count == 0 ? 3 : count;


            for (int i = 0; i < xCell.Data.Count; i++)
            {
                SchemaFieldDef <SchemaAppKey> subS = SchemaDefinitionApp.GetSubSchemaDef(i);

                string guid = subS.Guid;
                string name = subS.Name;

                FieldBuilder fb = sb.AddSimpleField(name, typeof(Entity));

                fb.SetDocumentation(subS.Desc);
                fb.SetSubSchemaGUID(new Guid(guid));

                xCell.SubSchemaFields.Add(name, guid);
            }
        }