Example #1
0
        private static void OnUpdate(EventArgs args)
        {
            foreach (var handler in InvokeHandlers.ToArray())
            {
                try
                {
                    if (handler.Invoke())
                    {
                        InvokeHandlers.Remove(handler);
                    }
                }
                catch (Exception e)
                {
                    InvokeHandlers.Remove(handler);
                    Log.Error(e);
                }
            }

            foreach (var handler in Handlers.ToArray())
            {
                try
                {
                    handler.Invoke();
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
Example #2
0
 private Func <object, object[], IMessage> GetHandler(System.Type returnType)
 {
     System.Type type = typeof(InvokeHandlersTestClass);
     if (returnType == typeof(bool))
     {
         return((i, p) => InvokeHandlers.ForBoolReturnType(type.GetMethod("BoolReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(int))
     {
         return((i, p) => InvokeHandlers.ForInt32ReturnType(type.GetMethod("Int32ReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(uint))
     {
         return((i, p) => InvokeHandlers.ForUInt32ReturnType(type.GetMethod("UInt32ReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(long))
     {
         return((i, p) => InvokeHandlers.ForInt64ReturnType(type.GetMethod("Int64ReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(ulong))
     {
         return((i, p) => InvokeHandlers.ForUInt64ReturnType(type.GetMethod("UInt64ReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(string))
     {
         return((i, p) => InvokeHandlers.ForStringReturnType(type.GetMethod("StringReturnTypeMethod"), i, p));
     }
     if (returnType == typeof(byte[]))
     {
         return((i, p) => InvokeHandlers.ForBytesReturnType(type.GetMethod("BytesReturnTypeMethod"), i, p));
     }
     return(null);
 }
        private void Export(ISearchDataSet dataset, int quantity)
        {
            DialogResult result = MessageBox.Show("¿Desea exportar las publicaciones (publicaciones de twitter) con el contenido completo?", "Export content", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                IList <IPublication> publications = dataset.GetPublications();
                ReadHtmlContents(publications);
                dataset.AddOrReplacePublications(publications);
            }


            //FolderBrowserDialog folderDialog = new FolderBrowserDialog();
            //DialogResult resultFolderDialog = folderDialog.ShowDialog();


            string folderName = "";

            //if (resultFolderDialog == DialogResult.OK)
            //{
            //    string folderName = folderDialog.SelectedPath;
            //    dataset.BasePath = folderName + "/";
            //    dataset.ExportDataSet(-1);
            //IQueryConfiguration queryConfiguration = queriesControl.GetCurrentQueryConfiguration();
            //       string folderName = "..//..//..//Database//LemmatizedPublications";
            //string folderName = "..//..//..//Database//LemmatizedPublications";
            folderName       = "..//..//..//LemmatizedPublications";
            dataset.BasePath = folderName + "/";

            InvokeHandlers invokeHandlers = new InvokeHandlers(InvokeScrapperHandlers);

            this.Invoke(invokeHandlers);
            //}
        }
Example #4
0
        private void Export(ISearchDataSet dataset, int quantity)
        {
            DialogResult result = MessageBox.Show("¿Desea exportar las publicaciones (publicaciones de twitter) con el contenido completo?", "Export content", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                IList <IPublication> publications = dataset.GetPublications();
                ReadHtmlContents(publications);
                dataset.AddOrReplacePublications(publications);
            }

            IQueryConfiguration queryConfiguration = queriesControl.GetCurrentQueryConfiguration();

            if (queryConfiguration != null)
            {
                dataset.BaseName = queryConfiguration.SinceDate.ToShortDateString().Replace("/", "-") + "_" + queryConfiguration.UntilDate.AddDays(-1).ToShortDateString().Replace("/", "-");
            }
            else
            {
                dataset.BaseName = DateTime.Now.AddDays(-1).ToShortDateString().Replace("/", "-") + "_" + DateTime.Now.ToShortDateString().Replace("/", "-");
            }

            InvokeHandlers invokeHandlers = new InvokeHandlers(InvokeScrapperHandlers);

            this.Invoke(invokeHandlers);
        }
Example #5
0
        public static void BeginInvoke(Action callback, int timeout = 0)
        {
            if (timeout == 0)
            {
                Context.Post(state => callback(), null);
                return;
            }

            InvokeHandlers.Add(new UpdateHandler(callback, new TimeoutHandler(timeout, true)));
        }
Example #6
0
        public static void BeginInvoke(Action callback, int timeout = 0)
        {
            if (timeout < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout));
            }

            if (timeout == 0)
            {
                Threading.SynchronizationContext.Post(state => callback(), null);
                return;
            }

            InvokeHandlers.Add(new UpdateHandler(callback, new TimeoutHandler(timeout, true)));
        }