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


C# WSqlCommand.ExecuteScalar方法代码示例

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


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

示例1: GetMessageTopLines

        /// <summary>
        /// Gets message header + number of specified lines.
        /// </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 message top lines to get. For example: Inbox,Public Folders/Documnets .</param>
        /// <param name="msgID">MessageID.</param>
        /// <param name="nrLines">Number of lines to retrieve. NOTE: line counting starts at the end of header.</param>
        /// <returns>Returns message header + number of specified lines.</returns>
        public byte[] GetMessageTopLines(string accessingUser,string folderOwnerUser,string folder,string msgID,int nrLines)
        {
            /* 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 'r' permission.
                    There is builtin user system, skip ACL for it.
                *) Get message top lines.
            */

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

            // 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 'r' 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.r) == 0){
                    throw new InsufficientPermissionsException("Insufficient permissions for folder '" + accessingUser + "/" + folder + "' !");
                }
            }

            //--- Get message top lines
            if(nrLines < 50){
                using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_GetMessageTopLines")){
                    sqlCmd.AddParameter("_userName"  ,NpgsqlDbType.Varchar,folderOwnerUser);
                    sqlCmd.AddParameter("_folder"    ,NpgsqlDbType.Varchar,folder);
                    sqlCmd.AddParameter("_messageID" ,NpgsqlDbType.Varchar,msgID);

                    return GetTopLines(new MemoryStream((byte[])sqlCmd.ExecuteScalar()),nrLines);
                }
            }
            else{
                EmailMessageItems msgItems = new EmailMessageItems(msgID,IMAP_MessageItems_enum.Message);
                GetMessageItems(accessingUser,folderOwnerUser,folder,msgItems);
                byte[] topLines = GetTopLines(msgItems.MessageStream,nrLines);
                msgItems.MessageStream.Dispose();
                return topLines;
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:82,代码来源:pgsql_API.cs

示例2: 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

示例3: GetMailboxSize

        /// <summary>
        /// Gets specified user mailbox size.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <returns>Returns mailbox size.</returns>
        public long GetMailboxSize(string userName)
        {
            using(WSqlCommand sqlCmd = new WSqlCommand(m_ConStr,"lspr_GetMailboxSize")){
                sqlCmd.AddParameter("_userName",NpgsqlDbType.Varchar,userName);

                object result = sqlCmd.ExecuteScalar();
                if(result == DBNull.Value){
                    return 0;
                }
                else{
                    return (long)result;
                }
            }
        }
开发者ID:janemiceli,项目名称:authenticated_mail_server,代码行数:19,代码来源:pgsql_API.cs


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