For now you can follow these steps
- you need to loop thru each extension of a layer
- QI to IServerLayerExtension
- if succeeded, you get hold of a PropertySet object using ServerProperties
- then get/set value to the key named ‘ServiceLayerID’
For now you cannot enable ‘allow assignment of unique numeric IDs for map service publishing’ programmatically
it is on a private interface. Esri peraphs adds it in 10.4 but not sure
IMapDocument mapDocument = new MapDocumentClass();
mapDocument.Open("C:\\Temp\\MyProject.mxd");
IMap b = mapDocument.get_Map(0);
ILayerExtensions c = b.get_Layer(0) as ILayerExtensions;
IServerLayerExtension g = c.get_Extension(0) as IServerLayerExtension;
IPropertySet psN = new PropertySet();
psN.SetProperty("ServiceLayerID", 8);
g.ServerProperties = psN;
mapDocument.Save();
For table
IMapDocument mapDocument = new MapDocumentClass();
mapDocument.Open(@"C:\\Temp\\MyProject.mxd");
IMap b = mapDocument.get_Map(0);
IStandaloneTableCollection c = b as IStandaloneTableCollection;
ITableExtensions d = c.get_StandaloneTable(0) as ITableExtensions;
IServerLayerExtension g = d.get_Extension(0) as IServerLayerExtension;
IPropertySet psN = new PropertySet();
psN.SetProperty("ServiceTableID", 8);
g.ServerProperties = psN;
mapDocument.Save();