private void InitiliazeazaImagini()
        {
            pictureBox1.BackColor = pictureBox2.BackColor = pictureBox3.BackColor = pictureBox4.BackColor = pictureBox5.BackColor = pictureBox6.BackColor = Color.Transparent;
            imagini     = GetImages.GetAllImages();
            listaOameni = GetImages.ImaginiOameni();

            #region trash

            int index = r.Next(0, 19);
            pictureBox1.Image = imagini[index];
            pictureBox1.Tag   = imagini[index].Tag;

            index             = r.Next(0, 19);
            pictureBox2.Image = imagini[index];
            pictureBox2.Tag   = imagini[index].Tag;

            index             = r.Next(0, 19);
            pictureBox3.Image = imagini[index];
            pictureBox3.Tag   = imagini[index].Tag;

            index             = r.Next(0, 19);
            pictureBox4.Image = imagini[index];
            pictureBox4.Tag   = imagini[index].Tag;

            index             = r.Next(0, 19);
            pictureBox5.Image = imagini[index];
            pictureBox5.Tag   = imagini[index].Tag;

            index             = r.Next(0, 19);
            pictureBox6.Image = imagini[index];
            pictureBox6.Tag   = imagini[index].Tag;

            #endregion trash
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            string type     = context.Request.QueryString["type"].Trim().ToLower();
            string param    = context.Request.QueryString["ids"].Trim();
            string callback = context.Request.QueryString["callback"].Trim();
            string phypath  = (string)context.Cache["IMAGEPATH"];
            string webpath  = (string)context.Cache["IMAGEURL"];

            context.Response.Write(callback + "(" + GetImages.getResource(phypath + "\\" + type, webpath + "/" + type, param) + ")");
        }
Ejemplo n.º 3
0
        public TestGetImages()
        {
            GetImages getImages = new GetImages();

            ArrayList urls = getImages.Get();

            foreach (string url in urls)
            {
                System.Console.WriteLine(url);
            }
        }
Ejemplo n.º 4
0
        public static void addPhotos(int brafId, string entry, string extract)
        {
            //AdferoVideoOutputsClient xc = new AdferoVideoClient(baseUrl, publicKey, secretKey).VideoOutputs();

            string publicKey = MyGlobals.VideoPublicKey;
            string secretKey = MyGlobals.VideoSecretKey;
            string baseUrl   = "http://" + MyGlobals.VideoBaseURL + "/v2/";

            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "************Just checking the BAseURL**********************<br>";
            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + baseUrl;
            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>***********************************************<br>";

            //in case there are no photos
            MyGlobals.CompleteContent = entry;
            MyGlobals.CompleteExtract = extract;



            AdferoClient client = new AdferoClient(baseUrl, publicKey, secretKey);

            AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotosClient photos = client.ArticlePhotos();

            foreach (AdferoVideoDotNet.AdferoArticles.ArticlePhotos.AdferoArticlePhotoListItem phot in photos.ListForArticle(brafId, 0, 20).Items)
            {
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "////////////////////////Display entry Preimage///////////////////////////////<br>";
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Here is a photo" + phot.Id;
                //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>/////////////////////////////////////////////////////////////////////////<br>";
                //string test = photos.Get(brafId).SourcePhotoId.ToString();
                int    imageID = phot.Id;
                int    photoID = photos.Get(imageID).SourcePhotoId;
                string alttext = photos.Get(imageID).Fields["altText"];
                string caption = photos.Get(imageID).Fields["caption"];

                MyGlobals.imageID = photoID.ToString();

                string photoURL = "http://" + MyGlobals.VideoPhotoURL + "/v2/photo/" + photoID + ".jpg";
                //TODO still need to add global value here

                //string entry = "TEST CONTENT";
                //string description = "TEST EXTRACT";
                string appPath = HttpRuntime.AppDomainAppVirtualPath == "/" ? appPath = "" : appPath = HttpRuntime.AppDomainAppVirtualPath;



                GetImages retrieveImage2 = new GetImages(photoURL, entry, extract, appPath, caption);
                retrieveImage2.DownloadImageDebug();



                MyGlobals.CompleteContent = retrieveImage2._entry;
                MyGlobals.CompleteExtract = retrieveImage2._description;
            }
        }
Ejemplo n.º 5
0
        private GetImages Mapper(SqlDataReader reader)
        {
            GetImages model = new GetImages();
            int       index = 0;

            model.Image       = (byte[])reader[index++];
            model.Description = reader.GetString(index++);
            model.Name        = reader.GetString(index++);
            model.Email       = reader.GetString(index++);
            model.Id          = reader.GetInt32(index++);
            index++;
            return(model);
        }
Ejemplo n.º 6
0
        public async Task <PagedResultDto <ImageDto> > GetImages(GetImages input)
        {
            //Total Record
            var countQuery = _repository.GetAll()
                             .WhereIf(!string.IsNullOrEmpty(input.Filter),
                                      p => p.thietbi.NAME.Contains(input.Filter));
            var totalRecord = countQuery.Count();
            //Record with filter & pager
            var result = _repository
                         .GetAll()
                         .WhereIf(!string.IsNullOrEmpty(input.Filter), p => p.thietbi.NAME.Contains(input.Filter))
                         .OrderBy(p => p.thoigian)
                         .PageBy(input).ToList();

            return(new PagedResultDto <ImageDto>(
                       totalRecord,
                       result.MapTo <List <ImageDto> >()
                       ));
        }
Ejemplo n.º 7
0
        public List <GetImages> GetUserImages(string SearchCondition)
        {
            List <GetImages> ImagesList = new List <GetImages>();

            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString))
            {
                conn.Open();
                using (SqlCommand cmd = new SqlCommand("dbo.Images_Get", conn))
                {
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@SearchCondition", SearchCondition);
                    SqlDataReader reader = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection);
                    while (reader.Read())
                    {
                        GetImages model = Mapper(reader);
                        ImagesList.Add(model);
                    }
                }
                conn.Close();
            }
            return(ImagesList);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create()
        {
            Models.ViewModels.EnemyItem enemyItem = new Models.ViewModels.EnemyItem();

            enemyItem.enemyImages = GetImages.gettheImages("Enemy");


            /*
             * TheLogic.Items items = new Items(_context);
             * enemyItem.AllItems = await items.getAllItems();
             *
             * TheLogic.Types types = new Types(_context);
             * enemyItem.Type = await types.getAllTypes();
             */



            enemyItem.enemyImages = Logic.getImages.gettheImages("Enemy");

            string path = Path.Combine(Environment.CurrentDirectory, @"wwwroot\images\Enemy\");

            enemyItem.enemyImages = new List <string>();
            foreach (string item in Directory.GetFiles(path))
            {
                enemyItem.enemyImages.Add(Path.GetFileName(item));
            }



            enemyItem.AllItems = await _context.Items.ToListAsync();

            //enemyItem.Type = await _context.Types.ToListAsync();
            enemyItem.Enemy = new Enemy();

            return(View(enemyItem));
        }
Ejemplo n.º 9
0
        public String updateScript()
        {
            connection.Open();
            cmd.Connection = connection;

            //Get current directory for style sheets and images
            string appPath = HttpRuntime.AppDomainAppVirtualPath == "/" ? appPath = "" : appPath = HttpRuntime.AppDomainAppVirtualPath;

            //Base api URL
            string newsURL = getNewsURL();
            string baseUrl = getBaseURL();

            ApiContext ac = new ApiContext(newsURL, baseUrl);

            //Since this column is an identity column in the table this value does not actually get inserted.
            int entryID = 0;

            //Used to compare the current BraftonID from the xml feed to the Brafton IDs in the Blog_Entries table
            int compareIDs;

            //Blog_Entries table variables
            string   artBlogID;
            string   title;
            string   entry;
            DateTime addedDate;
            string   description      = string.Empty;
            string   published        = "True";
            string   allowComments    = "False";
            string   displayCopyright = "False";
            string   photoURL;
            string   byline;
            string   caption;
            ////////////////////////////

            //Blog_Categories table variables
            string slug;
            string category;
            int    parentID    = 0;
            int    intPortalID = getPortalID();
            ////////////////////////////

            //This is for storing all of the category xml urls during the iteration
            ArrayList xmlArtCatURLs = new ArrayList();

            //Blog_Entry_Categories table Arrays, these are populated while populating
            //The Blog_Entry DataTable and Blog_Categories DataTable
            ArrayList entryIDArray  = new ArrayList();
            ArrayList categoryArray = new ArrayList();
            /////////////////////////////////////////////////////////////////////////

            DataTable articleTable = DataTables.GetTable("Blog_Entries");

            //For Limit
            int l = 0;

            //Set the limit of the amount of articles that can be imported at a time
            int limit = getLimit();

            //Fill Blog_Entries DataTable
            foreach (newsItem ni in ac.News)
            {
                if (l < limit)
                {
                    artBlogID   = ni.id.ToString();
                    title       = ni.headline;
                    entry       = ni.text;
                    description = ni.extract;
                    addedDate   = ni.publishDate;
                    photoURL    = ni.PhotosHref;
                    byline      = ni.byLine;
                    //////////////////////////////////////////////////////////////////////////

                    //Passes all Brafton posts from the Database into this method and checks to see if this posts already exists
                    cmd.CommandText = "IF (SELECT BraftonID FROM Blog_Entries WHERE BraftonID='" + artBlogID + "') IS NOT NULL BEGIN SELECT 0 END ELSE SELECT 1";
                    compareIDs      = (int)cmd.ExecuteScalar();

                    if (compareIDs == 1)
                    {
                        photo          img           = ni.photos.First();
                        photo.Instance photoInstance = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Large).FirstOrDefault();

                        //Checks to see if large images are enabled on the feed
                        if (photoInstance != null)
                        {
                            photoURL = photoInstance.url.ToString();
                            caption  = img.caption.ToString();

                            //Checks to see if the feed has photos enabled.
                            if (!string.IsNullOrEmpty(photoURL))
                            {
                                GetImages retrieveImage = new GetImages(photoURL, entry, description, appPath, caption);
                                retrieveImage.DownloadImage();



                                //The images is placed into the description and the entry here
                                description = retrieveImage._description;
                                entry       = retrieveImage._entry;

                                //errorCheckingLabel.text = description;
                            }
                        }

                        //Checks to see if the feed has the byline enabled.
                        if (!string.IsNullOrEmpty(byline))
                        {
                            entry = entry.Insert(entry.Length, "<br /><br /><span class='byline'> By " + byline + "</span>");
                        }

                        articleTable.Rows.Add(getBlogID(), entryID, title, entry, addedDate, published, description, allowComments, displayCopyright, null, "", artBlogID);

                        //Place the category URL into the array for future use
                        xmlArtCatURLs.Add(ni.CategoriesHref);

                        //For Future Use with Blog_Entry_Categories
                        entryIDArray.Add(artBlogID);

                        //increment limit
                        l++;
                    }
                }
            }

            //Check to see if the article table is empty, if it is, cancel the whole operation.
            if (articleTable != null && articleTable.Rows.Count > 0)
            {
                //Used to copy the DataTables to the MSSQL Database
                using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                {
                    bulkCopy.DestinationTableName = "Blog_Entries";
                    bulkCopy.WriteToServer(articleTable);
                }

                DataTable categoryTable = DataTables.GetTable("Blog_Categories");
                /////////////////////////////////////////////////////////////

                //Fill Blog_Categories DataTable
                for (int i = 0; i < articleTable.Rows.Count; i++)
                {
                    XmlDocument tmpXMLDoc = new XmlDocument();
                    tmpXMLDoc.Load(xmlArtCatURLs[i].ToString());
                    XmlNode name = tmpXMLDoc.GetElementsByTagName("name")[0];

                    if (name != null)
                    {
                        category = name.InnerText;
                    }
                    else
                    {
                        category = "Uncategorized";
                    }

                    slug = strip(category) + ".aspx";

                    cmd.CommandText = "IF (SELECT Category FROM Blog_Categories WHERE Category='" + category + "') IS NOT NULL BEGIN SELECT 0 END ELSE SELECT 1";
                    compareIDs      = (int)cmd.ExecuteScalar();

                    if (compareIDs == 1)
                    {
                        //Compares the rows in the categoryTable to the category currently being processed.
                        categoryTable.DefaultView.Sort = "Category";
                        int findRow = categoryTable.DefaultView.Find(category);

                        if (findRow == -1)
                        {
                            //Create the row in the datatable
                            categoryTable.Rows.Add(entryID, category, slug, parentID, intPortalID);
                        }
                    }

                    //For Future Use with Blog_Entry_Categories
                    categoryArray.Add(category);
                }

                //Used to copy the DataTables to the MSSQL Database
                if (categoryTable != null && categoryTable.Rows.Count > 0)
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                    {
                        bulkCopy.DestinationTableName = "Blog_Categories";
                        bulkCopy.WriteToServer(categoryTable);
                    }
                }

                //Temporary variables that change with each iteration
                int    tempCatID;
                int    tempEntryID;
                string tempSlug;
                int    PageTabId = getTabID();

                //Match the CategoryIDs with the EntryIDs for the Blog_Entry_Categories Table
                DataTable catEntryTable = DataTables.GetTable("Blog_Entry_Categories");
                for (int i = 0; i < articleTable.Rows.Count; i++)
                {
                    category  = categoryArray[i].ToString();
                    artBlogID = entryIDArray[i].ToString();

                    cmd.CommandText = "Select EntryID From Blog_Entries Where BraftonID = '" + artBlogID + "'";
                    tempEntryID     = (int)cmd.ExecuteScalar();

                    cmd.CommandText = "Select Title From Blog_Entries Where BraftonID = '" + artBlogID + "'";
                    tempSlug        = (string)cmd.ExecuteScalar();

                    cmd.CommandText = "Select CatID From Blog_Categories Where Category ='" + category + "'";
                    tempCatID       = (int)cmd.ExecuteScalar();

                    catEntryTable.Rows.Add(entryID, tempEntryID, tempCatID);

                    //For Permalinks
                    setPermalinks(PageTabId, tempEntryID, tempSlug, artBlogID);
                }

                //Used to copy the DataTables to the MSSQL Database
                if (catEntryTable != null && catEntryTable.Rows.Count > 0)
                {
                    using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                    {
                        bulkCopy.DestinationTableName = "Blog_Entry_Categories";
                        bulkCopy.WriteToServer(catEntryTable);
                    }
                }

                //Dispose of all of the tables, datasets and commands
                catEntryTable.Dispose();
                categoryTable.Dispose();
            }

            articleTable.Dispose();
            cmd.Dispose();

            connection.Close();

            return(description);
        }
Ejemplo n.º 10
0
        public string updateScriptDebug()
        {
            if (MyGlobals.ArtOrBlog == "articles")
            {
                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Start of articles<br>";
                connection.Open();
                cmd.Connection = connection;

                //Get current directory for style sheets and images
                //was getting errors from the following so simplified it to AppDomainAppPath.ToString();
                string appPath = HttpRuntime.AppDomainAppVirtualPath == "/" ? appPath = "" : appPath = HttpRuntime.AppDomainAppVirtualPath;
                //string appPath = HttpRuntime.AppDomainAppVirtualPath.ToString();//AppDomainAppPath

                //Base api URL
                string newsURL = getNewsURL();
                string baseUrl = getBaseURL();
                //  MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>************************************************<br>";
                // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "newsURL " + newsURL + "<br>";
                //  MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "baseUrl " + baseUrl + "<br>";
                // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "<br>************************************************<br>";

                ApiContext ac;

                if (MyGlobals.ArtOrBlog == "archive")
                {
                    ac = new ApiContext(MyGlobals.ArchiveLink);
                }
                else
                {
                    ac = new ApiContext(newsURL, baseUrl);
                }

                //Since this column is an identity column in the table this value does not actually get inserted.
                int entryID = 0;

                //Used to compare the current BraftonID from the xml feed to the Brafton IDs in the Blog_Entries table
                int compareIDs;

                //Blog_Entries table variables
                string   artBlogID;
                string   title;
                string   entry;
                DateTime addedDate;
                string   description       = string.Empty;
                string   description_debug = string.Empty;
                bool     published         = true;
                bool     allowComments     = false;
                bool     displayCopyright  = false;
                string   photoURL;
                string   byline;
                string   caption;
                int      PageTabId = getTabID();
                ////////////////////////////

                //Blog_Categories table variables
                string slug;
                string category;
                int    parentID    = 0;
                int    intPortalID = getPortalID();
                ////////////////////////////

                //This is for storing all of the category xml urls during the iteration
                ArrayList xmlArtCatURLs = new ArrayList();

                //Blog_Entry_Categories table Arrays, these are populated while populating
                //The Blog_Entry DataTable and Blog_Categories DataTable
                ArrayList entryIDArray  = new ArrayList();
                ArrayList categoryArray = new ArrayList();
                /////////////////////////////////////////////////////////////////////////

                DataTable articleTable = DataTables.GetTable("Blog_Entries");

                //For Limit
                int l = 0;

                //Set the limit of the amount of articles that can be imported at a time
                int limit = getLimit();


                #region Article Loop DEBUG
                //Fill Blog_Entries DataTable
                foreach (newsItem ni in ac.News)
                {
                    if (l < limit)
                    {
                        artBlogID   = ni.id.ToString();
                        title       = ni.headline;
                        entry       = ni.text;
                        description = ni.extract;
                        addedDate   = ni.publishDate;
                        photoURL    = ni.PhotosHref;
                        byline      = ni.byLine;
                        DateTime today = DateTime.Today;
                        //for operations after update or insert
                        int    entryId;
                        string tempSlug;



                        using (DNNDataLayerDataContext dnnContext = new DNNDataLayerDataContext())
                        {
                            Blog_Entry be = dnnContext.Blog_Entries.FirstOrDefault(x => x.BraftonID == artBlogID);

                            if (be != null)
                            {
                                #region Update Article
                                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Start of update<br>";

                                //If update feed content is on we do some stuff
                                int updateCheck = MyGlobals.IncludeUpdatedFeedContent;
                                int lastDayUpd  = 0;
                                int todayDay    = 0;

                                lastDayUpd = be.LastUpdatedOn.Value.DayOfYear;
                                //todayDay = DateTime.Today.DayOfYear;
                                //TODO set this check back in place FJD


                                //if the article has not been updated today
                                if (lastDayUpd != todayDay)
                                {
                                    //if they have updated feed content checked
                                    if (updateCheck == 1)
                                    {
                                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                        //Update the article
                                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                        //Lets get the entryID that matches the BraftonID
                                        //But if there isn't one it means this is a new article and we should skip the update

                                        //cmd.CommandText = "IF (SELECT EntryID FROM Blog_Entries WHERE BraftonID='" + artBlogID + "') IS NULL BEGIN SELECT 0 END ELSE (SELECT EntryID FROM Blog_Entries WHERE BraftonID=" + artBlogID + ")";

                                        //int getDNNID = (int)cmd.ExecuteScalar();

                                        //if (getDNNID > 0)
                                        //{
                                        // DateTime today = DateTime.Today;
                                        //string displayDate = today.ToString("dd/MM/yyyy");

                                        #region IMAGE HANDLER

                                        //photo img = ni.photos.First();
                                        //photo.Instance photoInstance = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Medium).FirstOrDefault();
                                        //string photoTest = photoInstance.type.ToString();

                                        photo          img = ni.photos.First();
                                        photo.Instance photoInstanceLarge  = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Large).FirstOrDefault();
                                        photo.Instance photoInstanceMedium = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Medium).FirstOrDefault();
                                        photo.Instance photoInstanceSmall  = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Small).FirstOrDefault();
                                        photo.Instance photoInstance;

                                        if (photoInstanceLarge != null)
                                        {
                                            photoInstance = photoInstanceLarge;
                                            //MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Large<br>";
                                        }
                                        else if (photoInstanceMedium != null)
                                        {
                                            photoInstance = photoInstanceMedium;
                                            // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Medium<br>";
                                        }
                                        else if (photoInstanceSmall != null)
                                        {
                                            photoInstance = photoInstanceSmall;
                                            // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Small<br>";
                                        }
                                        else
                                        {
                                            photoInstance = null;
                                        }
                                        //Otherwise leave it as null and move on


                                        //Checks to see if large images are enabled on the feed
                                        if (photoInstance != null)
                                        {
                                            photoURL = photoInstance.url.ToString();
                                            caption  = img.caption.ToString();


                                            //Checks to see if the feed has photos enabled.
                                            if (!string.IsNullOrEmpty(photoURL))
                                            {
                                                GetImages retrieveImage2 = new GetImages(photoURL, entry, description, appPath, caption);
                                                retrieveImage2.DownloadImageDebug();

                                                //The images is placed into the description and the entry here


                                                entry                   = retrieveImage2._entry;
                                                description             = retrieveImage2._description;
                                                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "**********************************************************<br>";
                                                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "brafton ID: " + artBlogID + "<br>";
                                                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Description: " + description + "<br>";
                                                MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "**********************************************************<br>";
                                                //string testUrl = HttpContext.Current.Request.Url.Host;
                                            }
                                        }



                                        #endregion IMAGE HANDLER

                                        //Checks to see if the feed has the byline enabled.
                                        if (!string.IsNullOrEmpty(byline))
                                        {
                                            entry = entry.Insert(entry.Length, "<br /><br /><span class='byline'> By " + byline + "</span>");
                                        }


                                        #region Update Article


                                        be.Title       = title;
                                        be.Entry       = entry;
                                        be.Description = description;
                                        //be.Copyright = null;
                                        be.LastUpdatedOn = today;
                                        be.AllowComments = false;
                                        //dnnContext.
                                        dnnContext.SubmitChanges();
                                        #endregion

                                        entryId  = be.EntryID;
                                        tempSlug = title;

                                        //Update Permalinks
                                        setPermalinks(PageTabId, entryId, tempSlug, artBlogID);
                                    } //end of update check
                                }     //end of check for update today
                                #endregion Update Article
                            }

                            else

                            {
                                #region New Article
                                photo          img = ni.photos.First();
                                photo.Instance photoInstanceLarge  = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Large).FirstOrDefault();
                                photo.Instance photoInstanceMedium = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Medium).FirstOrDefault();
                                photo.Instance photoInstanceSmall  = img.Instances.Where(x => x.type == enumeratedTypes.enumPhotoInstanceType.Small).FirstOrDefault();
                                photo.Instance photoInstance;

                                if (photoInstanceLarge != null)
                                {
                                    photoInstance = photoInstanceLarge;
                                    // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Large<br>";
                                }
                                else if (photoInstanceMedium != null)
                                {
                                    photoInstance = photoInstanceMedium;
                                    //  MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Medium<br>";
                                }
                                else if (photoInstanceSmall != null)
                                {
                                    photoInstance = photoInstanceSmall;
                                    // MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Using Small<br>";
                                }
                                //Otherwise leave it as null and move on
                                else
                                {
                                    photoInstance = null;
                                }



                                #region IMAGE HANDLER
                                //Checks to see if medium images are enabled on the feed
                                if (photoInstance != null)
                                {
                                    photoURL = photoInstance.url.ToString();
                                    caption  = img.caption.ToString();

                                    //Checks to see if the feed has photos enabled.
                                    if (!string.IsNullOrEmpty(photoURL))
                                    {
                                        GetImages retrieveImage2 = new GetImages(photoURL, entry, description, appPath, caption);
                                        retrieveImage2.DownloadImageDebug();

                                        //The images is placed into the description and the entry here

                                        description_debug = retrieveImage2._description;
                                        entry             = retrieveImage2._entry;
                                    }
                                }
                                #endregion IMAGE HANDLER
                                //Checks to see if the feed has the byline enabled.
                                if (!string.IsNullOrEmpty(byline))
                                {
                                    entry = entry.Insert(entry.Length, "<br /><br /><span class='byline'> By " + byline + "</span>");
                                }

                                Blog_Entry newBlogEntry = new Blog_Entry();

                                newBlogEntry.BlogID           = getBlogID();
                                newBlogEntry.Title            = title;
                                newBlogEntry.Entry            = entry;
                                newBlogEntry.AddedDate        = addedDate;
                                newBlogEntry.Published        = published;
                                newBlogEntry.Description      = description_debug;
                                newBlogEntry.AllowComments    = allowComments;
                                newBlogEntry.DisplayCopyright = displayCopyright;
                                newBlogEntry.BraftonID        = artBlogID;
                                newBlogEntry.LastUpdatedOn    = today;

                                dnnContext.Blog_Entries.InsertOnSubmit(newBlogEntry);
                                dnnContext.SubmitChanges();



                                entryId  = newBlogEntry.EntryID;
                                tempSlug = title;


                                //For Permalinks
                                setPermalinks(PageTabId, entryId, tempSlug, artBlogID);

                                ///////////////////////////////////////////////////

                                //Place the category URL into the array for future use
                                xmlArtCatURLs.Add(ni.CategoriesHref);

                                //For Future Use with Blog_Entry_Categories
                                entryIDArray.Add(artBlogID);

                                //increment limit
                                l++;
                                /////////////////////////////////////////////////////
                                #endregion New Article
                            }
                        }

                        //////Passes all Brafton posts from the Database into this method and checks to see if this posts already exists
                        ////cmd.CommandText = "IF (SELECT BraftonID FROM Blog_Entries WHERE BraftonID='" + artBlogID + "') IS NOT NULL BEGIN SELECT 0 END ELSE SELECT 1";
                        //////cmd.CommandText = "SELECT 1";
                        ////compareIDs = (int)cmd.ExecuteScalar();

                        ////if it doesn't exist
                        //if (compareIDs == 1)
                        //#region Write Article DEBUG

                        //{



                        //   // articleTable.Rows.Add(getBlogID(), entryID, title, entry, addedDate, published, description, allowComments, displayCopyright, null, "", artBlogID);



                        //}

                        //else

                        //    //***************************************************************************************
                        //    //***************************************************************************************
                        //    //***************************************************************************************


                        //}
                        //#endregion Write Article DEBUG
                    }
                }

                #endregion Article Loop DEBUG
                //Check to see if the article table is empty, if it is, cancel the whole operation.
                if (articleTable != null && articleTable.Rows.Count > 0)
                {
                    ///////////////////////////////////////////////////////////////////////////////////
                    //TODO: category stuff
                    ///////////////////////////////////////////////////////////////////////////////////
                    #region Category stuff


                    using (DNNDataLayerDataContext dnnContext = new DNNDataLayerDataContext())
                    {
                        //Blog_Category bc = dnnContext.Blog_Categories.FirstOrDefault(x => x.Category == artBlogID);
                    }


                    //Used to copy the DataTables to the MSSQL Database
                    //using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                    //{
                    //    bulkCopy.DestinationTableName = "Blog_Entries";
                    //    bulkCopy.WriteToServer(articleTable);
                    //}

                    DataTable categoryTable = DataTables.GetTable("Blog_Categories");
                    /////////////////////////////////////////////////////////////

                    //Fill Blog_Categories DataTable
                    for (int i = 0; i < articleTable.Rows.Count; i++)
                    {
                        XmlDocument tmpXMLDoc = new XmlDocument();
                        tmpXMLDoc.Load(xmlArtCatURLs[i].ToString());
                        XmlNode name = tmpXMLDoc.GetElementsByTagName("name")[0];

                        if (name != null)
                        {
                            category = name.InnerText;
                        }
                        else
                        {
                            category = "Uncategorized";
                        }

                        slug = strip(category) + ".aspx";

                        cmd.CommandText = "IF (SELECT Category FROM Blog_Categories WHERE Category='" + category + "') IS NOT NULL BEGIN SELECT 0 END ELSE SELECT 1";
                        compareIDs      = (int)cmd.ExecuteScalar();

                        if (compareIDs == 1)
                        {
                            //Compares the rows in the categoryTable to the category currently being processed.
                            categoryTable.DefaultView.Sort = "Category";
                            int findRow = categoryTable.DefaultView.Find(category);

                            if (findRow == -1)
                            {
                                //Create the row in the datatable
                                categoryTable.Rows.Add(entryID, category, slug, parentID, intPortalID);
                            }
                        }

                        //For Future Use with Blog_Entry_Categories
                        categoryArray.Add(category);
                    }

                    //Used to copy the DataTables to the MSSQL Database
                    if (categoryTable != null && categoryTable.Rows.Count > 0)
                    {
                        using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                        {
                            bulkCopy.DestinationTableName = "Blog_Categories";
                            //bulkCopy.WriteToServer(categoryTable);
                        }
                    }

                    //Temporary variables that change with each iteration
                    int    tempCatID;
                    int    tempEntryID;
                    string tempSlug;
                    //int PageTabId = getTabID();

                    //Match the CategoryIDs with the EntryIDs for the Blog_Entry_Categories Table
                    DataTable catEntryTable = DataTables.GetTable("Blog_Entry_Categories");
                    for (int i = 0; i < articleTable.Rows.Count; i++)
                    {
                        category  = categoryArray[i].ToString();
                        artBlogID = entryIDArray[i].ToString();

                        cmd.CommandText = "Select EntryID From Blog_Entries Where BraftonID = '" + artBlogID + "'";
                        tempEntryID     = (int)cmd.ExecuteScalar();

                        cmd.CommandText = "Select Title From Blog_Entries Where BraftonID = '" + artBlogID + "'";
                        tempSlug        = (string)cmd.ExecuteScalar();

                        cmd.CommandText = "Select CatID From Blog_Categories Where Category ='" + category + "'";
                        tempCatID       = (int)cmd.ExecuteScalar();

                        catEntryTable.Rows.Add(entryID, tempEntryID, tempCatID);

                        //For Permalinks
                        //setPermalinks(PageTabId, tempEntryID, tempSlug, artBlogID);
                    }

                    //Used to copy the DataTables to the MSSQL Database
                    if (catEntryTable != null && catEntryTable.Rows.Count > 0)
                    {
                        using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection))
                        {
                            bulkCopy.DestinationTableName = "Blog_Entry_Categories";
                            bulkCopy.WriteToServer(catEntryTable);
                        }
                    }

                    //Dispose of all of the tables, datasets and commands
                    catEntryTable.Dispose();
                    categoryTable.Dispose();
                }

                articleTable.Dispose();
                cmd.Dispose();

                connection.Close();
                #endregion Category Stuff

                return(description_debug);
            }//end of articles
            MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "Video Include Global =" + MyGlobals.IncludeVideo;
            //If the feed includes videos
            if (MyGlobals.IncludeVideo == 1)
            {
                ImportVideos();
            }
            MyGlobals.MyGlobalError = MyGlobals.MyGlobalError + "ARTORBLOG" + MyGlobals.ArtOrBlog;
            string returnVal = "include video";
            return(returnVal);
        }
        private async Task InitializationDataAsync()
        {
            var getimage = new GetImages();

            ImageList = getimage.GetImage();
        }
Ejemplo n.º 12
0
        readonly List<string> ImageSizes = new[] { "320x480" }.ToList(); //{ "320x480", "640x960", "640x1136", "768x1024", "1536x2048" }.ToList()

        public object Get(GetImages request)
        {
            return Directory.GetFiles(UploadsDir).Map(x => x.SplitOnLast(Path.DirectorySeparatorChar).Last());
        }