Example #1
0
        public static int Connect()
        {
            Console.WriteLine(DateTime.Now + ": BuisinessLogicClass.Connect");
            int status = 0; // status types: not available; not connected; connected.

            if (ServerClass.Authentificate())
            {
                status = 2;
                Properties.Settings.Default.Connection = true;
                ConnectionMessage = "Connection and authentification successfull";
                Headline          = "Success";
                return(status);
            }
            else if (ServerClass.CheckAvailability())
            {
                status            = 1;
                ConnectionMessage = "Authentification has failed. \r\nThe server is available.";
                Headline          = "Authentification fail";
                Properties.Settings.Default.Connection = false;
            }
            else
            {
                ConnectionMessage = "Redmine server " + Properties.Settings.Default.RedmineAddress + " is not accesible.\r\nYou will work offline.";
                Headline          = "Server not available";
                Properties.Settings.Default.Connection = false;
            }
            Console.WriteLine(DateTime.Now + ConnectionMessage);
            Thread MessageBoxThread = new Thread(ShowMessage);

            MessageBoxThread.Start();
            return(status);
        }
Example #2
0
 public static void Update()
 {
     if (Properties.Settings.Default.Connection & !Properties.Settings.Default.OldCommits)
     {
         ServerClass.UpdateVariables();
         ServerClass.GetAllIssues();
     }
 }
Example #3
0
 public static void CreateIssue(DataStructureClass.DataStructure NewData)
 {
     if (Properties.Settings.Default.Connection)
     {
         ServerClass.CreateIssue(NewData);
     }
     else
     {
         LocalClass.CreateIssue(NewData);
     }
 }
Example #4
0
 public static void EditIssue(DataStructureClass.DataStructure EditedData)
 {
     if (Properties.Settings.Default.Connection)
     {
         ServerClass.EditIssue(EditedData);
     }
     else
     {
         LocalClass.EditIssue(EditedData);
         LocalClass.EditIssueCommit(EditedData);
     }
 }
Example #5
0
 public static void CommitOneTimeEntry(int Id, string CommentText, int Activity)
 {
     Console.WriteLine(DateTime.Now + ": BuisinessLogicClass.CommitOneTimeEntry: " + Id);
     if (Properties.Settings.Default.Connection)
     {
         ServerClass.CommitTime(Id, CommentText, Activity, DateTime.Now, GetOneIssue(Id));
     }
     else
     {
         LocalClass.CommitTime(Id, CommentText, Activity);
     }
     DataStructureClass.DataStructure IssueData = LocalClass.GetOneIssue(Id);
     IssueData._notCommittedWorkingTime = 0;
     LocalClass.EditIssue(IssueData);
 }
Example #6
0
 public static void OldCommits(bool OperationType)
 {
     Console.WriteLine(DateTime.Now + ": BuisinessLogicClass.OldCommits");
     if (OperationType)
     {
         foreach (string line in LocalClass.GetLocalCommits())
         {
             try
             {
                 if (line.Substring(0, 5) == "Time:")
                 {
                     string    newLine = line.Substring(5);
                     TimeEntry Entry   = JsonConvert.DeserializeObject <TimeEntry>(newLine);
                     DataStructureClass.DataStructure IssueData = new DataStructureClass.DataStructure()
                     {
                         _notCommittedWorkingTime = Convert.ToInt32(Entry.Hours * 3600),
                         _id           = Entry.Issue.Id,
                         _projectId    = Entry.Project.Id,
                         _assignedToId = Entry.User.Id
                     };
                     ServerClass.CommitTime(Entry.Issue.Id, Entry.Comments, Entry.Activity.Id, Convert.ToDateTime(Entry.SpentOn), IssueData);
                 }
                 if (line.Substring(0, 5) == "Edit:")
                 {
                     string newLine = line.Substring(5);
                     DataStructureClass.DataStructure IssueData = JsonConvert.DeserializeObject <DataStructureClass.DataStructure>(newLine);
                     ServerClass.EditIssue(IssueData);
                 }
                 if (line.Substring(0, 5) == "NewI:")
                 {
                     string    newLine = line.Substring(5);
                     TimeEntry Entry   = JsonConvert.DeserializeObject <TimeEntry>(newLine);
                     DataStructureClass.DataStructure IssueData = JsonConvert.DeserializeObject <DataStructureClass.DataStructure>(newLine);
                     ServerClass.CreateIssue(IssueData);
                 }
             }
             catch
             {
                 MessageBox.Show("The" + line.Substring(0, 4) + "failed to get to the server.", "Send data to server fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         LocalClass.DeleteLocalCommits();
     }
 }
Example #7
0
 public static void AddIssueByItsId(int IssueId)
 {
     ServerClass.AddIssue(IssueId);
 }
Example #8
0
 public static string FindIssue(int IssueId)
 {
     AddIssueId = IssueId;
     return(ServerClass.FindIssue(IssueId));
 }