Пример #1
0
        /// <summary>
        /// Processes and returns a list of images in the CSS file.
        /// </summary>
        /// <param name="downloadString"></param>
        /// <param name="sourceUrl"></param>
        /// <param name="alreadyProcessed"></param>
        public List<SquishedImage> ProcessCss(string downloadString, string sourceUrl, ref List<string> alreadyProcessed)
        {
            IEnumerable<string> imagesInCssString = new List<string>();

            // Retrieve the Css files from the html string
            List<string> extractedCss = _utils.ExtractCssHrefFromHtmlString(downloadString);

            // Loop through the extracted Css and process
            foreach (string cssFile in extractedCss)
            {
                if (_commonUtils.IsValidCssExtension(cssFile))
                {
                    if (!alreadyProcessed.Contains(cssFile))
                    {
                        // Add to already processed list
                        alreadyProcessed.Add(cssFile);

                        // TODO: Fix this
                        List<string> extractImagesFromCssFile = _utils.ExtractImagesFromCssFile(cssFile, sourceUrl);

                        // Join the new list with the existing image list.
                        imagesInCssString = extractImagesFromCssFile.Union(imagesInCssString);
                    }
                }
            }

            // Send the images through to Smush.it
            List<SquishedImage> images = new List<SquishedImage>();
            foreach (var imagePath in imagesInCssString)
            {
                images.Add(ProcessSingleImage(imagePath, sourceUrl, false));
            }

            return images;
        }
Пример #2
0
        /// <summary>
        /// Adds new book in repository(if it was not there)
        /// </summary>
        /// <param name="book">Some new book</param>
        public void AddBook(Book book)
        {
            try
            {
                if (book == null)
                    throw new ArgumentNullException("Book is null");

                books = repository.LoadToList();
                if (books.Contains(book))
                    throw new ArgumentException("Book is already in booklist");
                else
                {
                    books.Add(book);
                    logger.Info("Book was added successfully");
                    repository.LoadToFile(books);
                }
            }
            catch (Exception e)
            {
                logger.Info(e.Message);
                logger.Error(e.StackTrace);
            }
        }
Пример #3
0
 public IEnumerable<Hero> GetHeroByNames(List<string> names)
 {
     return _context.Heroes.Where(x => names.Contains(x.Name));
 }
Пример #4
0
        /// <summary>
        /// Removes some book from repository (if this book was there)
        /// </summary>
        /// <param name="book">Some book to remove</param>
        public void RemoveBook(Book book)
        {
            try
            {
                if (book == null)
                    throw new ArgumentException("Book is null");

                books = repository.LoadToList();
                if (!books.Contains(book))
                    throw new ArgumentException("There is no this book in booklist");
                else
                {
                    books.Remove(book);
                    logger.Info("Book was removed successfully");
                    repository.LoadToFile(books);
                }
            }
            catch (Exception e)
            {
                logger.Info(e.Message);
                logger.Error(e.StackTrace);
            }
        }
Пример #5
0
        private Expression<Func<SalesOrder, bool>> GetQueryExp(int companyId, int customerId, int commodityId, int commodityTypeId, int brandId, int warsehouseId, int status, DateTime? startDate, DateTime? endDate, List<int> listCommodity, List<int> listCompany)
        {
            var clauses = new List<Clause>();
            if (customerId != 0)
            {
                clauses.Add(new Clause
                {
                    PropertyName = "CompanyId",
                    Operator = Operator.Eq,
                    Value = customerId
                });
            }

            if (companyId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CompanyId",
                    Value = companyId
                });
            }

            if (commodityId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CommodityId",
                    Value = commodityId
                });
            }

            if (commodityTypeId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.CommodityTypeId",
                    Value = commodityTypeId
                });
            }

            if (brandId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.BrandId",
                    Value = brandId
                });
            }

            if (warsehouseId != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Stock.WarehouseId",
                    Value = warsehouseId
                });
            }

            if (status != 0)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Eq,
                    PropertyName = "Status",
                    Value = status
                });
            }

            if (startDate.HasValue)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Ge,
                    PropertyName = "Date",
                    PropertyType = typeof(DateTime),
                    Value = startDate.Value
                });
            }

            if (endDate.HasValue)
            {
                clauses.Add(new Clause
                {
                    Operator = Operator.Le,
                    PropertyName = "Date",
                    PropertyType = typeof(DateTime),
                    Value = endDate.Value
                });
            }

            var manager = new QueryManager<SalesOrder>();
            return manager.Compile(clauses, o => listCompany.Contains(o.Stock.CompanyId) && listCommodity.Contains(o.Stock.CommodityId));
        }
 public static List<Kitap> mostRentedBook(DateTime First, DateTime Last)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select KitapID,COUNT(KitapID) as KiralamaSayisi from dbo.Kiralama" +
         " join dbo.KiralamaDetay on Kiralama.ID = KiralamaDetay.ID" +
         " where KiralamaDetay.KiralamaTarihi between";
     CommandString += " '" + convertToSqlDate(First.ToShortDateString()) + "' and";
     CommandString += " '" + convertToSqlDate(Last.ToShortDateString()) + "' group by KitapID";
     CommandString += " order by KiralamaSayisi desc";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     int max = 0;
     List<int> Kitaplar = new List<int>();
     if (reader.Read())
     {
         max = reader.GetInt32(1);
         Kitaplar.Add(reader.GetInt32(0));
     }
     while (reader.Read())
     {
         int currentCount = reader.GetInt32(1);
         if (currentCount == max)
         {
             Kitaplar.Add(reader.GetInt32(0));
         }
         else if (currentCount < max)
         {
             break;
         }
     }
     reader.Close();
     con.Close();
     if (Kitaplar.Count > 0)
     {
         CommandString = "select * from dbo.Kitap where ";
         foreach (int item in Kitaplar)
         {
             CommandString += "ID=" + item.ToString() + " or ";
         }
         CommandString = CommandString.Remove(CommandString.Length - 4);
         cmd = new SqlCommand(CommandString, con);
         con.Open();
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             int id = reader.GetInt32(0);
             SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
             SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
             AuthorCon.Open();
             SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
             List<Yazar> YazarList = new List<Yazar>();
             while (AuthorReader.Read())
             {
                 YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
             }
             AuthorReader.Close();
             AuthorCon.Close();
             Yazar[] Yazarlar = null;
             if (YazarList.Count > 0)
             {
                 Yazarlar = new Yazar[YazarList.Count];
                 YazarList.CopyTo(Yazarlar);
             }
             Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
             Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
             Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
                 reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
             try
             {
                 Current.Ozet = reader.GetString(9);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Ozet = "";
             }
             try
             {
                 Current.Kapak = reader.GetString(10);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Kapak = "";
             }
             if (!Value.Contains(Current))
             {
                 Value.Add(Current);
             }
         }
         reader.Close();
         con.Close();
     }
     return Value;
 }
 public static List<Kitap> search(string kitapAdi, Yazar[] yazarlar, int[] yillar)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select ID,Adi,BasimYili,YayineviID,KategoriID,SayfaSayisi,HasarDurumu,KiralamaDurumu,Ucret,Ozet,Kapak ";
     CommandString += "from dbo.Kitap join dbo.KitapYazar on dbo.Kitap.ID = dbo.KitapYazar.KitapID where ";
     CommandString += "(Adi like '%" + kitapAdi + "%') and (";
     int counter = 0;
     foreach (Yazar item in yazarlar)
     {
         if (item.ID != 0)
         {
             CommandString += "dbo.KitapYazar.YazarID=" + item.ID.ToString() + " or ";
             counter++;
         }
     }
     if (counter > 0)
     {
         CommandString = CommandString.Remove(CommandString.Length - 4);
         CommandString += ") and (";
     }
     foreach (int item in yillar)
     {
         CommandString += "dbo.Kitap.BasimYili='" + item.ToString() + "' or ";
     }
     CommandString = CommandString.Remove(CommandString.Length - 4);
     CommandString += ")";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     while (reader.Read())
     {
         int id = reader.GetInt32(0);
         SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
         SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
         AuthorCon.Open();
         SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
         List<Yazar> YazarList = new List<Yazar>();
         while (AuthorReader.Read())
         {
             YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
         }
         AuthorReader.Close();
         AuthorCon.Close();
         Yazar[] Yazarlar = null;
         if (YazarList.Count > 0)
         {
             Yazarlar = new Yazar[YazarList.Count];
             YazarList.CopyTo(Yazarlar);
         }
         Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
         Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
         Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
             reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
         try
         {
             Current.Ozet = reader.GetString(9);
         }
         catch (SqlNullValueException snve)
         {
             Current.Ozet = "";
         }
         try
         {
             Current.Kapak = reader.GetString(10);
         }
         catch (SqlNullValueException snve)
         {
             Current.Kapak = "";
         }
         if (!Value.Contains(Current))
         {
             Value.Add(Current);
         }
     }
     reader.Close();
     con.Close();
     return Value;
 }
Пример #8
0
        public static List<string> GetAllTags()
        {
            List<string> result = new List<string>();

            List<Book> books = GetBooks(0);

            foreach (Book book in books)
                foreach (string tag in book.Tags)
                    if (result.Contains(tag) == false)
                        result.Add(tag);

            return result;
        }