예제 #1
0
        public static Image GetPicFromDB(KidsUser u, ImageActType Act, bool ReplaceEmptyPicture, int? width, int? hight)
        {
            var c = HttpContext.Current.Server;

            string BasdeFolder = c.MapPath(SystemConfigs.UrlKidsPicFilesPath(u.SSOUserName));
            Image img = GetPicFromDB(Act, u, BasdeFolder, ReplaceEmptyPicture, width, hight);

            return img;
        }
예제 #2
0
        private static Image GetPicFromDB(ImageActType Act, KidsUser u, string BasdeFolder, bool ReplaceEmptyPicture, int? width, int? hight)
        {
            var c = HttpContext.Current.Server;
            Image img = null;

            switch (Act)
            {
                case ImageActType.ChildImage_Main:
                    try
                    {
                        if (ReplaceEmptyPicture)
                            img = !string.IsNullOrWhiteSpace(u.ChildPic)
                                      ? Image.FromFile(BasdeFolder + u.ChildPic)
                                      : Image.FromFile(u.ChildSex
                                                       ? c.MapPath("~/App_Themes/Default/images/1.jpg")
                                                       : c.MapPath("~/App_Themes/Default/images/0.jpg")
                                                       );
                        else
                            img = !string.IsNullOrWhiteSpace(u.ChildPic)
                                 ? Image.FromFile(BasdeFolder + u.ChildPic)
                                 : new Bitmap(0, 0);
                    }
                    catch
                    {
                        img = Image.FromFile(c.MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
                    }
                    break;

                case ImageActType.ChildPic:
                    try
                    {
                        if (ReplaceEmptyPicture)
                            img = !string.IsNullOrWhiteSpace(u.ChildPic)
                                      ? Image.FromFile(BasdeFolder + u.ChildPic)
                                      : Image.FromFile(c.MapPath("~/App_Themes/Default/images/Blank.jpg"));
                        else
                            img = !string.IsNullOrWhiteSpace(u.ChildPic)
                                 ? Image.FromFile(BasdeFolder + u.ChildPic)
                                 : new Bitmap(0, 0);
                    }
                    catch
                    {
                        img = Image.FromFile(c.MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
                    }
                    break;

                case ImageActType.ChildIdentityPic:
                    try
                    {
                        if (ReplaceEmptyPicture)
                            img = !string.IsNullOrWhiteSpace(u.ChildIdentityPic)
                                     ? Image.FromFile(BasdeFolder + u.ChildIdentityPic)
                                     : Image.FromFile(c.MapPath("~/App_Themes/Default/images/Blank.jpg"));
                        else
                            img = !string.IsNullOrWhiteSpace(u.ChildIdentityPic)
                                 ? Image.FromFile(BasdeFolder + u.ChildIdentityPic)
                                 : new Bitmap(0, 0);
                    }
                    catch
                    {
                        img = Image.FromFile(c.MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
                    }
                    break;

                case ImageActType.ChildNationalCardFaceUPPic:
                    try
                    {
                        if (ReplaceEmptyPicture)
                            img = !string.IsNullOrWhiteSpace(u.ChildNationalCardFaceUPPic)
                                     ? Image.FromFile(BasdeFolder + u.ChildNationalCardFaceUPPic)
                                     : Image.FromFile(c.MapPath("~/App_Themes/Default/images/Blank.jpg"));
                        else
                            img = !string.IsNullOrWhiteSpace(u.ChildNationalCardFaceUPPic)
                                 ? Image.FromFile(BasdeFolder + u.ChildNationalCardFaceUPPic)
                                 : new Bitmap(0, 0);
                    }
                    catch
                    {
                        img = Image.FromFile(c.MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
                    }
                    break;

                case ImageActType.ChildNationalCardFaceDownPic:
                    try
                    {
                        if (ReplaceEmptyPicture)
                            img = !string.IsNullOrWhiteSpace(u.ChildNationalCardFaceDownPic)
                                     ? Image.FromFile(BasdeFolder + u.ChildNationalCardFaceDownPic)
                                     : Image.FromFile(c.MapPath("~/App_Themes/Default/images/Blank.jpg"));
                        else
                            img = !string.IsNullOrWhiteSpace(u.ChildNationalCardFaceDownPic)
                                 ? Image.FromFile(BasdeFolder + u.ChildNationalCardFaceDownPic)
                                 : new Bitmap(0, 0);
                    }
                    catch
                    {
                        img = Image.FromFile(c.MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
                    }
                    break;
            }

            if (width.HasValue && hight.HasValue)
                img = FileUploadUtil.ResizeImage(img, new Size(width.Value, hight.Value));
            return img;
        }
예제 #3
0
        private void GetPicFromDB(ImageActType Act)
        {
            Image img;
            if (KidsSecureFormBaseClass.OnlineKidsUser != null && KidsSecureFormBaseClass.OnlineKidsUser.Kids_UserInfo != null)
            {
                var u = KidsSecureFormBaseClass.OnlineKidsUser.Kids_UserInfo;
                string BasdeFolder = MapPath(SystemConfigs.UrlKidsPicFilesPath(u.SSOUserName));

                int? width = null, hight = null;
                if (Request["w"].IsInt32() && Request["h"].IsInt32())
                {
                    width = Request["w"].ToInt32();
                    hight = Request["h"].ToInt32();
                }
                img = GetPicFromDB(Act, u, BasdeFolder, true, width, hight);
            }
            else
            {
                img = Image.FromFile(MapPath("~/App_Themes/Default/images/unknown_user.jpg"));
            }
            SaveImage(img);
        }