Example #1
0
 public override bool InsertObject(string tableNam, CommonEntityBase model)
 {
     try
     {
         cpsHelper.insertSingle(string.Format("{0}_{1}", tableNam, model.PrimaryKey), SerializeToXml(model));
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Example #2
0
        internal static string GetId(CommonEntityBase entity)
        {
            var device = entity as DeviceEntity;

            if (device != null)
            {
                return(String.Format("d:{0} ({1})", device.DeviceId, SharedRes.Formats.Device.FormatWith(device)).Replace(",", "").Replace(";", ""));
            }
            var location = entity as LocationEntity;

            if (location != null)
            {
                return(String.Format("l:{0} ({1})", location.LocationId, location.Name).Replace(",", "").Replace(";", ""));
            }
            var organization = entity as OrganizationEntity;

            if (organization != null)
            {
                return(String.Format("o:{0} ({1})", organization.OrganizationId, organization.Name).Replace(",", "").Replace(";", ""));
            }
            return(null);
        }
 /// <summary>
 /// Formats a string with the specified object using the index of all properties on the object.
 /// Format string already does this, this is just for convenience.
 /// </summary>
 /// <param name="format"></param>
 /// <param name="entity"></param>
 /// <returns></returns>
 public static string FormatWith(this string format, CommonEntityBase entity)
 {
     return(String.Format(format, entity.Fields.Select(x => x.CurrentValue).ToArray()));
 }