Esempio n. 1
0
        protected CUserEntity CreateUser(CUserEntity newUser)
        {
            try
            {
                COrganizeEntity organize = new COrganizeEntity(ConnString).Load(Usr_Organize);

                // create resource for user's folder
                CResourceEntity folderRes = new CResourceEntity(ConnString);
                folderRes.Res_Name   = "";
                folderRes.Res_Parent = organize.Org_Resource;
                folderRes.Res_Type   = (int)RESOURCETYPE.FOLDERRESOURCE;
                folderRes.Res_Id     = folderRes.Insert();

                folderRes.Res_Name = folderRes.Res_Id.ToString() + newUser.Usr_Member;
                folderRes.Update();

                // create user's folder
                String userPath = folderRes.MakeFullPath();
                Directory.CreateDirectory(userPath);

                // create user
                newUser.Usr_Resource = folderRes.Res_Id;
                newUser.ConnString   = ConnString;
                newUser.Usr_Id       = newUser.Insert();
                return(newUser);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 2
0
        public COrganizeEntity CreateOrganize(String organizeName)
        {
            try
            {
                // Check privilege
                CACLEntity acl = new CACLEntity();
                acl.Acl_Resource  = 0;
                acl.Acl_Operation = (int)ACLOPERATION.CREATEORGANIZE;
                if (!CheckPrivilege(acl))
                {
                    throw new Exception("当前用户无创建组织权限");
                }

                // create resource for this organize
                CResourceEntity res = new CResourceEntity(ConnString);
                res.Res_Name   = organizeName;
                res.Res_Parent = 0;
                res.Res_Type   = (int)RESOURCETYPE.ORGANIZERESOURCE;
                res.Res_Id     = res.Insert();

                // create default storage folder named as organize resource id
                String organizePath = Path.Combine(MidLayerSettings.AppPath, res.Res_Id.ToString() + organizeName);
                Directory.CreateDirectory(organizePath);

                // create resource for default folder of organize
                CResourceEntity folderRes = new CResourceEntity(ConnString);
                folderRes.Res_Name   = res.Res_Id.ToString() + organizeName;
                folderRes.Res_Parent = 0;
                folderRes.Res_Type   = (int)RESOURCETYPE.FOLDERRESOURCE;
                folderRes.Res_Id     = folderRes.Insert();

                // Create organize entity
                COrganizeEntity organize = new COrganizeEntity(ConnString);
                organize.Org_Name = organizeName;
                //organize = res.Res_Id;
                organize.Org_Resource = res.Res_Id;
                organize.Insert();

                // create archive folder for organzie
                String archivePath = Path.Combine(organizePath, "Archive");
                Directory.CreateDirectory(archivePath);

                // create resource for archive folder
                CResourceEntity archiveRes = new CResourceEntity(ConnString);
                archiveRes.Res_Name   = "Archive";
                archiveRes.Res_Parent = folderRes.Res_Id;
                archiveRes.Res_Type   = (int)RESOURCETYPE.FOLDERRESOURCE;
                archiveRes.Res_Id     = archiveRes.Insert();

                organize.Org_ArchiveRes = archiveRes.Res_Id;
                organize.Update();

                return(organize);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Esempio n. 3
0
        // newUser.Usr_Organize neend be set
        public CUserEntity CreateAdminlUser(CUserEntity newUser)
        {
            try
            {
                // Check privilege
                CACLEntity acl = new CACLEntity();
                acl.Acl_Operation = (int)ACLOPERATION.CRETAEORGANIZEADMIN;
                acl.Acl_Resource  = Usr_Organize;
                if (!CheckPrivilege(acl))
                {
                    throw new Exception("当前用户无创建管理员用户权限");
                }

                // create admin
                newUser.Usr_Type = (int)USERTYPE.ORGANIZEADMIN;
                CUserEntity user = CreateUser(newUser);

                // add acls to admin, organize acl, root dir acl
                COrganizeEntity organize = new COrganizeEntity(ConnString);
                organize = organize.Load(user.Usr_Organize);

/*
 *              CACLEntity acl1 = new CACLEntity(ConnString);
 *              acl1.Acl_CreateTime = DateTime.Now;
 *              acl1.Acl_Creator = Usr_Id;
 *              acl1.Acl_Operation = 0;
 *              acl1.Acl_Resource = organize.Org_Id;
 *              acl1.Acl_Role = user.Usr_Id;
 *              acl1.Acl_RType = (int)ACLROLETYPE.USERROLE;
 *              acl1.Acl_Id = acl1.Insert();
 */
                CACLEntity acl2 = new CACLEntity(ConnString);
                acl2.Acl_CreateTime = DateTime.Now;
                acl2.Acl_Creator    = Usr_Id;
                acl2.Acl_Operation  = (int)ACLOPERATION.WRITE;
                acl2.Acl_Resource   = organize.Org_Resource;
                acl2.Acl_Role       = user.Usr_Id;
                acl2.Acl_RType      = (int)ACLROLETYPE.USERROLE;
                acl2.Acl_Id         = acl2.Insert();

                CACLEntity acl3 = new CACLEntity(ConnString);
                acl3.Acl_CreateTime = DateTime.Now;
                acl3.Acl_Creator    = Usr_Id;
                acl3.Acl_Operation  = (int)ACLOPERATION.READ;
                acl3.Acl_Resource   = organize.Org_Resource;
                acl3.Acl_Role       = user.Usr_Id;
                acl3.Acl_RType      = (int)ACLROLETYPE.USERROLE;
                acl3.Acl_Id         = acl3.Insert();

                return(user);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 4
0
        public COrganizeEntity GetUserOrganize()
        {
            if (m_userOrganize != null)
            {
                return(m_userOrganize);
            }

            m_userOrganize = new COrganizeEntity(ConnString);
            m_userOrganize = m_userOrganize.Load(Usr_Organize);
            return(m_userOrganize);
        }
Esempio n. 5
0
        // list all resources shared to me
        public List <CResourceEntity> ListShareResources()
        {
            List <CResourceEntity> resources  = new List <CResourceEntity>();
            COrganizeEntity        organize   = new COrganizeEntity(ConnString).Load(this.Usr_Organize);
            CResourceEntity        archiveRes = organize.GetArchiveFolder();

            if (Usr_Type == (int)USERTYPE.SYSTEMADMIN || Usr_Type == (int)USERTYPE.ORGANIZEADMIN)
            {
                return(resources);
            }

            List <CACLEntity> acls = GetAllACLs();

            foreach (CACLEntity acl in acls)
            {
                if (acl.Acl_Operation != (int)ACLOPERATION.READ && acl.Acl_Operation != (int)ACLOPERATION.WRITE)
                {
                    continue;
                }

                if (acl.Acl_Resource == organize.Org_Resource)
                {
                    continue;
                }

                CResourceEntity res = new CResourceEntity(ConnString).Load(acl.Acl_Resource);
                if (res.Res_Type != (int)RESOURCETYPE.FILERESOURCE && res.Res_Type != (int)RESOURCETYPE.FOLDERRESOURCE)
                {
                    continue;
                }

                bool existed = false;
                foreach (CResourceEntity r in resources)
                {
                    if (r.Res_Id == res.Res_Id)
                    {
                        existed = true;
                        break;
                    }
                }

                if (!existed && !res.IsChild(archiveRes.Res_Id) && !res.IsChild(Usr_Resource))
                {
                    resources.Add(res);
                }
            }

            return(resources);
        }
Esempio n. 6
0
        /// <summary>
        /// 系统邮件服务——赵英武
        /// </summary>
        /// <param name="resId"></param>
        /// <param name="body"></param>
        public void MailSend(int resId, string body)
        {
            CMailEntity        mail     = new CMailEntity();
            List <CMailEntity> mailList = new List <CMailEntity>();
            string             filter   = "this.M_Resource ='" + resId + "'";

            filter  += "and this.M_Organize ='" + this.Usr_Organize + "'";
            mailList = mail.GetObjectList(filter);
            if (mailList.Count <= 0)
            {
                return;
            }

            COrganizeEntity org     = new COrganizeEntity().Load(this.Usr_Organize);
            string          from    = org.Org_Mail;
            string          subject = "文档管理系统邮件服务";
            string          pwd     = org.Org_MailPassword;

            SmtpClient client = new SmtpClient();

            client.Host = org.Org_MailSmtp;
            if (client.Host == null)
            {
                return;
            }
            if (org.Org_MailSSL == (int)SSL.CHECKED)
            {
                client.EnableSsl = true;
            }

            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.Credentials    = new System.Net.NetworkCredential(from, pwd);

            foreach (CMailEntity m in mailList)
            {
                string      to  = m.M_UsrMail;
                MailMessage msg = new MailMessage(from, to, subject, body);
                client.Send(msg);
            }
        }
Esempio n. 7
0
 public CUserEntity(String connectionString)
 {
     ConnString     = connectionString;
     m_userOrganize = null;
 }