예제 #1
0
        public string GetOrAllocateMapping(string value, int projectNumber, UIDType uidType)
        {
            using (var con = _database.Server.GetConnection())
            {
                con.Open();

                var cmd =
                    _server.GetCommand(
                        "SELECT ReleaseUID from UIDMapping WHERE ProjectNumber = @ProjectNumber AND UIDType = @UIDType AND PrivateUID = @PrivateUID",
                        con);

                _server.AddParameterWithValueToCommand("@ProjectNumber", cmd, projectNumber);
                _server.AddParameterWithValueToCommand("@UIDType", cmd, uidType);
                _server.AddParameterWithValueToCommand("@PrivateUID", cmd, value);

                var result = cmd.ExecuteScalar();

                if (result == DBNull.Value || result == null)
                {
                    var m = new UIDMapping();
                    m.UIDType             = uidType;
                    m.ProjectNumber       = projectNumber;
                    m.PrivateUID          = value;
                    m.ReleaseUID          = GetKindaUid();
                    m.IsExternalReference = false;

                    InsertMapping(m);

                    return(m.ReleaseUID);
                }

                return(result.ToString());
            }
        }
예제 #2
0
        public void Update(UIDMapping mapping)
        {
            var table = _database.ExpectTable(_tableName);
            var sql   = "UPDATE " + table.GetFullyQualifiedName() + " SET " +
                        "PrivateUID = @PrivateUID, " +
                        "ProjectNumber = @ProjectNumber, " +
                        "UIDType = @UIDType, " +
                        "IsExternalReference = @IsExternalReference " +
                        "WHERE ReleaseUID = @ReleaseUID";

            using (var conn = GetConnection())
            {
                conn.Open();
                var cmd = _server.GetCommand(sql, conn);
                _server.AddParameterWithValueToCommand("@PrivateUID", cmd, mapping.PrivateUID);
                _server.AddParameterWithValueToCommand("@ProjectNumber", cmd, mapping.ProjectNumber);
                _server.AddParameterWithValueToCommand("@UIDType", cmd, mapping.UIDType);
                _server.AddParameterWithValueToCommand("@IsExternalReference", cmd, mapping.IsExternalReference);
                _server.AddParameterWithValueToCommand("@ReleaseUID", cmd, mapping.ReleaseUID);

                cmd.ExecuteNonQuery();
            }
        }
예제 #3
0
 public void InsertMapping(UIDMapping mapping)
 {
     InsertMappings(new[] { mapping });
 }