예제 #1
0
        public async Task SetProperty(string name, Car car, string value)
        {
            var key = PropertyKey(name, car);
            var rec = await GetPropertyRecord(key);

            try {
                if (rec != null)
                {
                    rec.Value = value;
                    await PropertiesTable.UpdateRecord(rec, PropertyRecord.VALUE);
                }
                else
                {
                    rec = new PropertyRecord {
                        Name  = key,
                        Value = value
                    };
                    rec = await PropertiesTable.CreateRecord(rec);

                    Properties[name] = rec;
                }
            } catch (Exception exc) {
                Debug.ExceptionCaught(exc);
            }
        }
예제 #2
0
        //static ClassRef @class = new ClassRef(typeof(MainBase));

        public MainBase(string apiKey, string baseId) :
            base(apiKey, baseId)
        {
            //Debug.EnableTracing(@class);

            BasesTable      = new BasesTable(this);
            ProduceTable    = new ProduceTable(this);
            ContactsTable   = new ContactsTable(this);
            CustomersTable  = new CustomersTable(this);
            PlacesTable     = new PlacesTable(this);
            InvoicesTable   = new InvoicesTable(this);
            ArticlesTable   = new ArticlesTable(this);
            RouteTable      = new RouteTable(this);
            PropertiesTable = new PropertiesTable(this);
        }
예제 #3
0
        async Task <PropertyRecord> GetPropertyRecord(string key)
        {
            PropertyRecord rec = null;

            if (Properties.ContainsKey(key))
            {
                rec = Properties[key];
                try {
                    rec = await PropertiesTable.GetRecord(rec.Id);
                }
                catch (Exception exc) {
                    Debug.ExceptionCaught(exc);
                    rec = null;
                }
                if (rec == null)
                {
                    Properties.Remove(key);
                }
            }
            else
            {
                try {
                    var result = await PropertiesTable.FilterRecords($"Name = \"{key}\"");

                    if (result?.Records != null && result.Records.Length > 0)
                    {
                        rec = result.Records[0];

                        if (rec != null)
                        {
                            Properties[key] = rec;
                        }
                    }
                }
                catch (Exception exc) {
                    Debug.ExceptionCaught(exc);
                    rec = null;
                }
            }

            return(rec);
        }