/// <summary> /// Insert a list of rows /// </summary> /// <param name="vo"></param> /// <returns></returns> public bool Insert(List <AnnotationVo> voList) { if (voList == null || voList.Count == 0) { return(true); // nothing to do } if (ServiceFacade.UseRemoteServices) { List <ServiceTypes.AnnotationVo> serviceVoList = ServiceFacade.TypeConversionHelper.Convert <List <AnnotationVo>, List <ServiceTypes.AnnotationVo> >(voList); Mobius.Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusAnnotationService, (int)Services.Native.ServiceOpCodes.MobiusAnnotationService.Insert, new Services.Native.NativeMethodTransportObject(new object[] { instanceId, serviceVoList })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); bool succeeded = (bool)resultObject.Value; return(succeeded); } else { return(Instance.Insert(voList)); } }
/// <summary> /// Perform a deep clone of an annotation table UserObject including the underlying data /// </summary> /// <param name="uo"></param> /// <returns></returns> public static UserObject DeepClone(UserObject uo) { UserObject uo2 = uo.Clone(); long oldCode, newCode; // Create a copy of the user object including remapping of the codes AnnotationDao dao = new AnnotationDao(); MetaTable mt = MetaTable.Deserialize(uo.Content); // deserialize metatable xml int newMethodCode = UserObjectDao.GetNextId(); uo2.Id = newMethodCode; // store in UserObject id as well mt.Code = newMethodCode.ToString(); mt.Name = "ANNOTATION_" + mt.Code; mt.Label = uo.Name; Dictionary <long, long> codeMap = new Dictionary <long, long>(); foreach (MetaColumn mc in mt.MetaColumns) { if (!Lex.IsNullOrEmpty(mc.ResultCode)) { if (!long.TryParse(mc.ResultCode, out oldCode)) { continue; } newCode = dao.GetNextIdLong(); codeMap[oldCode] = newCode; mc.Name = "R_" + newCode; mc.ResultCode = newCode.ToString(); } } // Write import state if checking for updates if (mt.ImportParms != null && mt.ImportParms.CheckForFileUpdates) { UserObject udisUo = new UserObject(UserObjectType.ImportState, uo2.Owner, mt.Name); UserDataImportState udis = new UserDataImportState(); udis.UserDatabase = false; // indicate annotation table udis.UserDataObjectId = uo2.Id; // store id of annotation table user object udis.ClientFile = mt.ImportParms.FileName; udis.CheckForFileUpdates = mt.ImportParms.CheckForFileUpdates; udis.ClientFileModified = mt.ImportParms.ClientFileModified; udis.FileName = mt.ImportParms.FileName; udisUo.Description = udis.Serialize(); // serialize to description UserObjectDao.Write(udisUo); } // Copy the data dao.BeginTransaction(); dao.BufferInserts(true); dao.OpenReader(uo.Id); Dictionary <long, long> groupMap = new Dictionary <long, long>(); int readCount = 0; while (true) { AnnotationVo vo = dao.Read(); if (vo == null) { break; } if (!codeMap.ContainsKey(vo.rslt_typ_id)) { continue; } vo.rslt_typ_id = codeMap[vo.rslt_typ_id]; // map the result code vo.rslt_id = dao.GetNextIdLong(); // new result id vo.mthd_vrsn_id = newMethodCode; if (!groupMap.ContainsKey(vo.rslt_grp_id)) // map the group id { groupMap[vo.rslt_grp_id] = dao.GetNextIdLong(); } vo.rslt_grp_id = groupMap[vo.rslt_grp_id]; dao.Insert(vo); readCount++; if (readCount % 1000 == 0) { dao.ExecuteBufferedInserts(); dao.Commit(); } } dao.ExecuteBufferedInserts(); dao.Commit(); dao.Dispose(); uo2.Count = groupMap.Count; // update the count uo2.CreationDateTime = uo2.UpdateDateTime = DateTime.Now; uo2.Content = mt.Serialize(); return(uo2); }