Beispiel #1
0
        public object UpdateTemplate(int Id, string Name, int period, int periodItem, int hour, bool AutoGenerated)
        {
            ProjectSecurity.DemandAuthentication();

            SaveOrUpdateTemplate(Global.EngineFactory.GetReportEngine().GetTemplate(Id), Name, period, periodItem, hour, AutoGenerated);
            return(new { Message = "success", Name = Name, Cron = Global.EngineFactory.GetReportEngine().GetTemplate(Id).Cron });
        }
Beispiel #2
0
        public string InitUsersDdlByProject(string project)
        {
            ProjectSecurity.DemandAuthentication();

            var projectID = Convert.ToInt32(project);

            if (projectID == -1)
            {
                return(GetAllUsersDropDownList());
            }
            else
            {
                var sb = new StringBuilder().AppendFormat("<option value='-1' id='ddlUser-1'>{0}</option>", CustomNamingPeople.Substitute <ProjectsCommonResource>("AllUsers").HtmlEncode());

                var users = Global.EngineFactory.GetProjectEngine()
                            .GetTeam(projectID)
                            .Select(p => p.UserInfo)
                            .OrderBy(u => u, UserInfoComparer.Default)
                            .ToList();

                foreach (var u in users)
                {
                    if (u.Status != EmployeeStatus.Terminated)
                    {
                        sb.AppendFormat("<option value='{0}' id='ddlUser{0}'>{1}</option>", u.ID, u.DisplayUserName());
                    }
                }

                return(sb.ToString());
            }
        }
Beispiel #3
0
        public string InitProjectsDdlByTag(string tag)
        {
            ProjectSecurity.DemandAuthentication();

            if (string.IsNullOrEmpty(tag))
            {
                return(GetAllProjectsDropDownList());
            }
            else
            {
                var sb = new StringBuilder()
                         .AppendFormat("<option value='-1' id='ddlProject-1'>{0}</option>", ProjectResource.AllProjects);

                foreach (var id in Global.EngineFactory.GetTagEngine().GetTagProjects(tag))
                {
                    var p = Global.EngineFactory.GetProjectEngine().GetByID(id);
                    if (p != null)
                    {
                        sb.AppendFormat("<option value='{0}' id='ddlProject{0}'>{1}</option>", id, p.HtmlTitle.HtmlEncode());
                    }
                }

                return(sb.ToString());
            }
        }
Beispiel #4
0
        public string GetPreview(string text, string commentID)
        {
            text = HtmlUtility.GetFull(text);
            ProjectSecurity.DemandAuthentication();

            return(GetHTMLComment(text, commentID));
        }
Beispiel #5
0
        public ImportStatus StartImportFromBasecamp(string url, string token, bool processClosed, bool disableNotifications)
        {
            ProjectSecurity.DemandAuthentication();

            //Validate all data
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException(SettingsResource.EmptyURL);
            }
            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentException(SettingsResource.EmptyToken);
            }
            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new ArgumentException(SettingsResource.MalformedUrl);
            }
            if (!Regex.IsMatch(url.Trim(), @"^http[s]{0,1}://.+\.basecamphq\.com[/]{0,1}$"))
            {
                throw new ArgumentException(SettingsResource.NotBasecampUrl);
            }

            ImportQueue.Add(url, token, processClosed, disableNotifications);
            return(ImportQueue.GetStatus());
        }
Beispiel #6
0
        public string SaveTemplate(string reportParams, string title, int period, int periodItem, int hour, bool sendEmail)
        {
            ProjectSecurity.DemandAuthentication();

            if (title == null || title.Trim().Length == 0)
            {
                throw new ArgumentNullException("title");
            }

            var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var rp         = serializer.Deserialize <ReportParams>(reportParams);
            var filter     = ParseJSONFilter(rp);

            var reptype = 0;

            int.TryParse(rp.ReportType, out reptype);

            var template = new ReportTemplate((ReportType)reptype);

            template.Filter = filter;

            SaveOrUpdateTemplate(template, title, period, periodItem, hour, sendEmail);

            return(string.Empty);
        }
        public String UserManager(String value, bool notifyIsChecked, int projID)
        {
            ProjectSecurity.DemandAuthentication();

            Project = Global.EngineFactory.GetProjectEngine().GetByID(projID);

            var checkedParticipant = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var shapeTeam          = new List <Participant>();

            if (Project != null)
            {
                shapeTeam.Add(Global.EngineFactory.GetParticipantEngine().GetByID(Project.Responsible));
            }

            for (int index = 0; index < checkedParticipant.Length; index++)
            {
                shapeTeam.Add(Global.EngineFactory.GetParticipantEngine().GetByID(new Guid(checkedParticipant[index])));
            }

            var oldTeam = Global.EngineFactory.GetProjectEngine().GetTeam(Project.ID);

            var removeFromTeam = new List <Participant>();
            var inviteToTeam   = new List <Participant>();

            foreach (var participant in oldTeam)
            {
                if (!shapeTeam.Contains(participant))
                {
                    if (participant.ID != Project.Responsible)
                    {
                        removeFromTeam.Add(participant);
                    }
                }
            }

            foreach (var participant in shapeTeam)
            {
                if (!oldTeam.Contains(participant))
                {
                    Global.EngineFactory.GetParticipantEngine().RemoveFromFollowingProjects(Project.ID, participant.ID);
                    inviteToTeam.Add(participant);
                }
            }



            foreach (var participant in inviteToTeam)
            {
                Global.EngineFactory.GetProjectEngine().AddToTeam(Project, participant, notifyIsChecked);
            }

            foreach (var participant in removeFromTeam)
            {
                Global.EngineFactory.GetProjectEngine().RemoveFromTeam(Project, participant, notifyIsChecked);
            }


            return(RenderProjectTeam(shapeTeam, oldTeam));
        }
        public bool IsSubscribeToTask(int taskid)
        {
            var task = EngineFactory.GetTaskEngine().GetByID(taskid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            return(EngineFactory.GetTaskEngine().IsSubscribedToTask(task));
        }
Beispiel #9
0
 private void ChechDocBuilder()
 {
     ProjectSecurity.DemandAuthentication();
     if (string.IsNullOrEmpty(FilesLinkUtility.DocServiceDocbuilderUrl))
     {
         throw ProjectSecurity.CreateSecurityException();
     }
 }
Beispiel #10
0
        public string LoadCommentBBCode(string commentID)
        {
            ProjectSecurity.DemandAuthentication();

            var finded = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentID));

            return(finded != null ? finded.Content : String.Empty);
        }
Beispiel #11
0
        public string LoadCommentBBCode(string commentId)
        {
            ProjectSecurity.DemandAuthentication();

            var comment = Global.EngineFactory.GetCommentEngine().GetByID(new Guid(commentId));

            return(comment != null ? comment.Content : string.Empty);
        }
Beispiel #12
0
        public ReportTemplateWrapper SaveReportTemplate(
            string name,
            string period,
            int periodItem,
            int hour,
            bool autoGenerated,
            ReportType reportType,
            int tag,
            int project,
            TaskStatus?status,
            Guid departament,
            Guid userId,
            ReportTimeInterval reportTimeInterval,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            int viewType,
            bool noResponsible)
        {
            ProjectSecurity.DemandAuthentication();

            if (name == null || name.Trim().Length == 0)
            {
                throw new ArgumentNullException("name");
            }

            var filter = new TaskFilter
            {
                TagId         = tag,
                DepartmentId  = departament,
                UserId        = userId,
                TimeInterval  = reportTimeInterval,
                FromDate      = fromDate,
                ToDate        = toDate,
                ViewType      = viewType,
                NoResponsible = noResponsible
            };

            if (project != 0)
            {
                filter.ProjectIds.Add(project);
            }

            if (status != null)
            {
                filter.TaskStatuses.Add((TaskStatus)status);
            }

            var template = new ReportTemplate(reportType)
            {
                Filter = filter
            };

            SaveOrUpdateTemplate(template, name, period, periodItem, hour, autoGenerated);
            MessageService.Send(Request, MessageAction.ReportTemplateCreated, template.Name);

            return(new ReportTemplateWrapper(template));
        }
        public TaskWrapper SubscribeToTask(int taskid)
        {
            var task = EngineFactory.GetTaskEngine().GetByID(taskid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            EngineFactory.GetTaskEngine().FollowTask(task);

            return(new TaskWrapper(task));
        }
Beispiel #14
0
        public object DeleteTemplates(int[] TemplateIds)
        {
            ProjectSecurity.DemandAuthentication();

            foreach (int tId in TemplateIds)
            {
                Global.EngineFactory.GetReportEngine().DeleteTemplate(tId);
            }
            return(TemplateIds);
        }
Beispiel #15
0
        public bool IsSubscribedToMessage(int messageid)
        {
            var messageEngine = EngineFactory.MessageEngine;

            var message = messageEngine.GetByID(messageid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            return(messageEngine.IsSubscribed(message));
        }
Beispiel #16
0
        public IEnumerable <EmployeeWraperFull> GetProjectMessageSubscribers(int messageid)
        {
            var messageEngine = EngineFactory.MessageEngine;

            var message = messageEngine.GetByID(messageid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            return(messageEngine.GetSubscribers(message).Select(r => new EmployeeWraperFull(CoreContext.UserManager.GetUsers(new Guid(r.ID))))
                   .OrderBy(r => r.DisplayName).ToList());
        }
Beispiel #17
0
        public void DeleteAllTemplates()
        {
            ProjectSecurity.DemandAuthentication();

            var myTemplates = Global.EngineFactory.GetReportEngine().GetTemplates(SecurityContext.CurrentAccount.ID);

            foreach (var template in myTemplates)
            {
                Global.EngineFactory.GetReportEngine().DeleteTemplate(template.Id);
            }
        }
Beispiel #18
0
        public void DeleteAutoTemplates()
        {
            ProjectSecurity.DemandAuthentication();

            var autoTemplates = Global.EngineFactory.GetReportEngine().GetTemplates(SecurityContext.CurrentAccount.ID).FindAll(t => t.AutoGenerated);

            foreach (var template in autoTemplates)
            {
                Global.EngineFactory.GetReportEngine().DeleteTemplate(template.Id);
            }
        }
Beispiel #19
0
        public MessageWrapper SubscribeToMessage(int messageid)
        {
            var discussionEngine = EngineFactory.MessageEngine;
            var discussion       = discussionEngine.GetByID(messageid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            discussionEngine.Follow(discussion);
            MessageService.Send(Request, MessageAction.DiscussionUpdatedFollowing, discussion.Project.Title, discussion.Title);

            return(new MessageWrapperFull(discussion, new ProjectWrapperFull(discussion.Project, EngineFactory.FileEngine.GetRoot(discussion.Project.ID)), GetProjectMessageSubscribers(messageid)));
        }
Beispiel #20
0
        public ReportTemplateWrapper DeleteReportTemplate(int reportid)
        {
            ProjectSecurity.DemandAuthentication();

            var reportEngine = EngineFactory.GetReportEngine();

            var reportTemplate = reportEngine.GetTemplate(reportid).NotFoundIfNull();

            reportEngine.DeleteTemplate(reportid);

            return(new ReportTemplateWrapper(reportTemplate));
        }
        public TaskWrapper SubscribeToTask(int taskid)
        {
            var taskEngine = EngineFactory.TaskEngine;
            var task       = taskEngine.GetByID(taskid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            taskEngine.Follow(task);
            MessageService.Send(Request, MessageAction.TaskUpdatedFollowing, MessageTarget.Create(task.ID), task.Project.Title, task.Title);

            return(TaskWrapperSelector(task));
        }
Beispiel #22
0
        public ReportFile RemoveGeneratedReport(int fileid)
        {
            ProjectSecurity.DemandAuthentication();

            var reportEngine = EngineFactory.ReportEngine;

            var report = reportEngine.GetByFileId(fileid).NotFoundIfNull();

            reportEngine.Remove(report);

            return(report);
        }
        public TaskWrapper SubscribeToTask(int taskid)
        {
            var taskEngine = EngineFactory.GetTaskEngine();
            var task       = taskEngine.GetByID(taskid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            taskEngine.Follow(task);
            MessageService.Send(_context, MessageAction.TaskUpdatedFollowing, task.Project.Title, task.Title);

            return(new TaskWrapper(task));
        }
Beispiel #24
0
        public string GetAutugeneratedTime(string cronString)
        {
            ProjectSecurity.DemandAuthentication();

            var cron = new CronExpression(cronString)
            {
                TimeZone = CoreContext.TenantManager.GetCurrentTenant().TimeZone
            };
            var date = cron.GetTimeAfter(DateTime.UtcNow);

            return(date.HasValue ? string.Format("@ {0}", TenantUtil.DateTimeFromUtc(date.Value).ToShortString()) : string.Empty);
        }
Beispiel #25
0
        public MessageWrapper SubscribeToMessage(int messageid)
        {
            var messageEngine = EngineFactory.GetMessageEngine();

            var message = messageEngine.GetByID(messageid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            messageEngine.Follow(message);

            return(new MessageWrapper(message));
        }
        public MessageWrapper SubscribeToMessage(int messageid)
        {
            var discussionEngine = EngineFactory.GetMessageEngine();
            var discussion       = discussionEngine.GetByID(messageid).NotFoundIfNull();

            ProjectSecurity.DemandAuthentication();

            discussionEngine.Follow(discussion);
            MessageService.Send(_context, MessageAction.DiscussionUpdatedFollowing, discussion.Project.Title, discussion.Title);

            return(new MessageWrapper(discussion));
        }
Beispiel #27
0
        public ReportTemplateWrapper UpdateReportTemplate(
            int reportid,
            string name,
            string period,
            int periodItem,
            int hour,
            bool autoGenerated,
            ReportType reportType,
            int tag,
            int project,
            TaskStatus?status,
            Guid departament,
            Guid userId,
            ReportTimeInterval reportTimeInterval,
            ApiDateTime fromDate,
            ApiDateTime toDate,
            int viewType,
            bool noResponsible)
        {
            ProjectSecurity.DemandAuthentication();

            var filter = new TaskFilter
            {
                TagId         = tag,
                DepartmentId  = departament,
                UserId        = userId,
                TimeInterval  = reportTimeInterval,
                FromDate      = fromDate,
                ToDate        = toDate,
                ViewType      = viewType,
                NoResponsible = noResponsible
            };

            if (project != 0)
            {
                filter.ProjectIds.Add(project);
            }

            if (status != null)
            {
                filter.TaskStatuses.Add((TaskStatus)status);
            }

            var template = EngineFactory.GetReportEngine().GetTemplate(reportid);

            template.Filter = filter;

            SaveOrUpdateTemplate(template, name, period, periodItem, hour, autoGenerated);
            MessageService.Send(Request, MessageAction.ReportTemplateUpdated, template.Name);

            return(new ReportTemplateWrapper(template));
        }
Beispiel #28
0
        public ReportTemplateWrapper DeleteReportTemplate(int reportid)
        {
            ProjectSecurity.DemandAuthentication();

            var reportEngine = EngineFactory.GetReportEngine();

            var reportTemplate = reportEngine.GetTemplate(reportid).NotFoundIfNull();

            reportEngine.DeleteTemplate(reportid);
            MessageService.Send(Request, MessageAction.ReportTemplateDeleted, reportTemplate.Name);

            return(new ReportTemplateWrapper(reportTemplate));
        }
        public string ChangeDiscussionParticipants(string discussionId, string value)
        {
            ProjectSecurity.DemandAuthentication();

            if (string.IsNullOrEmpty(discussionId))
            {
                return(string.Empty);
            }
            var discussion   = Global.EngineFactory.GetMessageEngine().GetByID(int.Parse(discussionId));
            var participants = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            Global.EngineFactory.GetMessageEngine().SaveOrUpdate(discussion, false, participants.Select(p => new Guid(p)), null);
            return(ProjectsCommonResource.UnSubscribeOnNewComment);
        }
Beispiel #30
0
        public string GetReportUrl(string reportParams)
        {
            ProjectSecurity.DemandAuthentication();

            var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            var rp         = serializer.Deserialize <ReportParams>(reportParams);

            var reptype = 0;

            int.TryParse(rp.ReportType, out reptype);

            var filter = ParseJSONFilter(rp);

            return(string.Format("reports.aspx?action=generate&reportType={0}&{1}", reptype, filter.ToUri()));
        }