Ejemplo n.º 1
0
        public ActionResult EditPost(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            article article = db.articles.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            ViewBag.created_by = new SelectList(db.users, "id", "username", article.created_by);
            return(View(article));
        }
Ejemplo n.º 2
0
        public ActionResult Detail(int id)
        {
            article reVal = null;
            var     art   = new ArticleMgr().GetArticle(id);

            if (art.Success && art.Item != null)
            {
                reVal         = art.Item;
                ViewBag.Title = art.Item.title;
            }
            var next = new Business.Article.ArticleMgr().GetNextArticle(id);

            ViewBag.nextid = next.Item.aid;
            ViewBag.title  = next.Item.title;
            return(View(reVal));
        }
Ejemplo n.º 3
0
        public string Update(article updateArticle)
        {
            string ret       = "";
            var    anArticle = db.article.SingleOrDefault(x => x.articleId == updateArticle.articleId);

            if (anArticle != null)
            {
                anArticle = reflectionUtl.assign <article, article>(anArticle, updateArticle);
                db.Entry(anArticle).State = EntityState.Modified;// .article.Update(updateArticle);
            }
            else
            {
                throw new Exception($"article {updateArticle.articleId} not found!");
            }
            return(ret);
        }
        // GET: articles1/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            article article = await db.articles.FindAsync(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            ViewBag.C_id      = new SelectList(db.magazines, "C_id", "name", article.C_id);
            ViewBag.volume_id = new SelectList(db.volumes, "volume_id", "year", article.volume_id);
            return(View(article));
        }
Ejemplo n.º 5
0
        public ActionResult blogDetail(int id)
        {
            article        article     = manager.getArticle(id);
            List <article> whole       = manager.getArticleList(0, "", "").ToList();
            int            index       = whole.IndexOf(article);
            article        nextArticle = (index + 1) <= whole.Count() - 1 ?  whole[index + 1] : null;
            article        preArticle  = (index - 1) >= 0 && (index - 1) < whole.Count() - 1 ? whole[index - 1] : null;

            blogDetailVM model = new blogDetailVM()
            {
                article         = article,
                nextArticle     = nextArticle,
                previousArticle = preArticle
            };

            return(View(model));
        }
Ejemplo n.º 6
0
        public ViewResult Detail(int id)
        {
            article myarticle = dbContext.article.Find(id);

            ViewBag.sid     = myarticle.id;
            ViewBag.stitle  = myarticle.title;
            ViewBag.author  = myarticle.users.email;
            ViewBag.date    = myarticle.create_at;
            ViewBag.aid     = myarticle.category.id;
            ViewBag.atitle  = myarticle.category.title;
            ViewBag.content = HttpUtility.HtmlDecode(myarticle.content);
            var result = (from c in dbContext.comments
                          where c.article_id == id && c.is_show == true
                          select c).ToList <comments>();

            return(View(result));
        }
Ejemplo n.º 7
0
        private void Bind()
        {
            Model.article_goods model = bll.GetGoodsModel(id);
            if (model != null)
            {
                lbltitle2.Text     = model.title;
                lbltitle.Text      = model.title;
                lblContent.Text    = model.content;
                Image1Url          = model.img_url;
                lblMarkePrice.Text = model.market_price.ToString();
                lblprice.Text      = model.sell_price.ToString();
                if (model.shangpinType.ToString().Length >= 75)
                {
                    lblIntroduce.Text = model.shangpinType.ToString().Substring(0, 75);
                }
                else
                {
                    lblIntroduce.Text = model.shangpinType.ToString();
                }
                //lbllianxiren.Text = model.lianxiren;
                //lbldianhua.Text = model.dianhua;
                Status = model.Status;
                int i = 0;
                foreach (var item in model.albums)
                {
                    i++;
                    Images += " <li><a  href='" + item.small_img + "'><img src=\"" + item.small_img + "\" alt=\"" + item.remark + "\" width=\"68\" height=\"50\" rel=\"" + item.big_img + "\"/></a></li>";
                }
            }

            DAL.article dalArticle = new article();
            DataTable   dt         = dalArticle.GetPageJPList("1", 4, "   and channel_id=" + model.channel_id).Tables[0];

            if (dt.Rows.Count > 0)
            {
                repdatezuixin.DataSource = dt.DefaultView;
                repdatezuixin.DataBind();
            }

            dt = dalArticle.GetPageJPList("3", 5, "  and channel_id=" + model.channel_id).Tables[0];
            if (dt.Rows.Count > 0)
            {
                repdatetemai.DataSource = dt.DefaultView;
                repdatetemai.DataBind();
            }
        }
        public ActionResult Create(article article)
        {
            if (db.articles.Any(x => x.Name.Trim() == article.Name.Trim()))
            {
                ModelState.AddModelError("Name", "This name has already been entered");
            }

            if (ModelState.IsValid)
            {
                article.AddTime = DateTime.Now;
                db.articles.Add(article);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(article));
        }
Ejemplo n.º 9
0
        public void getAllCatalogue()//pour le client
        {
            article art = new article(1, "T1", "TY1", 1, 1);

            //Stream str = strr;

            using (Stream str = File.Open("data.bin", FileMode.Create, FileAccess.ReadWrite))
            {
                BinaryFormatter bin = new BinaryFormatter();

                Console.Write("Le client demande a consulter la base de donnée ");
                getAllCatalogue1();
                Console.WriteLine("le nombre de tuples dans la BD est : " + L.Count.ToString());

                bin.Serialize(str, L);
            }
        }
Ejemplo n.º 10
0
        public JsonResult ProcessUpdate(int id, string title, int catid, string author, string content)
        {
            article myarticle = dbContext.article.Find(id);

            myarticle.title       = title;
            myarticle.category_id = catid;
            myarticle.content     = content;
            myarticle.create_at   = DateTime.Now;
            if (dbContext.SaveChanges() != 0)
            {
                return(Json(new { status = 1, data = "Modifié avec succès" }));
            }
            else
            {
                return(Json(new { status = 0, data = "Échec de modifier" }));
            }
        }
Ejemplo n.º 11
0
 public ActionResult fbart(article model)
 {
     if (model != null)
     {
         reflectModel.setValues(model);
         if (model.content.Length > 0 && model.title.Length > 0)
         {
             model.addtime = DateTime.MinValue;
             var user = (user)Session["user"];
             model.uid = (int)user.id;
             if (EfExt.insert(model) > 0)
             {
                 return(Content("发布成功"));
             }
         }
     }
     return(Content("发布失败"));
 }
Ejemplo n.º 12
0
 public ActionResult Update(article Model)
 {
     if (Model != null)
     {
         var query = db.article.FirstOrDefault(x => x.id == Model.id);
         query.categoryId = Model.categoryId;
         query.contents   = Model.contents;
         query.seoLink    = Model.seoLink;
         query.thumbnail  = Model.thumbnail;
         query.title      = Model.title;
         db.SaveChanges();
         return(RedirectToAction("Index", "Article"));
     }
     else
     {
     }
     return(View());
 }
Ejemplo n.º 13
0
        // GET: Article/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            article article = db.articles.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }
            ViewBag.AuthorId           = new SelectList(db.UsersAuthors, "UserId", "IP", article.AuthorId);
            ViewBag.SubscriptionTypeId = new SelectList(db.SubscriptionTypes, "id", "Name", article.SubscriptionTypeId);
            ViewBag.id         = new SelectList(db.ArticlePublisheds, "ArticleId", "IP", article.id);
            ViewBag.categoryId = new SelectList(db.Categories, "id", "Name", article.categoryId);
            return(View(article));
        }
Ejemplo n.º 14
0
 private void metroButton3_Click(object sender, EventArgs e)
 {
     try
     {
         if (remoteOperation != null)
         {
             art1 = new article(Convert.ToInt32(metroTextBox1.Text), metroTextBox2.Text, metroTextBox3.Text, Convert.ToInt32(metroTextBox4.Text), Convert.ToInt32(metroTextBox5.Text));
             remoteOperation.insert(art1);
             clear();
             GetAllArticle();
             //MetroMessageBox.Show(this, "Insertion terminée avec succé", "MetroMessagebox", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception)
     {
         MetroMessageBox.Show(this, "Sheck your intry data please", "MetroMessagebox", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 15
0
 //Если слово - существительное, то указать артикль:
 private void comboBox2_TextChanged(object sender, EventArgs e)
 {
     checkButtonEble();
     if (comboBox2.SelectedItem.ToString() == "Substantiv")
     {
         comboBox1.Text    = "der";
         isArticle         = true;
         comboBox1.Visible = true;
         label4.Visible    = true;
     }
     else
     {
         art               = article.none;
         isArticle         = false;
         comboBox1.Visible = false;
         label4.Visible    = false;
     }
 }
Ejemplo n.º 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int    AreaID = 0;
            string proID  = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(proID))
            {
                BLL.article         bll   = new BLL.article();
                Model.article_goods model = bll.GetGoodsModel(int.Parse(proID));
                if (model != null)
                {
                    AreaID = model.Areaid;
                }
            }
            DAL.article dalArticle = new article();
            repdate1.DataSource = dalArticle.GetPageindexList("", 4, " and channel_id =" + Request.QueryString["mid"] + " and id !=" + int.Parse(proID) + " and Areaid=" + AreaID);
            repdate1.DataBind();
        }
        public JsonResult ProcessUpdate(int id, string title, int catid, string author, string desc, string content)
        {
            article myarticle = dbContext.article.Find(id);

            myarticle.title   = title;
            myarticle.cateid  = catid;
            myarticle.content = content;
            myarticle.desc    = desc;
            myarticle.time    = DateTime.Now;
            if (dbContext.SaveChanges() != 0)
            {
                return(Json(new { status = 1, data = "修改成功!" }));
            }
            else
            {
                return(Json(new { status = 0, data = "修改失败!" }));
            }
        }
Ejemplo n.º 18
0
        public JsonResult test()
        {
            List <article> list = new List <article>();
            article        customerA;

            customerA         = new article();
            customerA.artDate = "2017/11/27";
            customerA.title   = "XXX";
            customerA.content = "1234";
            list.Add(customerA);

            var Result = new
            {
                data = list
            };

            return(Json(Result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 19
0
        private static List <article> getArticle(string href)
        {
            List <article> List = new List <article>();

            try
            {
                var readHtml = new HtmlDocument();
                readHtml.LoadHtml(getResponse(href));
                var data = new article();
                data.title        = readHtml.QuerySelector(_cat.article.title).InnerText;
                data.article_info = readHtml.QuerySelector(_cat.article.article_info).OuterHtml;
                data.descriptions = readHtml.QuerySelector(_cat.article.descriptions).InnerText;
                data.avatar       = readHtml.QuerySelector(_cat.article.avatar).InnerHtml;
                List.Add(data);
            }
            catch (Exception ex) { throw ex; }
            return(List);
        }
Ejemplo n.º 20
0
        public static OpenGraph ToOpenGraph(this organisation org, product p, article a)
        {
            var graph = new OpenGraph
            {
                fbid        = org.users.First().FBID,
                sitename    = org.MASTERsubdomain.storeName,
                description = org.motd,
                address     = org.address,
                countryname = org.country.HasValue ? Country.GetCountry(org.country.Value).name : "",
                email       = "",
                fax         = org.fax,
                latitude    = org.latitude.HasValue ? org.latitude.ToString() : "",
                longtitude  = org.longtitude.HasValue ? org.longtitude.ToString() : "",
                locality    = org.city.HasValue ? org.MASTERcity.name : "",
                region      = "",
                postcode    = org.postcode,
                phone       = org.phone,
            };

            if (p != null)
            {
                graph.type  = "product";
                graph.title = p.title;
                graph.url   = org.MASTERsubdomain.ToHostName().ToDomainUrl(p.ToLiquidProductUrl());
                graph.image = p.thumb.HasValue
                                  ? org.MASTERsubdomain.ToHostName().ToDomainUrl(Img.by_size(p.product_image.url,
                                                                                             Imgsize.SMALL))
                                  : org.MASTERsubdomain.ToHostName().ToDomainUrl(GeneralConstants.PHOTO_NO_THUMBNAIL);
            }
            else if (a != null)
            {
                graph.type  = "article";
                graph.title = a.title;
                graph.url   = org.MASTERsubdomain.ToHostName().ToDomainUrl(a.ToLiquidUrl());
            }
            else
            {
                graph.type  = "company";
                graph.title = org.MASTERsubdomain.storeName;
                graph.url   = org.MASTERsubdomain.ToHostName().ToDomainUrl();
            }

            return(graph);
        }
Ejemplo n.º 21
0
        public ActionResult ArticleSave(long?id, string title, string content, string tags, bool publish, int target_blog)
        {
            var a = new article();

            if (id.HasValue)
            {
                a = MASTERdomain.blogs.SelectMany(x => x.articles).SingleOrDefault(x => x.id == id.Value);
                if (a == null)
                {
                    return(Json("Article not found".ToJsonFail()));
                }
                db.article_tags.DeleteAllOnSubmit(a.article_tags);
            }
            else
            {
                a.created = DateTime.UtcNow;
                a.creator = sessionid.Value;
                var blog = MASTERdomain.blogs.SingleOrDefault(x => x.id == target_blog);
                if (blog == null)
                {
                    return(Json("Blog not found".ToJsonFail()));
                }
                blog.articles.Add(a);
            }
            a.title     = title;
            a.content   = content;
            a.blogid    = target_blog;
            a.published = publish? DateTime.UtcNow: (DateTime?)null;

            var taglist = tags.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var tag in taglist)
            {
                var t = new article_tag();
                t.name        = tag;
                t.handle      = tag.ToPerma();
                t.subdomainid = subdomainid.Value;
                a.article_tags.Add(t);
            }

            repository.Save();

            return(Json("Article saved successfully".ToJsonOKMessage()));
        }
Ejemplo n.º 22
0
        // GET: Content/Details/5
        public ActionResult Details(int?id, string type)
        {
            var tax_Content_Type = from t in db.taxonomies select t;

            ViewBag._index_data_type = type;
            ViewBag._taxonomies      = new SelectList(tax_Content_Type.Where(c => c.content_type.Equals("Material")), "id", "title");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            article article = db.articles.Find(id);

            ViewBag._index_feedback = db.feedbacks.Include(f => f.user).Where(f => f.article_id == id).ToList();
            if (article == null)
            {
                return(HttpNotFound());
            }
            return(View(article));
        }
        public ActionResult UpdateVote(String vote, String id, String user)
        {
            TempData.Keep("id");
            int updateVote = int.Parse(vote);

            updateVote = updateVote + 1;
            short     articleId    = short.Parse(id);
            votetable newVote      = new votetable();
            article   articleModel = new article();
            member    memberModel  = new member();

            using (DBModel dbModel = new DBModel())
            {
                memberModel       = dbModel.members.Where(x => x.uname == user).FirstOrDefault();
                newVote.userId    = memberModel.id;
                newVote.articleId = articleId;

                articleModel      = dbModel.articles.Where(x => x.id == articleId).FirstOrDefault();
                articleModel.vote = updateVote;
                try
                {
                    dbModel.votetables.Add(newVote);
                    dbModel.SaveChanges();
                }
                catch
                {
                    String errorInfo = "already";
                    return(Json(errorInfo));
                }
                if (updateVote == 150)
                {
                    dbModel.Entry(articleModel).State = System.Data.Entity.EntityState.Modified;
                    dbModel.articles.Remove(articleModel);
                    dbModel.SaveChanges();
                    String deleteArticle = "deleted";
                    return(Json(deleteArticle));
                }
                dbModel.Entry(articleModel).State = System.Data.Entity.EntityState.Modified;
                dbModel.SaveChanges();
            }

            return(Json(updateVote));
        }
Ejemplo n.º 24
0
        public ActionResult Create(article article, string[] _taxonomies, string[] _taxonomies_category, string[] _article_meta, string _premium, HttpPostedFileBase ImageFile, string content_type)
        {
            ViewBag._content_type = content_type;
            if (ModelState.IsValid)
            {
                if (ImageFile != null)
                {
                    Upload(ImageFile);
                    article.setMeta("imagefile", ImagePath);
                }

                if (_premium != null)
                {
                    article.setMeta("premium", _premium);
                }

                //save to article
                article.published_at = DateTime.Now;
                article.created_at   = DateTime.Now;
                article.created_by   = db.users.Where(u => u.username == User.Identity.Name).FirstOrDefault().id;
                db.articles.Add(article);
                db.SaveChanges();

                if (_taxonomies != null)
                {
                    taxonomiesToData(_taxonomies, article);
                }

                if (_taxonomies_category != null)
                {
                    taxonomiesToData(_taxonomies_category, article);
                }

                return(RedirectToAction("Index", new { content_type }));
            }
            var tax_Content_Type = from t in db.taxonomies select t;

            ViewBag.created_by           = new SelectList(db.users, "id", "username", article.created_by);
            ViewBag._taxonomies          = new SelectList(tax_Content_Type.Where(c => c.content_type == "Material"), "id", "title");
            ViewBag._taxonomies_category = new SelectList(tax_Content_Type.Where(c => c.content_type == "Category"), "C_key", "C_value");

            return(RedirectToAction("Index", new { content_type }));
        }
Ejemplo n.º 25
0
        public ActionResult UpdateArticle(int id)
        {
            if (Session["email"] == null)
            {
                Response.Redirect("~/Admin/Login");
            }

            article myarticle = dbContext.article.Find(id);

            ViewBag.id      = myarticle.id;
            ViewBag.atitle  = myarticle.title;
            ViewBag.author  = myarticle.users.email;
            ViewBag.title   = myarticle.category.title;
            ViewBag.content = myarticle.content;
            var result = (from c in dbContext.category
                          select c).ToList <category>();

            return(View(result));
        }
Ejemplo n.º 26
0
        public ActionResult setNewArticle(ViewModel.newArcticelVM model)
        {
            if (model.description.Contains("script"))
            {
                return(RedirectToAction("blog", "Admin"));
            }
            model.tag = model.tag.Replace(",", "-");

            string ss = Session["imageListAdd"] as string;

            ss = ss.Substring(0, ss.Length - 1);
            List <string> imageList = ss.Split(',').ToList();
            string        imagename = "";

            if (imageList != null)
            {
                imagename = imageList[0];
            }
            string device = RandomString(10);
            string code   = MD5Hash(device + "ncase8934f49909");

            article newArticle = new article()
            {
                articleCatID = model.catList,
                content      = model.description,
                hashtags     = model.tag,
                date         = DateTime.Now,
                image        = imagename,
                title        = model.title,
                writer       = "مدیر",
            };
            dbRespose res = manager.addArticle(newArticle);

            if (res.status == 200)
            {
                return(RedirectToAction("blog"));
            }
            else
            {
                return(RedirectToAction("blog"));
            }
        }
Ejemplo n.º 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     DTcms.BLL.article article = new article();
     if (!IsPostBack)
     {
         if (ucl_news.Text.Trim() != "")
         {
             DataTable dt  = article.GetNewsList(5, "category_id=" + ucl_news.Text.Trim(), "id asc").Tables[0];
             string    htm = "";
             for (int i = 1; i < dt.Rows.Count; i++)
             {
                 htm += "<li><a href='Detail.aspx?id=" + dt.Rows[i]["id"].ToString() + "' target='_blank'>" + dt.Rows[i]["title"].ToString() + "</a></li>";
             }
             ucl_news.Text = htm;
         }
         else
         {
             ucl_news.Text = "";
         }
     }
 }
Ejemplo n.º 28
0
        public void insert(article p) // pour ajouter un nouveau article
        {
            init();
            Articles art = new Articles();

            art.Code_article     = p.Codearticle;
            art.Titre_article    = p.Titrearticle;
            art.Type_article     = p.Typearticle;
            art.Frais_soumission = p.FraisSoumission;
            art.Nombre_page      = p.NombrePage;

            try
            {
                db.Articles.InsertOnSubmit(art);
                db.SubmitChanges();
            }
            catch (Exception)
            {
                //throw;
            }
        }
Ejemplo n.º 29
0
        public JsonResult IsCheckedAddArticle(string title, int catid, string author, string desc, string content)
        {
            article article = new article();

            article.title   = title;
            article.cateid  = catid;
            article.content = content;
            article.desc    = desc;
            //article.creator = author;
            article.time = DateTime.Now;
            var result = ArticleBLL.IsCheckedAddArticle(article, author);

            if (result == 1)
            {
                return(Json(new { status = 1, data = "添加成功!" }));
            }
            else
            {
                return(Json(new { status = 0, data = "添加失败!" }));
            }
        }
Ejemplo n.º 30
0
 public void AddByImport(article entity)
 {
     _iConnection.ExecuteScalar <article>(
         "INSERT INTO article (author, doi, journal, month, note, number, pages, title, volume, year," +
         " bibtexkey,entrytype) VALUES( @author, @doi, @journal, @month, @note, @number, @pages, @title," +
         " @volume, @year, @bibtexkey, @entrytype)", new
     {
         entity.doi,
         entity.entrytype,
         entity.author,
         entity.journal,
         entity.month,
         entity.note,
         entity.number,
         entity.pages,
         entity.title,
         entity.volume,
         entity.year,
         entity.bibtexkey
     });
 }
Ejemplo n.º 31
0
        public static async Task<string> GetArticleV2(article a, bool OverrideCache = false)
        {
#if DEBUG
            var local = Windows.Storage.ApplicationData.Current.LocalFolder;
            var localFolder = await local.CreateFolderAsync("cache", Windows.Storage.CreationCollisionOption.OpenIfExists);
            var filename = a.id.ToString() + ".htmlcache";
            if (!OverrideCache)
            {
                try
                {
                    using (var fs = await localFolder.OpenStreamForReadAsync(filename))
                    {
                        if (fs.Length <= 0)
                            throw new ArgumentException();
                        using (var sr = new StreamReader(fs))
                        {
                            return await sr.ReadToEndAsync();
                        }
                    }
                }
                catch
                { }
            }
#endif

            var req = NewJsonRequest();
            req.Resource = "/apis/minisite/article/{id}.json";
            req.Method = Method.GET;
            req.AddParameter(new Parameter() { Name = "id", Value = a.id, Type = ParameterType.UrlSegment });

            var resp = await RestSharpAsync.RestSharpExecuteAsyncTask<GetArticleResponse>(WwwClient, req);
            ProcessError(resp);

            string html = "";
            if (resp.Data != null)
            {
                html = @"<div class=""article-head""><h1>"
                    + resp.Data.result.title
                    + "</h1><p style=\"color: #999;\">"
                    + resp.Data.result.author.nickname + " 发表于 " + Common.HumanReadableTime(resp.Data.result.DatePublished)
                    + "</p></div>"
                    + @"<div class=""article-content"">"
                    + resp.Data.result.content
                    + "</div>";
                a.CommentCount = resp.Data.result.replies_count;
                a.minisite_name = (resp.Data.result.minisite == null ? "科学人" : resp.Data.result.minisite.name);
                if (string.IsNullOrEmpty(a.title))
                {
                    a.title = resp.Data.result.title;
                    a.Abstract = resp.Data.result.summary;
                    a.HtmlContent = html;
                    a.pic = string.IsNullOrEmpty(resp.Data.result.image)
                        ? resp.Data.result.small_image
                        : resp.Data.result.image;
                }
            }

#if DEBUG
            var file = await localFolder.CreateFileAsync(filename, CreationCollisionOption.OpenIfExists);
            var bytes = Encoding.UTF8.GetBytes(html);
            using (var stream = await file.OpenStreamForWriteAsync())
            {
                try
                {
                    stream.WriteAsync(bytes, 0, html.Length);
                }
                catch
                {
                    file.DeleteAsync();
                }
            }
#endif

            return html;
        }
Ejemplo n.º 32
0
        public static async Task<GuokrObjectWithId> GetGuokrObjectFromReply(string url)
        {
            var response = await GetRedirectUri(new Uri(url, UriKind.Absolute));

            GuokrObjectWithId a = null;
            if (response.AbsolutePath.Contains("/post/"))
                a = new GuokrPost() { m_url = response.AbsolutePath };
            else if (response.AbsolutePath.Contains("/article/"))
                a = new article() { wwwurl = response.DnsSafeHost + response.AbsolutePath };
            else
                throw new NotImplementedException();

            return a;
        }
Ejemplo n.º 33
0
 public void InsertBookmarkIfNotExist(article a)
 {
     if (!IsArticleExist(a.id))
         BookmarkItems.InsertOnSubmit(a);
 }
Ejemplo n.º 34
0
        public void SaveNewArticle(Product Record, int countryId)
        {
            country cou = _context.country.Where(c => c.id == countryId).FirstOrDefault();
            webshop webshop = _context.webshop.Where(w => w.url == Record.Webshop).FirstOrDefault();

            if (webshop == default(webshop))
            {
                return;
            }

            if (cou == default(country))
            {
                Console.WriteLine("Could not find country id {0}, aborting the save.", countryId);
                return;
            }
            article art = new article
            {
                description = Record.Description,
                brand = Record.Brand,
                image_loc = Record.Image_Loc

            };
            // Do not modify this as this is neccessary to get the last id.
            _context.article.Add(art);

            ean ean = new ean
            {
                ean1 = Record.EAN,
                article_id = art.id
            };
            _context.ean.Add(ean);

            title title = new title
            {
                title1 = Record.Title,
                country_id = (short)countryId,
                article_id = art.id,
                country = cou
            };
            _context.title.Add(title);

            title_synonym ts = new title_synonym
            {
                title = Record.Title,
                title_id = title.id,
                occurrences = 1
            };
            _context.title_synonym.Add(ts);

            if (Record.SKU != "")
            {
                sku sku = new sku
                {
                    sku1 = Record.SKU,
                    article_id = art.id
                };
                _context.sku.Add(sku);
            }

            decimal castedShipCost;
            decimal castedPrice;
            if (!(decimal.TryParse(Record.DeliveryCost, NumberStyles.Any, CultureInfo.InvariantCulture, out castedShipCost))) Console.WriteLine("Cannot cast shipping cost " + Record.DeliveryCost + " to decimal.");
            if (!(decimal.TryParse(Record.Price, NumberStyles.Any, CultureInfo.InvariantCulture, out castedPrice))) Console.WriteLine("Cannot cast price " + Record.Price + " to decimal.");

            product product = new product
            {
                article_id = art.id,
                ship_cost = castedShipCost,
                ship_time = Record.DeliveryTime,
                price = castedPrice,
                webshop_url = webshop.url,
                direct_link = Record.Url,
                affiliate_name = Record.Affiliate,
                affiliate_unique_id = Record.AffiliateProdID
            };
            _context.product.Add(product);
            _context.SaveChanges();
        }