Ejemplo n.º 1
0
        public DateTime ToUtc(TrimDateTime dateTime)
        {
            if (dateTime.IsTimeClear)
            {
                return(DateTime.SpecifyKind(dateTime.ToDateTime(), DateTimeKind.Utc));
            }

            TimeZoneInfo userTimeZone = getTimeZoneInfo();

            return(TimeZoneInfo.ConvertTimeToUtc(dateTime.ToDateTime(), userTimeZone));
        }
 //public void Dispose()
 //{
 //    if (m_loader != null)
 //    {
 //        m_loader.Dispose();
 //        m_loader = null;
 //    }
 //    if (m_origin != null)
 //    {
 //        m_origin.Dispose();
 //        m_origin = null;
 //    }
 //}
 bool getNextRecord(PropertyOrFieldValue[] fields)
 {
     // this function would normally be processing some input data source,
     // reading the next item, setting yp the fields array from this input.
     // For the example, we "hard code" some simple property values and
     // provide 5 records.
     m_recordCount++;
     if (m_recordCount > 5)
     {
         return false;
     }
     // a simple title
     String title = "Test Bulk Loaded Record Import #" + System.Convert.ToString(m_recordCount);
     title += ", imported from run number " + System.Convert.ToString(m_loader.RunHistoryUri);
     // some notes
     String notes = "Some notes for the bulk imported record #"
     + System.Convert.ToString(m_recordCount)
     + " data imported at: "
     + TrimDateTime.Now.ToLongDateTimeString();
     // a random date
     TrimDateTime dateCreated = new TrimDateTime(2007, 12, 14, 12, 0, 0);
     // create a location "on the fly" for the Author property
     //PropertyOrFieldValue[] authorFields = new PropertyOrFieldValue[2];
     //authorFields[0] = new PropertyOrFieldValue(PropertyIds.LocationTypeOfLocation);
     //authorFields[1] = new PropertyOrFieldValue(PropertyIds.LocationSortName);
     //authorFields[0].SetValue(LocationType.Position);
     //authorFields[1].SetValue("Position #" + System.Convert.ToString(m_recordCount));
     ////12 12 HP TRIM Bulk Data Importing Programming Guide
     //// if we are rerunning, check to see if it already exists
     //PropertyValue positionName = new PropertyValue(PropertyIds.LocationSortName);
     //positionName.SetValue("Position #" + System.Convert.ToString(m_recordCount));
     //Int64 authorUri = m_loader.FindLocation(positionName);
     //if (authorUri == 0)
     //{
     //    // use the loader to setup the new location's properties
     //    Location authorLoc = m_loader.NewLocation();
         
     //        m_loader.SetProperties(authorLoc, authorFields);
     //        // now submit the location to the bulk loader queue
     //        authorUri = m_loader.SubmitLocation(authorLoc);
         
     //}
     // now set up the fields array based on these values
     fields[0].SetValue(title);
     fields[1].SetValue(dateCreated);
     fields[2].SetValue(notes);
     fields[3].SetValue(lCont);
     //fields[3].SetValue(authorUri);
     return true;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Save Button - used to save a record. If the assignee is invalid it displays an error.
        /// The record the verified before getting saved.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Save_Click(object sender, EventArgs e)
        {
            try
            {
                using (Database objDB = getDatabase())                 //create a database object
                {
                    recNumber = RecNumVal.Text;                        //record number
                    title     = RecTitleVal.Text;                      //record title
                    date      = new TrimDateTime(DateCreatedVal.Text); //record date of creation
                    locName   = AssigneeVal.Text;                      //record assignee

                    Record rec = new Record(objDB, recNumber);         //record object
                    rec.Title       = title;
                    rec.DateCreated = date;
                    location        = new Location(objDB, rec.Assignee.Name); //location object
                    if (location.Name != locName)                             //checking if the assignee name has changed
                    {
                        try
                        {
                            Location loc = new Location(objDB, locName);
                            rec.SetAssignee(loc);
                        }
                        //An exception is thrown if the location name is invalid
                        catch (Exception k)
                        {
                            System.Diagnostics.Trace.WriteLine(k.Message);
                            MessageBox.Show("The assingee is invalid or does not exist");
                            return;
                        }
                    }
                    //Saving the record object
                    if (rec.Verify(true))
                    {
                        rec.Save();
                        MessageBox.Show("Record Saved");
                    }
                    else //Error is displayed if record verification fails
                    {
                        MessageBox.Show(rec.ErrorMessage);
                    }
                }
            }
            // Display any exception thrown in a msgbox
            catch (Exception k)
            {
                MessageBox.Show(k.Message);
            }
        }