BExIS.Dcm.UploadWizard.UploadWizardHelper.IsUnique2 C# (CSharp) Method

IsUnique2() public static method

test unique of primary keys on a dataset
public static IsUnique2 ( long datasetId, List primaryKeys ) : System.Boolean
datasetId long
primaryKeys List
return System.Boolean
        public static Boolean IsUnique2(long datasetId, List<long> primaryKeys)
        {
            Hashtable hashtable = new Hashtable();

                // load data
                DatasetManager datasetManager = new DatasetManager();
                Dataset dataset = datasetManager.GetDataset(datasetId);
                DatasetVersion datasetVersion;

                List<long> dataTupleIds = new List<long>();

                if (datasetManager.IsDatasetCheckedIn(datasetId))
                {
                    datasetVersion = datasetManager.GetDatasetLatestVersion(datasetId);

                    #region load all datatuples first

                    int size = 10000;
                    int counter = 0;
                    IEnumerable<long> dataTuplesIds;
                    dataTuplesIds = datasetManager.GetDatasetVersionEffectiveTupleIds(datasetVersion);
                    IEnumerable<long> currentIds;
                    DataTuple dt;
                    do
                    {
                        currentIds = dataTupleIds.Skip(counter * size).Take(size);

                        //byte[] pKey;
                        string pKey;
                        foreach (long dtId in currentIds)
                        {
                            dt = datasetManager.DataTupleRepo.Query(d=>d.Id.Equals(dtId)).FirstOrDefault();

                            //pKey = getPrimaryKeysAsByteArray(dt, primaryKeys);
                            pKey = pKey = getPrimaryKeysAsStringFromXml(dt, primaryKeys);

                            if (pKey.Count() > 0)
                            {

                                try
                                {
                                    //Debug.WriteLine(pKey +"   : " +Utility.ComputeKey(pKey));
                                    hashtable.Add(pKey, "");
                                    //hashtable.Add(pKey, 0);
                                }
                                catch
                                {
                                    return false;
                                }
                            }
                        }

                        counter++;
                    }
                    while (currentIds.Count() >= (size * counter));

                    #endregion

                }
                else
                {
                    throw new Exception("Dataset is not checked in.");
                }

                return true;
        }