Ejemplo n.º 1
0
        public ActionResult ResetImage(int ID)
        {
            //string fileName = Server.MapPath(@"..\..\UsersData\Logo\Images\No_Image.png");
            string fileName = "../../UsersData/Logo/Images/No_Image.png";

            byte[] defaultImage = System.IO.File.ReadAllBytes(Server.MapPath(fileName));
            DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();

            DSRCManagementSystem.Master_ApplicationSettings obj = new DSRCManagementSystem.Master_ApplicationSettings();
            try
            {
                var dbImageLogo = db.Master_ApplicationSettings.FirstOrDefault(x => x.AppID == 7);
                dbImageLogo.AppValue = fileName;
                db.SaveChanges();
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json(true, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult ThemeSettings(DSRCManagementSystem.Models.ThemeSettings collection)
        {
            ViewBag.Message = "";
            DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1();

            DSRCManagementSystem.Master_ApplicationSettings obj = new DSRCManagementSystem.Master_ApplicationSettings();
            try
            {
                var Photopath     = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Log").Select(o => o).FirstOrDefault();
                var fileExtension = collection.Photo != null?Path.GetExtension(collection.Photo.FileName) : "";

                if (fileExtension == ".gif" || fileExtension == ".jpg" || fileExtension == ".jpeg" || fileExtension == ".png" || fileExtension == "")
                {
                    if (collection.Photo != null)
                    {
                        string   _filePath         = Path.GetDirectoryName(System.AppDomain.CurrentDomain.BaseDirectory);
                        FileInfo fileInfo          = new FileInfo(_filePath);
                        string   directoryFullPath = fileInfo.DirectoryName + @"\DSRCHRMSRemainderService\Templates\logo.png";
                        bool     ImgExists         = System.IO.File.Exists(directoryFullPath);
                        var      valpath           = Path.Combine(directoryFullPath);
                        if (ImgExists == true)
                        {
                            FileInfo file = new FileInfo(directoryFullPath);
                            collection.Photo.SaveAs(valpath);
                        }
                        string FilePath = collection.Photo.FileName;
                        var    fileName = Guid.NewGuid().ToString() + Path.GetFileName(collection.Photo.FileName);
                        var    path     = Path.Combine(Server.MapPath(Url.Content("~/UsersData/Logo/Images/")), fileName);
                        //Create Directory if not created, Mostly happens during first execution
                        //Added by Prasanth k
                        if (!Directory.Exists(Server.MapPath(Url.Content("~/UsersData/Logo/Images/"))))
                        {
                            Directory.CreateDirectory(Server.MapPath(Url.Content("~/UsersData/Logo/Images/")));
                        }
                        try
                        {
                            WebImage img = new WebImage(collection.Photo.InputStream);
                            if (img.Width > 1000)
                            {
                                img.Resize(1000, 1000);
                            }
                            img.Save(path);

                            //     collection.Photo.SaveAs(path);
                        }
                        catch (Exception)
                        {
                        }
                        var Extension = collection.Photo != null?Path.GetExtension(collection.Photo.FileName) : "";

                        if (Extension != null)
                        {
                            var    Themelogo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(o => o).FirstOrDefault();
                            string ImgPath   = ConfigurationManager.AppSettings["ImgPath"].ToString() + fileName;
                            Themelogo.AppValue = ImgPath;
                            objdb.SaveChanges();
                            Session["Save"] = 1;
                        }
                    }
                    var      Themecolor    = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "ThemeColor").Select(o => o).FirstOrDefault();
                    var      startdate     = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Financial Start Date").Select(o => o).FirstOrDefault();
                    var      enddate       = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Financial End Date").Select(o => o).FirstOrDefault();
                    var      facebook      = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Facebook").Select(o => o).FirstOrDefault();
                    var      companyname   = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o).FirstOrDefault();
                    var      VersionNumber = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Version").Select(o => o).FirstOrDefault();
                    var      InTime        = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "In Time").Select(o => o).FirstOrDefault();
                    var      OutTime       = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Out Time").Select(o => o).FirstOrDefault();
                    DateTime dt1           = Convert.ToDateTime(collection.AcademicStartdate);
                    DateTime dt2           = Convert.ToDateTime(collection.AcademicEnddate);

                    if (dt1.Date > dt2.Date)
                    {
                        TempData["message"] = "Startdate";
                    }

                    else
                    {
                        if (startdate != null)
                        {
                            startdate.AppValue = collection.AcademicStartdate;
                            objdb.SaveChanges();
                        }
                        if (enddate != null)
                        {
                            enddate.AppValue = collection.AcademicEnddate;
                            objdb.SaveChanges();
                        }
                        if (facebook != null)
                        {
                            if (collection.Facebook == "" || collection.Facebook == null)
                            {
                                facebook.AppValue = facebook.AppValue;
                                objdb.SaveChanges();
                            }
                            else
                            {
                                facebook.AppValue = collection.Facebook;
                                objdb.SaveChanges();
                            }
                        }

                        if (companyname != null)
                        {
                            if (collection.CompanyName == "" || collection.CompanyName == null)
                            {
                                companyname.AppValue = companyname.AppValue;
                                objdb.SaveChanges();
                            }
                            else
                            {
                                companyname.AppValue = collection.CompanyName;
                                objdb.SaveChanges();
                            }
                        }

                        if (VersionNumber != null)
                        {
                            if (collection.VersionNumber == "" || collection.VersionNumber == null)
                            {
                                VersionNumber.AppValue = VersionNumber.AppValue;
                                objdb.SaveChanges();
                            }
                            else
                            {
                                VersionNumber.AppValue = collection.VersionNumber;
                                objdb.SaveChanges();
                            }
                        }

                        if (collection.Colors != null)
                        {
                            Themecolor.AppValue = objdb.Master_ThemeColors.Where(x => x.ColorId == collection.Colors).Select(o => o.ColorName).FirstOrDefault();
                            objdb.SaveChanges();
                            Session["Save"] = 1;
                        }
                        if (InTime != null)
                        {
                            InTime.AppValue = collection.InTime;
                            objdb.SaveChanges();
                        }
                        if (OutTime != null)
                        {
                            OutTime.AppValue = collection.OutTime;
                            objdb.SaveChanges();
                        }
                        TempData["startdate"] = collection.AcademicStartdate.ToString();
                        TempData["enddate"]   = collection.AcademicEnddate.ToString();
                        TempData["InTime"]    = collection.InTime.ToString();
                        TempData["OutTime"]   = collection.OutTime.ToString();
                        objdb.SaveChanges();
                        var themelogo = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Log").Select(o => o).FirstOrDefault();
                        Session["LoginLogo"] = themelogo.AppValue;
                        TempData["doc"]      = themelogo.AppValue;
                        TempData["message"]  = "Added";
                        ViewBag.Message      = "Success";
                    }
                }
                else
                {
                    TempData["message"] = "Wrongformat";
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(RedirectToAction("ThemeSettings", "ThemeSettings"));
        }