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


C# Result.Add方法代码示例

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


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

示例1: checkUploadPic

        /// <summary>
        /// 检查上传的图片是否合法
        /// </summary>
        /// <param name="postedFile"></param>
        /// <param name="errors"></param>
        public static void checkUploadPic( HttpFile postedFile, Result errors )
        {
            if (postedFile == null) {
                errors.Add( lang.get( "exPlsUpload" ) );
                return;
            }

            // 检查文件大小
            if (postedFile.ContentLength <= 1) {
                errors.Add( lang.get( "exPlsUpload" ) );
                return;
            }

            int uploadMax = 1024 * 1024 * config.Instance.Site.UploadPicMaxMB;
            if (postedFile.ContentLength > uploadMax) {
                errors.Add( lang.get( "exUploadMax" ) + " " + config.Instance.Site.UploadPicMaxMB + " MB" );
                return;
            }

            // TODO: (flash upload) application/octet-stream
            //if (postedFile.ContentType.ToLower().IndexOf( "image" ) < 0) {
            //    errors.Add( lang.get( "exPhotoFormatTip" ) );
            //    return;
            //}

            // 检查文件格式
            if (Uploader.isAllowedPic( postedFile ) == false) {
                errors.Add( lang.get( "exUploadType" ) + ":" + postedFile.FileName + "(" + postedFile.ContentType + ")" );
            }
        }
开发者ID:robin88,项目名称:wojilu,代码行数:35,代码来源:Uploader.cs

示例2: CheckLogin

 public static Result CheckLogin(String username, String password)
 {
     Result result = new Result();
     if (string.IsNullOrEmpty(username))
     {
         result.Add("Sorry,管理员账号不能为空");
     }
     else if (string.IsNullOrEmpty(password))
     {
         result.Add("Sorry,管理员密码不能为空");
     }
     else
     {
         if (password.Length != 32)
         {
             password = Encryptor.Md5Encryptor32(Encryptor.Md5Encryptor32(password));
         }
         System.Xml.XmlNode xn = System.IO.XMLHelper.GetDataOne(PathHelper.Map("~/xcenter/data/wechat/manager.xml"), "Manager", System.IO.XMLHelper.CreateEqualParameter("Username", username));
         if (xn == null)
         {
             result.Add("Sorry,管理员账号不存在");
         }
         else if (xn.Attributes["Password"].Value != password)
         {
             result.Add("Sorry,您输入的密码不正确");
         }
     }
     return result;
 }
开发者ID:hetykai,项目名称:weback,代码行数:29,代码来源:Sys.cs

示例3: Delete

        public Result Delete( int id )
        {
            Result result = new Result();

            MessageAttachment attachment = GetById( id );
            if (attachment == null) {
                result.Add( lang.get( "exDataNotFound" ) );
                return result;
            }

            attachment.delete();

            String filePath = strUtil.Join( sys.Path.DiskPhoto, attachment.Url );
            String absPath = PathHelper.Map( filePath );

            if (file.Exists( absPath )) {

                try {
                    file.Delete( absPath );
                }
                catch (IOException ex) {
                    logger.Error( ex.ToString() );
                    result.Add( ex.ToString() );
                }

            }
            else {
                result.Add( "文件不存在:" + absPath );
            }

            return result;
        }
开发者ID:robin88,项目名称:wojilu,代码行数:32,代码来源:MessageAttachmentService.cs

示例4: Delete

        public virtual Result Delete( long id )
        {
            Result result = new Result();

            UserFile attachment = GetById( id );
            if (attachment == null) {
                result.Add( lang.get( "exDataNotFound" ) );
                return result;
            }

            attachment.delete();
            countDataCount( attachment );

            String filePath = strUtil.Join( sys.Path.DiskPhoto, attachment.PathRelative );
            String absPath = PathHelper.Map( filePath );

            if (file.Exists( absPath )) {

                try {
                    file.Delete( absPath );
                    result.Info = attachment;
                }
                catch (IOException ex) {
                    logger.Error( ex.ToString() );
                    result.Add( ex.ToString() );
                }

            }
            else {
                result.Add( "文件不存在:" + absPath );
            }

            return result;
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:34,代码来源:UserFileService.cs

示例5: Buy

        public virtual Result Buy( int buyerId, int creatorId, ForumTopic topic )
        {
            if (topic == null) throw new ArgumentNullException( "ForumBuyLogService.Buy" );

            Result result = new Result();
            if (topic.Price <= 0) {
                result.Add( "topic.price <=0" );
                return result;
            }

            if (incomeService.HasEnoughKeyIncome( buyerId, topic.Price ) == false) {
                result.Add( String.Format( alang.get( typeof( ForumApp ), "exIncome" ), KeyCurrency.Instance.Name ) );
                return result;
            }

            // 购买日志
            ForumBuyLog log = new ForumBuyLog();
            log.UserId = buyerId;
            log.TopicId = topic.Id;
            log.insert();

            String msg = string.Format( "访问需要购买的帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData( topic ), topic.Title );
            incomeService.AddKeyIncome( buyerId, -topic.Price, msg );

            String msg2 = string.Format( "销售帖子 <a href=\"{0}\">{1}</a>", alink.ToAppData( topic ), topic.Title );
            incomeService.AddKeyIncome( creatorId, topic.Price, msg2 );

            return result;
        }
开发者ID:Boshin,项目名称:wojilu,代码行数:29,代码来源:ForumBuyLogService.cs

示例6: Create

        public Result Create( int ownerId, string targetUserName )
        {
            Result result = new Result();
            if (strUtil.IsNullOrEmpty( targetUserName )) {
                result.Add( lang.get( "exUserName" ) );
                return result;
            }

            User target = userService.GetByName( targetUserName );
            if (target == null) {
                result.Add( lang.get( "exUser" ) );
                return result;
            }

            Blacklist b = new Blacklist();
            b.User = new User( ownerId );
            b.Target = target;

            result = b.insert();

            if (result.IsValid) {

                friendService.DeleteFriendByBlacklist( ownerId, target.Id );
                followerService.DeleteFollow( target.Id, ownerId );

            }

            return result;
        }
开发者ID:robin88,项目名称:wojilu,代码行数:29,代码来源:BlacklistService.cs

示例7: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
        {
            Object obj = target.get( info.Name );

            Boolean isNull = false;
            if (info.Type == typeof( String )) {
                if (obj == null) {
                    isNull = true;
                }
                else if (strUtil.IsNullOrEmpty( obj.ToString() )) {
                    isNull = true;
                }
            }
            else if (obj == null) {
                isNull = true;
            }

            if (isNull) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }
                else {
                    EntityInfo ei = Entity.GetInfo( target );
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + "can not be null" );
                }
            }
        }
开发者ID:2014AmethystCat,项目名称:wojilu,代码行数:28,代码来源:NotNullAttribute.cs

示例8: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result )
        {
            if (!Regex.IsMatch( cvt.ToNotNull( target.get( info.Name ) ), this.Regexp, RegexOptions.Singleline )) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }

                else {
                    EntityInfo ei = Entity.GetInfo( target );
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + " is not match the format pattern : " + this.Regexp );
                }

            }
        }
开发者ID:991899783,项目名称:BookShop,代码行数:15,代码来源:PatternAttribute.cs

示例9: ResultAddGivesException

        public void ResultAddGivesException()
        {
            ClauseComponent r = new Result();
            ClauseComponent r2 = new Result();

            r.Add(true, r2);
        }
开发者ID:stijn26,项目名称:Project_2014-2015_DotNet,代码行数:7,代码来源:ClauseComponentTest.cs

示例10: mainCalculations

 public Result mainCalculations()
 {
     Result res = new Result();
     double resEnergy = energy;
     Vector3D curPosition = position;
     ResultPoint r;
     r.Position = position;
     r.Energy = energy;
     res.Add(r);
     do
     {
         double ls = WayLength();
         Vector3D omega = Omega();
         Vector3D contactPoint = ContactPoint(omega, ls, curPosition);
         curPosition = contactPoint;
         int elementNumber;
         if (data.env.Length == 2)
         {
             elementNumber = ChooseElement();
         }
         else
         {
             elementNumber = 0;
         }
         resEnergy = Final(elementNumber, resEnergy, omega);
         r.Energy = resEnergy;
         r.Position = contactPoint;
         res.Add(r);
     } while (resEnergy >= Et);
     return res;
 }
开发者ID:AnastasiaPetrovskaya,项目名称:DiffusionOfSlowingNeutrons,代码行数:31,代码来源:model.cs

示例11: Buy

        public virtual Result Buy( int buyerId, int creatorId, ForumTopic topic )
        {
            Result result = new Result();
            if (userIncomeService.HasEnoughKeyIncome( buyerId, topic.Price ) == false) {
                result.Add( String.Format( alang.get( typeof( ForumApp ), "exIncome" ), KeyCurrency.Instance.Name ) );
                return result;
            }

            // 日志:买方减少收入
            UserIncomeLog log = new UserIncomeLog();
            log.UserId = buyerId;
            log.CurrencyId = KeyCurrency.Instance.Id;
            log.Income = -topic.Price;
            log.DataId = topic.Id;
            log.ActionId = actionId;
            db.insert( log );

            // 日志:卖方增加收入
            UserIncomeLog log2 = new UserIncomeLog();
            log2.UserId = creatorId;
            log2.CurrencyId = KeyCurrency.Instance.Id;
            log2.Income = topic.Price;
            log2.DataId = topic.Id;
            log2.ActionId = actionId;
            db.insert( log2 );

            userIncomeService.AddKeyIncome( buyerId, -topic.Price );
            userIncomeService.AddKeyIncome( creatorId, topic.Price );

            return result;
        }
开发者ID:LeoLcy,项目名称:cnblogsbywojilu,代码行数:31,代码来源:ForumBuyLogService.cs

示例12: Validate

        public override void Validate( String action, IEntity target, EntityPropertyInfo info, Result result ) {
            Object obj = target.get( info.Name );

            EntityInfo ei = Entity.GetInfo( target );
            int count = getCount( action, target, ei, info, obj );

            if (count > 0) {
                if (strUtil.HasText( this.Message )) {
                    result.Add( this.Message );
                }

                else {
                    String str = "[" + ei.FullName + "] : property \"" + info.Name + "\" ";
                    result.Add( str + " should be unique, but it has been in database" );
                }
            }
        }
开发者ID:mfz888,项目名称:xcore,代码行数:17,代码来源:UniqueAttribute.cs

示例13: SendSms

 public static Result SendSms(string smstext, string sendto)
 {
     Result result = new Result();
     try
     {
         string url = string.Format("{0}/api/smsapi.aspx?uid={1}&key={2}&smstext={3}&sendto={4}"
              , cfgHelper.GetAppSettings("WlnServer"), cfgHelper.GetAppSettings("WlnUid"), cfgHelper.GetAppSettings("WlnKey"), smstext, sendto);
         string resultStr = System.Text.UTF8Encoding.UTF8.GetString(new System.Net.WebClient().DownloadData(url));
         SmsResult al = Json.ToObject<SmsResult>(resultStr);
         if (al != null && !al.success)
         {
             result.Add(al.msg);
         }
     }
     catch(Exception ex)
     {
         result.Add(ex.Message);
     }
     return result;
 }
开发者ID:nust03,项目名称:xcore,代码行数:20,代码来源:BaseServer.cs

示例14: Register

 public static Result Register(String username, String password,Boolean supper)
 {
     Result result = new Result();
     if (string.IsNullOrEmpty(username))
     {
         result.Add("Sorry,管理员账号不能为空");
     }
     else if (string.IsNullOrEmpty(password))
     {
         result.Add("Sorry,管理员密码不能为空");
     }
     else
     {
         if (password.Length != 32)
         {
             password = Encryptor.Md5Encryptor32(Encryptor.Md5Encryptor32(password));
         }
         result.Join(System.IO.XMLHelper.AddData(PathHelper.Map("~/xcenter/data/wechat/manager.xml"), "Manager", System.IO.XMLHelper.CreateInsertParameter("Username", username), System.IO.XMLHelper.CreateInsertParameter("Password", password), System.IO.XMLHelper.CreateInsertParameter("Supper", supper ? "true" : "false")));
     }
     return result;
 }
开发者ID:hetykai,项目名称:weback,代码行数:21,代码来源:Sys.cs

示例15: IsHtmlDirError

        public static bool IsHtmlDirError( String htmlDir, Result errors )
        {
            if (strUtil.HasText( htmlDir )) {

                if (htmlDir.Length > 50) {
                    errors.Add( "目录名称不能超过50个字符" );
                    return true;
                }

                if (isReservedKeyContains( htmlDir )) {
                    errors.Add( "目录名称是保留词,请换一个" );
                    return true;
                }

                if (isHtmlDirUsed( htmlDir )) {
                    errors.Add( "目录名称已被使用,请换一个" );
                    return true;
                }

            }

            return false;
        }
开发者ID:ningboliuwei,项目名称:wojilu,代码行数:23,代码来源:HtmlHelper.cs


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