Ejemplo n.º 1
0
        private void GitForm_Load(object sender, EventArgs e)
        {
            string enlistmentRoot   = @"E:\JProject\GitRepository\Work";
            string workingDirectory = @"E:\JProject\GitRepository\Work\developmentdocs";
            string repoUrl          = "https://gitee.com/SkeCloud/SkeFramework.git";
            string gitBinPath       = @"D:\Program Files\Git\cmd\git.exe";

            GitBaseConfig      authConfig = new GitAuthConfig(enlistmentRoot, workingDirectory, repoUrl, gitBinPath);
            IGitCommandService command    = new GitCommandService(authConfig);
            //Result result = gitProcess.InvokeGitOutsideEnlistment("version");
            string version = command.GitVersion();

            //string error = "";
            string originUrl = "http://192.168.104.43/netProject/developmentdocs.git";
            //string username = "******";
            //string password = "******";
            //ICredentialService credentialStore = new CredentialService(authConfig);
            //credentialStore.TryStoreCredential(repoUrl,  username,  password, out error);
            //username = "";
            //password = "";
            //credentialStore.TryGetCredential(repoUrl, out username, out password, out error);

            CloneService cloneService = new CloneService(authConfig);
            Result       result       = cloneService.GitClone(originUrl, "master");

            result = cloneService.GitPull();
        }
Ejemplo n.º 2
0
        public void Clone_ObjectWithNullable()
        {
            var service = new CloneService();

            var value = new WithNullables
            {
                MyInt      = 10,
                MyBool     = true,
                MyChar     = 'c',
                MyDateTime = new DateTime(2000, 12, 12),
                MyGuid     = new Guid("2cb3f7e5-47fb-456f-a234-9d8909f69b2c")
            };

            var result = service.DeepClone(value);

            value.MyInt      = 100;
            value.MyBool     = false;
            value.MyChar     = 'e';
            value.MyDateTime = new DateTime(1900, 11, 11);
            value.MyGuid     = Guid.NewGuid();

            Assert.AreEqual(10, result.MyInt);
            Assert.AreEqual(true, result.MyBool);
            Assert.AreEqual('c', result.MyChar);
            Assert.AreEqual(new DateTime(2000, 12, 12), result.MyDateTime);
            Assert.AreEqual(new Guid("2cb3f7e5-47fb-456f-a234-9d8909f69b2c"), result.MyGuid);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Occurs when the button is clicked.
        /// </summary>
        /// <param name="sender">The sender of the event.</param>
        /// <param name="e">A <see cref="RoutedEventArgs"/> that contains the event data.</param>
        private void OnRemoveFromQatButtonClick(object sender, RoutedEventArgs e)
        {
            // Remove the item from the list
            int selectedIndex = qatItemsListBox.SelectedIndex;
            RibbonControlReference controlRef = (RibbonControlReference)qatItemsListBox.SelectedItem;

            qatItems.RemoveAt(selectedIndex);

            // Dispose the cloned item if it is not already in the real QAT
            if (!this.Ribbon.QuickAccessToolBarItems.Contains(controlRef.Control))
            {
                CloneService.DisposeClone(controlRef.Control);
            }

            this.UpdateButtons();
        }
Ejemplo n.º 4
0
        public void Clone_ComplexObject()
        {
            var service = new CloneService();
            var value   = new ComplexObject
            {
                MyUser = new MyUser {
                    Name = "Marie"
                },
                MyList = new List <string> {
                    "a", "b"
                },
                MyArray     = new string[] { "a", "b" },
                MyEnumValue = MyEnum.val2,
                MyCol       = new ObservableCollection <MyUser>(new List <MyUser>
                {
                    new MyUser {
                        Name = "Marie col"
                    }
                }),
                MyDict = new Dictionary <string, string>
                {
                    { "key1", "value 1" }
                }
            };

            var result = service.DeepClone(value);

            value.MyUser = new MyUser {
                Name = "Pat"
            };
            value.MyList.Add("c");
            value.MyArray[0]  = "a!";
            value.MyEnumValue = MyEnum.val1;

            value.MyCol.Add(new MyUser {
                Name = "Pat col"
            });
            value.MyDict.Add("key3", "value 3");

            Assert.AreEqual("Marie", result.MyUser.Name);
            Assert.AreEqual(2, result.MyList.Count);
            Assert.AreEqual("a", result.MyArray[0]);
            Assert.AreEqual(MyEnum.val2, result.MyEnumValue);

            Assert.AreEqual(1, result.MyCol.Count);
            Assert.AreEqual(1, result.MyDict.Count);
        }
Ejemplo n.º 5
0
        public void Clone_ObjectWithNullableNulls()
        {
            var service = new CloneService();

            var value = new WithNullables {
            };

            var result = service.DeepClone(value);

            value.MyInt      = 100;
            value.MyBool     = false;
            value.MyChar     = 'e';
            value.MyDateTime = new DateTime(1900, 11, 11);
            value.MyGuid     = Guid.NewGuid();

            Assert.AreEqual(null, result.MyInt);
            Assert.AreEqual(null, result.MyBool);
            Assert.AreEqual(null, result.MyChar);
            Assert.AreEqual(null, result.MyDateTime);
            Assert.AreEqual(null, result.MyGuid);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 拉去项目代码
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public bool GitProjectSourceCode(PdProject project, string RequestUser)
        {
            string        enlistmentRoot   = project.SourcePath;
            string        workingDirectory = project.SourcePath;
            string        repoUrl          = project.VersionUrl;
            string        gitBinPath       = project.GitBinPath;
            GitBaseConfig config           = new GitAuthConfig(enlistmentRoot, workingDirectory, repoUrl, gitBinPath);
            CloneService  cloneService     = new CloneService(config);
            ConfigResult  configResult     = cloneService.GetFromLocalConfig(GitConstant.GitCommandConfig.RemoteOriginUrl);
            string        value            = "";
            string        error            = "";
            Result        result;

            if (configResult.TryParseAsString(out value, out error))
            {
                ConfigResult configResult1 = cloneService.GetFromLocalConfig($"branch.{project.GitBranch}.remote");
                if (configResult1.TryParseAsString(out value, out error) && !String.IsNullOrEmpty(value))
                {
                    result = cloneService.GitPull();
                }
                else
                {
                    result = cloneService.ForceCheckout(project.GitBranch);
                }
            }
            else
            {
                result = cloneService.GitClone(project.VersionUrl, project.GitBranch);
            }
            string          message      = JsonConvert.SerializeObject(project);
            string          HandleUser   = ServerConstData.ServerName;
            LoginResultType resultType   = result.ExitCode == 0 ? LoginResultType.SUCCESS_PUBLISHGIT : LoginResultType.FAILED;
            int             HandleResult = (int)resultType;

            DataHandleManager.Instance().UcLoginLogHandle.
            InsertPublishDeployGitLog(RequestUser, message, HandleUser, HandleResult, result.Output);
            return(result.ExitCodeIsSuccess);
        }
Ejemplo n.º 7
0
 public Task <ParentModel> CloneAsync(EntityHeader user, EntityHeader org, string name, string key)
 {
     return(Task.FromResult(CloneService.Clone(this, user, org, name, key)));
 }