Esempio n. 1
0
        /// <summary>
        /// Main method that gathers data
        /// </summary>
        /// <param name="context">iDroneContext</param>
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;
                Context = cont;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode("dnshost", cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, "dnshost"))
                    {
                        //do work
                        WriteToUsageLogFile("DNSHost.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started DNSHost calls");

                        GetAllDNSHosts();

                        WriteToUsageLogFile("DNSHost.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed DNSHost calls");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "Drone.MarketShare.Components.DNSHost.GetData()");
            }
        }
Esempio n. 2
0
        private bool GetBoolFromXMLConfig(string node)
        {
            bool boolVal;

            bool.TryParse(XMLUtility.GetTextFromAccountNode(Xml, node), out boolVal);
            return(boolVal);
        }
Esempio n. 3
0
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, ProcessorName))
                    {
                        WriteToUsageLogFile("FacebookInsight.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started GetInsightInfo");

                        string accountId   = XMLUtility.GetTextFromAccountNode(Xml, "id");
                        string accessToken = XMLUtility.GetTextFromAccountNode(Xml, "accesstoken");
                        FBIO = new Graph().GetInsightInfo(accountId, accessToken);

                        WriteToUsageLogFile("FacebookInsight.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed GetInsightInfo");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "FacebookInsight.GetData()");
            }
        }
Esempio n. 4
0
        public override T LerXML <T>(XmlDocument doc)
        {
            if (typeof(T) != typeof(EnvEvento))
            {
                throw new InvalidCastException($"Cannot cast type '{typeof(T).Name}' into type '{typeof(EnvEvento).Name}'.");
            }

            var retornar = base.LerXML <T>(doc) as EnvEvento;

            var eventos = doc.GetElementsByTagName("evento");

            if ((eventos?.Count ?? 0) > 0)
            {
                retornar.Evento = new Evento[eventos.Count];

                var index = 0;

                foreach (XmlElement xmlEl in eventos)
                {
                    var xml = new StringBuilder();
                    xml.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    xml.Append($"<envEvento xmlns=\"{xmlEl.NamespaceURI}\">");
                    xml.Append($"{xmlEl.OuterXml}</envEvento>");

                    var envEvt = XMLUtility.Deserializar <EnvEvento>(xml.ToString());
                    var evt    = envEvt.Evento[0];
                    SignEvent(evt, xmlEl);
                    retornar.Evento[index++] = evt;
                }
            }

            return((T)(object)retornar);
        }
Esempio n. 5
0
        internal object HeapDeresolve(XElement serialized, IResolver resolver)
        {
            object instance;
            Guid   finalGuid;

            if (XMLUtility.GUIDAttributeConatins(serialized))
            {
                finalGuid = new Guid(XMLUtility.GuidOfAttributeInternal(serialized));
                instance  = resolver.GetTemplateInstance(serialized);
                if (instance != null)
                {
                    HeapManager.Managed.Add(finalGuid, instance);
                }
                DeresolveInternal(serialized, ref instance, resolver);
            }
            else
            {
                finalGuid = new Guid(XMLUtility.GuidOfValueInternal(serialized));
                instance  = HeapManager.Managed.ValueOf(finalGuid);
                if (instance == null)
                {
                    instance = AutoDeresolve(HeapManager.Serialized.ValueOf(finalGuid));;
                }
            }

            return(instance);
        }
Esempio n. 6
0
        public bool Update(System.Xml.XmlNode _PlayerNode, UploadID _Uploader /*Contains LastSeen*/, DateTime _LastSeen, PlayerHistory _PlayerHistory, WowVersionEnum _WowVersion, Func <int, VF.SQLUploadID> _GetSQLUploadIDFunc = null)
        {
            var newCharacter = new PlayerData.CharacterData(_PlayerNode);
            var newGuild     = new PlayerData.GuildData(_PlayerNode);
            var newGear      = new PlayerData.GearData(_PlayerNode, _WowVersion);
            var newHonor     = new PlayerData.HonorData(_PlayerNode, _WowVersion);

            if (newGear.Items.Count == 0 && newGuild.GuildName == "nil" && newGuild.GuildRank == "nil" && newHonor.CurrentRank == 0 && _WowVersion == WowVersionEnum.Vanilla)
            {
                return(true);
            }

            PlayerData.ArenaData newArena = null;
            string newTalentPointsData    = null;

            if (_WowVersion == WowVersionEnum.TBC)
            {
                newArena            = new PlayerData.ArenaData(_PlayerNode);
                newTalentPointsData = XMLUtility.GetChildValue(_PlayerNode, "TalentsData", "");
            }
            if (_GetSQLUploadIDFunc != null)
            {
                UpdateSQL(_GetSQLUploadIDFunc, Uploader, _LastSeen, _PlayerHistory, _WowVersion, newCharacter, newGuild, newGear, newHonor, newArena, newTalentPointsData);
            }
            return(Update(_Uploader, _LastSeen, _PlayerHistory, _WowVersion, newCharacter, newGuild, newGear, newHonor, newArena, newTalentPointsData));
        }
Esempio n. 7
0
        private void GetChannelData()
        {
            YouTubeDataSource yds = DroneDataSource as YouTubeDataSource;

            if (!Object.Equals(null, yds))
            {
                foreach (Competitor account in yds.GetCompetitorAccounts())
                {
                    if (!String.IsNullOrEmpty(account.YouTubeAccount))
                    {
                        ChannelManager cManager = new ChannelManager(new KeyValuePair <int, string>(account.ID, account.YouTubeAccount)
                                                                     , Utility.ApplicationName
                                                                     , XMLUtility.GetTextFromAccountNode(Xml, "token/devkey"));
                        Channel chan = cManager.GetUserChannel();

                        if (!Object.Equals(chan, null))
                        {
                            YouTubeDataComponent ydc = new YouTubeDataComponent();
                            ydc.YouTubeChannel = chan;
                            DroneDataSource.Process(ydc);
                        }
                        else
                        {
                            Utility.WriteToLogFile(String.Format("YouTube_ChannelNull_{0:M_d_yyyy}", DateTime.Today) + ".log", "No account info for: " + account.YouTubeAccount);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;
                Context = cont;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, ProcessorName))
                    {
                        WriteToUsageLogFile("YouTube.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started GetChannelData");

                        GetSquatterData();
                        GetChannelData();

                        WriteToUsageLogFile("YouTube.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed GetChannelData");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "YouTube.GetData()");
            }
        }
Esempio n. 9
0
        private void LoadStatics()
        {
            staticList = XMLUtility.XMLReader <ObjectsNode>(StringConsts.StaticsFile);
            foreach (ObjectsNode node in staticList)
            {
                switch (node.Shape)
                {
                case GeneralConstants.HorizontalLine:
                    HorizontalLine(node);
                    break;

                case GeneralConstants.RightTriangle:
                    RightTriangle(node);
                    break;

                case GeneralConstants.LeftTriangle:
                    LeftTriangle(node);
                    break;

                case GeneralConstants.VerticalLine:
                    VerticalLine(node);
                    break;
                }
            }
        }
Esempio n. 10
0
        public void TwitterUtility_GetNextRunInterval()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            DateTime nextRun = XMLUtility.GetNextRunInterval(t.Xml);

            Assert.IsNotNull(nextRun);
        }
 private void LoadEmpires()
 {
     foreach (string empirePaths in Directory.GetFiles(XMLUtility.userEmpireXMLPath))
     {
         avalableEmpires.Add(XMLUtility.LoadUserXML <Empire>(empirePaths));
     }
 }
Esempio n. 12
0
        private MarketShareEngine()
        {
            try
            {
                string      xmlFolder          = Utility.ComponentBaseFolder + "\\Xml";
                XmlDocument _marketAnalysisXML = new XmlDocument();
                _marketAnalysisXML.Load(Path.Combine(xmlFolder, "MarketAnalysis.xml"));
                _maxPageByteSize = XMLUtility.GetNodeFromXml(_marketAnalysisXML, "MarketAnalysis/PageByteLimit").InnerText.ConvertStringToInt(1048576);

                _sitebuilderRulesXML.Load(Path.Combine(xmlFolder, "SiteBuilderRules.xml"));
                _shoppingcartRulesXML.Load(Path.Combine(xmlFolder, "ShoppingCartRules.xml"));

                XmlDocument ruleTypes = new XmlDocument();
                ruleTypes.Load(Path.Combine(xmlFolder, "RuleTypes.xml"));

                Assembly assembly = Assembly.GetExecutingAssembly();
                foreach (XmlNode ruleNode in ruleTypes.SelectNodes("//Rule"))
                {
                    Type type = assembly.GetType(String.Format("{0}.{1}", typeof(MarketShareEngine).Namespace, ruleNode.InnerText));
                    if (!Object.Equals(null, type))
                    {
                        IProcessor proc = Activator.CreateInstance(type) as IProcessor;
                        if (!Object.Equals(null, proc))
                        {
                            _processors.Add(ruleNode.InnerText.ToLower(), proc);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "API.MarketAnalysis.MarketShareEngine Constructor");
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Main method that gathers data
        /// </summary>
        /// <param name="context">iDroneContext</param>
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;
                Context = cont;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) &&
                        XMLUtility.IsComponentEnabled(Xml, ProcessorName) &&
                        (int)DateTime.Today.DayOfWeek == (int)Enum.Parse(typeof(DayOfWeek), XMLUtility.GetTextFromAccountNode(Xml, ProcessorName + "/interval"), true) ||
                        Utility.FileExists("Crunchbase_AllCompanies.txt"))                                    //if this file exists, it means the service failed and is restarting.
                    {
                        //do work
                        WriteToUsageLogFile("Crunchbase.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started Crunchbase calls");

                        GetAllCompanies();

                        WriteToUsageLogFile("Crunchbase.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed Crunchbase calls");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "Drone.SmallBusinessTracking.Components.Crunchbase.GetData()");
            }
        }
Esempio n. 14
0
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;
                Context = cont;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, ProcessorName))
                    {
                        GetFanDemographics();
                        GetPageInfoForAllCompetitors();
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "FacebookFanInfo.GetData()");
            }
        }
Esempio n. 15
0
        public void Facebook_GetFanDemographicsAndInsertQueue()
        {
            FacebookFanInfo fg = new FacebookFanInfo();

            string accountId   = XMLUtility.GetTextFromAccountNode(fg.Xml, "id");
            string accessToken = XMLUtility.GetTextFromAccountNode(fg.Xml, "accesstoken");

            Demographic <Country> country = _graph.GetFanDemographics <Demographic <Country> >(accountId, accessToken, "page_fans_country");

            if (!Object.Equals(country, null))
            //fg.Context.MSMQManager.AddToQueue(country, "country");
            {
            }

            Demographic <Locale> locale = _graph.GetFanDemographics <Demographic <Locale> >(accountId, accessToken, "page_fans_locale");

            if (!Object.Equals(locale, null))
            //fg.Context.MSMQManager.AddToQueue(locale, "locale");
            {
            }

            Demographic <Gender> gender = _graph.GetFanDemographics <Demographic <Gender> >(accountId, accessToken, "page_fans_gender_age");

            if (!Object.Equals(gender, null))
            //fg.Context.MSMQManager.AddToQueue(gender, "gender");
            {
            }

            Assert.IsNotNull(fg);
        }
        private static PolicyBuilder BuildPolicyBuilderFromPollyTransientFailureExceptionsXMLFile()
        {
            return(ExceptionHandlingUtility.WrapFuncWithExceptionHandling(() =>
            {
                PolicyBuilder policyBuilder = null;
                XDocument xDoc = XDocument.Load(Path.Combine(typeof(BasicPollyExceptionHandler).Assembly.Location, "ExceptionHandling", "PollyBasedExceptionHandling", "PollyTransientFailureExceptions.xml"));
                _pollyTransientFailureExceptions = XMLUtility.DeSerialize <PollyTransientFailureExceptions>(xDoc.ToString());
                _splittedTransientFailureExceptions = _pollyTransientFailureExceptions.TransientFailureExceptions.SelectMany(x => x.CommaSeperatedTransientFailureExceptions.Split(",", StringSplitOptions.RemoveEmptyEntries)).Distinct();

                if (_splittedTransientFailureExceptions.IsNotNullOrEmpty())
                {
                    string firstTransientFailureException = _splittedTransientFailureExceptions.First();
                    string assemblyName = _pollyTransientFailureExceptions.TransientFailureExceptions.SingleOrDefault(x => x.CommaSeperatedTransientFailureExceptions.Contains(firstTransientFailureException)).AssemblyName;
                    Type firstTransientFailureExceptionType = MetaDataUtility.GetType(assemblyName, firstTransientFailureException);
                    Type[] transientFailureExceptionTypesArray = new Type[1];
                    transientFailureExceptionTypesArray[0] = firstTransientFailureExceptionType;
                    policyBuilder = MetaDataUtility.InvokeStaticMethod <Policy, PolicyBuilder>("Handle", transientFailureExceptionTypesArray);

                    IEnumerable <string> transientFailureExceptionsOtherThanTheFirst = _splittedTransientFailureExceptions.Skip(1);
                    if (transientFailureExceptionsOtherThanTheFirst.IsNotNullOrEmpty())
                    {
                        transientFailureExceptionsOtherThanTheFirst.ForEach(x =>
                        {
                            assemblyName = _pollyTransientFailureExceptions.TransientFailureExceptions.SingleOrDefault(y => y.CommaSeperatedTransientFailureExceptions.Contains(x)).AssemblyName;
                            Type transientFailureExceptionTypeForOtherThanTheFirst = MetaDataUtility.GetType(assemblyName, x);
                            Type[] transientFailureExceptionTypesArrayForOtherThanTheFirst = new Type[1];
                            transientFailureExceptionTypesArrayForOtherThanTheFirst[0] = transientFailureExceptionTypeForOtherThanTheFirst;
                            policyBuilder = MetaDataUtility.InvokeInstanceMethod <PolicyBuilder, PolicyBuilder>(policyBuilder, "Or", transientFailureExceptionTypesArrayForOtherThanTheFirst);
                        }
                                                                            );
                    }
                }
                return policyBuilder;
            }, _staticLoggerInstance));
        }
Esempio n. 17
0
        public void TwitterUtility_GetUserID()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());
            long id = XMLUtility.GetUserId(t.Xml);

            Assert.IsNotNull(id);
        }
Esempio n. 18
0
        static VersionHandlingHttpControllerSelector()
        {
            Assembly  currentAssembly         = typeof(VersionHandlingHttpControllerSelector).Assembly;
            string    currentAssemblyLocation = currentAssembly.Location;
            string    currentAssemblyName     = currentAssembly.GetName().Name;
            string    controllersXMLPath      = ControllersXMLPath.IsNotNullOrEmpty() ? ControllersXMLPath : Path.Combine(currentAssemblyLocation, "ControllerDispatchment", "ControllerEntityVersionsAndNamesMapping", "ControllerEntityVersionsAndNamesMapping.xml");
            XDocument xDocForControllersXML   = XDocument.Load(controllersXMLPath);

            _controllersXML = XMLUtility.DeSerialize <ControllersXML>(xDocForControllersXML.ToString());
            string controllersXSDPath         = ControllersXSDPath.IsNotNullOrEmpty() ? ControllersXSDPath : ("RestfulWebAPI.ControllerDispatchment.ControllerEntityVersionsAndNamesMapping.ControllerEntityVersionsAndNamesMapping.xsd");
            string controllersXSDAssemblyName = ControllersXSDAssemblyName.IsNotNullOrEmpty() ? ControllersXSDAssemblyName : currentAssemblyName;
            string xmlValidationErrors        = XSDUtility.Validate(controllersXSDAssemblyName, ControllersXSDPath, xDocForControllersXML.ToString());

            if (xmlValidationErrors.IsNotNullOrEmpty())
            {
                HttpResponseUtility.ThrowHttpResponseError(HttpStatusCode.InternalServerError, xmlValidationErrors);
            }

            string    entitiesXMLPath    = EntitiesXMLPath.IsNotNullOrEmpty() ? EntitiesXMLPath : Path.Combine(currentAssemblyLocation, "ControllerDispatchment", "ControllerEntityVersionsAndNamesMapping", "EntitiesAndIDTypesMapping.xml");
            XDocument xDocForEntitiesXML = XDocument.Load(entitiesXMLPath);

            _entitiesXML = XMLUtility.DeSerialize <EntitiesXML>(xDocForEntitiesXML.ToString());
            string entitiesXSDPath         = EntitiesXSDPath.IsNotNullOrEmpty() ? EntitiesXSDPath : ("RestfulWebAPI.ControllerDispatchment.ControllerEntityVersionsAndNamesMapping.EntitiesAndIDTypesMapping.xsd");
            string entitiesXSDAssemblyName = EntitiesXSDAssemblyName.IsNotNullOrEmpty() ? EntitiesXSDAssemblyName : currentAssemblyName;

            xmlValidationErrors = XSDUtility.Validate(entitiesXSDAssemblyName, entitiesXSDPath, xDocForEntitiesXML.ToString());
            if (xmlValidationErrors.IsNotNullOrEmpty())
            {
                HttpResponseUtility.ThrowHttpResponseError(HttpStatusCode.InternalServerError, xmlValidationErrors);
            }

            //Register this cache in Unity DI Container with Singleton lifetime
            _cache = Container.Instance.Resolve <ICache <string, HttpControllerDescriptor> >();
        }
Esempio n. 19
0
        /// <summary>
        /// Main method that gathers data
        /// </summary>
        /// <param name="context">IDroneContext</param>
        public override void GetData(object context)
        {
            try
            {
                TwitterContext cont = context as TwitterContext;
                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);

                    //lock the thread and write to context
                    lock (cont) cont.NextRun = XMLUtility.GetNextRunInterval(Xml);

                    //do work
                    if (XMLUtility.IsEnabled(Xml))
                    {
                        WriteToUsageLogFile("Twitter.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started GetAllMentionsByQuery");

                        GetAllMentionsByQuery(cont);

                        WriteToUsageLogFile("Twitter.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed GetAllMentionsByQuery");
                    }

                    //lock the thread and write to context
                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "Drone.Twitter.Components.Twitter.GetData()");
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Main method that gathers data
        /// </summary>
        /// <param name="context">iDroneContext</param>
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, ProcessorName))
                    {
                        //do work
                        WriteToUsageLogFile("TwitterTrend.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started GetTwitterTrendsAllPlaces");

                        TwitterDataComponent _dataComponent = DroneDataComponent as TwitterDataComponent;
                        _dataComponent.TrendRootList = GetTwitterTrendsAllPlaces();
                        //DroneDataSource.Process(_dataComponent);
                        //add via webapi call if this is needed again

                        WriteToUsageLogFile("TwitterTrend.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed GetTwitterTrendsAllPlaces");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "Drone.Twitter.Components.TwitterTrend.GetData()");
            }
        }
Esempio n. 21
0
 private void OnEnable()
 {
     m_spritePath = XMLUtility.Load <string>(m_prefix + "m_spritePath");
     m_outputPath = XMLUtility.Load <string>(m_prefix + "m_outputPath");
     //m_isRename = XMLUtility.Load<bool>(m_prefix + "m_isRename");
     m_cutStr = XMLUtility.Load <string>(m_prefix + "m_cutStr");
 }
Esempio n. 22
0
 private void OnDisable()
 {
     XMLUtility.Save(m_prefix + "m_spritePath", m_spritePath);
     XMLUtility.Save(m_prefix + "m_outputPath", m_outputPath);
     //XMLUtility.Save(m_prefix + "m_isRename", m_isRename);
     XMLUtility.Save(m_prefix + "m_cutStr", m_cutStr);
 }
Esempio n. 23
0
        static void deserializeFSDDL2()
        {
            string dirXml = "";

            FileStream   fileStream = new FileStream(@"D:\backup\FSDDLTest2.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
            StreamReader reader     = new StreamReader(fileStream);

            dirXml = reader.ReadToEnd();

            reader.Close();
            fileStream.Close();

            DataIntegrator.Descriptions.FileSystem.FSDDL.Directory dir = XMLUtility.XmlDeserialize(dirXml, typeof(DataIntegrator.Descriptions.FileSystem.FSDDL.Directory), new Type[] { typeof(DataIntegrator.Descriptions.FileSystem.FSDDL.File) }) as DataIntegrator.Descriptions.FileSystem.FSDDL.Directory;

            Console.WriteLine(dir);

            Console.WriteLine(dir.Name);

            Console.WriteLine(dir.Directories[0].Directories[0].Files[0].Name);

            Console.WriteLine(Encoding.UTF8.GetString(dir.Directories[0].Directories[0].Files[0].Content));

            DataIntegrator.Helpers.FileSystem.FileSystemHelper helper = new DataIntegrator.Helpers.FileSystem.FileSystemHelper();

            System.IO.DirectoryInfo dirInfo = helper.WriteFiles(@"D:\bakcup\DITest", dir) as System.IO.DirectoryInfo;

            Console.WriteLine(dirInfo.FullName);

            Console.Read();
        }
Esempio n. 24
0
        /// <summary>
        /// Main method that gathers data
        /// </summary>
        /// <param name="context">iDroneContext</param>
        public override void GetData(object context)
        {
            try
            {
                BaseContext cont = context as BaseContext;
                Context = cont;

                if (!Object.Equals(cont, null))
                {
                    SetContextStatus("processing", cont);
                    SetNextRunIntervalByNode(ProcessorName, cont);

                    if (XMLUtility.IsEnabled(Xml) && XMLUtility.IsComponentEnabled(Xml, ProcessorName))
                    {
                        //do work
                        WriteToUsageLogFile("MarketShareBuilder.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Started MarketShareBuilder calls");

                        GetBuilders();

                        WriteToUsageLogFile("MarketShareBuilder.GetData | Thread:" + Thread.CurrentThread.ManagedThreadId.ToString(), "Completed MarketShareBuilder calls");
                    }

                    SetContextStatus("waiting", cont);
                }

                RaiseProcessingCompletedEvent(new EventArgs());
                GC.Collect();
            }
            catch (Exception e)
            {
                ExceptionExtensions.LogError(e, "Drone.SmallBusinessTracking.Components.MarketShareBuilder.GetData()");
            }
        }
Esempio n. 25
0
        static void serializeFSDDL2()
        {
            DataIntegrator.Helpers.FileSystem.FileSystemHelper helper = new DataIntegrator.Helpers.FileSystem.FileSystemHelper();

            DataIntegrator.Descriptions.FileSystem.FSDDL.Directory dir = helper.ListFiles(@"D:\home\v-rawang\Documents\Quanta\Quanta 2nd round\", "*.xml");

            string dirXml = XMLUtility.XmlSerialize(dir, new Type[] { typeof(DataIntegrator.Descriptions.FileSystem.FSDDL.File) });

            Console.Write(dirXml);

            FileStream fileStream = new FileStream(@"D:\backup\FSDDLTest2.xml", FileMode.Create, FileAccess.Write, FileShare.Write);

            StreamWriter writer = new StreamWriter(fileStream, Encoding.UTF8);

            dirXml = dirXml.Insert(dirXml.IndexOf("?>"), " encoding=\"utf-8\"");
            dirXml = dirXml.Substring(0, dirXml.LastIndexOf(">") + 1);

            writer.Write(dirXml);

            writer.Flush();
            fileStream.Flush();

            writer.Close();
            fileStream.Close();

            Console.Write(dirXml);

            Console.Read();
        }
Esempio n. 26
0
        public void TestCMCCTestPortal(BrowserOp browser)
        {
            XMLUtility xml           = new XMLUtility("./TestPortal.xml");
            string     userName      = xml.readNodeValue("UserName");
            string     pwd           = xml.readNodeValue("PWD");
            string     manufacturer  = xml.readNodeValue("manufacturer");
            string     model         = xml.readNodeValue("model");
            string     packageType   = xml.readNodeValue("packageType");
            string     packageStatus = xml.readNodeValue("packageStatus");

            EditOp.EditInput(browser, "mobile", userName);
            EditOp.EditInput(browser, "password", pwd);
            ButtonOp.buttonClick(browser, "submit");
            Utility.wait(5);
            HyperLinkOp.LinkClick(browser, "包管理");
            //ButtonOp.buttonClick(browser, "A16");
            ButtonOp.buttonClick(browser, "//input[@id='A16' and @value='固件更新包管理']");
            Utility.wait(1);
            ComboBoxOp.ComboBoxItemSelect(browser, "manufacturer", manufacturer);
            Utility.wait(1);
            ComboBoxOp.ComboBoxItemSelect(browser, "model_name", model);
            Utility.wait(1);
            ComboBoxOp.ComboBoxItemSelect(browser, "packageType", packageType);
            Utility.wait(1);
            ComboBoxOp.ComboBoxItemSelect(browser, "packageStatus", packageStatus);

            ButtonOp.buttonClick(browser, "submit2");
        }
Esempio n. 27
0
        private static void LoadConfig()
        {
            string configFilePath = AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["ElasticSearchClusterConfig"];
            string xml            = File.ReadAllText(configFilePath);

            _instance = XMLUtility.Deserialize <ElasticSearchClusterConfig>(xml);
        }
Esempio n. 28
0
        public void TwitterUtility_UseSinceID()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.UseSinceId(t.Xml, "twitter");

            Assert.IsTrue(enabledProperty);
        }
Esempio n. 29
0
        public void TwitterUtility_IsEnabled_BadXmlDefaultsFalse()
        {
            Drone.Twitter.Components.Twitter t = new Twitter.Components.Twitter(new TwitterTestDataSource());

            bool enabledProperty = XMLUtility.IsEnabled(new XmlDocument());

            Assert.IsFalse(enabledProperty);
        }
Esempio n. 30
0
        public static DateTime ParseLastSeenUTC(System.Xml.XmlNode _PlayerNode)
        {
            string   dateTime = XMLUtility.GetChildValue(_PlayerNode, "DateTimeUTC", "2000-01-01 01:01:01");
            DateTime lastSeen;

            System.DateTime.TryParse(dateTime, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AdjustToUniversal, out lastSeen);
            return(lastSeen);
        }