示例#1
0
        /// <summary>
        /// Overwrite an existing Activity object.
        /// </summary>
        /// <param name="activityId"></param>
        /// <param name="activity"></param>
        public void Update(int activityId, Activity activity)
        {
            if (null != activity)
            {
                if (activity.ID != activityId)
                {
                    activity.ID = activityId;
                }

                _svc.Store(activityId,
                    null,
                    Activity.Serialize(activity),
                    new ObjectIndex[]
                {
                    ObjectIndex.Create(IndexType, (int)activity.ActivityType),
                    ObjectIndex.Create(IndexExpires, activity.ExpiresUTC),
                });
            }
        }
示例#2
0
 public static byte[] Serialize(Activity act)
 {
     var buffer = new MemoryStream();
     Serializer.Serialize<Activity>(buffer, act);
     return buffer.ToArray();
 }
示例#3
0
        /// <summary>
        /// Adds a new Activity to the Object Store. A new Object ID will be generated and assigned to 
        /// the Activity instance.
        /// </summary>
        /// <param name="activity"></param>
        /// <returns></returns>
        public ObjectID Add(Activity activity)
        {
            ObjectID returnValue = null;

            if (null != activity)
            {
                activity.ID = _svc.NextID();

                returnValue = _svc.Store(
                    activity.ID,
                    null,
                    Activity.Serialize(activity),
                    new ObjectIndex[]
                {
                    ObjectIndex.Create(IndexType, (int)activity.ActivityType),
                    ObjectIndex.Create(IndexExpires, activity.ExpiresUTC),
                });
            }

            return returnValue;
        }