private static void UpdateGUID(DataTable dt, DataColumn dc, string columnName, GWDataDBField field) { if (dc.ColumnName == columnName) { Dictionary <string, string> rpIDs = new Dictionary <string, string>(); foreach (DataRow dr in dt.Rows) { object o = dr[dc]; string rpID = (o == null) ? "" : o.ToString(); if (rpID.Length < 1) // need to generate GUID { string guid = DicomMappingHelper.GetGUID(dr); if (rpIDs.ContainsKey(guid)) { // 20100222 // has already generated GUID in this loop, // for example there are two records with same guid and splitted according to multiple procedure codes // 20100227 // as we move the auto generating STDUID before the procedure code spliting in the class Kodak.GCGateway.DicomAdapter.MWLServer.Dicom.WorklistSCP, // this (different records with the same guid/data_id) will not happen any more. rpID = rpIDs[guid]; } else { rpID = DHelper.GetDicomGUID(Program.DeviceMgt.DeviceDirInfor.Header.ID, Program.ConfigMgt.Config.MaxAutoGeneratedLengthOfSTDUID); rpIDs.Add(guid, rpID); } dr[dc] = rpID; } } if (rpIDs.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (KeyValuePair <string, string> pair in rpIDs) { string tableName = GWDataDB.GetTableName(Program.InterfaceName, GWDataDBTable.Order); string pkName = GWDataDBField.o_DATA_ID.FieldName; string fieldName = field.FieldName; sb.Append("UPDATE ").Append(tableName) .Append(" SET ").Append(fieldName).Append(" = '").Append(pair.Value).Append("'") .Append(" WHERE ").Append(pkName).Append(" = '").Append(pair.Key).Append("';\r\n"); } if (Program.Database.DoQuery(sb.ToString()) == null) { Program.Log.Write(LogType.Error, "Update " + columnName + " into database failed."); } else { Program.Log.Write("Update " + columnName + " into database succeeded."); } } } }
private void GenerateGUID() { List <string> list = new List <string>(); DateTime dtBegin = DateTime.Now; for (int i = 0; i < count; i++) { //string guid = DHelper.GetDicomGUID("2147483647"); list.Add(DHelper.GetDicomGUID("500", maxLenGUID)); } DateTime dtEnd = DateTime.Now; TimeSpan dtSpan = dtEnd.Subtract(dtBegin); double average = (double)dtSpan.TotalMilliseconds / (double)count; foreach (string guid in list) { AddItem(guid, Thread.CurrentThread.ManagedThreadId.ToString(), average.ToString()); } }