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


C# System.Result类代码示例

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


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

示例1: MigrateDB

        public static void MigrateDB()
        {
            SQLSvrDbi.DbConnectionString = Configuration.Configurator.GetDBConnString(SourceDBConnName);
            GemFireXDDbi.DbConnectionString = Configuration.Configurator.GetDBConnString(DestDBConnName);

            try
            {
                if (MigrateTables)
                    MigrateDbTables();
                if (MigrateViews)
                    MigrateDbViews();
                if (MigrateIndexes)
                    MigrateDbIndexes();
                if (MigrateProcedures)
                    MigrateDbStoredProcedures();
                if (MigrateFunctions)
                    MigrateDbFunctions();
                if (MigrateTriggers)
                    MigrateDbTriggers();
            }
            catch (ThreadAbortException e)
            {
                Result = Result.Aborted;
                OnMigrateEvent(new MigrateEventArgs(Result.Aborted, "Operation aborted!"));
            }
            catch (Exception e)
            {
                Helper.Log(e);
            }
            finally
            {
                dbTableList.Clear();
            }
        }
开发者ID:leloulight,项目名称:gemfirexd-oss,代码行数:34,代码来源:Migrator.cs

示例2: GetTags

        public Yield GetTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            string type = DreamContext.Current.GetParam("type", "");
            string fromStr = DreamContext.Current.GetParam("from", "");
            string toStr = DreamContext.Current.GetParam("to", "");
            bool showPages = DreamContext.Current.GetParam("pages", false);
            string partialName = DreamContext.Current.GetParam("q", "");

            // parse type
            TagType tagType = TagType.ALL;
            if(!string.IsNullOrEmpty(type) && !SysUtil.TryParseEnum(type, out tagType)) {
                throw new DreamBadRequestException("Invalid type parameter");
            }

            // check and validate from date
            DateTime from = (tagType == TagType.DATE) ? DateTime.Now : DateTime.MinValue;
            if(!string.IsNullOrEmpty(fromStr) && !DateTime.TryParse(fromStr, out from)) {
                throw new DreamBadRequestException("Invalid from date parameter");
            }

            // check and validate to date
            DateTime to = (tagType == TagType.DATE) ? from.AddDays(30) : DateTime.MaxValue;
            if(!string.IsNullOrEmpty(toStr) && !DateTime.TryParse(toStr, out to)) {
                throw new DreamBadRequestException("Invalid to date parameter");
            }

            // execute query
            var tags = TagBL.GetTags(partialName, tagType, from, to);
            XDoc doc = TagBL.GetTagListXml(tags, "tags", null, showPages);
            response.Return(DreamMessage.Ok(doc));
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:DekiWiki-Tags.cs

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

示例4: Search

        public Result Search(N2.Persistence.Search.Query query)
        {
            if (!query.IsValid())
                return Result.Empty;

            var s = accessor.GetSearcher();
            try
            {
                var q = CreateQuery(query);
                var hits = s.Search(q, query.SkipHits + query.TakeHits);

                var result = new Result();
                result.Total = hits.totalHits;
                var resultHits = hits.scoreDocs.Skip(query.SkipHits).Take(query.TakeHits).Select(hit =>
                {
                    var doc = s.Doc(hit.doc);
                    int id = int.Parse(doc.Get("ID"));
                    ContentItem item = persister.Get(id);
                    return new Hit { Content = item, Score = hit.score };
                }).Where(h => h.Content != null).ToList();
                result.Hits = resultHits;
                result.Count = resultHits.Count;
                return result;
            }
            finally
            {
                //s.Close();
            }
        }
开发者ID:wrohrbach,项目名称:n2cms,代码行数:29,代码来源:LuceneSearcher.cs

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

示例6: GetServiceById

        public Yield GetServiceById(DreamContext context, DreamMessage request, Result<DreamMessage> response) {

            bool privateDetails = PermissionsBL.IsUserAllowed(DekiContext.Current.User, Permissions.ADMIN);

            //Private feature requires api-key
            var identifier = context.GetParam("id");
            uint serviceId = 0;
            if(identifier.StartsWith("=")) {
                var serviceInfo = DekiContext.Current.Instance.RunningServices[XUri.Decode(identifier.Substring(1))];
                if(serviceInfo != null) {
                    serviceId = serviceInfo.ServiceId;
                }
            } else {
                if(!uint.TryParse(identifier, out serviceId)) {
                    throw new DreamBadRequestException(string.Format("Invalid id '{0}'", identifier));
                }
            }
            ServiceBE service = ServiceBL.GetServiceById(serviceId);
            DreamMessage responseMsg = null;
            if(service == null) {
                responseMsg = DreamMessage.NotFound(string.Format(DekiResources.SERVICE_NOT_FOUND, identifier));
            } else {
                responseMsg = DreamMessage.Ok(ServiceBL.GetServiceXmlVerbose(DekiContext.Current.Instance, service, null, privateDetails));
            }
            response.Return(responseMsg);
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:27,代码来源:DekiWiki-Services.cs

示例7: GetHistoryCmds

        private List<Result> GetHistoryCmds(string cmd, Result result)
        {
            IEnumerable<Result> history = CMDStorage.Instance.CMDHistory.Where(o => o.Key.Contains(cmd))
                .OrderByDescending(o => o.Value)
                .Select(m =>
                {
                    if (m.Key == cmd)
                    {
                        result.SubTitle = string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value);
                        return null;
                    }

                    var ret = new Result
                    {
                        Title = m.Key,
                        SubTitle =  string.Format(context.API.GetTranslation("wox_plugin_cmd_cmd_has_been_executed_times"), m.Value),
                        IcoPath = "Images/cmd.png",
                        Action = (c) =>
                        {
                            ExecuteCmd(m.Key);
                            return true;
                        }
                    };
                    return ret;
                }).Where(o => o != null).Take(4);
            return history.ToList();
        }
开发者ID:gotatsu,项目名称:Wox,代码行数:27,代码来源:CMD.cs

示例8: Process

        public override Result Process(Result result)
        {
            if(result.Line.StartsWith("#"))
            {

                if(result.Line.StartsWith(Constants.HeaderField))
                {
                    LogContext.Storage.Insert(GetStorageKey(result), new FieldParser().ParseFields(result.Line));
                }

                result.Canceled = true;
                return result;
            }

            try
            {
                var parsedLine = ParseLine(result);
                result.EventTimeStamp = parsedLine.TimeStamp;

                foreach(var field in parsedLine.Fields)
                {
                    var token = FieldToJToken.Parse(field);
                    result.Json.Add(field.Key, token);
                }

                return result;
            }
            catch(Exception ex)
            {
                Log.ErrorException("Line: " + result.Line + " could not be parsed.", ex);
                result.Canceled = true;
                return result;
            }
        }
开发者ID:fatbwif,项目名称:LogFlow,代码行数:34,代码来源:IISLogProcessor.cs

示例9: GetUserAllOrder

 //获取用户的所有有效订单数据
 public Result<List<OrderViewModel>> GetUserAllOrder(int userId,List<int> orderStatus)
 {
     var result = new Result<List<OrderViewModel>>();
     result.Data= orderDataAccess.GetUserAllOrder(userId, orderStatus);
     result.Status = new Status() {Code = "1"};
     return result;
 }
开发者ID:BHfeimao,项目名称:DotNetStudio,代码行数:8,代码来源:OrderService.cs

示例10: Query

 public override List<Result> Query(Query query)
 {
     if (query.RawQuery == "h mem")
     {
         var rl = new List<Result>();
         var r = new Result();
         r.Title = GetTotalPhysicalMemory();
         r.SubTitle = "Copy this number to the clipboard";
         r.IcoPath = "[Res]:sys";
         r.Score = 100;
         r.Action = e =>
         {
             context_.Api.HideAndClear();
             try
             {
                 Clipboard.SetText(r.Title);
                 return true;
             }
             catch (System.Runtime.InteropServices.ExternalException)
             {
                 return false;
             }
         };
         rl.Add(r);
         return rl;
     }
     return null;
 }
开发者ID:xxy1991,项目名称:cozy,代码行数:28,代码来源:Main.cs

示例11: Optimize

 static Result Optimize(Result current, Func<double[],double> evaluator)
 {
     bool[,] tried = new bool[current.vector.Length, 2];
     int coordinate = 0;
     int direction = 0;
     bool cont = false;
     Result newResult = null;
     while(true)
     {
         if (tried.Cast<bool>().All(z => z)) break;
         coordinate = rnd.Next(current.vector.Length);
         direction = rnd.Next(2);
         if (tried[coordinate, direction]) continue;
         tried[coordinate, direction] = true;
         newResult = Shift(current, coordinate, direction, evaluator);
         if (newResult.value > current.value)
         {
             cont = true;
             break;
         }
     }
     if (!cont) return null;
     for (int i=0;i<10;i++)
     {
         var veryNew = Shift(newResult, coordinate, direction, evaluator);
         if (veryNew.value <= newResult.value) return newResult;
         newResult = veryNew;
     }
     return newResult;
 }
开发者ID:xoposhiy,项目名称:icfpc2015,代码行数:30,代码来源:GradientOptimizer.cs

示例12: Main

        public static void Main()
        {
            maps = mapIndices
               .Select(z => Problems.LoadProblems()[z].ToMap(Seed))
               .ToArray();

            var vector = new double[WeightedMetric.KnownFunctions.Count()];
            for (int i=0;i<WeightedMetric.KnownFunctions.Count();i++)
            {
                var test = WeightedMetric.Test.Where(z => z.Function == WeightedMetric.KnownFunctions.ElementAt(i)).FirstOrDefault();
                if (test == null) continue;
                vector[i] = test.Weight;
            }

            Console.Write(Print(vector)+"\t BASELINE");
            baseline = Run(vector);
            var current = new Result { vector = vector, value = 1 };
            Console.WriteLine("  OK");
            while (true)
            {
                var newCurrent = Optimize(current, Evaluate);
                if (newCurrent != null)
                {
                    current = newCurrent;
                    Console.WriteLine(Print(current.vector) + "\t OPT\t" + current.value);
                    continue;
                }
                else
                {
                    Console.WriteLine(Print(current.vector) + "\t END\t" + current.value);
                    Console.ReadKey();
                    break;
                }
            }
        }
开发者ID:xoposhiy,项目名称:icfpc2015,代码行数:35,代码来源:GradientOptimizer.cs

示例13: Delete

		public Result<bool> Delete(string aSourceId, string rev, Result<bool> aResult)
		{
			ArgCheck.NotNullNorEmpty("aSourceId", aSourceId);

			Coroutine.Invoke(DeleteHelper, aSourceId, rev, aResult);
			return aResult;
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:7,代码来源:SourceController.cs

示例14: GetArchiveFiles

 public Yield GetArchiveFiles(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
     IList<AttachmentBE> removedFiles = AttachmentBL.Instance.GetResources(DeletionFilter.DELETEDONLY, null, null);
     XDoc responseXml = AttachmentBL.Instance.GetFileXml(removedFiles, true, "archive", null, null);            
     response.Return(DreamMessage.Ok(responseXml));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-RecycleBin.cs

示例15: GetSiteStatus

 public Yield GetSiteStatus(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.UPDATE);
     var status = new XDoc("status")
         .Elem("state", DekiContext.Current.Instance.Status);
     response.Return(DreamMessage.Ok(status));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Site.cs


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