Beispiel #1
0
        public static async Task FillTableWithDataFromLog()
        {
            Functions.StarsTable          table      = new Functions.StarsTable(GetConnectionString());
            Dictionary <string, DateTime> gazerDates = GitHubAPI.GetGazerDatesFromLog("../../../data/gazerDates.csv");
            DateTime created = DateTime.Parse("2018-01-04T03:34:45Z").Date;

            int totalDays = (DateTime.UtcNow.Date - created).Days + 1;

            DateTime[] days = Enumerable.Range(0, totalDays).Select(i => created.AddDays(i)).ToArray();

            int[] newStarsByDay = new int[totalDays];
            foreach ((_, DateTime dt) in gazerDates)
            {
                newStarsByDay[(dt - created).Days] += 1;
            }

            int[] totalStarsByDay = new int[totalDays];
            totalStarsByDay[0] = newStarsByDay[0];
            for (int i = 1; i < totalDays; i++)
            {
                totalStarsByDay[i] = totalStarsByDay[i - 1] + newStarsByDay[i];
            }

            for (int i = 0; i < totalDays; i++)
            {
                DateTime day   = days[i];
                int      stars = totalStarsByDay[i];
                await table.Insert("scottplot", "scottplot", stars, day);
            }
        }
        private void DownloadChangelog()
        {
            logger.Info("Downloading latest changelog...");

            GitHubAPI gitHubAPI = new GitHubAPI(App.ProxyConfig);
            Release   release   = gitHubAPI.GetReleaseByTagName(App.RepoInfo, App.CurrentVersion);

            if (release.HttpStatusCode != HttpStatusCode.OK)
            {
                release = gitHubAPI.GetLatestRelease(App.RepoInfo);
            }

            // OnDownloaded
            if (release.HttpStatusCode == HttpStatusCode.OK)
            {
                this.viewModel.ReleaseBodyMarkdown = $"## {release.Name}\n" +
                                                     $"{gitHubAPI.GitHubify(release.Body)}";

                this.viewModel.PublishedAt = release.PublishedAt?.ToString(App.UserCulture);

                logger.Info("Changelog downloaded");
            }
            else
            {
                this.viewModel.ReleaseBodyMarkdown = "### Failed loading the changelog!\n" +
                                                     $"You can read the latest changes [here]({Releases.GetUrlOfLatestRelease(App.RepoInfo)}).";
                this.PanelPublished.Visibility = Visibility.Collapsed;

                logger.Warn($"Failed to download the latest changelog. StatusCode = {release.HttpStatusCode}");
            }
        }
Beispiel #3
0
        public static async Task AddCurrentStarsToTable()
        {
            (_, string json) = GitHubAPI.RequestRepo("scottplot", "scottplot", GetGitHubToken());
            int stars = GitHubAPI.TotalStars(json);

            Functions.StarsTable table = new Functions.StarsTable(GetConnectionString());
            await table.Insert("scottplot", "scottplot", stars, DateTime.Now);
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            // TODO: Load plugins here

            var parameters = new StartParameters();

            for (int i = 0; i < args.Length; i++) // TODO: Consider moving this out of this file
            {
                var arg = args[i];
                try
                {
                    if (arg.StartsWith("-"))
                    {
                        switch (arg)
                        {
                        case "--config":
                            parameters.Configuration = args[++i];
                            break;

                        case "--help":
                            DisplayHelp();
                            return;

                        case "--setup":
                            parameters.RunSetup = true;
                            break;

                        default:
                            Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information.");
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information.");
                        return;
                    }
                }
                catch
                {
                    Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information.");
                    return;
                }
            }

            if (!File.Exists(parameters.Configuration) || parameters.RunSetup)
            {
                Setup.FirstTimeSetup();
            }
            else
            {
                Configuration = Configuration.Load(parameters.Configuration);
            }

            GitHubAPI.Login(Configuration.GitHubUsername, Configuration.GitHubPassword);
        }
Beispiel #5
0
        protected VersionChecker()
        {
            this.gitHubAPI = new GitHubAPI(App.ProxyConfig);

            this.current = Settings.Current;
            this.current.PropertyChanged += this.CurrentSettings_PropertyChanged;
            SettingsView.SettingsSaved   += this.SettingsView_SettingsSaved;

#if DEBUG
            this.checkVersionTimer = null;
#else
            this.checkVersionTimer = new Timer(state => this.CheckNow(), null, CalcCheckVersionDueTime().Add(TimeSpan.FromMinutes(2.5)), new TimeSpan(-1));
#endif
        }
Beispiel #6
0
        public void GetAsyncTest()
        {
            var fakeResponseHandler        = new FakeResponseHandler();
            HttpResponseMessage repMessage = new HttpResponseMessage(HttpStatusCode.OK);

            repMessage.Headers.Add("X-RateLimit-Remaining", "10");
            fakeResponseHandler.AddFakeResponse(new Uri("http://NetTask.net/test"), repMessage);

            var httpClient = new GitHubAPI(fakeResponseHandler);

            var response1 = httpClient.Get("http://NetTask.net/test1");
            var response2 = httpClient.Get("http://NetTask.net/test");

            Assert.AreEqual(response1.StatusCode, HttpStatusCode.NotFound);
            Assert.AreEqual(response2.StatusCode, HttpStatusCode.OK);
        }
Beispiel #7
0
        public void RateLimitTest()
        {
            try
            {
                var fakeResponseHandler        = new FakeResponseHandler();
                HttpResponseMessage repMessage = new HttpResponseMessage(HttpStatusCode.OK);
                repMessage.Headers.Add("X-RateLimit-Remaining", "0");
                fakeResponseHandler.AddFakeResponse(new Uri("http://NetTask.net/test"), repMessage);

                var httpClient = new GitHubAPI(fakeResponseHandler);
                var response2  = httpClient.Get("http://NetTask.net/test");
            }catch (Exception ex) when(ex.GetType() != typeof(CustomException))
            {
            }

            Assert.Fail();
        }
Beispiel #8
0
        public static void RunAsync([TimerTrigger(TRIGGER_DAILY)] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            var    db       = new StarsTable(log);
            string userName = "******";
            string repoName = "scottplot";

            // add the latest star count to the database
            string gitHubToken = Environment.GetEnvironmentVariable("GitHubToken", EnvironmentVariableTarget.Process);

            (var _, string json) = GitHubAPI.RequestRepo(userName, repoName, gitHubToken);
            int stars = GitHubAPI.TotalStars(json);

            db.Insert(userName, repoName, stars, DateTime.UtcNow).GetAwaiter().GetResult();

            // plot historical star count as an image and upload it
            var bmp = db.GetGraphBitmap();

            db.UploadImage(bmp).GetAwaiter().GetResult();
        }
Beispiel #9
0
        public static void FirstTimeSetup()
        {
            // TODO: Consider refactoring
            // TODO: Alternate locales
            var config = new Configuration();

            Console.WriteLine("Welcome to Virtue. Let's get started.");
            Console.WriteLine("We need a GitHub account to work with. Virtue is strongly GitHub-oriented.");
            Console.WriteLine("It is suggested that you create a seperate account for Virtue than your own.");
            AuthenticatedUser user;

            do
            {
                Console.Write("Username: "******"Password: "******"Try again.");
                }
            } while (user == null);

            Program.Configuration = config;
        }
Beispiel #10
0
 public static void ViewCurrentStars()
 {
     (_, string json) = GitHubAPI.RequestRepo("scottplot", "scottplot", GetGitHubToken());
     Console.WriteLine($"STARS: {GitHubAPI.TotalStars(json)}");
 }
Beispiel #11
0
 public HomeController(GitHubAPI gitHub)
 {
     this.gitHub = gitHub;
 }
Beispiel #12
0
        public override bool Init()
        {
            base.Init();
            GitHubApi           = new GitHubAPI();
            MarketProjects      = new ObservableCollection <ProjectItem>();
            dockableManager     = MainFrmUI as IDockableManager;
            dataManager         = MainFrmUI.PluginDictionary["DataManager"] as IDataManager;
            ProcessCollection   = new ObservableCollection <IDataProcess>();
            CurrentProcessTasks = new ObservableCollection <TaskBase>();
            if (!MainDescription.IsUIForm)
            {
                return(true);
            }
            this.datatTimer = new DispatcherTimer();
            var aboutAuthor = new BindingAction(GlobalHelper.Get("key_262"), d =>
            {
                var view       = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get("key_263"));
                var window     = new Window();
                window.Title   = GlobalHelper.Get("key_263");
                window.Content = view;
                window.ShowDialog();
            })
            {
                Description = GlobalHelper.Get("key_264"), Icon = "information"
            };
            var mainlink = new BindingAction(GlobalHelper.Get("key_265"), d =>
            {
                var url = "https://github.com/ferventdesert/Hawk";
                System.Diagnostics.Process.Start(url);
            })
            {
                Description = GlobalHelper.Get("key_266"), Icon = "home"
            };
            var helplink = new BindingAction(GlobalHelper.Get("key_267"), d =>
            {
                var url = "https://ferventdesert.github.io/Hawk/";
                System.Diagnostics.Process.Start(url);
            })
            {
                Description = GlobalHelper.Get("key_268"), Icon = "question"
            };

            var feedback = new BindingAction(GlobalHelper.Get("key_269"), d =>
            {
                var url = "https://github.com/ferventdesert/Hawk/issues";
                System.Diagnostics.Process.Start(url);
            })
            {
                Description = GlobalHelper.Get("key_270"), Icon = "reply_people"
            };


            var giveme = new BindingAction(GlobalHelper.Get("key_271"), d =>
            {
                var url =
                    "https://github.com/ferventdesert/Hawk/wiki/8-%E5%85%B3%E4%BA%8E%E4%BD%9C%E8%80%85%E5%92%8C%E6%8D%90%E8%B5%A0";
                System.Diagnostics.Process.Start(url);
            })
            {
                Description = GlobalHelper.Get("key_272"), Icon = "smiley_happy"
            };
            var blog = new BindingAction(GlobalHelper.Get("key_273"), d =>
            {
                var url = "http://www.cnblogs.com/buptzym/";
                System.Diagnostics.Process.Start(url);
            })
            {
                Description = GlobalHelper.Get("key_274"), Icon = "tower"
            };

            var update = new BindingAction(GlobalHelper.Get("checkupgrade"),
                                           d =>
            {
                AutoUpdater.Start("https://raw.githubusercontent.com/ferventdesert/Hawk/global/Hawk/autoupdate.xml");
            })
            {
                Description = GlobalHelper.Get("checkupgrade"), Icon = "arrow_up"
            };
            var helpCommands = new BindingAction(GlobalHelper.Get("key_275"))
            {
                Icon = "magnify"
            };

            helpCommands.ChildActions.Add(mainlink);
            helpCommands.ChildActions.Add(helplink);

            helpCommands.ChildActions.Add(feedback);
            helpCommands.ChildActions.Add(giveme);
            helpCommands.ChildActions.Add(blog);
            helpCommands.ChildActions.Add(aboutAuthor);
            helpCommands.ChildActions.Add(update);
            MainFrmUI.CommandCollection.Add(helpCommands);

            var hierarchy    = (Hierarchy)LogManager.GetRepository();
            var debugCommand = new BindingAction(GlobalHelper.Get("debug"))
            {
                ChildActions = new ObservableCollection <ICommand>
                {
                    new BindingAction(GlobalHelper.Get("key_277"))
                    {
                        ChildActions =
                            new ObservableCollection <ICommand>
                        {
                            new BindingAction("Debug", obj => hierarchy.Root.Level = Level.Debug),
                            new BindingAction("Info", obj => hierarchy.Root.Level  = Level.Info),
                            new BindingAction("Warn", obj => hierarchy.Root.Level  = Level.Warn),
                            new BindingAction("Error", obj => hierarchy.Root.Level = Level.Error),
                            new BindingAction("Fatal", obj => hierarchy.Root.Level = Level.Fatal)
                        }
                    }
                },
                Icon = ""
            };

            MainFrmUI.CommandCollection.Add(debugCommand);

            BindingCommands = new BindingAction(GlobalHelper.Get("key_279"));
            var sysCommand = new BindingAction();

            sysCommand.ChildActions.Add(
                new Command(
                    GlobalHelper.Get("key_280"),
                    obj =>
            {
                if (
                    MessageBox.Show(GlobalHelper.Get("key_281"), GlobalHelper.Get("key_99"),
                                    MessageBoxButton.OKCancel) ==
                    MessageBoxResult.OK)
                {
                    ProcessCollection.RemoveElementsNoReturn(d => true, RemoveOperation);
                }
            }, obj => true,
                    "clear"));

            sysCommand.ChildActions.Add(
                new Command(
                    GlobalHelper.Get("key_282"),
                    obj =>
            {
                if (
                    MessageBox.Show(GlobalHelper.Get("key_283"), GlobalHelper.Get("key_99"),
                                    MessageBoxButton.OKCancel) ==
                    MessageBoxResult.OK)
                {
                    SaveCurrentProject();
                }
            }, obj => true,
                    "save"));

            BindingCommands.ChildActions.Add(sysCommand);

            var taskAction1 = new BindingAction();


            taskAction1.ChildActions.Add(new Command(GlobalHelper.Get("key_284"),
                                                     async obj =>
            {
                var project = await GetRemoteProjectContent();
                if (project != null)
                {
                    foreach (var param in project.Parameters)
                    {
                        //TODO: how check if it is same? name?
                        if (CurrentProject.Parameters.FirstOrDefault(d => d.Name == param.Name) == null)
                        {
                            CurrentProject.Parameters.Add(param);
                        }
                    }
                    CurrentProject.ConfigSelector.SelectItem = project.ConfigSelector.SelectItem;
                }

                (obj as ProcessTask).Load(true);
            },
                                                     obj => obj is ProcessTask, "inbox_out"));



            BindingCommands.ChildActions.Add(taskAction1);
            var taskAction2 = new BindingAction(GlobalHelper.Get("key_287"));

            taskAction2.ChildActions.Add(new Command(GlobalHelper.Get("key_288"),
                                                     obj =>
            {
                var task = obj as TaskBase;
                task.Start();
            },
                                                     obj =>
            {
                var task = obj as TaskBase;
                return(task != null && task.IsStart == false);
            }, "play"));

            taskAction2.ChildActions.Add(new Command(GlobalHelper.Get("cancel_task"),
                                                     obj =>
            {
                var task = obj as TaskBase;
                if (task.IsStart)
                {
                    task.Remove();
                }

                task.Remove();
            },
                                                     obj =>
            {
                var task = obj as TaskBase;
                return(task != null);
            }, "cancel"));


            var runningTaskActions = new BindingAction(GlobalHelper.Get("key_290"));


            runningTaskActions.ChildActions.Add(new Command(GlobalHelper.Get("key_291"),
                                                            d => GetSelectedTask(d).Execute(d2 => { d2.IsPause = true; d2.ShouldPause = true; }), d => true, "pause"));
            runningTaskActions.ChildActions.Add(new Command(GlobalHelper.Get("key_292"),
                                                            d => GetSelectedTask(d).Execute(d2 => { d2.IsPause = false; d2.ShouldPause = false; }), d => ProcessTaskCanExecute(d, false), "play"));

            runningTaskActions.ChildActions.Add(new Command(GlobalHelper.Get("key_293"),
                                                            d =>
            {
                var selectedTasks = GetSelectedTask(d).ToList();
                CurrentProcessTasks.Where(d2 => selectedTasks.Contains(d2)).ToList().Execute(d2 => d2.Remove());
            }, d => ProcessTaskCanExecute(d, null), "delete"));


            runningTaskActions.ChildActions.Add(new Command(GlobalHelper.Get("property"),
                                                            d =>
            {
                var selectedTasks = GetSelectedTask(d).FirstOrDefault();
                PropertyGridFactory.GetPropertyWindow(selectedTasks).ShowDialog();
            }, d => ProcessTaskCanExecute(d, null), "settings"));



            BindingCommands.ChildActions.Add(runningTaskActions);
            BindingCommands.ChildActions.Add(runningTaskActions);


            var processAction = new BindingAction();


            dynamic processview =
                (MainFrmUI as IDockableManager).ViewDictionary.FirstOrDefault(d => d.Name == GlobalHelper.Get("key_794"))
                .View;

            processView = processview.processListBox as ListBox;

            var tickInterval = ConfigFile.GetConfig().Get <int>("AutoSaveTime");

            if (tickInterval > 0)
            {
                this.datatTimer.Tick    += timeCycle;
                this.datatTimer.Interval = new TimeSpan(0, 0, 0, tickInterval);
                this.datatTimer.Start();
            }
            ConfigFile.GetConfig().PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "AutoSaveTime")
                {
                    var tick = ConfigFile.GetConfig().Get <int>("AutoSaveTime");
                    if (tick <= 0)
                    {
                        tick = 1000000;
                    }
                    this.datatTimer.Interval = new TimeSpan(0, 0, 0, tick);
                }
            };

            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_294"), obj =>
            {
                if (obj != null)
                {
                    foreach (var process in GetSelectedProcess(obj))
                    {
                        if (process == null)
                        {
                            return;
                        }
                        var old = obj as IDataProcess;
                        if (old == null)
                        {
                            return;
                        }

                        var name = process.GetType().ToString().Split('.').Last();
                        var item = GetOneInstance(name, true, true);
                        (process as IDictionarySerializable).DictCopyTo(item as IDictionarySerializable);
                        item.Init();
                        item.Name = process.Name + "_copy";
                    }
                }
                else
                {
                    var plugin = GetOneInstance("SmartETLTool", true, true, true) as SmartETLTool;
                    plugin.Init();
                    ControlExtended.DockableManager.ActiveModelContent(plugin);
                }
            }, obj => true, "add"));

            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_295"), obj =>
            {
                if (obj == null)
                {
                    var plugin = GetOneInstance("SmartCrawler", true, true, true) as SmartCrawler;
                    plugin.Init();
                    ControlExtended.DockableManager.ActiveModelContent(plugin);
                }
                else
                {
                    foreach (var process in GetSelectedProcess(obj))
                    {
                        if (process == null)
                        {
                            return;
                        }
                        var name = process.GetType().ToString().Split('.').Last();
                        var item = GetOneInstance(name, true, true);

                        (process as IDictionarySerializable).DictCopyTo(item as IDictionarySerializable);
                        item.Init();
                        item.Name = process.Name + "_copy";
                    }
                }
            }, obj => true, "cloud_add"));


            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_296"), obj =>
            {
                if (obj == null)
                {
                    SaveCurrentProject();
                }
                else
                {
                    foreach (var process in GetSelectedProcess(obj))
                    {
                        SaveTask(process, false);
                    }
                }
            }, obj => true, "save"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_297"), obj =>
            {
                var process = GetSelectedProcess(obj).FirstOrDefault();
                if (process == null)
                {
                    return;
                }
                var view = (MainFrmUI as IDockableManager).ViewDictionary.FirstOrDefault(d => d.Model == process);
                if (view == null)
                {
                    LoadProcessView(process);
                }
                (MainFrmUI as IDockableManager).ActiveModelContent(process);

                process.Init();
            }, obj => true, "tv"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_298"), obj =>
            {
                if (MessageBox.Show(GlobalHelper.Get("delete_confirm"), GlobalHelper.Get("key_99"), MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
                foreach (var process in GetSelectedProcess(obj))
                {
                    if (process == null)
                    {
                        return;
                    }

                    RemoveOperation(process);
                    ProcessCollection.Remove(process);
                    var tasks = CurrentProcessTasks.Where(d => d.Publisher == process).ToList();
                    if (tasks.Any())
                    {
                        foreach (var item in tasks)
                        {
                            item.Remove();
                            XLogSys.Print.Warn(string.Format(GlobalHelper.Get("key_299"), process.Name, item.Name));
                        }
                    }
                }
            }, obj => true, "delete"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("key_300"),
                                                       obj => { ControlExtended.DockableManager.ActiveThisContent(GlobalHelper.Get("ModuleMgmt")); },
                                                       obj => true, "home"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("find_ref"),
                                                       obj =>
            {
                PrintReferenced(obj as IDataProcess);
            }, obj => true, "diagram"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("property"),
                                                       obj =>
            {
                PropertyGridFactory.GetPropertyWindow(obj).ShowDialog();
            }, obj => true, "settings"));
            processAction.ChildActions.Add(new Command(GlobalHelper.Get("param_group"),
                                                       obj =>
            {
                this.dockableManager.ActiveThisContent(GlobalHelper.Get("ModuleMgmt"));
                MainTabIndex = 2;
            }, obj => true, "equalizer"));
            BindingCommands.ChildActions.Add(processAction);
            BindingCommands.ChildActions.Add(taskAction2);


            var attributeactions = new BindingAction(GlobalHelper.Get("key_301"));

            attributeactions.ChildActions.Add(new Command(GlobalHelper.Get("key_302"), obj =>
            {
                var attr = obj as XFrmWorkAttribute;
                if (attr == null)
                {
                    return;
                }

                var process = GetOneInstance(attr.MyType.Name, newOne: true, isAddUI: true);
                process.Init();
            }, icon: "add"));
            BindingCommands.ChildActions.Add(attributeactions);


            var marketAction = new BindingAction();

            marketAction.ChildActions.Add(new Command(GlobalHelper.Get("connect_market"), async obj =>
            {
                GitHubApi.Connect(ConfigFile.GetConfig().Get <string>("Login"), ConfigFile.GetConfig().Get <string>("Password"));
                MarketProjects.Clear();
                ControlExtended.SetBusy(ProgressBarState.Indeterminate, message: GlobalHelper.Get("get_remote_projects"));
                MarketProjects.AddRange(await GitHubApi.GetProjects(ConfigFile.GetConfig().Get <string>("MarketUrl")));
                ControlExtended.SetBusy(ProgressBarState.NoProgress);
            }, icon: "refresh"));

            BindingCommands.ChildActions.Add(marketAction);


            var marketProjectAction = new BindingAction();

            marketProjectAction.ChildActions.Add(new Command(GlobalHelper.Get("key_307"), async obj =>
            {
                var projectItem = obj as ProjectItem;
                var keep        = MessageBoxResult.Yes;
                if (projectItem == null)
                {
                    return;
                }
                if (MessageBox.Show(GlobalHelper.Get("is_load_remote_project"), GlobalHelper.Get("key_99"), MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
                {
                    return;
                }
                if (NeedSave())
                {
                    keep = MessageBox.Show(GlobalHelper.Get("keep_old_datas"), GlobalHelper.Get("key_99"),
                                           MessageBoxButton.YesNoCancel);
                    if (keep == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }
                var proj = await this.GetRemoteProjectContent(projectItem);
                LoadProject(proj, keep == MessageBoxResult.Yes);
            }, icon: "download"));


            var config = ConfigFile.GetConfig <DataMiningConfig>();

            if (config.Projects.Any())
            {
                var project = config.Projects.FirstOrDefault();
                if (project != null)
                {
                    ControlExtended.SafeInvoke(() => { CurrentProject = LoadProject(project.SavePath); }, LogType.Info,
                                               GlobalHelper.Get("key_303"));
                }
            }
            BindingCommands.ChildActions.Add(marketProjectAction);
            if (MainDescription.IsUIForm)
            {
                ProgramNameFilterView =
                    new ListCollectionView(PluginProvider.GetPluginCollection(typeof(IDataProcess)).ToList());

                ProgramNameFilterView.GroupDescriptions.Clear();
                ProgramNameFilterView.GroupDescriptions.Add(new PropertyGroupDescription("GroupName"));
                var taskView    = PluginProvider.GetObjectInstance <ICustomView>(GlobalHelper.Get("key_304"));
                var userControl = taskView as UserControl;
                if (userControl != null)
                {
                    userControl.DataContext = this;
                    dynamic control = userControl;
                    currentProcessTasksView = control.currentProcessTasksView;
                    ((INotifyCollectionChanged)CurrentProcessTasks).CollectionChanged += (s, e) =>
                    {
                        ControlExtended.UIInvoke(() =>
                        {
                            if (e.Action == NotifyCollectionChangedAction.Add)
                            {
                                dockableManager.ActiveThisContent(GlobalHelper.Get("key_304"));
                            }
                        });
                    }
                    ;
                    dockableManager.AddDockAbleContent(taskView.FrmState, this, taskView, GlobalHelper.Get("key_304"));
                }
                ProcessCollectionView = new ListCollectionView(ProcessCollection);
                ProcessCollectionView.GroupDescriptions.Clear();
                ProcessCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("TypeName"));
            }

            var fileCommand = MainFrmUI.CommandCollection.FirstOrDefault(d => d.Text == GlobalHelper.Get("key_305"));

            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("key_306"), obj => CreateNewProject())
            {
                Icon = "add"
            });
            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("key_307"), obj =>
            {
                var keep = MessageBoxResult.No;
                if (NeedSave())
                {
                    keep = MessageBox.Show(GlobalHelper.Get("keep_old_datas"), GlobalHelper.Get("key_99"),
                                           MessageBoxButton.YesNoCancel);
                    if (keep == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }
                LoadProject(keepLast: keep == MessageBoxResult.Yes);
            })
            {
                Icon = "inbox_out"
            });
            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("key_308"), obj => SaveCurrentProject())
            {
                Icon = "save"
            });
            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("key_309"), obj => SaveCurrentProject(false))
            {
                Icon = "save"
            });
            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("generate_project_doc"), obj =>
            {
                if (CurrentProject == null)
                {
                    return;
                }
                var doc     = this.GenerateRemark(this.ProcessCollection);
                var docItem = new DocumentItem()
                {
                    Title = this.CurrentProject.Name, Document = doc
                };
                PropertyGridFactory.GetPropertyWindow(docItem).ShowDialog();
            }, obj => CurrentProject != null)
            {
                Icon = "help"
            });
            fileCommand.ChildActions.Add(new BindingAction(GlobalHelper.Get("recent_file"))
            {
                Icon         = "save",
                ChildActions =
                    new ObservableCollection <ICommand>(config.Projects.Select(d => new BindingAction(d.SavePath, obj =>
                {
                    var keep = MessageBoxResult.No;
                    if (NeedSave())
                    {
                        keep = MessageBox.Show(GlobalHelper.Get("keep_old_datas"), GlobalHelper.Get("key_99"),
                                               MessageBoxButton.YesNoCancel);
                        if (keep == MessageBoxResult.Cancel)
                        {
                            return;
                        }
                    }
                    LoadProject(d.SavePath, keep == MessageBoxResult.Yes);
                })
                {
                    Icon = "folder"
                }))
            });
            var languageMenu = new BindingAction(GlobalHelper.Get("key_lang"))
            {
                Icon = "layout"
            };

            var files = Directory.GetFiles("Lang");

            foreach (var f in files)
            {
                var ba = new BindingAction(f, obj => { AppHelper.LoadLanguage(f); })
                {
                    Icon = "layout"
                };

                languageMenu.ChildActions.Add(ba);
            }
            //  helpCommands.ChildActions.Add(languageMenu);

            return(true);
        }
Beispiel #13
0
        public IActionResult GithubRepos()
        {
            var starredRepos = GitHubAPI.GithubRepos();

            return(View(starredRepos));
        }
Beispiel #14
0
 public GitHubMirror(string gitHubOwner, string gitHubRepo, string gitHubBranch, string gitHubBaseDir, string localDir, string oAuthToken)
 {
     this.gitHubBaseDir = gitHubBaseDir;
     this.localDir      = localDir;
     this.gitHubAPI     = new GitHubAPI(gitHubOwner, gitHubRepo, gitHubBranch, "myty-blog-engine", oAuthToken);
 }