Пример #1
0
        private void loadImages()
        {
            Console.WriteLine("loading images");
            d.FileData     fd    = new d.FileData();
            string[]       files = Directory.GetFiles(TESTIMAGES_PATH);
            ba.ImageHelper ih    = new ba.ImageHelper();

            foreach (string f in files)
            {
                FileInfo fi = new FileInfo(f);
                int      id = fd.Create(fi.Extension, getRandomText(5, 100), getRandomText(50, 500), 1);
                if (id > 0) //neccessary check: might have been duplicate titles, since it's a random generator
                {
                    string imagePath      = FILES_PATH + ba.UrlHelper.GetImageName(id, fi.Extension);
                    string imageThumbPath = FILES_PATH + ba.UrlHelper.GetImageName(id, "s" + fi.Extension);
                    ih.MakeImage(f, imagePath, 0, 0);
                    ih.MakeImage(f, imageThumbPath, 100, 75);
                    Bitmap im = new Bitmap(imagePath);
                    d.File df = new d.File(id);
                    df.Size        = (int)fi.Length;
                    df.ImageWidth  = im.Width;
                    df.ImageHeight = im.Height;
                    df.Update();
                    im.Dispose();
                }
            }
        }
Пример #2
0
        private void loadImageLabels()
        {
            Console.WriteLine("loading image labels");
            d.FileContentLabelData fl = new d.FileContentLabelData();
            DataTable dtFiles         = new d.FileData().GetImages("f.id").Tables[0];
            DataTable dtLabels        = new d.ContentLabelData().GetList();
            int       fileId;
            int       labelId;
            int       labelsToAdd;
            int       totalLabels = dtLabels.Rows.Count;

            foreach (DataRow dr in dtFiles.Rows)
            {
                fileId      = Convert.ToInt32(dr[0]);
                labelsToAdd = rnd.Next(totalLabels + 1);
                for (int i = 0; i < labelsToAdd; i++)
                {
                    labelId = Convert.ToInt32(dtLabels.Rows[rnd.Next(totalLabels)][0]);
                    fl.AddLink(fileId, labelId);
                }
            }
        }
Пример #3
0
        private void loadFiles()
        {
            Console.WriteLine("loading files");
            d.FileData fd    = new d.FileData();
            string[]   files = Directory.GetFiles(TESTFILES_PATH);

            foreach (string f in files)
            {
                for (int i = 0; i < 50; i++)
                {
                    FileInfo fi = new FileInfo(f);
                    int      id = fd.Create(fi.Extension, getRandomText(5, 100), getRandomText(50, 500), 1);
                    if (id > 0)
                    {
                        string filePath = FILES_PATH + ba.UrlHelper.GetFileName(id, fi.Extension);

                        File.Copy(f, filePath);
                        d.File df = new d.File(id);
                        df.Size = (int)fi.Length;
                        df.Update();
                    }
                }
            }
        }