Ejemplo n.º 1
0
        private void WindowFile_Loaded(object sender, RoutedEventArgs e)
        {
            redis = new RedisClient(MainWindow.myRedisIP, MainWindow.myRedisPort, null, MainWindow.database);
            dir   = redis.Get <string>(RedisKeyName.svnBaseDirKey);
            if (dir == null || dir.Trim() == "")
            {
                MessageBox.Show("svn 地址为空!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
                return;
            }
            //svn.Authentication.UserNamePasswordHandlers += new EventHandler<SharpSvn.Security.SvnUserNamePasswordEventArgs>(
            //    delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
            //    {
            //        e1.UserName = "******";
            //        e1.Password = "******";
            //    });

            try
            {
                Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                SvnTarget repos = (SvnTarget)dir;
                {
                    svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                        delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
                    {
                        e1.UserName = GlobalVariable.svnUserName;
                        e1.Password = GlobalVariable.svnPassword;
                    });
                    try
                    {
                        svn.GetList(repos, out list);
                        My_Load();
                    }
                    catch (SvnException)
                    {
                        SvnLoginInWindow slw = new SvnLoginInWindow(repos);
                        slw.Owner = this;
                        slw.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Error);
                this.Close();
            }
        }
Ejemplo n.º 2
0
        private void CompileToolWindow_Loaded(object sender, RoutedEventArgs e)
        {
            thisWindowRedis = new RedisClient(MainWindow.myRedisIP, MainWindow.myRedisPort, null, MainWindow.database);
            MyInitial();
            // 根据权限初始化按钮
            {
                ArrayList allTrunkCodeBtn = new ArrayList();
                {
                    allTrunkCodeBtn.Add(trunkCodeBtn1);
                    allTrunkCodeBtn.Add(trunkCodeBtn2);
                    allTrunkCodeBtn.Add(trunkCodeBtn3);
                    allTrunkCodeBtn.Add(trunkCodeBtn4);
                    setBtn(allTrunkCodeBtn, RedisKeyName.trunkCodeCommandSet, RedisKeyName.trunkCodeCommandPrefix, RedisKeyName.userAuthorityPrefix);
                }
                ArrayList allBranchCodeBtn = new ArrayList();
                {
                    allBranchCodeBtn.Add(branchCodeBtn1);
                    allBranchCodeBtn.Add(branchCodeBtn2);
                    allBranchCodeBtn.Add(branchCodeBtn3);
                    allBranchCodeBtn.Add(branchCodeBtn4);
                    setBtn(allBranchCodeBtn, RedisKeyName.branchCodeCommandSet, RedisKeyName.branchCodeCommandPrefix, RedisKeyName.userAuthorityPrefix);
                }
                {
                    byte[][] allCommand = thisWindowRedis.SMembers(RedisKeyName.serverCommandSet);
                    foreach (var item in allCommand)
                    {
                        MenuItem newMenuItem = new MenuItem();
                        newMenuItem.Header = thisWindowRedis.Get <string>(RedisKeyName.serverCommandPrefix +
                                                                          Encoding.UTF8.GetString(item) + ":name");
                        newMenuItem.Name   = Encoding.UTF8.GetString(item);
                        newMenuItem.Click += OnMenuItemClick;
                        if (MainWindow.myAuthority == 3 || thisWindowRedis.Get <int>(
                                RedisKeyName.userAuthorityPrefix +
                                MainWindow.myUsername + ":" +
                                Encoding.UTF8.GetString(item)) == 1)
                        {
                            newMenuItem.IsEnabled = true;
                        }
                        else
                        {
                            newMenuItem.IsEnabled = false;
                        }
                        SMenu.Items.Add(newMenuItem);
                    }
                    allCommand = thisWindowRedis.SMembers(RedisKeyName.tagIDSet);
                    foreach (var item in allCommand)
                    {
                        MenuItem newMenuItem = new MenuItem();
                        newMenuItem.Tag    = Encoding.UTF8.GetString(item);
                        newMenuItem.Header = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":param").Replace(" ", "/").Replace("_", "__");
                        newMenuItem.Click += OnSwitchTo;
                        newMenuItem.Name   = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":name");
                        string fatherName = thisWindowRedis.Get <string>(
                            RedisKeyName.binTagPrefix +
                            Encoding.UTF8.GetString(item) + ":father"
                            );
                        newMenuItem.IsEnabled = true;
                        MenuItem fatherMenuItem = FindChildByName(SMenu, fatherName);
                        if (fatherMenuItem != null)
                        {
                            fatherMenuItem.Items.Add(newMenuItem);
                        }
                    }
                }
            }
            // 服务器列表渲染
            byte[][] allKeys = thisWindowRedis.SMembers(RedisKeyName.serverIDSet);
            foreach (var item in allKeys)
            {
                string serverID = Encoding.UTF8.GetString(item);
                serverListView.Items.Add(new Server(serverID));
                currentBranchOfServer.Add(serverID, thisWindowRedis.Get <int>(RedisKeyName.currentBranchOfServerPrefix + serverID));
            }

            // 等待任务队列渲染
            //list = redis.GetAllItemsFromList(Wtask_list);
            //foreach (var item in list)
            //{
            //    Task2 this_task = js.Deserialize<Task2>(item);
            //    Wtask_queue.Items.Add(this_task);
            //}
            // 等待任务队列更新线程
            Thread updateWaitingTask = new Thread(new ThreadStart(UpdateWaitingTaskQueueListView));

            updateWaitingTask.IsBackground = true;
            updateWaitingTask.Start();

            // 已完成队列渲染
            List <string> finishedTaskList = thisWindowRedis.GetAllItemsFromList(RedisKeyName.finishedTaskList);

            foreach (var taskID in finishedTaskList)
            {
                finishedTaskQueueListView.Items.Insert(0, new Task(taskID));
            }

            // 已完成队列更新线程
            Thread subscrbe = new Thread(new ThreadStart(OnSubscribe));

            subscrbe.IsBackground = true;
            subscrbe.Start();

            // svn日志查看是否需要输入密码
            {
                SvnClient svn    = new SvnClient();
                SvnTarget target = null;
                try
                {
                    target = (SvnTarget)thisWindowRedis.Get <string>("svn_assist:config:svn_log:1:link");
                    svn.Authentication.UserNamePasswordHandlers += new EventHandler <SharpSvn.Security.SvnUserNamePasswordEventArgs>(
                        delegate(Object s, SharpSvn.Security.SvnUserNamePasswordEventArgs e1)
                    {
                        e1.UserName = GlobalVariable.svnUserName;
                        e1.Password = GlobalVariable.svnPassword;
                    });
                    Collection <SvnListEventArgs> list = new Collection <SvnListEventArgs>();
                    svn.GetList(target, out list);
                    DrawSvnLog();
                }
                catch (ArgumentNullException ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                catch (SvnException)
                {
                    SvnLoginInWindow slw = new SvnLoginInWindow(target);
                    slw.Show();
                    slw.Owner = this;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.Source, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                svn.Dispose();
            }

            // svn 高亮当前版本
            Thread highLightCurrentRevision = new Thread(new ThreadStart(HighLightCurrentRevision));

            highLightCurrentRevision.IsBackground = true;
            highLightCurrentRevision.Start();
        }