コード例 #1
0
        public static async Task Read(ListsActivity thisActivity)
        {
            ReadWrite.ReadUser();

            //for offline user
            if (AppData.currentUser == null)
            {
                AppData.currentUser = new UserClass()
                {
                    Name  = "Me",
                    Email = "defEmail",
                    Uid   = "defUid"
                };

                PrepareFirstList.Prepare();

                ReadWrite.WriteData();
                ReadWrite.WriteUser();
            }
            else
            {
                ReadWrite.ReadData();
                AppData.currentLists = AppData.offlineLists;
            }

            thisActivity.SetProfileButton("Login!", Color.Orange);



            //for online user
            if (AppData.auth.CurrentUser != null)
            {
                thisActivity.SetProfileButton("Online!", Color.Green);

                await ReadDataFromCloud.Read();

                AppData.currentLists = CompareLists.Compare(AppData.onlineLists, AppData.offlineLists);

                ReadWrite.WriteData();
                foreach (GroceryListClass any in AppData.currentLists)
                {
                    SaveListOnCloud.Save(any);
                }

                await ReadInvitations.Read();

                await FetchInvitations.Fetch();

                foreach (GroceryListClass any in AppData.invitationLists)
                {
                    AppData.currentLists.Add(any);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates the schema table.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="tableName">Table name for the schema to be created.</param>
        /// <returns></returns>
        public static Schema <T> CreateTable <T>(string tableName) where T : TfEntity, new()
        {
            if (TfSettings.Database.Migrate == false)
            {
                return(new Schema <T>(tableName));
            }

            CreateDB();

            var table = InformationSchemaTables;

            table.Case.Where(table.Column(x => x.table_name), Is.EqualTo, tableName);
            table.Case.AddColumns(table.Column(x => x.table_name));

            var newSchema = new Schema <T>(tableName);

            if (table.Count == 0)
            {
                newSchema.CreateTable();
            }
            else
            {
                var columns = InformationSchemaColumns;

                columns.Case.Where(columns.Column(x => x.table_name), Is.EqualTo, tableName);
                columns.Case.AddColumns(columns.Column(x => x.column_name));

                var currentColumns = columns.Select.Entities?.Select(x => x.column_name)?.ToList();
                var entityColumns  = newSchema.Entity.GetColumns()?.ToList();

                if (CompareLists.UnorderedEqual(entityColumns, currentColumns))
                {
                    return(newSchema);
                }

                newSchema.AddTableColumns(entityColumns.MissingItems(currentColumns));

                Thread.Sleep(1000);

                currentColumns = columns.Select.Entities?.Select(x => x.column_name)?.ToList();

                newSchema.DropTableColumns(currentColumns.MissingItems(entityColumns));
            }

            return(newSchema);
        }