當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。