Esempio n. 1
0
        private DiscoveryResultItem DeserializeResults(
            int nodeId,
            IDataReader result)
        {
            Guid     guid     = Guid.NewGuid();
            DateTime dateTime = (DateTime)result[0];
            string   s        = (string)result[1];

            PersistentDiscoveryCache._log.DebugFormat("Found data in cache for Node {0} from {1}", (object)nodeId, (object)dateTime);
            DiscoveryResultItem    discoveryResultItem1 = new DiscoveryResultItem(guid, new int?(nodeId), dateTime);
            DataContractSerializer contractSerializer   = new DataContractSerializer(typeof(DiscoveredObjectTree));

            try
            {
                using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(s)))
                {
                    XmlDictionaryReader           textReader               = XmlDictionaryReader.CreateTextReader((Stream)memoryStream, Encoding.UTF8, new XmlDictionaryReaderQuotas(), (OnXmlDictionaryReaderClose)null);
                    DiscoveryResultItem           discoveryResultItem2     = discoveryResultItem1;
                    OrionDiscoveryJobProgressInfo discoveryJobProgressInfo = new OrionDiscoveryJobProgressInfo();
                    discoveryJobProgressInfo.set_Status(new DiscoveryComplexStatus((DiscoveryStatus)2, string.Empty));
                    discoveryJobProgressInfo.set_JobId(guid);
                    discoveryResultItem2.set_Progress(discoveryJobProgressInfo);
                    discoveryResultItem1.set_ResultTree((DiscoveredObjectTree)contractSerializer.ReadObject(textReader));
                }
                return(discoveryResultItem1);
            }
            catch (Exception ex)
            {
                PersistentDiscoveryCache._log.Error((object)"Error while deserializing result tree!", ex);
                return((DiscoveryResultItem)null);
            }
        }
Esempio n. 2
0
        public void StoreResultForNode(int nodeId, DiscoveryResultItem result)
        {
            DateTime now = DateTime.Now;

            try
            {
                string str;
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    new DataContractSerializer(typeof(DiscoveredObjectTree)).WriteObject((Stream)memoryStream, (object)result.get_ResultTree());
                    str = Encoding.UTF8.GetString(memoryStream.ToArray());
                }
                using (SqlCommand textCommand = SqlHelper.GetTextCommand("UPDATE NodeListResourcesCache SET \r\nCachedTime = @time, CacheBlob = @blob WHERE NodeId=@nodeId\r\nIF @@ROWCOUNT = 0\r\n    INSERT INTO NodeListResourcesCache (NodeId, CachedTime, CacheBlob) VALUES(\r\n     @nodeId, @time, @blob\r\n    )"))
                {
                    textCommand.Parameters.AddWithValue("@nodeId", (object)nodeId);
                    textCommand.Parameters.AddWithValue("@time", (object)now);
                    textCommand.Parameters.AddWithValue("@blob", (object)str);
                    SqlHelper.ExecuteNonQuery(textCommand);
                }
            }
            catch (Exception ex)
            {
                PersistentDiscoveryCache._log.Error((object)string.Format("Error occured storing cached results for node [{0}]", (object)nodeId), ex);
            }
        }
Esempio n. 3
0
        // Token: 0x0600065C RID: 1628 RVA: 0x000261B8 File Offset: 0x000243B8
        private DiscoveryResultItem DeserializeResults(int nodeId, IDataReader result)
        {
            Guid     guid     = Guid.NewGuid();
            DateTime dateTime = (DateTime)result[0];
            string   s        = (string)result[1];

            PersistentDiscoveryCache._log.DebugFormat("Found data in cache for Node {0} from {1}", nodeId, dateTime);
            DiscoveryResultItem    discoveryResultItem    = new DiscoveryResultItem(guid, new int?(nodeId), dateTime);
            DataContractSerializer dataContractSerializer = new DataContractSerializer(typeof(DiscoveredObjectTree));
            DiscoveryResultItem    result2;

            try
            {
                using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(s)))
                {
                    XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(memoryStream, Encoding.UTF8, new XmlDictionaryReaderQuotas(), null);
                    discoveryResultItem.Progress = new OrionDiscoveryJobProgressInfo
                    {
                        Status = new DiscoveryComplexStatus(2, string.Empty),
                        JobId  = guid
                    };
                    discoveryResultItem.ResultTree = (DiscoveredObjectTree)dataContractSerializer.ReadObject(reader);
                }
                result2 = discoveryResultItem;
            }
            catch (Exception ex)
            {
                PersistentDiscoveryCache._log.Error("Error while deserializing result tree!", ex);
                result2 = null;
            }
            return(result2);
        }