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 string GetAttachmentPath3(int organizationID, int chatID, AttachmentProxy attachment)
        {
            string attachmentPath = AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ChatUploads, (int)attachment.FilePathID);

            attachmentPath += "\\" + chatID;

            attachmentPath = Path.Combine(attachmentPath, attachment.FileName);
            return(attachmentPath);
        }
Ejemplo n.º 3
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);
                }
            }
        }
        public static string CreateAttachment(RestCommand command, int ticketIDOrNumber, int actionID)
        {
            TicketsViewItem ticket = TicketsView.GetTicketsViewItemByIdOrNumber(command.LoginUser, ticketIDOrNumber);

            if (ticket.OrganizationID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }

            string path = AttachmentPath.GetPath(command.LoginUser, command.Organization.OrganizationID, AttachmentPath.Folder.Actions, 3);

            path = Path.Combine(path, actionID.ToString());
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            HttpFileCollection files = command.Context.Request.Files;

            if (files.Count > 0)
            {
                if (files[0].ContentLength > 0)
                {
                    string fileName = RemoveSpecialCharacters(DataUtils.VerifyUniqueUrlFileName(path, Path.GetFileName(files[0].FileName)));

                    files[0].SaveAs(Path.Combine(path, fileName));

                    Attachment attachment = (new Attachments(command.LoginUser)).AddNewAttachment();
                    attachment.RefType        = AttachmentProxy.References.Actions;
                    attachment.RefID          = (int)actionID;
                    attachment.OrganizationID = command.Organization.OrganizationID;
                    attachment.FileName       = fileName;
                    attachment.Path           = Path.Combine(path, fileName);
                    attachment.FileType       = files[0].ContentType;
                    attachment.FileSize       = files[0].ContentLength;
                    attachment.FilePathID     = 3;
                    attachment.Collection.Save();
                    return(attachment.Collection.GetXml("Attachments", "Attachment", true, command.Filters));
                }
                else
                {
                    throw new RestException(HttpStatusCode.BadRequest, "The file to attach is empty.");
                }
            }
            else
            {
                throw new RestException(HttpStatusCode.BadRequest, "No file to attach.");
            }
        }
        public static string CreateAttachmentDirectory(LoginUser loginUser, int parentOrganizationID, AttachmentProxy.References refType, int refID)
        {
            // hub save only saves two types of attachments on this code path
            AttachmentPath.Folder folder = AttachmentPath.Folder.CustomerHubLogo;
            if (refType == AttachmentProxy.References.Actions)
            {
                folder = AttachmentPath.Folder.Actions;
            }

            string path = AttachmentPath.GetPath(loginUser, parentOrganizationID, folder);

            path = Path.Combine(path, refID.ToString());
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            return(path);
        }
Ejemplo n.º 6
0
        public static string OrignalFileName(int organizationID, int userID)
        {
            string originalFileName;

            {
                Attachments attachments = new Attachments(LoginUser.Anonymous);
                attachments.LoadByReference(ReferenceType.UserPhoto, userID);
                StringBuilder path = new StringBuilder();
                if (attachments.Count > 0)
                {
                    path.Append(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ProfileImages, (int)attachments[0].FilePathID));
                }
                else
                {
                    path.Append(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ProfileImages));
                }
                originalFileName = AttachmentPath.GetImageFileName(path.ToString(), userID.ToString() + "avatar");
            }

            return(originalFileName);
        }
Ejemplo n.º 7
0
 public static string GetCsvFile(string uploadedFileName, LoginUser loginUser)
 {
     return(Path.Combine(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.Imports, 3), uploadedFileName));
 }
Ejemplo n.º 8
0
 public static string GetAttachmentPath9(LoginUser loginUser, string workingImage)
 {
     return(Path.Combine(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.TempImages, 3), workingImage));
     //temppath + "\\" + ImageResizer.Util.PathUtils.RemoveQueryString(img1.Value).Replace('/','\\');
 }
Ejemplo n.º 9
0
 public static string GetAttachmentPath8(LoginUser loginUser)
 {
     return(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.ProfileImages, 3));
 }
Ejemplo n.º 10
0
 public static string[] GetFiles(LoginUser loginUser)
 {
     return(Directory.GetFiles(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.TicketTypeImages), "*.*", SearchOption.TopDirectoryOnly));
 }
Ejemplo n.º 11
0
 public static string GetAttachmentPath7(LoginUser loginUser, string fileName)
 {
     return(Path.Combine(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.TempImages, 3), fileName));
 }
Ejemplo n.º 12
0
 public static string OriginalFileName1(int organizationID, int userID)
 {
     return(AttachmentPath.GetImageFileName(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.ProfileImages), userID.ToString() + "avatar"));
 }
Ejemplo n.º 13
0
 public static string GetAttachmentPath14(LoginUser loginUser, int organizationID)
 {
     return(AttachmentPath.GetPath(loginUser, organizationID, AttachmentPath.Folder.ImportLogs, 3));
 }
Ejemplo n.º 14
0
        static void SaveFiles(LoginUser loginUser, HttpContext context, AttachmentPath.Folder folder, int organizationID, int?itemID)
        {
            List <TeamSupport.Handlers.UploadResult> result = new List <TeamSupport.Handlers.UploadResult>();

            AttachmentProxy.References refType = AttachmentPath.GetFolderReferenceType(folder);

            string path = AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, folder, 3);

            if (itemID != null)
            {
                path = Path.Combine(path, itemID.ToString());
            }
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            HttpFileCollection files = context.Request.Files;

            for (int i = 0; i < files.Count; i++)
            {
                if (files[i].ContentLength > 0)
                {
                    string fileName = TeamSupport.Handlers.UploadUtils.RemoveSpecialCharacters(DataUtils.VerifyUniqueUrlFileName(path, Path.GetFileName(files[i].FileName)));

                    files[i].SaveAs(Path.Combine(path, fileName));
                    if (refType != AttachmentProxy.References.None && itemID != null)
                    {
                        Attachment attachment = (new Attachments(loginUser)).AddNewAttachment();
                        attachment.RefType        = refType;
                        attachment.RefID          = (int)itemID;
                        attachment.OrganizationID = organizationID;
                        attachment.FileName       = fileName;
                        attachment.Path           = Path.Combine(path, fileName);
                        attachment.FileType       = files[i].ContentType;
                        attachment.FileSize       = files[i].ContentLength;
                        attachment.FilePathID     = 3;
                        if (context.Request.Form["description"] != null)
                        {
                            attachment.Description = context.Request.Form["description"].Replace("\n", "<br />");
                        }
                        if (context.Request.Form["productFamilyID"] != null && context.Request.Form["productFamilyID"] != "-1")
                        {
                            attachment.ProductFamilyID = Int32.Parse(context.Request.Form["productFamilyID"]);
                        }

                        attachment.Collection.Save();
                        result.Add(new TeamSupport.Handlers.UploadResult(fileName, attachment.FileType, attachment.FileSize, attachment.AttachmentID));
                    }
                    else
                    {
                        switch (refType)
                        {
                        default:
                            break;
                        }
                    }
                }
            }
            context.Response.Clear();
            context.Response.ContentType = "text/plain";
            context.Response.Write(DataUtils.ObjectToJson(result.ToArray()));
        }
Ejemplo n.º 15
0
 public static string GetAttachmentPath16(LoginUser loginUser, int organizationId, int filePathID)
 {
     return(AttachmentPath.GetPath(loginUser, organizationId, AttachmentPath.Folder.ScheduledReportsLogs, filePathID));
 }
Ejemplo n.º 16
0
        private static void SaveFilesOld(LoginUser loginUser, int organizationID, int?_id, string _ratingImage, HttpContext context, AttachmentPath.Folder folder)
        {
            StringBuilder builder = new StringBuilder();
            string        path    = AttachmentPath.GetPath(loginUser, organizationID, folder);

            if (_id != null)
            {
                path = Path.Combine(path, _id.ToString());
            }
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            HttpFileCollection files = context.Request.Files;

            for (int i = 0; i < files.Count; i++)
            {
                if (files[i].ContentLength > 0)
                {
                    string fileName = TeamSupport.Handlers.UploadUtils.RemoveSpecialCharacters(DataUtils.VerifyUniqueUrlFileName(path, Path.GetFileName(files[i].FileName)));
                    if (builder.Length > 0)
                    {
                        builder.Append(",");
                    }
                    builder.Append(fileName);

                    if (_ratingImage != "")
                    {
                        fileName = _ratingImage + ".png";
                        AgentRatingsOptions ratingoptions = new AgentRatingsOptions(loginUser);
                        ratingoptions.LoadByOrganizationID(organizationID);

                        if (ratingoptions.IsEmpty)
                        {
                            AgentRatingsOption opt = (new AgentRatingsOptions(loginUser)).AddNewAgentRatingsOption();
                            opt.OrganizationID = organizationID;
                            switch (_ratingImage)
                            {
                            case "ratingpositive":
                                opt.PositiveImage = "/dc/" + organizationID + "/agentrating/ratingpositive";
                                break;

                            case "ratingneutral":
                                opt.NeutralImage = "/dc/" + organizationID + "/agentrating/ratingneutral";
                                break;

                            case "ratingnegative":
                                opt.NegativeImage = "/dc/" + organizationID + "/agentrating/ratingnegative";
                                break;
                            }
                            opt.Collection.Save();
                        }
                        else
                        {
                            switch (_ratingImage)
                            {
                            case "ratingpositive":
                                ratingoptions[0].PositiveImage = "/dc/" + organizationID + "/agentrating/ratingpositive";
                                break;

                            case "ratingneutral":
                                ratingoptions[0].NeutralImage = "/dc/" + organizationID + "/agentrating/ratingneutral";
                                break;

                            case "ratingnegative":
                                ratingoptions[0].NegativeImage = "/dc/" + organizationID + "/agentrating/ratingnegative";
                                break;
                            }
                            ratingoptions[0].Collection.Save();
                        }
                    }

                    fileName = Path.Combine(path, fileName);
                    files[i].SaveAs(fileName);
                }
            }
            context.Response.Write(builder.ToString());
        }
Ejemplo n.º 17
0
 public static void GetLogPath1(ScheduledReport scheduledReport, out string logPath, out string fileName)
 {
     logPath  = AttachmentPath.GetPath(scheduledReport.Collection.LoginUser, scheduledReport.OrganizationId, AttachmentPath.Folder.ScheduledReportsLogs, scheduledReport.FilePathID);
     fileName = scheduledReport.Id.ToString() + ".txt";
     logPath  = Path.Combine(logPath, fileName);
 }
Ejemplo n.º 18
0
 public static void GetLogPath(Import import, out string logPath, out string fileName)
 {
     logPath  = AttachmentPath.GetPath(import.Collection.LoginUser, import.OrganizationID, AttachmentPath.Folder.ImportLogs, import.FilePathID);
     fileName = import.ImportID.ToString() + ".txt";
     logPath  = Path.Combine(logPath, fileName);
 }
Ejemplo n.º 19
0
 public static string OriginalFileName3(int organizationParentId, int userId)
 {
     return(AttachmentPath.GetImageFileName(AttachmentPath.GetPath(LoginUser.Anonymous, organizationParentId, AttachmentPath.Folder.ContactImages), userId.ToString() + "avatar"));
 }
Ejemplo n.º 20
0
 public static string OriginalFileName2(int organizationID, int logoOrganizationId)
 {
     return(AttachmentPath.GetImageFileName(AttachmentPath.GetPath(LoginUser.Anonymous, organizationID, AttachmentPath.Folder.OrganizationsLogo), logoOrganizationId.ToString()));
 }
Ejemplo n.º 21
0
 public static string GetAttachmentPath10(LoginUser loginUser, int parentID)
 {
     return(AttachmentPath.GetPath(loginUser, parentID, AttachmentPath.Folder.OrganizationsLogo));
 }
Ejemplo n.º 22
0
 public static string GetAttachmentPath12(LoginUser loginUser, int organizationParentId)
 {
     return(AttachmentPath.GetPath(loginUser, organizationParentId, AttachmentPath.Folder.ContactImages));
 }
Ejemplo n.º 23
0
 public static string GetAttachmentPath4(int organizationID, LoginUser loginUser)
 {
     return(AttachmentPath.GetPath(loginUser, organizationID, AttachmentPath.Folder.Images));
 }
Ejemplo n.º 24
0
 public static string GetAttachmentPath15(LoginUser loginUser, int organizationID, int filePathID, string fileName)
 {
     return(Path.Combine(AttachmentPath.GetPath(loginUser, organizationID, AttachmentPath.Folder.Imports, filePathID), fileName));
 }
Ejemplo n.º 25
0
 public static string GetAttachmentPath5(LoginUser loginUser)
 {
     return(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.ChatImages));
 }
Ejemplo n.º 26
0
 public static string GetAttachmentPath17(LoginUser loginUser, int organizationId)
 {
     return(AttachmentPath.GetPath(loginUser, organizationId, AttachmentPath.Folder.ScheduledReports, 3));
 }
Ejemplo n.º 27
0
 public static string GetAttachmentPath1(LoginUser loginUser, Imports import)
 {
     return(AttachmentPath.GetPath(loginUser, loginUser.OrganizationID, AttachmentPath.Folder.ImportLogs, import[0].FilePathID));
 }