Пример #1
0
        /// <summary>
        /// Loads the file library acl.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        private bool LoadFileLibraryAcl(AssignmentEntity entity, out FileStorage fs, out AccessControlList acl)
        {
            acl = null;
            fs  = null;

            // Resolve ContainerKey
            string containerName = "FileLibrary";
            string containerKey  = string.Empty;

            if (entity.OwnerDocumentId.HasValue)
            {
                containerKey = UserRoleHelper.CreateDocumentContainerKey(entity.OwnerDocumentId.Value);
            }
            //else
            // TODO: Add Ace other owner here

            // Check ContainerKey
            if (string.IsNullOrEmpty(containerKey))
            {
                return(false);
            }

            // Open ACL
            BaseIbnContainer bic = BaseIbnContainer.Create(containerName, containerKey);

            fs = (FileStorage)bic.LoadControl("FileStorage");

            acl = AccessControlList.GetACL(fs.Root.Id);

            return(true);
        }
Пример #2
0
        public async Task putAssignment(int assignmentId, AssignmentEntity assignment)
        {
            var assignmentPut = await PIDBContext.Assignments.SingleOrDefaultAsync(a => a.Id == assignmentId);

            assignmentPut.AreaId     = assignment.AreaId;
            assignmentPut.UpdateDate = DateTime.Now;
        }
Пример #3
0
        /// <summary>
        /// Deletes sticked items if the method is "delete" or assignment state is not active
        /// </summary>
        /// <param name="context">The context.</param>
        public void Execute(BusinessContext context)
        {
            if (context.GetMethod() == RequestMethod.Load ||
                context.GetMethod() == RequestMethod.List)
            {
                return;
            }

            PrimaryKeyId?pkId = context.GetTargetPrimaryKeyId();

            if (pkId.HasValue)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, pkId.Value);

                if (entity.OwnerDocumentId.HasValue)
                {
                    if (context.GetMethod() == RequestMethod.Delete ||
                        entity.State != (int)AssignmentState.Active)
                    {
                        if (entity.UserId.HasValue)
                        {
                            Calendar.DeleteStickedObject(entity.UserId.Value, entity.OwnerDocumentId.Value, (int)ObjectTypes.Document, (Guid)pkId.Value);
                        }
                    }
                }
            }
        }
Пример #4
0
        public override void DataBind()
        {
            AssignmentEntity entity = (AssignmentEntity)this.DataItem;

            AssignmentId = entity.PrimaryKeyId;

            if (!String.IsNullOrEmpty(entity.Subject))
            {
                SubjectLabel.Text = entity.Subject;
            }
            else
            {
                SubjectLabel.Text = GetGlobalResourceObject("IbnFramework.BusinessProcess", "NoSubject").ToString();
            }

            if (entity.PlanFinishDate.HasValue)
            {
                DueDateLabel.Text = String.Concat(entity.PlanFinishDate.Value.ToShortDateString(), " ", entity.PlanFinishDate.Value.ToShortTimeString());
                if (entity.TimeStatus == (int)AssignmentTimeStatus.OverDue)
                {
                    DueDateLabel.CssClass = "ibn-error";
                }

                DueDateRow.Visible = true;
            }
            else
            {
                DueDateRow.Visible = false;
            }
        }
Пример #5
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp = (CommandParameters)Element;

                if (cp.CommandArguments["SelectedValue"] == null)
                {
                    throw new ArgumentException("SelectedValue is null for ReassignHandler");
                }
                if (cp.CommandArguments["ObjectId"] == null)
                {
                    throw new ArgumentException("ObjectId is null for ReassignHandler");
                }

                int          userId       = int.Parse(cp.CommandArguments["SelectedValue"]);
                PrimaryKeyId assignmentId = PrimaryKeyId.Parse(cp.CommandArguments["ObjectId"]);

                AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, assignmentId);
                assignment.UserId = userId;
                BusinessManager.Update(assignment);

                CHelper.AddToContext("RebindAssignments", true);
            }
        }
Пример #6
0
        public void CreateNewAssignment(DabDBContext db)
        {
            AssignmentEntity assignment = new AssignmentEntity();

            Console.WriteLine("Write Nr of the Asssignment:");
            assignment.AssignmentId = Convert.ToInt32(Console.ReadLine());
            db.Add(assignment);
        }
Пример #7
0
        /// <summary>
        /// Called when [assignment updated].
        /// </summary>
        /// <param name="primaryKey">The primary key.</param>
        private void OnAssignmentUpdated(AssignmentEntity oldEntity, AssignmentEntity newEntity)
        {
            PrimaryKeyId primaryKey = oldEntity.PrimaryKeyId.Value;

            // Check User
            if (newEntity.UserId != oldEntity.UserId)
            {
                OnAssignmentUserAssigned(primaryKey, oldEntity.UserId, newEntity.UserId);
            }

            // Subject
            if (newEntity.Subject != oldEntity.Subject)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_GeneralInfo, (Guid)primaryKey);
            }

            // Priority
            if (newEntity.Priority != oldEntity.Priority)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Priority, (Guid)primaryKey);
            }

            // State
            if (newEntity.State != oldEntity.State)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Status, (Guid)primaryKey);

                // delete DateTypeValue for closed assignment (we notify about active only)
                if (newEntity.State == (int)AssignmentState.Closed)
                {
                    Schedule.DeleteDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey);
                }
            }

            // Finish Date
            if (newEntity.PlanFinishDate != oldEntity.PlanFinishDate)
            {
                if (oldEntity.PlanFinishDate.HasValue)
                {
                    Schedule.DeleteDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey);
                }

                DateTime dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);

                if (newEntity.PlanFinishDate.HasValue && newEntity.PlanFinishDate.Value > dateTimeNow)
                {
                    Schedule.UpdateDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey, DataContext.Current.CurrentUserTimeZone.ToUniversalTime(newEntity.PlanFinishDate.Value));
                }

                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_FinishDate, (Guid)primaryKey);
            }
        }
Пример #8
0
        private void BindData()
        {
            AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, AssignmentId);

            if (assignment != null)
            {
                SubjectText.Text = assignment.Subject;
                if (assignment.PlanFinishDate.HasValue)
                {
                    DueDatePicker.SelectedDate = assignment.PlanFinishDate.Value;
                }
            }
        }
Пример #9
0
        private void BindValues()
        {
            string Title        = "";
            int    ObjectTypeId = (int)ObjectTypes.UNDEFINED;

            ///  EventTypeId, ParentId, ObjectTypeId, RelObjectTypeId, Title, IsActive
            using (IDataReader reader = SystemEvents.GetSystemEventType(EventTypeId))
            {
                if (reader.Read())
                {
                    Title        = reader["Title"].ToString();
                    ObjectTypeId = (int)reader["ObjectTypeId"];
                }
            }

            lblNotification.Text = SystemEvents.GetSystemEventName(Title);

            lblObjectType.Text = Util.CommonHelper.GetObjectTypeName(ObjectTypeId);
            if (ObjectId.HasValue)
            {
                lblObject.Text = Util.CommonHelper.GetObjectLinkAndTitle(ObjectTypeId, ObjectId.Value);
            }
            else if (ObjectUid.HasValue && ObjectTypeId == (int)ObjectTypes.Assignment)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)ObjectUid.Value);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    string link = Mediachase.Ibn.Web.UI.CHelper.GetAssignmentLink(ObjectUid.Value.ToString(), (int)ObjectTypes.Document, entity.OwnerDocumentId.Value, this.Page);
                    lblObject.Text = Util.CommonHelper.GetHtmlLink(link, entity.Subject);
                }
            }

            rblType.Items.Add(new ListItem(LocRM.GetString("Unsubscribe"), "1"));
            if (ObjectId.HasValue)
            {
                rblType.Items.Add(new ListItem(LocRM.GetString("UnsubscribeForObject"), "2"));
            }
            rblType.Items[0].Selected = true;

            lnkNotification.NavigateUrl = String.Format("~/Directory/UserView.aspx?UserId={0}&Tab=3", Security.CurrentUser.UserID);

            if (ObjectId.HasValue)
            {
                lnkNotificationForObject.NavigateUrl = String.Format("~/Directory/SystemNotificationForObject.aspx?ObjectId={0}&ObjectTypeId={1}", ObjectId.Value, ObjectTypeId);
            }
            else
            {
                lnkNotificationForObject.Visible = false;
            }
        }
Пример #10
0
        static internal Assignment ConvertCaseOfficer(AssignmentEntity res)
        {
            var co = new Assignment
            {
                Identifier             = res.ID,
                Accepted               = res.Accepted,
                Assigned               = res.Assigned,
                Active                 = res.Active,
                FlowInstanceIdentifier = res.FlowInstanceID
            };


            return(co);
        }
Пример #11
0
        protected void PriorityList_ItemCommand(object source, DataListCommandEventArgs e)
        {
            int priorityId = int.Parse(e.CommandArgument.ToString());

            if (ObjectTypeId == (int)ObjectTypes.Task)
            {
                Task2.UpdatePriority(ObjectId, priorityId);
            }
            else if (ObjectTypeId == (int)ObjectTypes.ToDo)
            {
                ToDo2.UpdatePriority(ObjectId, priorityId);
            }
            else if (ObjectTypeId == (int)ObjectTypes.Issue)
            {
                Issue2.UpdatePriority(ObjectId, priorityId);
            }
            else if (ObjectTypeId == (int)ObjectTypes.Document)
            {
                if (AssignmentId.HasValue)
                {
                    AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)AssignmentId.Value);
                    if (priorityId == (int)Priority.Low)
                    {
                        assignment.Priority = (int)AssignmentPriority.Low;
                    }
                    else if (priorityId == (int)Priority.Normal)
                    {
                        assignment.Priority = (int)AssignmentPriority.Normal;
                    }
                    else if (priorityId == (int)Priority.High)
                    {
                        assignment.Priority = (int)AssignmentPriority.High;
                    }
                    else if (priorityId == (int)Priority.VeryHigh)
                    {
                        assignment.Priority = (int)AssignmentPriority.VeryHigh;
                    }
                    else
                    {
                        assignment.Priority = (int)AssignmentPriority.Urgent;
                    }

                    BusinessManager.Update(assignment);
                }
            }

            CommandParameters cp = new CommandParameters(CommandName);

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString(), true);
        }
Пример #12
0
        public static bool CheckSecurityForObject(ObjectTypes objectType, Guid objectUid, int userId)
        {
            bool isValid = false;

            if (objectType == ObjectTypes.Assignment)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    Document.DocumentSecurity sec = Document.GetSecurity(entity.OwnerDocumentId.Value, userId);
                    isValid = sec.IsManager || sec.IsResource || sec.IsCreator;
                }
            }
            return(isValid);
        }
        public Assignment CreateAssignment(ExecutionContextInfo context, Assignment assignment)
        {
            if (assignment == null)
            {
                throw new ArgumentNullException("assignment");
            }

            if (assignment.Case == null || assignment.Case.Identifier == Guid.Empty)
            {
                throw new ArgumentNullException("Assignment.Case.Identifier");
            }

            if (assignment.Officer == null || assignment.Officer.Identifier == Guid.Empty)
            {
                throw new ArgumentNullException("Assignment.Officer.Identifier");
            }

            if (assignment.Assigned == null)
            {
                assignment.Assigned = DateTime.Now;
            }

            using (var ctx = new Server.System.Repository.DataAccess.CaseHandlingDatabaseContext())
            {
                var caseEntity    = (from ca in ctx.CaseEntities where ca.ID == assignment.Case.Identifier select ca).FirstOrDefault();
                var officerEntity = (from of in ctx.OfficerEntities where of.ID == assignment.Officer.Identifier select of).FirstOrDefault();
                if (caseEntity == null || officerEntity == null)
                {
                    throw new CaseHandlingException(string.Format("Case ({0}) or Officer ({1}) information not found provided by Workflow ({2})", assignment.Case.Identifier, assignment.Officer.Identifier, assignment.FlowInstanceIdentifier));
                }
                var c = new AssignmentEntity()
                {
                    ID             = Guid.NewGuid(),
                    Case           = caseEntity,
                    Officer        = officerEntity,
                    Active         = true,
                    Assigned       = assignment.Assigned,
                    FlowInstanceID = assignment.FlowInstanceIdentifier,
                };
                ctx.AssignmentEntities.AddObject(c);
                ctx.SaveChanges();
                assignment.Active     = c.Active;
                assignment.Identifier = c.ID;

                return(assignment);
            }
        }
Пример #14
0
        protected void DenyButton_ServerClick(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, AssignmentId.Value);

            assignment.ExecutionResult = (int)AssignmentExecutionResult.Declined;
            assignment.Comment         = CommentText.Text;
            BusinessManager.Execute(new CloseAssignmentRequest(assignment));

            // Notify parent control
            ItemCommand(sender, e);
        }
Пример #15
0
        /// <summary>
        /// Called when [assignment created].
        /// </summary>
        /// <param name="primaryKey">The primary key.</param>
        private void OnAssignmentCreated(PrimaryKeyId primaryKey)
        {
            DateTime         dateTimeNow = DataContext.Current.CurrentUserTimeZone.ToLocalTime(DateTime.UtcNow);
            AssignmentEntity entity      = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, primaryKey);

            SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Created, (Guid)primaryKey);

            if (entity.PlanFinishDate.HasValue && entity.PlanFinishDate.Value > dateTimeNow)
            {
                Schedule.UpdateDateTypeValue(DateTypes.AssignmentFinishDate, (Guid)primaryKey, DataContext.Current.CurrentUserTimeZone.ToUniversalTime(entity.PlanFinishDate.Value));
            }

            if (entity.UserId.HasValue)
            {
                SystemEvents.AddSystemEvents(SystemEventTypes.Assignment_Updated_Participant_Assigned, (Guid)primaryKey, entity.UserId.Value);
            }
        }
Пример #16
0
        /// <summary>
        /// Users the can write.
        /// </summary>
        /// <param name="entity">The entity.</param>
        /// <returns></returns>
        private bool CanUserWrite(AssignmentEntity entity)
        {
            if (entity.WorkflowInstanceId.HasValue &&
                !string.IsNullOrEmpty(entity.WorkflowActivityName))
            {
                PropertyValueCollection properties = WorkflowActivityWrapper.GetAssignmentProperties((Guid)entity.WorkflowInstanceId.Value, entity.WorkflowActivityName);

                if (properties.Contains(AssignmentCustomProperty.ReadOnlyLibraryAccess))
                {
                    bool?value = properties[AssignmentCustomProperty.ReadOnlyLibraryAccess] as bool?;
                    if (value.HasValue)
                    {
                        return(!value.Value);
                    }
                }
            }

            return(true);
        }
Пример #17
0
        private static bool ConfirmNotification(ObjectTypes objectType, DateTypes dateType, int?objectId, Guid?objectUid)
        {
            bool notify = false;

            bool hasRecurrence = false;

            if (objectId.HasValue)
            {
                using (IDataReader reader = DBCommon.GetRecurrence((int)objectType, objectId.Value))
                {
                    hasRecurrence = reader.Read();
                }
            }

            switch (objectType)
            {
            case ObjectTypes.CalendarEntry:
                notify = CalendarEntry.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Project:
                notify = Project.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Task:
                notify = Task.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.ToDo:
                notify = ToDo.ConfirmReminder(dateType, objectId.Value, hasRecurrence);
                break;

            case ObjectTypes.Assignment:
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                if (entity != null && entity.State == (int)AssignmentState.Active)
                {
                    notify = true;
                }
                break;
            }

            return(notify);
        }
Пример #18
0
        public void CreateAssignment(int weekID, PlaybookRow newRow, int requestorID)
        {
            var task = new AssignmentEntity
            {
                Description    = newRow.Description,
                Duration       = newRow.Duration,
                IntraweekID    = newRow.IntraweekID,
                PriorityID     = newRow.PriorityID,
                StatusID       = _statuses.Booked.ID,
                RequestorID    = requestorID,
                RequestedStamp = DateTime.Now,
                ResourceID     = newRow.ResourceID,
                WhatID         = newRow.WhatID,
                WhenID         = weekID,
                Completed      = 0.0,
            };

            _repository.Add(task);
            UnitOfWork.Commit();
        }
Пример #19
0
        protected void ApproveButton_ServerClick(object sender, EventArgs e)
        {
            AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, AssignmentId.Value);

            assignment.ExecutionResult = (int)AssignmentExecutionResult.Accepted;

            // files
            string      filesText = string.Empty;
            FileStorage fs        = FileStorage.Create(ContainerName, ContainerKey);

            FileInfo[] files = fs.GetFiles();
            if (files != null && files.Length > 0)
            {
                foreach (FileInfo file in files)
                {
                    if (!String.IsNullOrEmpty(filesText))
                    {
                        filesText += ", ";
                    }
                    filesText += file.Name;
                }

                filesText = String.Concat("<i>Файлы: ", filesText, "</i>");
            }

            if (!String.IsNullOrEmpty(filesText))
            {
                assignment.Comment = String.Format(CultureInfo.InvariantCulture,
                                                   "{0}\r\n{1}",
                                                   filesText, CommentText.Text);
            }
            else
            {
                assignment.Comment = CommentText.Text;
            }

            BusinessManager.Execute(new CloseAssignmentRequest(assignment));

            // Notify parent control
            ItemCommand(sender, e);
        }
Пример #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Guid             assignmentId = new Guid(Request.QueryString["id"]);
            AssignmentEntity entity       = null;

            try
            {
                entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)assignmentId);
            }
            catch
            {
            }

            if (entity != null && entity.OwnerDocumentId.HasValue)
            {
                Response.Redirect(CHelper.GetAssignmentLink(assignmentId.ToString(), (int)ObjectTypes.Document, entity.OwnerDocumentId.Value));
            }
            else
            {
                Response.Redirect("~/Common/NotExistingId.aspx?AssignmentId=" + assignmentId.ToString());
            }
        }
Пример #21
0
        private int BindAssignment()
        {
            int itemsCount = 0;

            if (AssignmentId != PrimaryKeyId.Empty)
            {
                FilterElementCollection filters = new FilterElementCollection();
                filters.Add(FilterElement.EqualElement(OwnerType, OwnerId));
                filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldUserId, Bus.Security.CurrentUser.UserID));
                filters.Add(FilterElement.EqualElement(AssignmentEntity.FieldState, AssignmentState.Active));
                filters.Add(FilterElement.EqualElement("PrimaryKeyId", AssignmentId));

                EntityObject[] assignments = BusinessManager.List(AssignmentEntity.ClassName, filters.ToArray());
                if (assignments != null && assignments.Length > 0)
                {
                    AssignmentEntity assignment = (AssignmentEntity)assignments[0];

                    SavedPath = AssignmentEntity.GetControlPath(assignment);

                    MCDataBoundControl control = (MCDataBoundControl)LoadAssignment();
                    if (control != null)
                    {
                        control.DataItem = assignment;
                        control.DataBind();
                    }

                    itemsCount = 1;
                }
                else
                {
                    SavedPath = String.Empty;
                    MainPlaceHolder.Controls.Clear();
                    itemsCount = 0;
                }
            }

            return(itemsCount);
        }
Пример #22
0
        protected void SaveButton_ServerClick(object sender, EventArgs e)
        {
            AssignmentEntity assignment = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, AssignmentId);

            if (assignment != null)
            {
                assignment.Subject = SubjectText.Text;
                if (DueDatePicker.SelectedDate != DateTime.MinValue)
                {
                    assignment.PlanFinishDate = DueDatePicker.SelectedDate;
                }
                else
                {
                    assignment.PlanFinishDate = null;
                }
                BusinessManager.Update(assignment);
            }

            // Close popup
            if (!String.IsNullOrEmpty(Request["closeFramePopup"]))
            {
                CommandParameters cp = new CommandParameters();
                if (Request["ReturnCommand"] != null)
                {
                    cp.CommandName = Request["ReturnCommand"];
                }
                Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, string.Empty, true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(),
                                                        "<script language='javascript'>" +
                                                        "try {window.opener.location.href=window.opener.location.href;}" +
                                                        "catch (e){} window.close();</script>");
            }
        }
Пример #23
0
        private static bool CheckRights(SystemEventTypes eventType, ObjectTypes objectType, ObjectTypes relObjectType, int?objectId, int?relObjectId, Guid?objectUid, int userId)
        {
            // если нужна дополнительная проверка в зависимости от типа события, то её нужно делать здесь
            bool retval = false;

            if (relObjectType == ObjectTypes.File_FileStorage && relObjectId != null)
            {
                FileInfo fileInfo = null;
                //Получаем оригинальный файл
                using (IDataReader reader = Mediachase.IBN.Database.ControlSystem.DBFile.GetById(0, relObjectId.Value))
                {
                    if (reader.Read())
                    {
                        fileInfo = new Mediachase.IBN.Business.ControlSystem.FileInfo(reader);
                    }
                }

                if (fileInfo != null)
                {
                    return(CheckFileStorageRight(fileInfo, "Read", userId));
                }
            }

            switch (objectType)
            {
            case ObjectTypes.ToDo:
                retval = ToDo.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.CalendarEntry:
                retval = CalendarEntry.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.Document:
                retval = Document.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.Issue:
                retval = Incident.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.List:
                retval = ListInfoBus.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.Project:
                retval = Project.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.Task:
                retval = Task.CanRead(objectId.Value, userId);
                break;

            case ObjectTypes.IssueRequest:
                retval = IssueRequest.CanUse(userId);
                break;

            case ObjectTypes.User:
                retval = Security.IsUserInGroup(userId, InternalSecureGroups.Administrator);
                break;

            case ObjectTypes.Assignment:
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    retval = Document.CanRead(entity.OwnerDocumentId.Value, userId);
                }
                break;

            default:
                // Для остальных временно разрешаем любой доступ
                retval = true;
                break;
            }

            return(retval);
        }
Пример #24
0
        public void InsertDummyData()
        {
            using var db = new DabDBContext();

            TeacherEntity teacher1 = new TeacherEntity();

            teacher1.Name = "Henrik Kirk";
            db.Add(teacher1);

            TeacherEntity teacher2 = new TeacherEntity();

            teacher2.Name = "S�ren";
            db.Add(teacher2);

            TeacherEntity teacher3 = new TeacherEntity();

            teacher3.Name = "Michael";
            db.Add(teacher3);

            TeacherEntity teacher4 = new TeacherEntity();

            teacher4.Name = "Lars";
            db.Add(teacher4);

            StudentEntity student1 = new StudentEntity();

            student1.Name = "Sebastian";
            db.Add(student1);

            StudentEntity student2 = new StudentEntity();

            student2.Name = "Tobias";
            db.Add(student2);

            StudentEntity student0 = new StudentEntity();

            student0.Name = "Gustav";
            db.Add(student0);

            AssignmentEntity assignment1 = new AssignmentEntity();

            assignment1.Teacher = teacher2;
            db.Add(assignment1);
            AssignmentEntity assignment2 = new AssignmentEntity();

            assignment2.Teacher = teacher2;
            db.Add(assignment2);
            AssignmentEntity assignment3 = new AssignmentEntity();

            assignment3.Teacher = teacher3;
            db.Add(assignment3);


            CourseEntity course = new CourseEntity()
            {
                Name        = "Databaser",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher1
                    },
                    assignment1,
                    assignment2
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher1,
                    teacher2
                }
            };
            CourseEntity course3 = new CourseEntity()
            {
                Name        = "MMLS",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher3
                    }
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher4
                }
            };

            db.Add(course3);
            CourseEntity course2 = new CourseEntity()
            {
                Name        = "SWD",
                Assignments = new List <AssignmentEntity>
                {
                    new AssignmentEntity
                    {
                        Teacher = teacher1
                    },
                    assignment3
                },
                Teachers = new List <TeacherEntity>()
                {
                    teacher3
                }
            };

            db.Add(course2);

            ExerciseEntity exercise1 = new ExerciseEntity();

            exercise1.Number    = 2;
            exercise1.Lecture   = "3 EF core";
            exercise1.Teacher   = teacher1;
            exercise1.Student   = student1;
            exercise1.HelpWhere = "Ex 3.1";
            exercise1.Course    = course;
            db.Add(exercise1);

            ExerciseEntity exercise2 = new ExerciseEntity();

            exercise2.Number    = 5;
            exercise2.Lecture   = "5 EF core";
            exercise2.Teacher   = teacher1;
            exercise2.Student   = student1;
            exercise2.HelpWhere = "Side 2";
            exercise2.Course    = course;
            db.Add(exercise2);


            ExerciseEntity exercise3 = new ExerciseEntity();

            exercise3.Number    = 1;
            exercise3.Lecture   = "Design patterns";
            exercise3.Teacher   = teacher3;
            exercise3.Student   = student0;
            exercise3.HelpWhere = "Det hele";
            exercise3.Course    = course2;
            db.Add(exercise3);

            ExerciseEntity exercise4 = new ExerciseEntity();

            exercise4.Number  = 4;
            exercise4.Lecture = "Functional Programming";
            exercise4.Teacher = teacher1;
            exercise4.Student = student0;
            exercise4.Course  = course2;
            db.Add(exercise4);

            ExerciseEntity exercise5 = new ExerciseEntity();

            exercise5.Number  = 5;
            exercise5.Lecture = "Some math";
            exercise5.Teacher = teacher4;
            exercise5.Student = student2;
            exercise5.Course  = course3;
            db.Add(exercise5);

            StudentCourseEntity joinedStudCourse = new StudentCourseEntity()
            {
                Students = student0,
                Courses  = course,
            };

            db.Add(joinedStudCourse);
            joinedStudCourse = new StudentCourseEntity()
            {
                Students = student1,
                Courses  = course,
            };
            db.Add(joinedStudCourse);
            joinedStudCourse = new StudentCourseEntity()
            {
                Students = student2,
                Courses  = course,
            };
            var testAss = new AssignmentStudentEntity()
            {
                Students    = student0,
                Assignments = assignment1,
            };

            db.Add(joinedStudCourse);

            db.SaveChanges();
        }
Пример #25
0
        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public virtual void Execute(BusinessContext context)
        {
            // Load ACL
            FileStorage       fs;
            AccessControlList acl;

            switch (context.GetMethod())
            {
            // Post Main Operations
            case AssignmentRequestMethod.Resume:
            case AssignmentRequestMethod.Activate:
            case AssignmentRequestMethod.AssignUser:
                AssignmentEntity entity      = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
                Guid             aclOwnerKey = (Guid)context.GetTargetPrimaryKeyId().Value;

                if (LoadFileLibraryAcl(entity, out fs, out acl))
                {
                    // Remove All Assignment ACE
                    for (int index = acl.Count - 1; index >= 0; index--)
                    {
                        if (acl[index].OwnerKey == aclOwnerKey)
                        {
                            acl.RemoveAt(index);
                        }
                    }

                    // Add New
                    if (entity.UserId.HasValue && CanUserWrite(entity))
                    {
                        acl.Add(new AccessControlEntry(entity.UserId.Value, "Write", true, aclOwnerKey));
                    }

                    // Save ACL
                    AccessControlList.SetACL(fs, acl, false);
                }
                break;

            // Pre Main Operations
            case AssignmentRequestMethod.Close:
            case AssignmentRequestMethod.Suspend:
            case RequestMethod.Delete:
                AssignmentEntity delEntity      = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, context.GetTargetPrimaryKeyId().Value);
                Guid             delAclOwnerKey = (Guid)context.GetTargetPrimaryKeyId().Value;

                if (LoadFileLibraryAcl(delEntity, out fs, out acl))
                {
                    // Remove All Assignment ACE
                    for (int index = acl.Count - 1; index >= 0; index--)
                    {
                        if (acl[index].OwnerKey == delAclOwnerKey)
                        {
                            acl.RemoveAt(index);
                        }
                    }

                    // Save ACL
                    AccessControlList.SetACL(fs, acl, false);
                }
                break;
            }
        }
Пример #26
0
 public void postAssignment(AssignmentEntity assignment)
 {
     PIDBContext.Assignments.Add(assignment);
 }
Пример #27
0
 /// <summary>
 /// Saves the old assignment entity.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="entity">The entity.</param>
 private void SaveOldAssignmentEntity(BusinessContext context, AssignmentEntity entity)
 {
     context.Items[OldAssignmentEntity] = entity;
 }
Пример #28
0
 /// <summary>
 /// Runs the workflow.
 /// </summary>
 /// <param name="entity">The entity.</param>
 public static void ProcessWorkflowRules(AssignmentEntity entity)
 {
     throw new NotImplementedException();
 }
Пример #29
0
        private static void ProcessGlobalSubscription(int hookId, DateTypes dateType, ObjectTypes objectType, int?objectId, Guid?objectUid)
        {
            // Формируем список пользователей, связанных с объектом
            List <int> users = new List <int>();

            if (objectType == ObjectTypes.Project)
            {
                using (IDataReader reader = DBProject.GetProjectSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Task)
            {
                using (IDataReader reader = DBTask.GetTaskSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        if ((bool)reader["IsRealTaskResource"] || (bool)reader["IsRealTaskManager"] || (bool)reader["IsCreator"])
                        {
                            users.Add((int)reader["UserId"]);
                        }
                    }
                }
            }
            else if (objectType == ObjectTypes.ToDo)
            {
                using (IDataReader reader = DBToDo.GetToDoSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.CalendarEntry)
            {
                using (IDataReader reader = DBEvent.GetListUsersForEvent(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Document)
            {
                using (IDataReader reader = DBDocument.GetDocumentSecurity(objectId.Value))
                {
                    while (reader.Read())
                    {
                        users.Add((int)reader["UserId"]);
                    }
                }
            }
            else if (objectType == ObjectTypes.Assignment)
            {
                AssignmentEntity entity = (AssignmentEntity)BusinessManager.Load(AssignmentEntity.ClassName, (PrimaryKeyId)objectUid.Value);
                if (entity != null && entity.OwnerDocumentId.HasValue)
                {
                    using (IDataReader reader = DBDocument.GetDocumentSecurity(entity.OwnerDocumentId.Value))
                    {
                        while (reader.Read())
                        {
                            users.Add((int)reader["UserId"]);
                        }
                    }
                }
            }

            // Проверим отсутствие индивидуальной подписки
            for (int i = 0; i < users.Count; i++)
            {
                int userId = users[i];

                // O.R. [2010-04-01]: Don't process inactive users
                if (User.GetUserActivity(userId) != User.UserActivity.Active)
                {
                    users.RemoveAt(i);
                    i--;
                }
                else if (objectId.HasValue)
                {
                    if (GetSubscriptionType(dateType, userId, objectId.Value) != SubscriptionTypes.Global)
                    {
                        users.RemoveAt(i);
                        i--;
                    }
                }
            }

            // Send Reminder
            if (users.Count > 0)
            {
                SendReminder(dateType, objectType, objectId, objectUid, users);
            }
        }