Ejemplo n.º 1
0
        protected void PullSQL_Click(object sender, EventArgs e)
        {
            try
            {
                SQL_Request req = new SQL_Request().OpenConnection();

                //request all assets
                req.GetAllAssets(true);
                if (req.Tag != null)
                {
                    //pull assets
                    Global.Library.Assets = req.Tag as List <Asset>;
                    //pull settings
                    //pull notifications
                    //pull calibrations
                    //pull history
                }
            }
            catch
            {
                //PopNotify("Error", "Error Pulling Library From SQL");
            }
            //PopNotify("Complete", "Library Pulled From SQL");
            UpdateAssetAdmin();
        }
        public static List <Asset> GetAllAssets()
        {
            //check internet for online offlne access

            var connected = Extensions.CheckForInternetConnection();

            if (!connected)
            {
                //load local
                var file = HttpContext.Current.Server.MapPath("/App_Data/library.xml");
                Extensions.ImportXmlLibraryFile(file);
                return(Global.Library.Assets);
            }
            SQL_Request req = new SQL_Request().OpenConnection();

            //request all assets
            req.GetAllAssets(true);
            if (req.Tag != null)
            {
                Global.Library.Assets = req.Tag as List <Asset>;
            }
            else
            {
                var file = HttpContext.Current.Server.MapPath("/App_Data/library.xml");
                Extensions.ImportXmlLibraryFile(file);
                return(Global.Library.Assets);
            }

            return(Global.Library.Assets);
        }
Ejemplo n.º 3
0
        protected void SendSQL_Click(object sender, EventArgs e)
        {
            try
            {
                SQL_Request req = new SQL_Request().OpenConnection();

                //request all assets
                req.GetAllAssets(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.Library.Assets)
                    {
                        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");
                        }
                    }
                    //upload settings
                    //upload history
                    //upload notifications
                    //upload Calibrations
                }
                req.CloseConnection();
            }
            catch
            {
                //PopNotify("Error", "Error Pushing Library To SQL");
            }
            //PopNotify("Complete", "Library Pushed To SQL");
        }
Ejemplo n.º 4
0
        public static Task <bool> LibraryAsync()
        {
            return(Task.Run(() =>
            {
                try
                {
                    SQL_Request req = new SQL_Request().OpenConnection();

                    //request all assets
                    req.GetAllAssets(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.Library.Assets)
                        {
                            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; }
            }));
        }
Ejemplo n.º 5
0
        protected void DeleteSQL_Click(object sender, EventArgs e)
        {
            SQL_Request req = new SQL_Request().OpenConnection();

            try
            {
                //request all assets
                req.GetAllAssets(false);
                if (req.Tag != null)
                {
                    var cloud = req.Tag as List <Asset>;

                    foreach (var asset in cloud)
                    {
                        try
                        {
                            req.DeleteAsset(asset.AssetNumber, false);
                        }
                        catch { //PopNotify("Error", "Error Deleting SQL Library");
                        }
                    }

                    req.CloseConnection();
                    Global.Library.Assets = new List <Asset>();
                }
            }
            catch
            {
                //PopNotify("Error", "Error Deleting SQL Library");
            }
            finally
            {
                req.CloseConnection();
                //PopNotify("Complete", "SQL Library Deleted");
            }
        }