Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Handles the MouseClick event of the ni control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
 void ni_MouseClick(object sender, MouseEventArgs e)
 {
     // Handle mouse button clicks.
     if (e.Button == MouseButtons.Left)
     {
         // Start Windows Explorer.
         //Process.Start("explorer", null);
         HelperContext _hlp = new HelperContext();
         try
         {
             //var jobPath = ConfigurationManager.AppSettings["BatchFile"];
             //Process.Start(jobPath, null);
             //_hlp.Logging("AutoCommittedSuccessfully", "Sync_Click");
             ni.MouseClick += new MouseEventHandler(ni_MouseClick);
             ni.Icon        = Resources.SyncTrayApp;
             ni.Text        = _hlp.SyncStatus();
             ni.Visible     = true;
         }
         catch (Exception ex)
         {
             _hlp.Logging(ex.Message, "Sync_Click");
         }
     }
 }
Ejemplo n.º 3
0
        private void Status_Load(object sender, EventArgs e)
        {
            try
            {
                string conflictSts = "You had changed the below files but someone else also made the changes and synchronized with server before you. We have moved all your below files to C:\\Conflicts ";

                Process p = new Process();
                p.StartInfo.FileName = appPath + flGitStsCheck;
                p.Start();
                p.WaitForExit();
                string gitStatus = File.ReadAllText(appPath + flGitSts);
                lblAllSyncStatus.Text = _hlp.SyncStatus();

                //Case: Current Status
                if (gitStatus.Contains("branch is up to date") && gitStatus.Contains("nothing to commit"))
                {
                    picMainStatus.Image       = Resources.green;
                    lblCurrentSyncStatus.Text = "Up to date with server.";
                }
                else if (gitStatus.Contains("branch is up to date") && (gitStatus.Contains("modified:") || gitStatus.Contains("deleted:")))
                {
                    picMainStatus.Image       = Resources.yellow;
                    lblCurrentSyncStatus.Text = "Up to date with server. But, there are changes in your system.";
                }
                else if (gitStatus.Contains("branch is ahead"))
                {
                    picMainStatus.Image       = Resources.yellow;
                    lblCurrentSyncStatus.Text = "There are changes in your system but not sync'd with server yet.";
                }
                else if (gitStatus.Contains("branch is behind") && (gitStatus.Contains("modified:") || gitStatus.Contains("deleted:")))
                {
                    picMainStatus.Image       = Resources.yellow;
                    lblCurrentSyncStatus.Text = "There are changes in server and there are changes in your system too.";
                }
                else if (gitStatus.Contains("branch is behind"))
                {
                    picMainStatus.Image       = Resources.yellow;
                    lblCurrentSyncStatus.Text = "There are changes in server.";
                }

                //Case2: Conflict state for Last Sync status
                if (File.Exists(appPath + flLastSyncSts))
                {
                    gitStatus = File.ReadAllText(appPath + flLastSyncSts);
                    if (gitStatus.ToUpper().Contains("CONFLICT"))
                    {
                        lnkConflicts.Text         = conflictPath;
                        picMainStatus.Image       = Resources.red;
                        lblMainStatus.Text        = "Conflicts found.";
                        lblLastSyncNeedsAttn.Text = "Needs your attention.";
                        lblLastSyncConflict.Text  = conflictSts + Environment.NewLine + gitStatus.Replace("CONFLICT FOUND |", "");;
                    }
                    else
                    {
                        picMainStatus.Image = Resources.green;
                        lblLastSyncSts.Text = "Everything went fine.";
                    }
                }
            }
            catch (Exception ex)
            {
                _hlp.Logging(ex.Message, "Status_Load");
            }
        }