internal BulkData(Interop.DataControl.SafeBulkDataHandle handle) { ResultType ret; int count, i; ret = Interop.DataControl.BulkCreate(out _handle); if (ret != ResultType.Success) { ErrorFactory.ThrowException(ret, true, "BulkCreate"); } ret = Interop.DataControl.BulkGetCount(handle, out count); for (i = 0; i < count; i++) { IntPtr bundleHandle; Bundle bundle; ret = Interop.DataControl.BulkGetData(handle, i, out bundleHandle); if (ret != ResultType.Success) { ErrorFactory.ThrowException(ret, true, "BulkGetData"); } bundle = new Bundle(new SafeBundleHandle(bundleHandle, false)); ret = Interop.DataControl.BulkAdd(_handle, bundle.SafeBundleHandle); if (ret != ResultType.Success) { ErrorFactory.ThrowException(ret, true, "BulkAdd"); } } }
private static void BulkInsertRequest(int requestId, IntPtr handlePtr, IntPtr bulk_data, IntPtr userData) { Provider provider; BulkInsertResult result; BulkData bulkData = new BulkData(new Interop.DataControl.SafeBulkDataHandle(bulk_data, false)); Interop.DataControl.SafeBulkDataHandle sbdh = bulkData.SafeBulkDataHandle; IntPtr bundleHandel; ResultType ret; int count = bulkData.GetCount(); List <string> queryList = new List <string>(); for (int i = 0; i < count; i++) { Interop.DataControl.BulkGetData(sbdh, i, out bundleHandel); queryList.Add(GetQuery(handlePtr, new SafeBundleHandle(bundleHandel, false), null, OperationType.Insert)); } provider = GetProvider(handlePtr); if (provider == null) { Log.Error(LogTag, "Provider not exist "); return; } result = provider.OnBulkInsert(queryList, bulkData); if (result != null) { if (result.Result) { ret = Interop.DataControl.SendBulkInsertResult(requestId, result.BulkResultData.SafeBulkDataHandle); if (ret != ResultType.Success) { Log.Error(LogTag, "SendBulkInsertResult fail " + ret.ToString()); } } else { ret = Interop.DataControl.SendError(requestId, result.Result.ToString()); if (ret != ResultType.Success) { Log.Error(LogTag, "SendError fail " + ret.ToString()); } } if (result.BulkResultData != null) { result.BulkResultData.Dispose(); } } else { Log.Info(LogTag, $"BulkInsertResult is null : {requestId.ToString()}"); } }