예제 #1
0
        public JsonResult ApprovePost(int?Id)
        {
            try
            {
                using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                {
                    var      currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal;
                    var      UserId      = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault();
                    NewsPost newsPost    = portalEntities.NewsPosts.Where(x => x.Id == Id).FirstOrDefault();
                    newsPost.IsReviewed = true;
                    newsPost.ReviewedBy = int.Parse(UserId);;
                    portalEntities.NewsPosts.Attach(newsPost);
                    portalEntities.Entry(newsPost).State = EntityState.Modified;
                    portalEntities.SaveChanges();
                    string category = newsType.GetByID(x => x.Id == newsPost.CategoryId).NewsType;
                    var    webadrs  = ConfigurationManager.AppSettings["webid"];
                    Task.Factory.StartNew(() => new apiPlugin().pagePublish(newsPost.OdiaTitle, (webadrs + "/News/" + category + "/" + newsPost.PostedYear + "/" + newsPost.PostedMonth + "/" + Id + "/" + newsPost.SlugUrl)));
                }
                Task.Factory.StartNew(() => new NewsOprations().UpdateData());

                return(Json(new { msg = "Post Approved Successfully" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            return(Json(new { msg = "Post Approve Unsucessful" }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
 public void UpdateData()
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             var item = portalEntities.Database.SqlQuery <int>("usp_LatestPopular");
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
예제 #3
0
 public int CheckRoleName(string RoleName)
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             var items = portalEntities.tblRoles.Where(x => x.RoleName == RoleName).ToList().Count;
             return(items);
         }
     }
     catch (Exception ex)
     {
     }
     return(0);
 }
예제 #4
0
 public int CheckNewsType(string NewsType)
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             var items = portalEntities.tblNewsType.Where(x => x.NewsType == NewsType).ToList().Count;
             return(items);
         }
     }
     catch (Exception ex)
     {
     }
     return(0);
 }
예제 #5
0
 public clsUser getCurrentUserId(int userId)
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             var item = portalEntities.Database.SqlQuery <clsUser>("usp_GetUser @UserId", new SqlParameter("@UserId", userId)).FirstOrDefault();
             return(item);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(null);
 }
예제 #6
0
 public JsonResult GetTopicData(int?Id)
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             var item = (from news in portalEntities.NewsPosts
                         where news.Id == Id
                         select new { news.OdiaTitle, news.Tags, news.SeoMeta, news.PostedOn, news.ODShortDesc, news.EnglishTitle, news.ODContent }).FirstOrDefault();
             return(Json(item, JsonRequestBehavior.AllowGet));
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(null);
 }
예제 #7
0
 public async Task Execute(IJobExecutionContext context)
 {
     Log.Info("Job was getting called");
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             using (SqlConnection connection = new SqlConnection(portalEntities.Database.Connection.ConnectionString))
             {
                 var item = portalEntities.SchdulePostConfig.ToList();
                 foreach (var lvltem in item)
                 {
                     if (lvltem.ScheduleTime <= DateTime.Now)
                     {
                         try
                         {
                             SqlCommand cmd = new SqlCommand("usp_AutoPublish", connection);
                             cmd.Parameters.Add("@PostId", SqlDbType.Decimal).Value = lvltem.PostId;
                             cmd.CommandType    = CommandType.StoredProcedure;
                             cmd.CommandTimeout = 90;
                             if (connection.State == ConnectionState.Closed)
                             {
                                 connection.Open();
                             }
                             int i = cmd.ExecuteNonQuery();
                             connection.Close();
                         }
                         catch (Exception ex)
                         {
                             Log.Error("Error Inside Loop", ex);
                         }
                     }
                     Thread.Sleep(1000);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex);
     }
 }
예제 #8
0
 public ActionResult LoginUser(Users _user)
 {
     using (NewsPortalEntities dBEntities = new NewsPortalEntities())
     {
         var userexist = dBEntities.tblUses.Where(x => x.UserName == _user.UserName && x.Password == _user.Password).ToList();
         if (userexist.Count == 0)
         {
             return(View("Home", "About"));
         }
         var identity = new ClaimsIdentity(new[] {
             new Claim(ClaimTypes.Sid, userexist.FirstOrDefault().UserName),
             new Claim(ClaimTypes.Email, userexist.FirstOrDefault().EmailId),
             new Claim(ClaimTypes.MobilePhone, userexist.FirstOrDefault().PhoneNo),
         }, "ApplicationCookie");
         var ctx         = Request.GetOwinContext();
         var authManager = ctx.Authentication;
         authManager.SignIn(identity);
     }
     return(View());
 }
예제 #9
0
 public decimal NewsPost(ClsPost objclsPost)
 {
     try
     {
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             NewsPost newsPost = new NewsPost();
             newsPost.EnglishTitle    = objclsPost.EnglishTitle;
             newsPost.OdiaTitle       = objclsPost.OdiaTitle;
             newsPost.EngShortDesc    = objclsPost.EngShortDesc;
             newsPost.ODShortDesc     = objclsPost.ODShortDesc;
             newsPost.SeoMeta         = objclsPost.SeoMeta;
             newsPost.Tags            = objclsPost.Tags;
             newsPost.CategoryId      = objclsPost.CategoryId;
             newsPost.HeaderImageName = objclsPost.ImageName;
             newsPost.ODContent       = objclsPost.ODContent;
             newsPost.IsActive        = true;
             newsPost.IsDeleted       = false;
             newsPost.IsReviewed      = objclsPost.IsReviewed;
             newsPost.CreatedBy       = objclsPost.CreatedBy;
             newsPost.ReviewedBy      = objclsPost.ReviewedBy;
             newsPost.PostedDate      = objclsPost.PostedDate;
             newsPost.PostedOn        = objclsPost.PostedOn;
             newsPost.PostedMonth     = objclsPost.PostedMonth;
             newsPost.PostedYear      = objclsPost.PostedYear;
             newsPost.SlugUrl         = objclsPost.SlugUrl;
             newsPost.Thumbnail86     = objclsPost.ImageName.Replace("Img", "Thumbnail_86x64");
             newsPost.Thumbnail210    = objclsPost.ImageName.Replace("Img", "Thumbnail_210x136");
             newsPost.Thumbnail279    = objclsPost.ImageName.Replace("Img", "Thumbnail_279x220");
             newsPost.Frequency       = 0;
             portalEntities.NewsPosts.Add(newsPost);
             portalEntities.SaveChanges();
             return(newsPost.Id);
         }
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(0);
 }
예제 #10
0
 public OpertionClass(NewsPortalEntities context)
 {
     this._context = context;
     this._table   = _context.Set <T>();
 }
예제 #11
0
 public OpertionClass()
 {
     this._context = new NewsPortalEntities();
     this._table   = _context.Set <T>();
 }
예제 #12
0
        public ContentResult HeaderImageUpload()
        {
            NewsPost nps = new NewsPost();

            try
            {
                int    NewsId     = 0;
                string FolderName = "";
                string path       = "";
                if (Request.Params["newsID"] == "0")
                {
                    using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                    {
                        NewsId = portalEntities.NewsPosts.Where(x => x.PostedDate.Value.Year == DateTime.Now.Year && x.PostedDate.Value.Month == DateTime.Now.Month && x.PostedDate.Value.Day == DateTime.Now.Day).ToList().Count;
                    }
                    NewsId = NewsId + 1;

                    FolderName = DateTime.Now.Date.ToString("ddMMyyyy");
                    path       = Server.MapPath("~/Uploads/" + FolderName + "/" + NewsId);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                else
                {
                    using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                    {
                        decimal newsID = Convert.ToDecimal(Request.Params["newsID"]);
                        nps = portalEntities.NewsPosts.Where(x => x.Id == newsID).FirstOrDefault();
                        string ImageName = "";
                        if (nps != null)
                        {
                            DeleteImage(nps.HeaderImageName);
                            ImageName  = nps.HeaderImageName;
                            FolderName = ImageName.Split('/')[0];
                            NewsId     = int.Parse(ImageName.Split('/')[1]);
                        }
                    }
                    path = Server.MapPath("~/Uploads/" + FolderName + "/" + NewsId);
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                string ImageUrl = "";
                string filename = "";
                string imgId    = DateTime.Now.Hour + "" + DateTime.Now.Minute;
                foreach (string key in Request.Files)
                {
                    HttpPostedFileBase postedFile = Request.Files[key];
                    ImageUrl = Path.Combine(path, "Img_" + imgId + ".jpg");
                    Stream strm     = postedFile.InputStream;
                    int    flstatus = GenerateThumbnails(0.2, strm, ImageUrl, 400, 210);
                    filename = postedFile.FileName;
                    CreateThumbnail(postedFile, NewsId, FolderName, imgId);
                    CreateThumbnail279(postedFile, NewsId, FolderName, imgId);
                    CreateThumbnail210(postedFile, NewsId, FolderName, imgId);
                }
                if (Request.Params["newsID"] != "0")
                {
                    string Image = FolderName + "/" + NewsId + "/" + "Img_" + imgId + ".jpg";
                    using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                    {
                        decimal  newsID   = Convert.ToDecimal(Request.Params["newsID"]);
                        NewsPost newsPost = portalEntities.NewsPosts.Where(x => x.Id == newsID).FirstOrDefault();
                        newsPost.HeaderImageName = Image;
                        newsPost.Thumbnail86     = Image.Replace("Img", "Thumbnail_86x64");
                        newsPost.Thumbnail210    = Image.Replace("Img", "Thumbnail_210x136");
                        newsPost.Thumbnail279    = Image.Replace("Img", "Thumbnail_279x220");
                        portalEntities.NewsPosts.Attach(newsPost);
                        portalEntities.Entry(newsPost).State = EntityState.Modified;
                        portalEntities.SaveChanges();
                    }
                }
                return(Content(FolderName + "/" + NewsId + "/" + "Img_" + imgId + ".jpg"));
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }
            return(null);
        }
예제 #13
0
        public JsonResult UploadFile()
        {
            string   ImageUrl = string.Empty;
            string   filename = string.Empty;
            NewsPost nps      = new NewsPost();

            try
            {
                int    NewsId     = 0;
                string FolderName = "";
                string path       = "";
                if (Request.Params["NewsId"] == "0")
                {
                    using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                    {
                        NewsId = portalEntities.NewsPosts.Where(x => x.PostedDate.Value.Year == DateTime.Now.Year && x.PostedDate.Value.Month == DateTime.Now.Month && x.PostedDate.Value.Day == DateTime.Now.Day).ToList().Count;
                    }
                    NewsId = NewsId + 1;

                    FolderName = DateTime.Now.Date.ToString("ddMMyyyy");
                    path       = Server.MapPath("~/Uploads/" + FolderName + "/" + NewsId + "/Content");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }
                else
                {
                    using (NewsPortalEntities portalEntities = new NewsPortalEntities())
                    {
                        decimal newsID = Convert.ToDecimal(Request.Params["NewsId"]);
                        nps = portalEntities.NewsPosts.Where(x => x.Id == newsID).FirstOrDefault();
                        string ImageName = "";
                        if (nps != null)
                        {
                            ImageName  = nps.HeaderImageName;
                            FolderName = ImageName.Split('/')[0];
                            NewsId     = int.Parse(ImageName.Split('/')[1]);
                        }
                    }
                    path = Server.MapPath("~/Uploads/" + FolderName + "/" + NewsId + "/Content");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                }

                string imgId = DateTime.Now.Minute + "" + DateTime.Now.Second;
                if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
                {
                    var postedFile = System.Web.HttpContext.Current.Request.Files["Image"];
                    if (postedFile.ContentLength > 0)
                    {
                        ImageUrl = Path.Combine(path, "Img_" + imgId + ".jpg");
                        Stream strm     = postedFile.InputStream;
                        int    flstatus = GenerateThumbnails(0.2, strm, ImageUrl, 400, 210);
                        filename = HttpContext.Request.Url.Scheme + "://" + HttpContext.Request.Url.Authority + "/Uploads/" + FolderName + "/" + NewsId + "/Content/Img_" + imgId + ".jpg";
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex.ToString());
            }

            return(Json(Convert.ToString(filename), JsonRequestBehavior.AllowGet));
        }
예제 #14
0
 public JsonResult UpdatePost(ClsPost clsPost)
 {
     try
     {
         var currentUser = (ClaimsPrincipal)Thread.CurrentPrincipal;
         var UserId      = currentUser.Claims.Where(x => x.Type == ClaimTypes.PrimarySid).Select(c => c.Value).SingleOrDefault();
         var Role        = currentUser.Claims.Where(x => x.Type == ClaimTypes.Role).Select(c => c.Value).SingleOrDefault();
         clsPost.IsReviewed = false;
         if (clsPost.IsSchedule == false)
         {
             if (Role == "SuperAdmin" || Role == "Admin")
             {
                 clsPost.ReviewedBy = int.Parse(UserId);
                 clsPost.IsReviewed = true;
             }
         }
         clsPost.Modified = DateTime.Now;
         bool IsReviewed = false;
         using (NewsPortalEntities portalEntities = new NewsPortalEntities())
         {
             NewsPost newsPost = portalEntities.NewsPosts.Where(x => x.Id == clsPost.Id).FirstOrDefault();
             IsReviewed               = newsPost.IsReviewed.Value;
             newsPost.EnglishTitle    = clsPost.EnglishTitle;
             newsPost.OdiaTitle       = clsPost.OdiaTitle;
             newsPost.EngShortDesc    = clsPost.EngShortDesc;
             newsPost.ODShortDesc     = clsPost.ODShortDesc;
             newsPost.SeoMeta         = clsPost.SeoMeta;
             newsPost.Tags            = clsPost.Tags;
             newsPost.CategoryId      = clsPost.CategoryId;
             newsPost.HeaderImageName = clsPost.ImageName;
             newsPost.ODContent       = clsPost.ODContent;
             newsPost.IsReviewed      = clsPost.IsReviewed;
             newsPost.ReviewedBy      = clsPost.ReviewedBy;
             newsPost.ModifiedOn      = clsPost.Modified;
             newsPost.Thumbnail86     = clsPost.ImageName.Replace("Img", "Thumbnail_86x64");
             newsPost.Thumbnail210    = clsPost.ImageName.Replace("Img", "Thumbnail_210x136");
             newsPost.Thumbnail279    = clsPost.ImageName.Replace("Img", "Thumbnail_279x220");
             newsPost.SlugUrl         = UrlGenerator.GetUrl(clsPost.EnglishTitle);
             portalEntities.NewsPosts.Attach(newsPost);
             portalEntities.Entry(newsPost).State = EntityState.Modified;
             portalEntities.SaveChanges();
             //if(IsReviewed==false)
             {
                 if (Role == "SuperAdmin" || Role == "Admin")
                 {
                     string category = newsType.GetByID(x => x.Id == newsPost.CategoryId).NewsType;
                     var    webadrs  = ConfigurationManager.AppSettings["webid"];
                     Task.Factory.StartNew(() => new apiPlugin().pagePublish(newsPost.OdiaTitle, (webadrs + "/News/" + category + "/" + newsPost.PostedYear + "/" + newsPost.PostedMonth + "/" + clsPost.Id + "/" + newsPost.SlugUrl)));
                 }
             }
         }
         Task.Factory.StartNew(() => new NewsOprations().UpdateData());
         if (clsPost.IsSchedule == true)
         {
             try
             {
                 SchdulePostConfig schPostConfig = schulepostconfig.GetByID(x => x.PostId == clsPost.Id);
                 if (schPostConfig != null)
                 {
                     schPostConfig.PostId       = clsPost.Id;
                     schPostConfig.PostedOn     = DateTime.Now;
                     schPostConfig.ScheduleTime = DateTime.Now.AddHours(clsPost.Delay);
                     schPostConfig.TimeDelay    = clsPost.Delay;
                     schulepostconfig.Edit(schPostConfig);
                     schulepostconfig.Save();
                 }
                 else
                 {
                     SchdulePostConfig scPostConfig = new SchdulePostConfig();
                     scPostConfig.PostId       = clsPost.Id;
                     scPostConfig.PostedOn     = DateTime.Now;
                     scPostConfig.ScheduleTime = DateTime.Now.AddHours(clsPost.Delay);
                     scPostConfig.TimeDelay    = clsPost.Delay;
                     schulepostconfig.Insert(scPostConfig);
                     schulepostconfig.Save();
                 }
             }
             catch (Exception ex)
             {
                 Log.Error("Update News schdule issue", ex);
             }
         }
         else
         {
             try
             {
                 SchdulePostConfig schPostConfig = schulepostconfig.GetByID(x => x.PostId == clsPost.Id);
                 if (schPostConfig != null)
                 {
                     schulepostconfig.Delete(x => x.PostId == clsPost.Id);
                     schulepostconfig.Save();
                 }
             }
             catch (Exception ex)
             {
                 Log.Error("Delete News schdule issue", ex);
             }
         }
         return(Json(new { msg = "Post Updated Successfully" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
     return(Json(new { msg = "Post Updation Unsucessful" }, JsonRequestBehavior.AllowGet));
 }