Ejemplo n.º 1
0
        protected override void PageLoad()
        {
            if (!Global.ModuleManager.IsVisible(ModuleType.TMDocs))
            {
                Response.Redirect(ProjectsCommonResource.StartURL);
            }

            int projectID;

            int.TryParse(UrlParameters.ProjectID, out projectID);
            var project = Global.EngineFactory.GetProjectEngine().GetByID(projectID);

            if (project == null || !ProjectSecurity.CanReadFiles(project))
            {
                Response.Redirect(ProjectsCommonResource.StartURL.ToLower());
            }

            var mainMenu = (MainMenu)LoadControl(MainMenu.Location);

            mainMenu.EnableImport     = false;
            mainMenu.EnableThirdParty = false;
            CommonContainerHolder.Controls.Add(mainMenu);

            var mainContent = (MainContent)LoadControl(MainContent.Location);

            mainContent.FolderIDCurrentRoot = FileEngine2.GetRoot(projectID);
            mainContent.TitlePage           = ProjectsCommonResource.ModuleName;
            mainContent.CurrentUserAdmin    = project.Responsible == SecurityContext.CurrentAccount.ID || ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);
            CommonContainerHolder.Controls.Add(mainContent);

            Title = HeaderStringHelper.GetPageTitle(ProjectsFileResource.Files, Master.BreadCrumbs);

            Master.DisabledSidePanel = true;
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(typeof(DiscussionDetails), Page);

            _hintPopup.Options.IsPopup = true;

            LoadCommentsControl();

            BindDiscussionParticipants();
            CanEdit = ProjectSecurity.CanEdit(Discussion);

            if (CanEdit)
            {
                LoadDiscussionParticipantsSelector();
            }

            CanReadFiles = ProjectSecurity.CanReadFiles(Discussion.Project);
            CanEditFiles = ProjectSecurity.IsInTeam(Project);
            Author       = CoreContext.UserManager.GetUsers(Discussion.CreateBy);
            FilesCount   = FileEngine2.GetMessageFiles(Discussion).Count();

            if (CanReadFiles && (CanEditFiles || FilesCount > 0))
            {
                LoadDiscussionFilesControl();
            }
            Page.EssenceStatus = string.Empty;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Utility.RegisterTypeForAjax(typeof(DiscussionDetails), Page);

            _hintPopup.Options.IsPopup = true;

            BindDiscussionParticipants();

            CanEdit           = ProjectSecurity.CanEdit(Discussion);
            CanReadFiles      = ProjectSecurity.CanReadFiles(Discussion.Project);
            CanEditFiles      = ProjectSecurity.IsInTeam(Project) && Discussion.Status == MessageStatus.Open;
            Author            = CoreContext.UserManager.GetUsers(Discussion.CreateBy);
            FilesCount        = FileEngine2.GetMessageFiles(Discussion).Count();
            FilesAvailable    = CanReadFiles && !MobileDetector.IsMobile && (CanEditFiles || FilesCount > 0);
            CommentsAvailable = Discussion.Status == MessageStatus.Open || Discussion.CommentsCount > 0;

            if (FilesAvailable)
            {
                LoadDiscussionFilesControl();
            }

            if (Discussion.Status == MessageStatus.Archived)
            {
                Page.EssenceStatus = MessageResource.ArchiveDiscussionStatus;
            }

            if (CommentsAvailable)
            {
                LoadCommentsControl();
            }
            else
            {
                discussionComments.Visible = false;
            }
        }
Ejemplo n.º 4
0
 private void SaveFileCategories(ICategory[] categories)
 {
     foreach (var category in categories)
     {
         if (category.Type == CategoryType.Attachment)
         {
             try
             {
                 var folder = new ASC.Files.Core.Folder
                 {
                     ParentFolderID = FileEngine2.GetRoot(FindProject(category.ProjectID)),
                     Title          = category.Name
                 };
                 folder = FileEngine2.SaveFolder(folder);
                 NewFileCategoriesID.Add(new FileCategoryIDWrapper {
                     inBasecamp = category.ID, inProjects = folder.ID
                 });
             }
             catch (Exception e)
             {
                 Status.LogError(string.Format(SettingsResource.FailedToSaveFileCategory, category.Name), e);
                 LogError(string.Format("file category '{0}' failed", category.Name), e);
                 NewFileCategoriesID.RemoveAll(x => x.inBasecamp == category.ID);
             }
         }
     }
 }
Ejemplo n.º 5
0
        private void LoadDiscussionFilesControl()
        {
            ProjectFolderId = (int)FileEngine2.GetRoot(Project.ID);

            var discussionFilesControl = (Studio.UserControls.Common.Attachments.Attachments)LoadControl(Studio.UserControls.Common.Attachments.Attachments.Location);

            discussionFilesControl.EmptyScreenVisible = false;
            discussionFilesControl.EntityType         = "message";
            discussionFilesControl.ModuleName         = "projects";
            discussionFilesControl.CanAddFile         = CanEditFiles;
            discussionFilesPlaceHolder.Controls.Add(discussionFilesControl);
        }
Ejemplo n.º 6
0
        public void InitAttachments()
        {
            var attachments = FileEngine2.GetTaskFiles(Task);

            AttachmentsCount = attachments.Count;

            var taskAttachments = (Studio.UserControls.Common.Attachments.Attachments)LoadControl(Studio.UserControls.Common.Attachments.Attachments.Location);

            taskAttachments.EntityType = "task";
            taskAttachments.ModuleName = "projects";
            phAttachmentsControl.Controls.Add(taskAttachments);
        }
Ejemplo n.º 7
0
        public void InitAttachments()
        {
            var attachments = FileEngine2.GetTaskFiles(Task);

            AttachmentsCount = attachments.Count();

            ProjectFolderId = (int)FileEngine2.GetRoot(Task.Project.ID);

            var taskAttachments = (Studio.UserControls.Common.Attachments.Attachments)LoadControl(Studio.UserControls.Common.Attachments.Attachments.Location);

            taskAttachments.EmptyScreenVisible = false;
            taskAttachments.EntityType         = "task";
            taskAttachments.ModuleName         = "projects";
            taskAttachments.CanAddFile         = CanEditTask;
            phAttachmentsControl.Controls.Add(taskAttachments);
        }
Ejemplo n.º 8
0
        protected override void PageLoad()
        {
            if (RequestContext.IsInConcreteProject && !ProjectSecurity.CanReadFiles(Project))
            {
                Response.Redirect("projects.aspx?prjID=" + Project.ID, true);
            }

            var mainContent = (MainContent)LoadControl(MainContent.Location);

            mainContent.FolderIDCurrentRoot = Project == null ? Files.Classes.Global.FolderProjects : FileEngine2.GetRoot(Project.ID);
            mainContent.TitlePage           = ProjectsCommonResource.ModuleName;
            CommonContainerHolder.Controls.Add(mainContent);

            Title = HeaderStringHelper.GetPageTitle(ProjectsFileResource.Files);

            Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/styles.ascx")));
            Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/FilesScripts.ascx")));
            Page.RegisterClientLocalizationScript(typeof(Files.Masters.ClientScripts.FilesLocalizationResources));
            Page.RegisterClientScript(typeof(Files.Masters.ClientScripts.FilesConstantsResources));
            Page.RegisterInlineScript(@"ZeroClipboard.setMoviePath('" + CommonLinkUtility.ToAbsolute("~/js/flash/zeroclipboard/zeroclipboard10.swf") + "');", true);
        }
        protected int GetDiscussionFilesCount()
        {
            var files = FileEngine2.GetMessageFiles(Discussion);

            return(files.Count);
        }
Ejemplo n.º 10
0
        protected override void PageLoad()
        {
            var mainContent = (MainContent)LoadControl(MainContent.Location);

            mainContent.FolderIDCurrentRoot = Project == null ? Files.Classes.Global.FolderProjects : FileEngine2.GetRoot(Project.ID);
            mainContent.TitlePage           = ProjectsCommonResource.ModuleName;
            CommonContainerHolder.Controls.Add(mainContent);

            Master.DisabledEmptyScreens = true;

            Title = HeaderStringHelper.GetPageTitle(ProjectsFileResource.Files);

            Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/styles.ascx")));
            Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/FilesScripts.ascx")));
            Page.RegisterClientLocalizationScript(typeof(Files.Masters.ClientScripts.FilesLocalizationResources));
            Page.RegisterClientScript(typeof(Files.Masters.ClientScripts.FilesConstantsResources));
            Page.RegisterInlineScript("if (typeof ZeroClipboard != 'undefined') {ZeroClipboard.setMoviePath('" + CommonLinkUtility.ToAbsolute("~/js/flash/zeroclipboard/zeroclipboard10.swf") + "');}");
        }
Ejemplo n.º 11
0
        private void SaveFiles(IBaseCamp basecampManeger, IEnumerable <IAttachment> attachments, int projectID)
        {
            var step = 100.0 / attachments.Count();

            Status.LogInfo(string.Format(ImportResource.ImportFileStarted, attachments.Count()));

            //select last version
            foreach (var attachment in attachments)
            {
                Status.FileProgress += step;
                try
                {
                    var httpWReq = basecampManeger.Service.GetRequest(attachment.DownloadUrl);
                    using (var httpWResp = (HttpWebResponse)httpWReq.GetResponse())
                    {
                        if (attachment.ByteSize > SetupInfo.MaxUploadSize)
                        {
                            Status.LogError(string.Format(ImportResource.FailedSaveFileMaxSizeExided, attachment.Name), new Exception());
                            continue;
                        }

                        var file = new ASC.Files.Core.File
                        {
                            FolderID      = FileEngine2.GetRoot(FindProject(projectID)),
                            Title         = attachment.Name,
                            ContentLength = attachment.ByteSize,
                            CreateBy      = FindUser(attachment.AuthorID),
                            CreateOn      = attachment.CreatedOn.ToUniversalTime()
                        };
                        if (file.Title.LastIndexOf('\\') != -1)
                        {
                            file.Title = file.Title.Substring(file.Title.LastIndexOf('\\') + 1);
                        }

                        file = FileEngine2.SaveFile(file, httpWResp.GetResponseStream());

                        if ("Message".Equals(attachment.OwnerType, StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                var messageId = FindMessage(attachment.OwnerID);
                                FileEngine2.AttachFileToMessage(new Message {
                                    ID = messageId
                                }, file.ID);                                                            //It's not critical
                            }
                            catch (Exception e)
                            {
                                LogError(string.Format("not critical. attaching file '{0}' to message  failed", attachment.Name), e);
                            }
                        }

                        if ("Todo".Equals(attachment.OwnerType, StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                var taskId = FindTask(attachment.OwnerID);
                                FileEngine2.AttachFileToTask(new Task {
                                    ID = taskId
                                }, file.ID);                                                   //It's not critical
                            }
                            catch (Exception e)
                            {
                                LogError(string.Format("not critical. attaching file '{0}' to message  failed", attachment.Name), e);
                            }
                        }

                        _newFilesID.Add(new FileIDWrapper
                        {
                            InBasecamp = attachment.ID,
                            InProjects = file.ID
                        });
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        Status.LogError(string.Format(ImportResource.FailedToSaveFile, attachment.Name), e);
                        LogError(string.Format("file '{0}' failed", attachment.Name), e);
                        _newFilesID.RemoveAll(x => x.InBasecamp == attachment.ID);
                    }
                    catch (Exception ex)
                    {
                        LogError(string.Format("file remove after error failed"), ex);
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void SaveFiles(BaseCamp basecampManeger, IEnumerable <IAttachment> attachments)
        {
            var step = 100.0 / attachments.Count();

            Status.LogInfo(string.Format(SettingsResource.ImportFileStarted, attachments.Count()));

            //select last version
            foreach (var attachment in attachments.GroupBy(a => a.Collection).Select(g => g.OrderByDescending(a => a.Vers).FirstOrDefault()))
            {
                Status.FileProgress += step;
                try
                {
                    HttpWebRequest HttpWReq = basecampManeger.Service.GetRequest(attachment.DownloadUrl);
                    using (HttpWebResponse HttpWResp = (HttpWebResponse)HttpWReq.GetResponse())
                    {
                        if (attachment.ByteSize > SetupInfo.MaxUploadSize)
                        {
                            break;
                        }

                        var file = new ASC.Files.Core.File();
                        file.FolderID      = attachment.CategoryID != -1 ? FindFileCategory(attachment.CategoryID) : FileEngine2.GetRoot(FindProject(attachment.ProjectID));
                        file.Title         = attachment.Name;
                        file.ContentLength = attachment.ByteSize;
                        file.ContentType   = MimeMapping.GetMimeMapping(attachment.Name);
                        file.CreateBy      = FindUser(attachment.AuthorID);
                        file.CreateOn      = attachment.CreatedOn.ToUniversalTime();
                        if (file.Title.LastIndexOf('\\') != -1)
                        {
                            file.Title = file.Title.Substring(file.Title.LastIndexOf('\\') + 1);
                        }

                        file = FileEngine2.SaveFile(file, HttpWResp.GetResponseStream());

                        if ("Post".Equals(attachment.OwnerType, StringComparison.OrdinalIgnoreCase))
                        {
                            try
                            {
                                var messageId = FindMessage(attachment.OwnerID);
                                FileEngine2.AttachFileToMessage(messageId, file.ID);//It's not critical
                            }
                            catch (Exception e)
                            {
                                LogError(string.Format("not critical. attaching file '{0}' to message  failed", attachment.Name), e);
                            }
                        }

                        NewFilesID.Add(new FileIDWrapper
                        {
                            inBasecamp = attachment.ID,
                            inProjects = file.ID,
                            version    = attachment.Vers,
                            collection = attachment.Collection
                        });
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        Status.LogError(string.Format(SettingsResource.FailedToSaveFile, attachment.Name), e);
                        LogError(string.Format("file '{0}' failed", attachment.Name), e);
                        NewFilesID.RemoveAll(x => x.inBasecamp == attachment.ID && x.version == attachment.Vers);
                    }
                    catch (Exception ex)
                    {
                        LogError(string.Format("file remove after error failed"), ex);
                    }
                }
            }
        }