Example #1
0
        /// <summary>
        /// Handles the Click event of the About control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void Sync_Click(object sender, EventArgs e)
        {
            try
            {
                if (File.Exists(appPath + flUserProfile) && !string.IsNullOrEmpty(File.ReadAllText(appPath + flUserProfile)))
                {
                    p = new Process();
                    p.StartInfo.FileName = appPath + "\\" + ConfigurationManager.AppSettings["BatchFile"];
                    p.StartInfo.Verb     = "runas";
                    p.Start();
                    p.WaitForExit();

                    _hlp.Logging("ManualSync", "Sync_Click");

                    System.Threading.Thread.Sleep(10000);
                    string gitStatus = File.ReadAllText(appPath + flLastSyncSts);
                    if (gitStatus.ToUpper().Contains("CONFLICT"))                     //TODO: need check the datetime and then call the conflict
                    {
                        new Notification().ShowDialog();
                    }
                    //MessageBox.Show("Sync completed.");
                }
                else
                {
                    new Settings().ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Sync Failed.");
                _hlp.Logging(ex.Message, "Sync_Click");
                _hlp.SaveUserSettings(DateTime.Now + "_Failure", false);
            }
        }
Example #2
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            //Create Conflict folder if not already,
            if (!Directory.Exists(conflictPath))
            {
                Directory.CreateDirectory(conflictPath);
            }

            if (txtUserName.Text == string.Empty)
            {
                lblStatusMsg.Text = "Please provide value";
                txtUserName.Focus();
                return;
            }
            if (textBox1.Text == string.Empty)
            {
                lblStatusMsg.Text = "Please provide value";
                textBox1.Focus();
                return;
            }
            if (txtUserToken.Text == string.Empty)
            {
                lblStatusMsg.Text = "Please provide value";
                txtUserToken.Focus();
                return;
            }

            string cfgRepoUrl  = ConfigurationManager.AppSettings["RepoUrl"];
            string cfgRepoName = ConfigurationManager.AppSettings["RepoName"];

            string[] getCfgUrl = cfgRepoUrl.Split('@');
            cfgRepoUrl = cfgRepoUrl.Replace(getCfgUrl[0], "https://" + txtUserToken.Text);
            _hlp.SaveUserSettings(txtUserName.Text + "|" + textBox1.Text + "|" + txtUserToken.Text + "|" + cfgRepoUrl + "|" + cfgRepoName, true);

            //Git-clone
            bool isCloneEnable = Convert.ToBoolean(ConfigurationManager.AppSettings["IsCloneEnable"]);

            if (isFirstClone && isCloneEnable)
            {
                p = new Process();
                p.StartInfo.FileName = appPath + flGitClone;
                p.StartInfo.Verb     = "runas";
                p.Start();
                p.WaitForExit();
            }
            else
            {
                p = new Process();
                p.StartInfo.FileName = appPath + flTaskSchedular;
                p.StartInfo.Verb     = "runas";
                p.Start();
                p.WaitForExit();
            }

            //p = new Process();
            //p.StartInfo.FileName = appPath + "\\task-enable.bat";
            //p.StartInfo.Verb = "runas";
            //p.Start();
            //p.WaitForExit();

            lblStatusMsg.Text = "Save successful.";
            System.Threading.Thread.Sleep(2000);
            this.Close();
        }