At last after so much of research, I have found a solution. Create an intermediate Document library and upload document. Route the document to the record center. Check out the sample code.
string strFilename="Name of the File uploaded";
Hashtable metadata=new Hashtable("Other Meta data columns");
bool IsOverwrite="True or False to overwrite the existing file";
byte[] by_FileStream="Array bytes of the uploaded file";
bool MoveToRecordCeter="True or False To move to record center";
string strSPSite="<Site URL>";
string strSPRecLib="<Intermediate Doc Lib>";
string RecordCenterUri="<Record Center URL>";
using (SPSite oSite = new SPSite(strSPSite))
{
SPWeb oWeb = oSite.OpenWeb();
string strAdditionalInformation = string.Empty;
try
{
SPList oList = oWeb.Lists.TryGetList(strSPRecLib);
if (oList != null)
{
SPFolder oFolder = oList.RootFolder;
SPFile oFile = null;
oFile = oFolder.Files.Add(oFolder.Url + "/" + strFilename, by_FileStream, metadata, IsOverwrite);
oFile.Update();
if (MoveToRecordCeter && RecordCenterUri.Length > 0)
{
string Offuri = RecordCenterUri.Trim();
SPOfficialFileHost ofh = new SPOfficialFileHost();
ofh.Action = SPOfficialFileAction.Move;
ofh.OfficialFileName = oFile.Name;
ofh.OfficialFileUrl = new Uri(Offuri);
OfficialFileResult returnValue = oFile.SendToOfficialFile("Content-type", ofh, "", SPOfficialFileSubmissionMode.ExpirationPolicy, out strAdditionalInformation);
if (returnValue != OfficialFileResult.Success)
{
throw new Exception("Error sending file to records center:" + strAdditionalInformation);
}
}
return true;
}
else
{
throw new Exception("List is not available.");
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (oWeb != null)
oWeb.Dispose();
}
}
Hope this would help some one :)