Пример #1
0
        public static Task <bool> LibraryAsync()
        {
            return(Task.Run(() =>
            {
                try
                {
                    SQL_Request req = new SQL_Request().OpenConnection();

                    //request all assets
                    req.GetAssets(false);


                    //merge all assets

                    //post merged assets as new master DB
                    if (req.Tag != null)
                    {
                        var cloud = req.Tag as List <Asset>;
                        //upload assets
                        foreach (Asset a in Global.AssetCache)
                        {
                            try
                            {
                                var lookup = cloud.FindAssetByNumber(a.AssetNumber);
                                if (lookup == null)
                                {
                                    req.AddAsset(a, false);
                                }
                                else
                                if (lookup.AssetNumber == a.AssetNumber)
                                {
                                    req.UpdateAsset(a, false);
                                }
                            }
                            catch
                            { //PopNotify("Error", "Error Pushing Library To SQL");
                            }
                        }
                    }
                    req.CloseConnection();
                    return true;
                }
                catch { return false; }
            }));
        }