Beispiel #1
0
 public CaseFile SyncCaseFile(CaseFile caseFile, User user)
 {
     if (CaseExists(caseFile))
     {
         if (IsAssignedCase(user, caseFile))
         {
             if (IsLocalOlder(caseFile))
             {
                 return(GetCaseFile(caseFile));
             }
             else
             {
                 ReportSyncer syncer = new ReportSyncer();
                 foreach (Report report in caseFile.reports)
                 {
                     syncer.SyncReport(caseFile, report.reportID);
                 }
                 return(caseFile);
             }
         }
         else
         {
             Console.WriteLine("You aren't assigned to this case");
             return(caseFile);
         }
     }
     else
     {
         InsertCaseFile(caseFile);
         return(caseFile);
     }
 }
Beispiel #2
0
        public CaseFile GetCaseFile(CaseFile caseFile)
        {
            try
            {
                MySqlDataReader reader = null;
                conn.Open();

                string       sqlStatement = "SELECT * FROM case_files WHERE case_id=@caseID";
                MySqlCommand command      = new MySqlCommand(sqlStatement, conn);
                command.Prepare();
                command.Parameters.AddWithValue("@caseID", caseFile.caseID);

                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    String caseID          = reader["case_id"].ToString();
                    String facilityName    = reader["facility_name"].ToString();
                    int    facilityLicense = reader.GetInt32("facility_license");
                    conn.Close();
                    CaseFile     tempCaseFile = new CaseFile(caseID, facilityName, facilityLicense);
                    ReportSyncer syncer       = new ReportSyncer();
                    return(syncer.GetAllReports(tempCaseFile));
                }

                conn.Close();
                return(caseFile);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(caseFile);
            }
        }
Beispiel #3
0
        private Boolean InsertCaseFile(CaseFile caseFile)
        {
            try
            {
                MySqlDataReader reader = null;
                conn.Open();

                string insertStatement = "INSERT INTO case_files" +
                                         "(facility_name, facility_license) " +
                                         "VALUES (@facilityName," +
                                         "@facilityLicense)";
                MySqlCommand command = new MySqlCommand(insertStatement, conn);
                command.Prepare();
                command.Parameters.AddWithValue("@facilityName", caseFile.facilityName);
                command.Parameters.AddWithValue("@facilityLicense", caseFile.facilityLicenseNo);

                command.ExecuteNonQuery();
                string getIDStatement = "SELECT @@IDENTITY AS theID";
                command = new MySqlCommand(getIDStatement, conn);
                reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    caseFile.caseID = reader["theID"].ToString();
                }
                conn.Close();

                ReportSyncer syncer = new ReportSyncer();

                foreach (Report report in caseFile.reports)
                {
                    syncer.InsertReport(caseFile, report);
                }

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }
        }