Exemplo n.º 1
0
 private static void InsertData(Article obj, string newDB)
 {
     if (CheckData(obj, newDB) == false)
     {
         CArticle.Insert(obj, new DAL());
     }
     ;
 }
Exemplo n.º 2
0
        private static bool CheckData(Article obj, string newDB)
        {
            string q = "USE " + newDB + "; ";

            q += "SELECT * FROM " + ARTICLE.ARTICLE_TBL + " WHERE " + ARTICLE.ARTICLE_NAME + " = '" + obj.Article_name + "'; ";

            using (IDataReader redr = new DAL().Listreader(q))
            {
                while (redr.Read() == true)
                {
                    obj.Article_id = redr[ARTICLE.ARTICLE_ID].ToString();

                    CArticle.Update(obj, new DAL());

                    return(true);
                }
                return(false);
            }
        }
Exemplo n.º 3
0
        public HttpResponseMessage SearchNews(string tag, string country)
        {
            HttpResponseMessage response    = Request.CreateResponse();
            List <CArticle>     articleList = new List <CArticle>();
            var article = new CArticle
            {
                Content = "Test content",
                Country = new CCountry {
                    Name = country
                },
                Date = DateTime.Now,
                Html = new byte[10],
                Tags = new CTag[] { new CTag {
                                        Value = tag
                                    } },
                Url = "Http://testurl.com"
            };
            var count = 0;

            for (var i = 0; i < 50; i++)
            {
                String q = (count++).ToString();                    // это всё равно не помогло =)  отложенная операция - почему?
                article.Title = $"Test Title {q}";
                articleList.Add(article);
            }

            CArticle[] articles = articleList.ToArray();
            try
            {
                response.Headers.AcceptRanges.Add("articles");
                response.StatusCode = HttpStatusCode.OK;
                response.Content    = new ObjectContent(typeof(CArticle[]), articles, new XmlMediaTypeFormatter());
                // response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("");
                // response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            }
            catch (Exception e)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message, new MediaTypeHeaderValue("application/xml"));
            }

            return(response);
        }