예제 #1
0
        private List <EventInviteEntity> BuilderInvite(EventsView model)
        {
            ///获取旧数据
            List <EventInviteEntity> oldlist = new App.EventsApplication().GetEventInvites(model.ID);

            foreach (EventInviteEntity tmpItem in oldlist)
            {
                if (tmpItem.UserID > 0)
                {
                    UsersEntity tmpUser = new App.UserApplication().GetUser(tmpItem.UserID);
                    tmpItem.FirstName = tmpUser.FirstName;
                    tmpItem.LastName  = tmpUser.LastName;
                    tmpItem.Email     = tmpUser.Email;
                }
            }


            ///获取project users 选中的用户,并区分是新加的,还是原本就有的
            List <EventInviteEntity> inviteList = new List <EventInviteEntity>();
            string projectUserIds = QF("chkProjectUser");

            if (projectUserIds.Trim() != string.Empty)
            {
                List <int> listUserId = new App.ProjectApplication().GetActiveUserIdByProjectId(model.ProjectID);
                projectUserIds = projectUserIds.Trim();
                if (projectUserIds.EndsWith(","))
                {
                    projectUserIds = projectUserIds.Remove(projectUserIds.Length - 1);
                }
                int tmpId;
                foreach (string s in projectUserIds.Split(','))
                {
                    if (int.TryParse(s, out tmpId))
                    {
                        if (listUserId.Contains(tmpId))
                        {
                            EventInviteEntity newEntity = new EventInviteEntity()
                            {
                                CreatedID = UserInfo.UserID,
                                EventID   = model.ID,
                                FromDay   = model.FromDay,
                                UserID    = tmpId,
                                Email     = "",
                                FirstName = "",
                                LastName  = ""
                            };
                            if (oldlist.Find(r => r.UserID == tmpId) != null)
                            {
                                newEntity.OptionStatus = 1;
                            }
                            else
                            {
                                newEntity.OptionStatus = 2;
                            }
                            inviteList.Add(newEntity);
                        }
                    }
                }
            }

            ///标记被删除的project users
            foreach (EventInviteEntity item in oldlist.FindAll(r => r.UserID > 0))
            {
                if (inviteList.Find(r => r.UserID == item.UserID) == null)
                {
                    item.OptionStatus = 3;
                    inviteList.Add(item);
                }
            }

            ///获取other user,  如果有填写 Email 则区分是新加的,还是原有的
            int otherusers_count = QF("otherusers_count", 0);

            if (otherusers_count > 0)
            {
                string firstName;
                string lastName;
                string email;
                for (int i = 1; i <= otherusers_count; i++)
                {
                    firstName = QF("txtOtherUserFirst" + i).Trim();
                    lastName  = QF("txtOtherUserLast" + i).Trim();
                    email     = QF("txtOtherUserEmail" + i).Trim().ToLower();
                    if (firstName != string.Empty && lastName != string.Empty)
                    {
                        EventInviteEntity newEntity = new EventInviteEntity()
                        {
                            CreatedID = UserInfo.UserID,
                            LastName  = lastName,
                            FirstName = firstName,
                            Email     = email,
                            FromDay   = model.FromDay,
                            EventID   = model.ID,
                            UserID    = 0
                        };

                        if (email != string.Empty)
                        {
                            if (oldlist.Find(r => r.Email.ToLower() == email) != null)
                            {
                                newEntity.OptionStatus = 1;
                            }
                            else
                            {
                                newEntity.OptionStatus = 2;
                            }
                        }
                        else
                        {
                            newEntity.OptionStatus = 2;
                        }
                        inviteList.Add(newEntity);
                    }
                }

                ///标记被删除的 other  users(只针对有email的)
                foreach (EventInviteEntity item in oldlist.FindAll(r => r.UserID == 0))
                {
                    if (item.Email != string.Empty)
                    {
                        if (inviteList.Find(r => r.Email.ToLower() == item.Email) == null)
                        {
                            item.OptionStatus = 3;
                            inviteList.Add(item);
                        }
                    }
                }
            }
            return(inviteList);
        }
예제 #2
0
        private List <EventInviteEntity> GetInviteData(EventEntity eventEntity, bool isDelete = false)
        {
            List <EventInviteEntity> list = new App.EventsApplication().GetEventInvites(eventEntity.ID);

            foreach (EventInviteEntity tmpItem in list.FindAll(r => r.UserID > 0))
            {
                UsersEntity    tmpUser      = new App.UserApplication().GetUser(tmpItem.UserID);
                CompanysEntity comanyEntity = new App.CompanyApplication().GetCompany(tmpUser.CompanyID);
                tmpItem.FirstName   = tmpUser.FirstName;
                tmpItem.LastName    = tmpUser.LastName;
                tmpItem.Email       = tmpUser.Email;
                tmpItem.IsSeleted   = true;
                tmpItem.Title       = tmpUser.Title;
                tmpItem.CompanyName = comanyEntity.CompanyName;
            }
            if (isDelete)
            {
                return(list);
            }

            List <int>     listUserId    = new App.ProjectApplication().GetActiveUserIdByProjectId(eventEntity.ProjectID);
            ProjectsEntity projectEntity = new App.ProjectApplication().Get(eventEntity.ProjectID);

            litProject.Text = projectEntity.Title;

            listUserId.Remove(UserInfo.UserID);
            if (UserInfo.Office == "CN" && UserInfo.UserType == "SUNNET")//山诺 上海的员工只能获取本公司的项目的相关人员
            {
                if (projectEntity.CompanyID == Config.SunnetCompany)
                {
                    foreach (int tmpId in listUserId)
                    {
                        UsersEntity tmpUser = new App.UserApplication().GetUser(tmpId);
                        if (tmpUser == null)
                        {
                            continue;
                        }
                        if (tmpUser.UserType == "SUNNET")
                        {
                            if (list.Find(r => r.UserID == tmpUser.UserID) == null)
                            {
                                list.Add(new EventInviteEntity()
                                {
                                    EventID = eventEntity.ID, UserID = tmpUser.UserID, FirstName = tmpUser.FirstName, LastName = tmpUser.LastName
                                });
                            }
                        }
                    }
                }
            }
            else
            {
                if (UserInfo.Role == RolesEnum.CLIENT || UserInfo.Role == RolesEnum.ADMIN || UserInfo.Role == RolesEnum.PM || UserInfo.Role == RolesEnum.Sales || UserInfo.Role == RolesEnum.Contactor)
                {
                    foreach (int tmpId in listUserId)
                    {
                        UsersEntity tmpUser = new App.UserApplication().GetUser(tmpId);
                        if (tmpUser == null)
                        {
                            continue;
                        }
                        CompanysEntity comanyEntity = new App.CompanyApplication().GetCompany(tmpUser.CompanyID);
                        if (projectEntity.CompanyID == Config.SunnetCompany) //如果是公司项目
                        {
                            if (list.Find(r => r.UserID == tmpUser.UserID) == null)
                            {
                                list.Add(new EventInviteEntity()
                                {
                                    EventID = eventEntity.ID,
                                    UserID  = tmpUser.UserID
                                    ,
                                    FirstName   = tmpUser.FirstName,
                                    LastName    = tmpUser.LastName,
                                    Title       = tmpUser.Title,
                                    CompanyName = comanyEntity.CompanyName
                                });
                            }
                        }
                        else
                        {
                            if (tmpUser.Role == RolesEnum.CLIENT || tmpUser.Role == RolesEnum.ADMIN || tmpUser.Role == RolesEnum.PM || tmpUser.Role == RolesEnum.Sales || UserInfo.Role == RolesEnum.Contactor)
                            {
                                if (list.Find(r => r.UserID == tmpUser.UserID) == null)
                                {
                                    list.Add(new EventInviteEntity()
                                    {
                                        EventID = eventEntity.ID,
                                        UserID  = tmpUser.UserID
                                        ,
                                        FirstName   = tmpUser.FirstName,
                                        LastName    = tmpUser.LastName,
                                        Title       = tmpUser.Title,
                                        CompanyName = comanyEntity.CompanyName
                                    });
                                }
                            }
                        }
                    }
                }
            }
            return(list);
        }