public TObjectServiceDemo() { try { objectServiceDemo = new ObjectServiceDemo(DefaultRepository, SecondaryRepository, UserLoginName, Password); sampleContentManager = new SampleContentManager(objectServiceDemo); } catch (FaultException <SerializableException> ex) { Console.WriteLine(String.Format("Got FaultException[{0}] with message: {1}\n", ex.Detail, ex.Message)); } catch (Exception exx) { Console.WriteLine(exx.StackTrace); } }
public IHttpActionResult DownloadEPFMDocument(DownloadContextDTO _DownloadContextDTO) { string object_id = _DownloadContextDTO.object_id; int RidType = _DownloadContextDTO.RidType; string category = _DownloadContextDTO.category; string SaveFilename = _DownloadContextDTO.SaveFilename; int attachsequence = _DownloadContextDTO.attachsequence; string attachmentguid = _DownloadContextDTO.attachmentguid; string result = ""; try { string username, password; (username, password) = SecurityHelper.GetCredentials(User.Identity as ClaimsIdentity); //username = "******"; //password = "******"; String repository = ConfigurationManager.AppSettings["EPFMRepository"]; //String username = ConfigurationManager.AppSettings["EPFMUsername"]; //String password = ConfigurationManager.AppSettings["EPFMPassword"]; String address = ConfigurationManager.AppSettings["EPFMAddress"]; ObjectServiceDemo objectService = new ObjectServiceDemo(repository, null, username, password, address); //string object_id = "090181cd80054c37"; ObjectIdentity objIdentity = new ObjectIdentity(new Qualification("dm_document where r_object_id = '" + object_id + "'"), repository); FileInfo fileInfo = null; try { fileInfo = objectService.GetWithContent(objIdentity, "Pleasanton", Emc.Documentum.FS.DataModel.Core.Content.ContentTransferMode.MTOM, object_id); } catch (Exception ex) { } if (fileInfo == null) { string TemplateFilePath = ConfigurationManager.AppSettings["TemplateFilePath"]; string Fullpath = Path.Combine(TemplateFilePath, SaveFilename); StreamWriter sw = new StreamWriter(Fullpath, false); sw.WriteLine("This is a sample file created at " + DateTime.Now); sw.Close(); fileInfo = new FileInfo(Fullpath); } MoveEPFMResultWrapper resultObj = null; // using (var client = new HttpClient()) { try { string uri = ConfigurationManager.AppSettings["CoreMoveEPFMUri"] + "?RidType=" + RidType + "&category=" + category + "&Tmpfilename=" + fileInfo.FullName + "&SaveFileName=" + SaveFilename + "&attachsequence=" + attachsequence + "&objectid=" + object_id + "&attachmentguid=" + attachmentguid; client.DefaultRequestHeaders.Authorization = ActionContext.Request.Headers.Authorization; var responseTask = client.GetAsync(uri); responseTask.Wait(); var httpresult = responseTask.Result; if (httpresult.IsSuccessStatusCode) { //var readTask = result.Content.ReadAsAsync<IList<StudentViewModel>>(); var readTask = httpresult.Content.ReadAsAsync <MoveEPFMResultWrapper>(); readTask.Wait(); resultObj = readTask.Result; Logger.WriteLog(JsonConvert.SerializeObject(resultObj)); } else { new Exception("ERCMS Core API failed" + httpresult.ReasonPhrase); } } catch (Exception ex) { Logger.WriteLog("ERCMS Core API failed " + ex.Message + Environment.NewLine + ex.StackTrace); throw ex; } } return(Content(HttpStatusCode.OK, resultObj)); } catch (Exception ex) { result = result + "Got exception" + ex.StackTrace; return(Ok(ex.Message)); } }