///<summary>returns int32</summary> public static int GetUniqueFileNum() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetInt(MethodBase.GetCurrentMethod())); } string command = "SELECT ValueString FROM preference WHERE PrefName='TrojanExpressCollectPreviousFileNumber'"; DataTable table = Db.GetTable(command); int previousNum = PIn.Int(table.Rows[0][0].ToString()); int thisNum = previousNum + 1; command = "UPDATE preference SET ValueString='" + POut.Long(thisNum) + "' WHERE PrefName='TrojanExpressCollectPreviousFileNumber'" + " AND ValueString='" + POut.Long(previousNum) + "'"; int result = Db.NonQ32(command); while (result != 1) //someone else sent one at the same time { previousNum++; thisNum++; command = "UPDATE preference SET ValueString='" + POut.Long(thisNum) + "' WHERE PrefName='TrojanExpressCollectPreviousFileNumber'" + " AND ValueString='" + POut.Long(previousNum) + "'"; result = Db.NonQ32(command); } return(thisNum); }
///<summary>There should always be one entry in the DB per IdentifierType enumeration.</summary> public static void InsertMissingValues() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod()); return; } //string command= "SELECT COUNT(*) FROM oidinternal"; //if(PIn.Long(Db.GetCount(command))==Enum.GetValues(typeof(IdentifierType)).Length) { // return;//The DB table has the right count. Which means there is probably nothing wrong with the values in it. This may need to be enhanced if customers have any issues. //} string command = "SELECT * FROM oidinternal"; List <OIDInternal> listOIDInternals = Crud.OIDInternalCrud.SelectMany(command); List <IdentifierType> listIDTypes = new List <IdentifierType>(); for (int i = 0; i < listOIDInternals.Count; i++) { listIDTypes.Add(listOIDInternals[i].IDType); } for (int i = 0; i < Enum.GetValues(typeof(IdentifierType)).Length; i++) { if (listIDTypes.Contains((IdentifierType)i)) { continue; //DB contains a row for this enum value. } //Insert missing row with blank OID. if (DataConnection.DBtype == DatabaseType.MySql) { command = "INSERT INTO oidinternal (IDType,IDRoot) " + "VALUES('" + ((IdentifierType)i).ToString() + "','')"; Db.NonQ32(command); } else //oracle { command = "INSERT INTO oidinternal (OIDInternalNum,IDType,IDRoot) " + "VALUES((SELECT MAX(OIDInternalNum)+1 FROM oidinternal),'" + ((IdentifierType)i).ToString() + "','')"; Db.NonQ32(command); } } }