コード例 #1
0
        public void AddItem <T>(T item)
        {
            Type         requestType = typeof(T);
            MobileEntity mobEntity   = null;

            try
            {
                if (requestType == typeof(SettingsContainer))
                {
                    //Todo use AutoMapper
                    SettingsContainer settingContainer = item as SettingsContainer;
                    if (settingContainer != null)
                    {
                        lock (settingContainer)
                        {
                            MobileUser             mobUser     = new MobileUser();
                            Tuple <double, double> geolocation = settingContainer.GetGeolocation();
                            mobUser.Latitude       = geolocation.Item1;
                            mobUser.Longitude      = geolocation.Item2;
                            mobUser.EventDateRange = settingContainer.GetEventDateRange();
                            mobUser.Guid           = settingContainer.GetGuid().ToString();
                            mobUser.MaxDistance    = settingContainer.GetMaxDistance();

                            mobEntity = mobUser;
                        }
                    }
                    else
                    {
                        mobEntity = null;
                    }
                }
                else
                {
                    mobEntity = converterService.Convert((item as Entity));
                }

                if (mobEntity != null)
                {
                    this.sqliteConnection.RunInTransaction(() =>
                    {
                        this.sqliteConnection.InsertOrReplaceWithChildren(mobEntity, true);
                    });
                }
            }
            catch (Exception e)
            {
                return;
            }
        }