Ejemplo n.º 1
0
        public static void ProcessAvatar(HttpContext context, string[] segments, int organizationID, string path, int filePathID)
        {
            string fileName = "";

            if (Path.GetExtension(path) == "")
            {
                path = Path.ChangeExtension(path, ".jpg");
                string imageFile = Path.GetFileName(path);
                path = Path.GetDirectoryName(path);
                string imagePath = Path.Combine(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ProfileImages, filePathID), path);
                fileName = AttachmentPath.GetImageFileName(imagePath, imageFile);
                if (!File.Exists(fileName))
                {
                    imagePath = Path.Combine(AttachmentPath.GetDefaultPath(LoginUser.Anonymous, AttachmentPath.Folder.ProfileImages, filePathID), path);
                    fileName  = AttachmentPath.GetImageFileName(imagePath, imageFile);
                }
            }
            else
            {
                fileName = Path.Combine(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ProfileImages, filePathID), path);
            }
            if (File.Exists(fileName))
            {
                WriteImage(context, fileName);
            }
        }
Ejemplo n.º 2
0
        public static void ProcessImages(HttpContext context, string[] segments, int organizationID)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 2; i < segments.Length; i++)
            {
                if (i != 2)
                {
                    builder.Append("\\");
                }
                builder.Append(segments[i]);
            }
            string path     = builder.ToString();
            string fileName = "";

            if (Path.GetExtension(path) == "")
            {
                path = Path.ChangeExtension(path, ".jpg");
                string imageFile = Path.GetFileName(path);
                path = Path.GetDirectoryName(path);
                string imagePath = Path.Combine(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.Images), path);
                if (!Directory.Exists(imagePath))
                {
                    Directory.CreateDirectory(imagePath);
                }
                fileName = AttachmentPath.GetImageFileName(imagePath, imageFile);
                if (!File.Exists(fileName))
                {
                    imagePath = Path.Combine(AttachmentPath.GetDefaultPath(LoginUser.Anonymous, AttachmentPath.Folder.Images), path);
                    fileName  = AttachmentPath.GetImageFileName(imagePath, imageFile);
                }
            }
            else
            {
                fileName = Path.Combine(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.Images), path);
            }

            if (File.Exists(fileName))
            {
                WriteImage(context, fileName);
            }
            else
            {
                fileName = Path.Combine(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.Images, 3), path);
                if (File.Exists(fileName))
                {
                    WriteImage(context, fileName);
                }
            }
        }