Пример #1
0
        /// <summary>
        /// Saves the data to the server
        /// </summary>
        /// <param name="ATable">The typed table from the data set</param>
        /// <param name="ATableChanges">The changes table</param>
        /// <param name="ATableDbName">The server table name to write to</param>
        /// <returns></returns>
        public static bool SaveChanges(TTypedDataTable ATable, TTypedDataTable ATableChanges, string ATableDbName)
        {
            TSubmitChangesResult SubmissionResult;
            TVerificationResultCollection VerificationResult;

            if (ATableChanges == null)
            {
                // There is nothing to be saved.
                return true;
            }

            // Submit changes to the PETRAServer
            try
            {
                SubmissionResult = TRemote.MCommon.DataReader.WebConnectors.SaveData(ATableDbName, ref ATableChanges, out VerificationResult);
            }
            catch (ESecurityDBTableAccessDeniedException)
            {
                Console.WriteLine("Error saving data prior to test: Access denied");
                return false;
            }
            catch (EDBConcurrencyException)
            {
                Console.WriteLine("Error saving data prior to test: Concurrency exception");
                return false;
            }
            catch (Exception Exp)
            {
                Console.WriteLine("Error saving data prior to test: General exception: {0}", Exp.Message);
                return false;
            }

            switch (SubmissionResult)
            {
                case TSubmitChangesResult.scrOK:
                    // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                    ATable.AcceptChanges();

                    // Merge back with data from the Server (eg. for getting Sequence values)
                    ATableChanges.AcceptChanges();
                    ATable.Merge(ATableChanges, false);

                    // need to accept the new modification ID
                    ATable.AcceptChanges();
                    return true;

                case TSubmitChangesResult.scrNothingToBeSaved:
                    return true;

                case TSubmitChangesResult.scrError:
                    Console.WriteLine(
                    "Error saving data prior to test: Submission of data failed. " +
                    VerificationResult.BuildVerificationResultString());
                    break;

                case TSubmitChangesResult.scrInfoNeeded:
                    Console.WriteLine("Error saving data prior to test: Info Needed");
                    break;
            }

            return false;
        }
Пример #2
0
 /// <summary>
 /// Loads all the current data from a specified table name into a Typed Table in a data set
 /// Uses TRemote.MCommon.DataReader.WebConnectors.GetData
 /// </summary>
 /// <param name="ATable">The typed table to load into</param>
 /// <param name="ATableName">The name of the server table to load</param>
 public static void LoadAll(TTypedDataTable ATable, string ATableName)
 {
     Ict.Common.Data.TTypedDataTable TypedTable;
     TRemote.MCommon.DataReader.WebConnectors.GetData(ATableName, null, out TypedTable);
     ATable.Merge(TypedTable);
 }