protected void DeleteSQL_Click(object sender, EventArgs e)
        {
            SQL_Request req = new SQL_Request().OpenConnection();

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

                    foreach (var asset in cloud)
                    {
                        try
                        {
                            req.DeleteData(asset.AssetNumber, false);
                        }
                        catch { Notification.Text = "SQL Erase Error"; }
                    }

                    req.CloseConnection();
                    Notification.Text = "SQL Erase Success";
                }
            }
            catch
            {
                Notification.Text = "SQL Erase Error";
            }
            finally
            {
                req.CloseConnection();
            }
        }
        protected void SendSQL_Click(object sender, EventArgs e)
        {
            SQL_Request req = new SQL_Request().OpenConnection();

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


            //merge all assets

            //post merged assets as new master DB
            if (req.Tag != null)
            {
                var cloud = req.Tag as List <Asset>;
                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.UpdateData(a, false);
                        }
                    }
                    catch { Notification.Text = "SQL-LINK Error"; }
                }
                Notification.Text = "SQL-LINK Complete";
            }
            req.CloseConnection();
        }
        public static bool PushSetting(SettingsDBData data)
        {
            var connected = Extensions.CheckForInternetConnection();

            if (!connected)
            {
                return(false);
            }
            SQL_Request req = new SQL_Request().OpenConnection();
            //barcode was scanned or manually inputted
            var sql_settings = GetSetting(data.Appname);

            if (sql_settings == null)
            {
                var result = req.SettingsAdd(data.Appname, data.XmlData, data.XmlData2, data.XmlData3, data.XmlData4, data.XmlData5);
                return(true);
            }


            try
            {
                var result = req.SettingsUpdate(data.Appname, data.XmlData, data.XmlData2, data.XmlData3, data.XmlData4, data.XmlData5);
            }
            catch
            {
                return(false);
            }
            finally { req.CloseConnection(); }
            return(true);
        }
        public static bool PushSetting(string xml, string guid)
        {
            string xmldata   = xml;
            var    connected = Extensions.CheckForInternetConnection();

            if (!connected)
            {
                return(false);
            }
            SQL_Request req = new SQL_Request().OpenConnection();
            //barcode was scanned or manually inputted
            var sql_settings = GetSetting(guid);

            if (sql_settings == null)
            {
                var result = req.SettingsAdd(guid, xmldata);
                return(true);
            }


            try
            {
                var result = req.SettingsUpdate(guid, xmldata);
            }
            catch
            {
                return(false);
            }
            finally { req.CloseConnection(); }
            return(true);
        }
        public static bool PushSettings(Settings settings, string AppName = "AWP_STARRAG_US")
        {
            string xmldata   = settings.Serialize();
            var    connected = Extensions.CheckForInternetConnection();

            if (!connected)
            {
                return(false);
            }
            SQL_Request req = new SQL_Request().OpenConnection();
            //barcode was scanned or manually inputted
            var sql_settings = GetSettings();

            if (sql_settings == null)
            {
                var result = req.SettingsAdd(AppName, xmldata);
                return(true);
            }


            try
            {
                var result = req.SettingsUpdate(AppName, xmldata);
            }
            catch
            {
                return(false);
            }
            finally { req.CloseConnection(); }
            return(true);
        }
Exemple #6
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");
            }
        }
Exemple #7
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");
        }
        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; }
            }));
        }
Exemple #9
0
 public static async Task <SQL_Request> CloseConnection(this SQL_Request request)
 {
     return(await request.CloseConnection());
 }