当前位置: 首页>>代码示例>>C#>>正文


C# WSqlCommand.AddParameter方法代码示例

本文整理汇总了C#中LumiSoft.MailServer.WSqlCommand.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# WSqlCommand.AddParameter方法的具体用法?C# WSqlCommand.AddParameter怎么用?C# WSqlCommand.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LumiSoft.MailServer.WSqlCommand的用法示例。


在下文中一共展示了WSqlCommand.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetFolderACL

        /// <summary>
        /// Sets specified folder ACL for specified user.
        /// </summary>
        /// <param name="accessingUser">User who accesses this method. 
        /// User needs r permission to call this method or Exception is thrown. 
        /// There is special user 'system' for which permission check is skipped.</param>
        /// <param name="folderOwnerUser">User who's folder it is.</param>
        /// <param name="folder">Folder what ACL to set. For example: Inbox,Public Folders/Documnets .</param>
        /// <param name="userOrGroup">>User or user which group ACL set to specified folder.</param>
        /// <param name="setType">Specifies how ACL flags must be stored (ADD,REMOVE,REPLACE).</param>
        /// <param name="aclFlags">ACL flags.</param>
        public void SetFolderACL(string accessingUser,string folderOwnerUser,string folder,string userOrGroup,IMAP_Flags_SetType setType,IMAP_ACL_Flags aclFlags)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that folder owner user exists.
                *) Ensure that user or user group exists.
                *) Normalize folder. Remove '/' from folder start and end, ... .
                *) Do Shared Folders mapping.
                *) Ensure that folder exists. Throw Exception if don't.
                *) See if user has sufficient permissions. User requires 'a' permission.
                   There is builtin user system, skip ACL for it.
                *) Set folder ACL folder.
            */

            //--- Validate values -------------------//
            ArgsValidator.ValidateUserName(folderOwnerUser);
            ArgsValidator.ValidateFolder(folder);
            ArgsValidator.ValidateUserName(userOrGroup);
            //---------------------------------------//

            // Ensure that folder owner user exists.
            if(!UserExists(folderOwnerUser)){
               throw new Exception("User '" + folderOwnerUser + "' doesn't exist !");
            }

            // Ensure that user or user group exists. Skip check for anyone.
            if(userOrGroup.ToLower() != "anyone" && !GroupExists(userOrGroup)){
                if(!UserExists(userOrGroup)){
                   throw new Exception("Invalid userOrGroup value, there is no such user or group '" + userOrGroup + "' !");
               }
            }

            // Normalize folder. Remove '/' from folder start and end.
            folder = API_Utlis.NormalizeFolder(folder);

            // Do Shared Folders mapping.
            string originalFolder = folder;
            SharedFolderMapInfo mappedFolder = MapSharedFolder(originalFolder);
            if(mappedFolder.IsSharedFolder){
               folderOwnerUser = mappedFolder.FolderOnwer;
               folder = mappedFolder.Folder;

               if(folderOwnerUser == "" || folder == ""){
                   throw new ArgumentException("Specified root folder '" + originalFolder + "' isn't accessible !");
               }
            }

            // Ensure that folder doesn't exists. Throw Exception if don't.
            if(!FolderExists(folderOwnerUser + "/" + folder)){
               throw new Exception("Folder '" + folder + "' doesn't exist !");
            }

            // See if user has sufficient permissions. User requires 'a' permission.
            //  There is builtin user system, skip ACL for it.
            if(accessingUser.ToLower() != "system"){
               IMAP_ACL_Flags acl = GetUserACL(folderOwnerUser,folder,accessingUser);
               if((acl & IMAP_ACL_Flags.a) == 0){
                   throw new InsufficientPermissionsException("Insufficient permissions for folder '" + accessingUser + "/" + folder + "' !");
               }
            }

            //--- Set folder ACL
            IMAP_ACL_Flags currentACL_Flags = GetUserACL(folderOwnerUser,folder,folderOwnerUser);
            if(setType == IMAP_Flags_SetType.Replace){
                currentACL_Flags = aclFlags;
            }
            else if(setType == IMAP_Flags_SetType.Add){
                currentACL_Flags |= aclFlags;
            }
            else if(setType == IMAP_Flags_SetType.Remove){
                currentACL_Flags &= ~aclFlags;
            }

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_SetFolderACL")){
                sqlCmd.AddParameter("_folderOwnerUser",NpgsqlDbType.Varchar,folderOwnerUser);
                sqlCmd.AddParameter("_folderName"     ,NpgsqlDbType.Varchar,folder);
                sqlCmd.AddParameter("_userOrGroup"    ,NpgsqlDbType.Varchar,userOrGroup);
                sqlCmd.AddParameter("_permissions"    ,NpgsqlDbType.Varchar,IMAP_Utils.ACL_to_String(currentACL_Flags));

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:93,代码来源:pgsql_API.cs

示例2: CreateFolder

        /// <summary>
        /// Creates new IMAP folder.
        /// </summary>
        /// <param name="accessingUser">User who accesses this method. 
        /// User needs r permission to call this method or Exception is thrown. 
        /// There is special user 'system' for which permission check is skipped.</param>
        /// <param name="folderOwnerUser">User who's folder it is.</param>
        /// <param name="folder">Folder what contains message to copy. For example: Inbox,Public Folders/Documnets .</param>
        public void CreateFolder(string accessingUser,string folderOwnerUser,string folder)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that user exists.
                *) Normalize folder. Remove '/' from folder start and end, ... .
                *) Do Shared Folders mapping.
                *) Ensure that folder doesn't exists. Throw Exception if don't.
                *) See if user has sufficient permissions. User requires 'c' permission.
                    There is builtin user system, skip ACL for it.
                *) Create folder.
            */

            //--- Validate values -------------------//
            ArgsValidator.ValidateUserName(folderOwnerUser);
            ArgsValidator.ValidateFolder(folder);
            //---------------------------------------//

            // Ensure that user exists.
            if(!UserExists(folderOwnerUser)){
                throw new Exception("User '" + folderOwnerUser + "' doesn't exist !");
            }

            // Normalize folder. Remove '/' from folder start and end.
            folder = API_Utlis.NormalizeFolder(folder);

            // Do Shared Folders mapping.
            string originalFolder = folder;
            SharedFolderMapInfo mappedFolder = MapSharedFolder(originalFolder);
            if(mappedFolder.IsSharedFolder){
                folderOwnerUser = mappedFolder.FolderOnwer;
                folder = mappedFolder.Folder;

                if(folderOwnerUser == "" || folder == ""){
                    throw new ArgumentException("Specified root folder '" + originalFolder + "' isn't accessible !");
                }
            }

            // Ensure that folder doesn't exists. Throw Exception if don't.
            if(FolderExists(folderOwnerUser + "/" + folder)){
                throw new Exception("Folder '" + folder + "' already exist !");
            }

            // See if user has sufficient permissions. User requires 'c' permission.
            //  There is builtin user system, skip ACL for it.
            if(accessingUser.ToLower() != "system"){
                IMAP_ACL_Flags acl = GetUserACL(folderOwnerUser,folder,accessingUser);
                if((acl & IMAP_ACL_Flags.c) == 0){
                    throw new InsufficientPermissionsException("Insufficient permissions for folder '" + accessingUser + "/" + folder + "' !");
                }
            }

            //--- Create folder
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_CreateFolder")){
                sqlCmd.AddParameter("_folderID",NpgsqlDbType.Varchar,Guid.NewGuid().ToString());
                sqlCmd.AddParameter("_userName",NpgsqlDbType.Varchar,folderOwnerUser);
                sqlCmd.AddParameter("_folder"  ,NpgsqlDbType.Varchar,folder);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:69,代码来源:pgsql_API.cs

示例3: DeleteFilter

        /// <summary>
        /// Deletes specified filter.
        /// </summary>
        /// <param name="filterID">FilterID of the filter which to delete.</param>
        public void DeleteFilter(string filterID)
        {
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_DeleteFilter")){
                sqlCmd.AddParameter("_filterID" ,NpgsqlDbType.Varchar,filterID);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:12,代码来源:pgsql_API.cs

示例4: AddUserMessageRuleAction

        /// <summary>
        /// Adds action to specified user message rule.
        /// </summary>
        /// <param name="userID">User who owns specified rule.</param>
        /// <param name="ruleID">Rule ID to which to add this action.</param>
        /// <param name="actionID">Action ID. Guid.NewID().ToString() is suggested.</param>
        /// <param name="description">Action description.</param>
        /// <param name="actionType">Action type.</param>
        /// <param name="actionData">Action data. Data structure depends on action type.</param>
        public void AddUserMessageRuleAction(string userID,string ruleID,string actionID,string description,GlobalMessageRuleAction_enum actionType,byte[] actionData)
        {
            if(userID == null || userID == ""){
                throw new Exception("Invalid userID value, userID can't be '' or null !");
            }
            if(ruleID == null || ruleID == ""){
                throw new Exception("Invalid ruleID value, ruleID can't be '' or null !");
            }
            if(actionID == null || actionID == ""){
                throw new Exception("Invalid actionID value, actionID can't be '' or null !");
            }

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_AddUserMessageRuleAction")){
                sqlCmd.AddParameter("_userID"      ,NpgsqlDbType.Varchar,userID);
                sqlCmd.AddParameter("_ruleID"      ,NpgsqlDbType.Varchar,ruleID);
                sqlCmd.AddParameter("_actionID"    ,NpgsqlDbType.Varchar,actionID);
                sqlCmd.AddParameter("_description" ,NpgsqlDbType.Varchar,description);
                sqlCmd.AddParameter("_actionType"  ,NpgsqlDbType.Integer,(int)actionType);
                sqlCmd.AddParameter("_actionData"  ,NpgsqlDbType.Bytea  ,actionData);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:32,代码来源:pgsql_API.cs

示例5: AddUsersDefaultFolder

        /// <summary>
        /// Adds users default folder.
        /// </summary>
        /// <param name="folderName">Folder name.</param>
        /// <param name="permanent">Spcifies if folder is permanent, user can't delete it.</param>
        public void AddUsersDefaultFolder(string folderName,bool permanent)
        {
            ArgsValidator.ValidateFolder(folderName);

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_AddUsersDefaultFolder")){
                sqlCmd.AddParameter("_folderName" ,NpgsqlDbType.Varchar,folderName);
                sqlCmd.AddParameter("_permanent  ",NpgsqlDbType.Boolean ,permanent);

                DataSet ds = sqlCmd.Execute();
                ds.Tables[0].TableName = "UsersDefaultFolders";
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:17,代码来源:pgsql_API.cs

示例6: AddSharedFolderRoot

        /// <summary>
        /// Add shared folder root.
        /// </summary>
        /// <param name="rootID">Root folder ID. Guid.NewID().ToString() is suggested.</param>
        /// <param name="enabled">Specifies if root folder is enabled.</param>
        /// <param name="folder">Folder name which will be visible to public.</param>
        /// <param name="description">Description text.</param>
        /// <param name="rootType">Specifies what type root folder is.</param>
        /// <param name="boundedUser">User which to bound root folder.</param>
        /// <param name="boundedFolder">Folder which to bound to public folder.</param>
        public void AddSharedFolderRoot(string rootID,bool enabled,string folder,string description,SharedFolderRootType_enum rootType,string boundedUser,string boundedFolder)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that root ID doesn't exists.
                *) Ensure that root doesn't exists.
                *) Add root folder.
            */

            if(rootID == null || rootID == ""){
                throw new Exception("Invalid rootID value, rootID can't be '' or null !");
            }

            //--- Validate values -------------------------------------//
            ArgsValidator.ValidateNotNull(rootID);
            ArgsValidator.ValidateSharedFolderRoot(folder);
            ArgsValidator.ValidateNotNull(description);
            if(rootType == SharedFolderRootType_enum.BoundedRootFolder){
                ArgsValidator.ValidateUserName(boundedUser);
                ArgsValidator.ValidateFolder(boundedFolder);
            }
            //---------------------------------------------------------//

            /* We handle these is SQL, sql returns these errors in ErrorText

                *) Ensure that root ID doesn't exists.
                *) Ensure that root doesn't exists.
            */

            // Insert group
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_AddSharedFolderRoot")){
                sqlCmd.AddParameter("_rootID"        ,NpgsqlDbType.Varchar,rootID);
                sqlCmd.AddParameter("_enabled"       ,NpgsqlDbType.Boolean,enabled);
                sqlCmd.AddParameter("-folder"        ,NpgsqlDbType.Varchar,folder);
                sqlCmd.AddParameter("_description"   ,NpgsqlDbType.Varchar,description);
                sqlCmd.AddParameter("_rootType"      ,NpgsqlDbType.Integer,rootType);
                sqlCmd.AddParameter("_boundedUser"   ,NpgsqlDbType.Varchar,boundedUser);
                sqlCmd.AddParameter("_boundedFolder" ,NpgsqlDbType.Varchar,boundedFolder);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:52,代码来源:pgsql_API.cs

示例7: AddUserAddress

        /// <summary>
        /// Add new email address to user.
        /// </summary>
        /// <param name="userName">User name. Use <see cref="IMailServerApi.GetUsers">>GetUsers()</see> to get valid values.</param>
        /// <param name="emailAddress">Email address to add.</param>
        /// <remarks>Throws exception if specified user email address exists.</remarks>
        public void AddUserAddress(string userName,string emailAddress)
        {
            if(userName.Length == 0){
                throw new Exception("You must specify userName");
            }
            if(emailAddress.Length == 0){
                throw new Exception("You must specify address");
            }
            if(emailAddress.IndexOf('@') == -1){
                throw new Exception("Invalid email address, @ is missing !");
            }

            string[] localPart_domain = emailAddress.Split('@');

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_AddEmailAddress")){
                sqlCmd.AddParameter("_localPart" ,NpgsqlDbType.Varchar,localPart_domain[0]);
                sqlCmd.AddParameter("_domainName",NpgsqlDbType.Varchar,localPart_domain[1]);
                sqlCmd.AddParameter("_OwnerID"   ,NpgsqlDbType.Varchar,GetUserID(userName));

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:28,代码来源:pgsql_API.cs

示例8: UpdateFilter

        /// <summary>
        /// Updates specified filter.
        /// </summary>		
        /// <param name="filterID">FilterID which to update.</param>
        /// <param name="description">Filter description</param>
        /// <param name="type">Filter type. Eg. ISmtpMessageFilter.</param>
        /// <param name="assembly">Assembly with full location. Eg. C:\MailServer\Filters\filter.dll .</param>
        /// <param name="className">Filter full class name, wih namespace. Eg. LumiSoft.MailServer.Fileters.Filter1 .</param>
        /// <param name="cost">Filters are sorted by cost and proccessed with cost value. Smallest cost is proccessed first.</param>
        /// <param name="enabled">Specifies if filter is enabled.</param>
        /// <returns></returns>
        public void UpdateFilter(string filterID,string description,string type,string assembly,string className,long cost,bool enabled)
        {
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_UpdateFilter")){
                sqlCmd.AddParameter("_filterID"    ,NpgsqlDbType.Varchar,filterID);
                sqlCmd.AddParameter("_description" ,NpgsqlDbType.Varchar,description);
                sqlCmd.AddParameter("_type"        ,NpgsqlDbType.Varchar,type);
                sqlCmd.AddParameter("_assembly"    ,NpgsqlDbType.Varchar,assembly);
                sqlCmd.AddParameter("_className"   ,NpgsqlDbType.Varchar,className);
                sqlCmd.AddParameter("_cost"        ,NpgsqlDbType.Bigint ,cost);
                sqlCmd.AddParameter("_enabled"     ,NpgsqlDbType.Boolean,enabled);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:25,代码来源:pgsql_API.cs

示例9: UpdateGroup

        /// <summary>
        /// Updates user group info.
        /// </summary>
        /// <param name="groupID">Group ID.</param>
        /// <param name="groupName">Group name.</param>
        /// <param name="description">Group description.</param>
        /// <param name="enabled">Specifies if group is enabled.</param>
        public void UpdateGroup(string groupID,string groupName,string description,bool enabled)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that group with specified ID does exist.  Throw Exception if doesn't.
                *) If group name is changed, ensure that new group name won't conflict
                   any other group or user name. Throw Exception if does.
                *) Udpate group.
            */

            //--- Validate values --------------------//
            if(groupID == null || groupID == ""){
                throw new Exception("Invalid groupID value, groupID can't be '' or null !");
            }
            ArgsValidator.ValidateUserName(groupName);
            ArgsValidator.ValidateNotNull(description);
            //----------------------------------------//

            /* We handle these is SQL, sql throws Excption

            *) Ensure that group with specified ID does exist.  Throw Exception if doesn't.
            *) If group name is changed, ensure that new group name won't conflict
               any other group or user name. Throw Exception if does.
            */

            // Update group
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_UpdateGroup")){
                sqlCmd.AddParameter("_groupID"     ,NpgsqlDbType.Varchar,groupID);
                sqlCmd.AddParameter("_groupName"   ,NpgsqlDbType.Varchar,groupName);
                sqlCmd.AddParameter("_description" ,NpgsqlDbType.Varchar,description);
                sqlCmd.AddParameter("_enabled"     ,NpgsqlDbType.Boolean,enabled);

                DataSet ds = sqlCmd.Execute();
                ds.Tables[0].TableName = "Groups";
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:43,代码来源:pgsql_API.cs

示例10: UnSubscribeFolder

        /// <summary>
        /// UnSubscribes IMAP folder.
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="folder"></param>
        public void UnSubscribeFolder(string userName,string folder)
        {
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_UnSubscribeFolder")){
                sqlCmd.AddParameter("_userName",NpgsqlDbType.Varchar,userName);
                sqlCmd.AddParameter("_folder"  ,NpgsqlDbType.Varchar,folder);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:14,代码来源:pgsql_API.cs

示例11: UpdateDomain

        /// <summary>
        /// Updates specified domain data.
        /// </summary>
        /// <param name="domainID">Domain ID which to update.</param>
        /// <param name="domainName">Domain name.</param>
        /// <param name="description">Domain description.</param>
        public void UpdateDomain(string domainID,string domainName,string description)
        {
            if(domainID.Length == 0){
                throw new Exception("You must specify domainID");
            }
            ArgsValidator.ValidateDomainName(domainName);

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_UpdateDomain")){
                sqlCmd.AddParameter("_domainID"   ,NpgsqlDbType.Varchar,domainID);
                sqlCmd.AddParameter("_domainName" ,NpgsqlDbType.Varchar,domainName);
                sqlCmd.AddParameter("_description",NpgsqlDbType.Varchar,description);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:21,代码来源:pgsql_API.cs

示例12: AddMailingListAddress

        /// <summary>
        /// Add new email address to specified mailing list.
        /// </summary>
        /// <param name="addressID">Address ID. Suggested value is Guid.NewGuid() .</param>
        /// <param name="mailingListName">Mailing list name name. Use <see cref="IMailServerApi.GetMailingLists">GetMailingLists()</see> to get valid values.</param>
        /// <param name="address">Mailing list member address.</param>
        /// <remarks>Throws exception if specified mailing list member already exists.</remarks>
        public void AddMailingListAddress(string addressID,string mailingListName,string address)
        {
            if(addressID.Length == 0){
                throw new Exception("You must specify addressID");
            }
            if(mailingListName.Length == 0){
                throw new Exception("You must specify mailingListName");
            }
            if(address.Length == 0){
                throw new Exception("You must specify address");
            }

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_AddMailingListAddress")){
                sqlCmd.AddParameter("_addressID"       ,NpgsqlDbType.Varchar,addressID);
                sqlCmd.AddParameter("_mailingListName" ,NpgsqlDbType.Varchar,mailingListName);
                sqlCmd.AddParameter("_address"         ,NpgsqlDbType.Varchar,address);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:27,代码来源:pgsql_API.cs

示例13: StoreMessageFlags

        /// <summary>
        /// Stores IMAP message flags (\seen,\draft, ...).
        /// </summary>
        /// <param name="accessingUser">User who accesses this method. 
        /// User needs r permission to call this method or Exception is thrown. 
        /// There is special user 'system' for which permission check is skipped.</param>
        /// <param name="folderOwnerUser">User who's folder it is.</param>
        /// <param name="folder">Folder which message flags to store. For example: Inbox,Public Folders/Documnets .</param>
        /// <param name="message">Fix ME: ???</param>
        /// <param name="msgFlags">Message flags to store.</param>
        public void StoreMessageFlags(string accessingUser,string folderOwnerUser,string folder,LumiSoft.Net.IMAP.Server.IMAP_Message message,IMAP_MessageFlags msgFlags)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that user exists.
                *) Normalize folder. Remove '/' from folder start and end, ... .
                *) Do Shared Folders mapping.
                *) Ensure that folder exists. Throw Exception if don't.
                *) Remove all message flags which permissions user doesn't have.
                *) Store message.
            */

            //--- Validate values -------------------//
            ArgsValidator.ValidateUserName(folderOwnerUser);
            ArgsValidator.ValidateFolder(folder);
            ArgsValidator.ValidateNotNull(message);
            //---------------------------------------//

            // Ensure that user exists.
            if(!UserExists(folderOwnerUser)){
                throw new Exception("User '" + folderOwnerUser + "' doesn't exist !");
            }

            // Normalize folder. Remove '/' from folder start and end.
            folder = API_Utlis.NormalizeFolder(folder);

            // Do Shared Folders mapping.
            string originalFolder = folder;
            SharedFolderMapInfo mappedFolder = MapSharedFolder(originalFolder);
            if(mappedFolder.IsSharedFolder){
                folderOwnerUser = mappedFolder.FolderOnwer;
                folder = mappedFolder.Folder;

                if(folderOwnerUser == "" || folder == ""){
                    throw new ArgumentException("Specified root folder '" + originalFolder + "' isn't accessible !");
                }
            }

            // Ensure that folder exists. Throw Exception if don't.
            if(!FolderExists(folderOwnerUser + "/" + folder)){
                throw new Exception("Folder '" + folder + "' doesn't exist !");
            }

            // Remove all message flags which permissions user doesn't have.
            if(accessingUser != "system"){
                IMAP_ACL_Flags userACL = GetUserACL(folderOwnerUser,folder,accessingUser);
                if((userACL & IMAP_ACL_Flags.s) == 0){
                    msgFlags &= ~IMAP_MessageFlags.Seen;
                }
                else if((userACL & IMAP_ACL_Flags.d) == 0){
                    msgFlags &= ~IMAP_MessageFlags.Deleted;
                }
                else if((userACL & IMAP_ACL_Flags.s) == 0){
                    msgFlags &= (~IMAP_MessageFlags.Answered | ~IMAP_MessageFlags.Draft | ~IMAP_MessageFlags.Flagged);
                }
            }

            //--- Store message flags
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_StoreMessageFlags")){
                sqlCmd.AddParameter("_userName"     ,NpgsqlDbType.Varchar,folderOwnerUser);
                sqlCmd.AddParameter("_folder"       ,NpgsqlDbType.Varchar,folder);
                sqlCmd.AddParameter("_messageID"    ,NpgsqlDbType.Varchar,message.ID);
                sqlCmd.AddParameter("_messageFlags" ,NpgsqlDbType.Integer,(int)message.Flags);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:77,代码来源:pgsql_API.cs

示例14: StoreMessage

        /// <summary>
        /// Stores message to specified folder.
        /// </summary>
        /// <param name="accessingUser">User who accesses this method. 
        /// User needs r permission to call this method or Exception is thrown. 
        /// There is special user 'system' for which permission check is skipped.</param>
        /// <param name="folderOwnerUser">User who's folder it is.</param>
        /// <param name="folder">Folder where to store message. For example: Inbox,Public Folders/Documnets .</param>
        /// <param name="msgStream">Stream where message has stored. Stream position must be at the beginning of the message.</param>
        /// <param name="date">Recieve date.</param>
        /// <param name="flags">Message flags.</param>
        public void StoreMessage(string accessingUser,string folderOwnerUser,string folder,Stream msgStream,DateTime date,IMAP_MessageFlags flags)
        {
            /* Implementation notes:
                *) Validate values. Throw ArgumnetExcetion if invalid values.
                *) Ensure that user exists.
                *) Normalize folder. Remove '/' from folder start and end, ... .
                *) Do Shared Folders mapping.
                *) Ensure that folder exists. Throw Exception if don't.
                *) See if user has sufficient permissions. User requires 'p' or 'i' permission.
                    There is builtin user system, skip ACL for it.
                *) Store message.
            */

            //--- Validate values -------------------//
            ArgsValidator.ValidateUserName(folderOwnerUser);
            ArgsValidator.ValidateFolder(folder);
            ArgsValidator.ValidateNotNull(msgStream);
            //---------------------------------------//

            // Ensure that user exists.
            if(!UserExists(folderOwnerUser)){
                throw new Exception("User '" + folderOwnerUser + "' doesn't exist !");
            }

            // Normalize folder. Remove '/' from folder start and end.
            folder = API_Utlis.NormalizeFolder(folder);

            // Do Shared Folders mapping.
            string originalFolder = folder;
            SharedFolderMapInfo mappedFolder = MapSharedFolder(originalFolder);
            if(mappedFolder.IsSharedFolder){
                folderOwnerUser = mappedFolder.FolderOnwer;
                folder = mappedFolder.Folder;

                if(folderOwnerUser == "" || folder == ""){
                    throw new ArgumentException("Specified root folder '" + originalFolder + "' isn't accessible !");
                }
            }

            // Ensure that folder exists. Throw Exception if don't.
            if(!FolderExists(folderOwnerUser + "/" + folder)){
                throw new Exception("Folder '" + folder + "' doesn't exist !");
            }

            // See if user has sufficient permissions. User requires 'p' or 'i' permission.
            //  There is builtin user system, skip ACL for it.
            if(accessingUser.ToLower() != "system"){
                IMAP_ACL_Flags acl = GetUserACL(folderOwnerUser,folder,accessingUser);
                if((acl & IMAP_ACL_Flags.p) == 0 && (acl & IMAP_ACL_Flags.i) == 0){
                    throw new InsufficientPermissionsException("Insufficient permissions for folder '" + accessingUser + "/" + folder + "' !");
                }
            }

            //--- Store message
            byte[] topLines = GetTopLines(msgStream,50);
            msgStream.Position = 0;
            byte[] messageData = new byte[msgStream.Length];
            msgStream.Read(messageData,0,messageData.Length);
            Mime m = null;
            try{
                msgStream.Position = 0;
                m = Mime.Parse(msgStream);
            }
            catch(Exception x){
                m = LumiSoft.Net.Mime.Mime.CreateSimple(new AddressList(),new AddressList(),"[BAD MESSAGE] Bad message, message parsing failed !","NOTE: Bad message, message parsing failed !\r\n\r\n" + x.Message,"");
            }
            byte[] envelope = System.Text.Encoding.Default.GetBytes(IMAP_Envelope.ConstructEnvelope(m.MainEntity));
            byte[] body     = System.Text.Encoding.Default.GetBytes(IMAP_BODY.ConstructBodyStructure(m,false));

            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_StoreMessage")){
                sqlCmd.AddParameter("_userName"     ,NpgsqlDbType.Varchar   ,folderOwnerUser);
                sqlCmd.AddParameter("_folder"       ,NpgsqlDbType.Varchar   ,folder);
                sqlCmd.AddParameter("_messageID"    ,NpgsqlDbType.Varchar   ,Guid.NewGuid().ToString());
                sqlCmd.AddParameter("_size"         ,NpgsqlDbType.Integer   ,msgStream.Length);
                sqlCmd.AddParameter("_messageFlags" ,NpgsqlDbType.Integer   ,(int)flags);
                sqlCmd.AddParameter("_date"         ,NpgsqlDbType.Timestamp ,date);
                sqlCmd.AddParameter("_topLines"     ,NpgsqlDbType.Bytea     ,topLines);
                sqlCmd.AddParameter("_data"         ,NpgsqlDbType.Bytea     ,messageData);
                sqlCmd.AddParameter("_imapEnvelope" ,NpgsqlDbType.Bytea     ,envelope);
                sqlCmd.AddParameter("_imapBody"     ,NpgsqlDbType.Bytea     ,body);

                DataSet ds = sqlCmd.Execute();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:95,代码来源:pgsql_API.cs

示例15: ValidateMailboxSize

        /// <summary>
        /// Checks if specified mailbox size is exceeded.
        /// </summary>
        /// <param name="userName">User name. Use <see cref="IMailServerApi.GetUsers">GetUsers()</see> to get valid values.</param>
        /// <returns>Returns true if exceeded.</returns>
        public bool ValidateMailboxSize(string userName)
        {
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_ValidateMailboxSize")){
                sqlCmd.AddParameter("_userName",NpgsqlDbType.Varchar,userName);

                DataSet ds = sqlCmd.Execute();
                return (bool)sqlCmd.ExecuteScalar();
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:14,代码来源:pgsql_API.cs


注:本文中的LumiSoft.MailServer.WSqlCommand.AddParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。