Exemplo n.º 1
0
        public LastContent getSuggestion()
        {
            LastContent lastContentObj = null;

            try
            {
                DataTable     lastContents = new DataTable();
                var           sql          = "SELECT * FROM Suggestion";
                SQLiteCommand command      = new SQLiteCommand(sql, m_dbConnection);
                lastContents.Load(command.ExecuteReader());
                command.Dispose();
                lastContentObj = new LastContent();

                for (int i = 0; i < lastContents.Rows.Count; i++)
                {
                    var productObj = new Pedia();
                    var type       = lastContents.Rows[i]["type"].ToString();

                    productObj.nid           = int.Parse(lastContents.Rows[i]["nid"].ToString());
                    productObj.picture       = lastContents.Rows[i]["picture"].ToString();
                    productObj.local_picture = lastContents.Rows[i]["local_picture"].ToString();
                    productObj.title         = lastContents.Rows[i]["title"].ToString();
                    productObj.url           = lastContents.Rows[i]["url"].ToString();


                    if (type == "product_kit")
                    {
                        if (lastContentObj.product_kit == null)
                        {
                            lastContentObj.product_kit = new List <Pedia>();
                        }
                        lastContentObj.product_kit.Add(productObj);
                    }
                    else if (type == "product")
                    {
                        if (lastContentObj.product == null)
                        {
                            lastContentObj.product = new List <Pedia>();
                        }
                        lastContentObj.product.Add(productObj);
                    }
                    else
                    {
                        if (lastContentObj.college == null)
                        {
                            lastContentObj.college = new List <Pedia>();
                        }
                        lastContentObj.college.Add(productObj);
                    }
                }
                return(lastContentObj);
            }
            catch (Exception e)
            {
                return(lastContentObj);
            }
        }
Exemplo n.º 2
0
        public bool insertSuggestion(LastContent lastContents)
        {
            try
            {
                deleteSuggestion();
                var sql = string.Empty;
                foreach (var product in lastContents.product)
                {
                    string local_picture = null;
                    if (!string.IsNullOrEmpty(product.picture))
                    {
                        local_picture = Helper.saveImage(product.picture);
                    }

                    sql += "INSERT INTO Suggestion (nid, title,url,picture,local_picture,type) " +
                           "values ('" + product.nid + "','" + product.title + "','" + product.url + "','" + product.picture + "','" + local_picture + "','product');";
                }

                foreach (var college in lastContents.college)
                {
                    string local_picture = null;
                    if (!string.IsNullOrEmpty(college.picture))
                    {
                        local_picture = Helper.saveImage(college.picture);
                    }

                    sql += "INSERT INTO Suggestion (nid, title,url,picture,local_picture,type) " +
                           "values ('" + college.nid + "','" + college.title + "','" + college.url + "','" + college.picture + "','" + local_picture + "','college');";
                }

                foreach (var product_kit in lastContents.product_kit)
                {
                    string local_picture = null;
                    if (!string.IsNullOrEmpty(product_kit.picture))
                    {
                        local_picture = Helper.saveImage(product_kit.picture);
                    }

                    sql += "INSERT INTO Suggestion (nid, title,url,picture,local_picture,type) " +
                           "values ('" + product_kit.nid + "','" + product_kit.title + "','" + product_kit.url + "','" + product_kit.picture + "','" + local_picture + "','product_kit');";
                }
                SQLiteCommand commandp = new SQLiteCommand(sql, m_dbConnection);
                commandp.ExecuteNonQuery();
                commandp.Dispose();
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public frmShowPedia(Classes.LastContent lastContent, string title)
        {
            InitializeComponent();

            var pedias = new List <Classes.Pedia>();

            if (lastContent.college != null)
            {
                pedias.AddRange(lastContent.college);
            }
            if (lastContent.product != null)
            {
                pedias.AddRange(lastContent.product);
            }
            if (lastContent.product_kit != null)
            {
                pedias.AddRange(lastContent.product_kit);
            }
            setPedia(pedias, title);
        }
Exemplo n.º 4
0
        public static LastContent lastContent()
        {
            LastContent lastContent = null;

            try
            {
                if (!isOffLine)
                {
                    lastContent = Classes.WebService.lastContent();
                    db.insertLastContent(lastContent);
                }
                lastContent = db.getLastContent();
            }
            catch (Exception)
            {
                lastContent = db.getLastContent();
                isOffLine   = true;
            }
            return(lastContent);
        }
Exemplo n.º 5
0
        public static LastContent suggestion(UserLogin userLogin)
        {
            LastContent suggestion = null;

            try
            {
                if (!string.IsNullOrEmpty(userLogin.sessid))
                {
                    suggestion = Classes.WebService.suggestion(userLogin);
                    db.insertSuggestion(suggestion);
                }
                suggestion = db.getSuggestion();
            }
            catch (Exception)
            {
                suggestion = db.getSuggestion();
                isOffLine  = true;
            }

            return(suggestion);
        }