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


C# SortedSet.Except方法代码示例

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


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

示例1: GetSObjectsAsXML

        public static Dictionary<string, string> GetSObjectsAsXML(IEnumerable<string> monikers)
        {
            var sw = Stopwatch.StartNew();
            var loaded = SObjectManager.Instance().LoadMultipleSObjectsAsXML(monikers);
            var allRequests = new SortedSet<string>(monikers);

            // TO DO: group requests by calculator and aggregate for bulk load from database
            foreach(var remainingRequest in allRequests.Except(loaded.Select(l => l.Key)))
            {
                try
                {
                    // can we create?
                    var calculated = SObjectCalculator.CalculateObject(remainingRequest);
                    if (calculated != null)
                    {
                        var xml = SObjectManager.Serialize(calculated);
                        loaded.Add(remainingRequest, xml);

                        // add to cache
                        SObjectManager.Instance().AddToCache(remainingRequest, xml);
                    }
                } catch (Exception ex)
                {
                    SLog.log.Error("Error calculating moniker " + remainingRequest, ex);
                }
            }
            SLog.log.DebugFormat("{0} objects bulk loaded in {1} ms", loaded.Count(), sw.ElapsedMilliseconds);
            return loaded;
        }
开发者ID:heimanhon,项目名称:researchwork,代码行数:29,代码来源:SObjectProvider.cs

示例2: GetSetupStatus

        public SetupStatus GetSetupStatus()
        {
            var setupStatus = new SetupStatus();

            try
            {
                if (string.IsNullOrEmpty(Configuration.ContextType))
                    return null;

                if (string.IsNullOrEmpty(Configuration.ScriptsBase))
                    return null;

                var schemaContext = (ISchemaContext)Activator.CreateInstanceFrom(_executingAssembly, Configuration.ContextType).Unwrap();

                if (schemaContext == null)
                    return null;

                var abstractList = schemaContext.GetScriptsInstalled();

                schemaContext.Dispose();

                var allEntries = abstractList
                    .Select(a => new SchemaVersion
                    {
                        ScriptPath = a.ScriptPath,
                        MajorVersion = a.MajorVersion,
                        MinorVersion = a.MinorVersion,
                        ScriptVersion = a.ScriptVersion
                    })
                    .ToList();
                allEntries.Sort(new SchemaVersionComparer());

                var schemaInstance = allEntries.LastOrDefault();

                if (schemaInstance == null)
                {
                    setupStatus.StatusCode = SetupStatusCode.NotInstalled;
                    setupStatus.Message = "None of the scripts have been run";

                    return setupStatus;
                }

                var sortedList = new SortedSet<SchemaVersion>();
                var filePath = HostingEnvironment.MapPath(Configuration.ScriptsBase);
                if (filePath != null)
                {
                    var files = Directory.GetFiles(filePath).ToList();
                    files.ForEach(f =>
                    {
                        var schemaItem = f.Parse();
                        sortedList.Add(schemaItem);
                    });
                }

                var lastInstance = sortedList.LastOrDefault();

                if (lastInstance != null && lastInstance.Equals(schemaInstance))
                {
                    setupStatus.StatusCode = SetupStatusCode.NoUpdates;
                    setupStatus.Message = "Your instance is up to date!";

                    return setupStatus;
                }

                var scriptsToBeRan = sortedList.Except(allEntries, new SchemaVersionEqualityComparer()).ToList();

                setupStatus.StatusCode = SetupStatusCode.HasUpdates;
                setupStatus.Message = "Your instance has some updates";
                setupStatus.FullPathsOfScripts = scriptsToBeRan;
                setupStatus.ScriptsPending = scriptsToBeRan.Select(s => Path.GetFileName(s.ScriptPath)).ToList();

                return setupStatus;
            }
            catch (Exception exception)
            {
                if (exception.Message.Contains("Invalid object name"))
                {
                    setupStatus.StatusCode = SetupStatusCode.DatabaseNotSetup;
                    setupStatus.Message = "Database has not been setup";
                }
                else
                {
                    setupStatus.StatusCode = SetupStatusCode.DatabaseError;
                    setupStatus.Message = exception.Message;
                }
            }

            return setupStatus;
        }
开发者ID:karthik25,项目名称:db-status-provider,代码行数:89,代码来源:SetupStatusGenerator.cs

示例3: DoRequest

    override public void DoRequest(IDictionary<string, QueuedRequest> requests)
    {
      var allMonikers = new SortedSet<string>(requests.Select(r => r.Key));
      // get the data
      if (allMonikers.Count > 0)
      {
        var executionStart = DateTime.Now;
        SLog.log.DebugFormat("About to request {0} monikers...", allMonikers.Count);
        SLog.log.DebugFormat("Just so I know {0}", "ben");
        try
        {
          var receivedObjects = getObjects(allMonikers.ToArray());
          //SObjectDTO[] receivedObjects = new ServiceClient.SymmetryServiceClient().GetMultipleObjects(allMonikers.ToArray());
          foreach (var response in receivedObjects)
          {
            try
            {
              SObjectProvider.Instance().AddToCache(response.Moniker, response);
            }
            catch (Exception ex)
            {
              SLog.log.Error("Error adding moniker to cache " + response.Moniker, ex);
            }
            try
            {
              QueuedRequest request = null;
              if (requests.TryGetValue(response.Moniker, out request))
              {
                request.ReponseEvent.Response = response;
                request.ReponseEvent.Event.Set();
              }
            }
            catch (Exception ex)
            {
              SLog.log.Error("Error retrieving moniker " + response.Moniker, ex);
            }
          }

          // check for errors
          var receivedMonikers = new SortedSet<string>(receivedObjects.Where(o => o != null).Select(o => o.Moniker));

          foreach (var erroredRequest in allMonikers.Except(receivedMonikers))
          {
            SObjectProvider.Instance().AddToErrorQueue(erroredRequest);
              try
              {
                  QueuedRequest request = null;
                  if (requests.TryGetValue(erroredRequest, out request))
                  {
                      request.ReponseEvent.Event.Set();
                  }
              }
              catch (Exception ex)
              {
                  SLog.log.ErrorFormat("Error retrieving moniker {0} : {1}", erroredRequest, ex);
              }
          }

          SLog.log.DebugFormat("Success retrieving {0} of {1} monikers in {2} ms.", receivedObjects.Length, allMonikers.Count, (DateTime.Now - executionStart).TotalMilliseconds);
        }
        catch (Exception ex)
        {
          SLog.log.Error("Error retrieving monikers from the service.", ex);
        }
      }

    }
开发者ID:heimanhon,项目名称:researchwork,代码行数:67,代码来源:ServiceRetriever.cs


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