public byte[] RetrieveDocument(int documentID) { Credentials credentials = new Credentials() { AppUsername = PODEnvironment.GetSetting("AppUsername"), ClientUsername = PODEnvironment.GetSetting("ClientUsername"), AppPassword = PODEnvironment.GetSetting("AppPassword") }; string companyID = PODEnvironment.GetSetting("companyID"); string documentType = PODEnvironment.GetSetting("documentType"); string conversionFlag = "PDF"; EDMOnlineServiceReference.DocumentManagementClient client = new DocumentManagementClient(); Document doc = new EDMOnlineServiceReference.Document(); try { var response = client.DocumentRetrieve(credentials, companyID, documentID, documentType, conversionFlag); byte[] responseData = response.documentContent; return(responseData); } catch (Exception ex) { _loggingManager.Log.Error(ex, ex.Source); throw; } }
public Node get_Node(string authTocken, long node_id) { DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuthDocManger = new CWS.DocumentManagement.OTAuthentication(); otAuthDocManger.AuthenticationToken = authTocken; Node node = null; try { node = docManClient.GetNode(ref otAuthDocManger, node_id); } catch (FaultException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } finally { docManClient.Close(); } return(node); }
public long get_ID_Node(string authTocken, long parent_id, string nom_dossier) { DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuthDocManger = new CWS.DocumentManagement.OTAuthentication(); otAuthDocManger.AuthenticationToken = authTocken; Node folder = null; try { folder = docManClient.GetNodeByName(ref otAuthDocManger, parent_id, nom_dossier); } catch (Exception e) { Console.WriteLine(e.Message); } finally { // Always close the client docManClient.Close(); } if (folder != null) { return(folder.ID); } else { return(0); } }
public Node[] get_List_Nodes(string authTocken, long parent_id) { DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuthDocManger = new CWS.DocumentManagement.OTAuthentication(); otAuthDocManger.AuthenticationToken = authTocken; Node[] nodes = null; try { nodes = docManClient.ListNodes(ref otAuthDocManger, parent_id, true); } catch (FaultException e) { MessageBox.Show(e.Message); } catch (Exception e) { MessageBox.Show(e.Message); } finally { docManClient.Close(); } return(nodes); }
public void rename(String otAuth, Node node, string name) { DocumentManagementClient docManClient = new DocumentManagementClient(); Controle_Tranche.CWS.DocumentManagement.OTAuthentication otAuthDocManger = new Controle_Tranche.CWS.DocumentManagement.OTAuthentication(); otAuthDocManger.AuthenticationToken = otAuth; try { docManClient.RenameNode(ref otAuthDocManger, node.ID, name); } catch (FaultException ex) { Console.WriteLine("Exception: " + ex.Message); } finally { docManClient.Close(); } }
public void set_Node(string authTocken, long node_id, Metadata metadata) { DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuthDocManger = new CWS.DocumentManagement.OTAuthentication(); otAuthDocManger.AuthenticationToken = authTocken; try { docManClient.SetNodeMetadata(ref otAuthDocManger, node_id, metadata); } catch (FaultException e) { Console.WriteLine(e.Message); } finally { docManClient.Close(); } }
static void Main(string[] args) { // The user's credentials string username = "******"; string password = "******"; // Create the Authentication service client AuthenticationClient authClient = new AuthenticationClient(); // Store the authentication token string authToken = null; // Call the AuthenticateUser() method to get an authentication token try { Console.Write("Authenticating User..."); authToken = authClient.AuthenticateUser(username, password); Console.WriteLine("Success!\n"); } catch (FaultException e) { Console.WriteLine("Failed!"); Console.WriteLine("{0} : {1}\n", e.Code.Name, e.Message); return; } finally { // Always close the client authClient.Close(); } // Create the DocumentManagement service client DocumentManagementClient docManClient = new DocumentManagementClient(); // Create the OTAuthentication object and set the authentication token OTAuthentication otAuth = new OTAuthentication(); otAuth.AuthenticationToken = authToken; // Store the favorites Node[] favorites = null; // Call the GetAllFavorites() method to get the user's favorites try { Console.Write("Getting the user's favorites..."); favorites = docManClient.GetAllFavorites(ref otAuth); Console.WriteLine("Success!\n"); } catch (FaultException e) { Console.WriteLine("Failed!"); Console.WriteLine("{0} : {1}\n", e.Code.Name, e.Message); return; } // Output the user's favorites Console.WriteLine("User's Favorites:\n"); if (favorites != null) { foreach (Node node in favorites) { Console.WriteLine(node.Name); } } else { Console.WriteLine("No Favorites."); } Console.WriteLine(); // The local file path of the file to upload string filePath = @"C:\Users\saislam\Downloads\opentext_logo.jpg"; // The ID of the parent container to add the document to int parentID = 7058; // Store the information for the local file FileInfo fileInfo = null; try { fileInfo = new FileInfo(filePath); } catch (Exception e) { Console.WriteLine("{0}\n", e.Message); return; } // Create the DocumentManagement service client // Create the OTAuthentication object and set the authentication token otAuth.AuthenticationToken = authToken; // Store the context ID for the upload string contextID = null; // Call the CreateDocumentContext() method to create the context ID try { Console.WriteLine("Generating context ID..."); // contextID = docManClient.CreateDocumentContext(ref otAuth, parentID, fileInfo.Name, null, false, null); Console.WriteLine("Success!\n"); //Node N=docManClient. Console.WriteLine("Enter the file path"); String path = Console.ReadLine(); //"C:\Backup\Book2.xlsx". "ADLP IT Comm Information Architecture_8192019.xlsx" Console.WriteLine("Enter Sheet number"); int sheetNum = Convert.ToInt32(Console.ReadLine()); //1 //Console.WriteLine("Enter column number : Last Level"); //int endLColumn = Convert.ToInt32(Console.ReadLine());//8 int endLColumn = 2; // Console.WriteLine("Enter Last row numebr"); //int endLRow = Convert.ToInt32(Console.ReadLine());//55 int endLRow = 50; Node n = docManClient.CreateFolder(ref otAuth, parentID, "Property Number 51", "This is another dummy folder", null); Console.WriteLine(n.Name); Console.WriteLine(n.ID); Console.WriteLine(n.Nickname); Console.WriteLine(n.Metadata); Console.ReadLine(); Stack <string> ll = new Stack <string>(); List <Dictionary <string, string> > folderDataList = new List <Dictionary <string, string> >(); Program prg = new Program(); string[,] arr = prg.readExcel(path, sheetNum, endLColumn, endLRow, ref folderDataList); String header = (String.Format("{0,-260}{1,-50}", "Folder Name", "Folder Path")); Console.WriteLine(header); String fullpath = ""; prg.printPathRecursive(arr, 0, 0, ll, ref fullpath); long objectID = n.ID; n = n.Position(docManClient.CreateFolder(ref otAuth, objectID, "Property Number 52", "This is another dummy folder", null)); } catch (FaultException e) { Console.WriteLine("{0} : {1}\n", e.Code.Name, e.Message); return; } finally { // Always close the client docManClient.Close(); } // Create a file stream to upload the file with FileStream fileStream = null; try { fileStream = new FileStream(fileInfo.FullName, FileMode.Open, FileAccess.Read); } catch (Exception e) { Console.WriteLine("{0}\n", e.Message); return; } void printPathRecursive(string[,] arr, int row, int col, Stack <string> stk, ref String path) { //in case of last column if (row > arr.GetLength(0) - 1) { //printPath(stk); return; } if (!string.IsNullOrEmpty(arr[row, col])) { //push into stack stk.Push(arr[row, col]); path = path + printPath(stk); // if cell having some data, move to digonal if (col < arr.GetLength(1) - 1 && !string.IsNullOrEmpty(arr[row + 1, col + 1])) { //move to digonal printPathRecursive(arr, row + 1, col + 1, stk, ref path); } else { // printPath(stk); row = row + 1; if (row < arr.GetLength(0)) { col = moveLeftSide(arr, row, col, ref stk, false, ref path); if (col < arr.GetLength(1) - 1) { col = col + 1; } else { stk.Pop(); } //move to digonal printPathRecursive(arr, row + 1, col, stk, ref path); } else { return; } } } else {//in case of column is empty //printPath(stk); if (row < arr.GetLength(0)) { col = moveLeftSide(arr, row, col, ref stk, true, ref path); printPathRecursive(arr, row + 1, col + 1, stk, ref path); } else { return; } } } string[,] readExcel(string path, int sheetNumber, int endLColumn, int endLRow, ref List <Dictionary <string, string> > permissionDataList) { Excel.Application excelApp = new Excel.Application(); int rowCount = 0; int colCount = 0; string[,] arr = null; if (excelApp != null) { Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(@path, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelWorkbook.Sheets[sheetNumber]; Excel.Range excelRange = excelWorksheet.UsedRange; rowCount = excelRange.Rows.Count; colCount = excelRange.Columns.Count; //default values int startLColumn = 0; int startLRow = 0; //user have to input these // endLColumn = 10; // endLRow = 55; Boolean isFound = false; //this for loop is used to get find the row and column from where level will start for (int i = 1; i <= rowCount && isFound == false; i++) { for (int j = 1; j <= colCount; j++) { // Console.WriteLine(i+" : "+ j); string cellValue = (string)(excelWorksheet.Cells[i, j] as Excel.Range).Value; // Console.WriteLine(cellValue+";;;"); if (!string.IsNullOrEmpty(cellValue) && cellValue.Equals("L1")) { startLColumn = j; startLRow = i; isFound = true; break; } } } int rowIndex = endLRow - (startLRow); int colIndex = endLColumn - (startLColumn - 1); arr = new string[rowIndex, colIndex]; for (int i = startLRow + 1; i <= endLRow; i++) { for (int j = startLColumn; j <= endLColumn; j++) { // Console.WriteLine(i+" : "+ j); string cellValue = (string)(excelWorksheet.Cells[i, j] as Excel.Range).Value; arr[i - (startLRow + 1), j - startLColumn] = cellValue; } } List <string> permissionList = new List <string>(); for (int k = endLColumn + 1; k < colCount; k++) { string cellValue = (string)(excelWorksheet.Cells[startLRow - 1, k] as Excel.Range).Value; permissionList.Add(cellValue); Console.WriteLine(startLRow - 1 + " : " + k + cellValue); } for (int i = startLRow + 1; i <= endLRow; i++) { int k = 0; Dictionary <string, string> hash = new Dictionary <string, string>(); for (int j = endLColumn + 1; j < colCount; j++) { // Console.WriteLine(i+" : "+ j); string cellValue = (string)(excelWorksheet.Cells[i, j] as Excel.Range).Value; if (string.IsNullOrEmpty(permissionList.ElementAt(k))) { break; } hash.Add(permissionList.ElementAt(k), cellValue); k++; } permissionDataList.Add(hash); } for (int i = 0; i < permissionDataList.Count; i++) { foreach (KeyValuePair <string, string> pair in permissionDataList.ElementAt(i)) { Console.WriteLine("KEY: " + pair.Key + "VALUE: " + pair.Value); } Console.WriteLine("-----------------------------------------------------" + i); } excelWorkbook.Close(); excelApp.Quit(); } return(arr); } }
public List <TicketTable> SearchDocument(string accountNumber = null, int?ticketNumber = null, DateTime?deliveryDate = null) { #region Request Parameters Credentials credentials = new Credentials() { AppUsername = PODEnvironment.GetSetting("AppUsername"), ClientUsername = PODEnvironment.GetSetting("ClientUsername"), AppPassword = PODEnvironment.GetSetting("AppPassword") }; string companyID = PODEnvironment.GetSetting("companyID"); string documentType = PODEnvironment.GetSetting("documentType"); DataFormat dataFormat = DataFormat.JSON; //fill the required columns to be returned from the service List <ResultField> resultDatas = new List <ResultField>(); List <TicketDocumentResultNames> FieldNamesList = Enum.GetValues(typeof(TicketDocumentResultNames)).Cast <TicketDocumentResultNames>().ToList(); List <TicketDocumentResultKeys> FieldKeysList = Enum.GetValues(typeof(TicketDocumentResultKeys)).Cast <TicketDocumentResultKeys>().ToList(); var zippedFields = FieldNamesList.Zip(FieldKeysList, (n, w) => new { Value = n, Key = w }); foreach (var zippedField in zippedFields) { resultDatas.Add(new ResultField() { FieldName = zippedField.Key.ToString(), FieldAlias = zippedField.Value.ToString() }); } //fill the search criteria fields List <DataField> searchDatas = new List <DataField>(); if (!String.IsNullOrWhiteSpace(accountNumber)) { DataField searchData = new DataField() { FieldName = TicketDocumentSearchKeys.fldCust_Acc.ToString(), FieldValue = accountNumber /* "143016" */ }; searchDatas.Add(searchData); } if (ticketNumber.HasValue) { DataField searchData = new DataField() { FieldName = TicketDocumentSearchKeys.fldSAP_Ticket_No.ToString(), FieldValue = ticketNumber.Value.ToString() /* "143016" */ }; searchDatas.Add(searchData); } if (deliveryDate.HasValue) { DataField searchData = new DataField() { FieldName = TicketDocumentSearchKeys.fldDate.ToString(), FieldValue = deliveryDate.Value.ToString("dd/MM/yyyy HH:mm:ss") /* "143016" */ }; searchDatas.Add(searchData); } //DataField searchData2 = new DataField() { FieldName = "fldCust_Acc", FieldValue = null }; //searchDatas.Add(searchData2); #region Zibil //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldSerial_No.ToString(), FieldAlias = TicketDocumentFieldNames.SerialNo.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldPOD_Ticket_No.ToString(), FieldAlias = TicketDocumentFieldNames.BarCode.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldSAP_Ticket_No.ToString(), FieldAlias = TicketDocumentFieldNames.TicketNo.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldDepot.ToString(), FieldAlias = TicketDocumentFieldNames.Depot.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldDate.ToString(), FieldAlias = TicketDocumentFieldNames.TicketDateDT.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldCust_Acc.ToString(), FieldAlias = TicketDocumentFieldNames.CustomerAcc.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldCust_Name.ToString(), FieldAlias = TicketDocumentFieldNames.CustomerName.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldHaulier_Acc.ToString(), FieldAlias = TicketDocumentFieldNames.HaulierAcc.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldVehicle_Reg.ToString(), FieldAlias = TicketDocumentFieldNames.VehicleReg.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldSAP_Quote.ToString(), FieldAlias = TicketDocumentFieldNames.SAPQuote.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldSAP_Invoice.ToString(), FieldAlias = TicketDocumentFieldNames.SAPInvoice.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldPayer.ToString(), FieldAlias = TicketDocumentFieldNames.Payer.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldDate_Imported.ToString(), FieldAlias = TicketDocumentFieldNames.DateImported.ToString() }); //resultDatas.Add(new ResultField() { FieldName = TicketDocumentFieldKeys.fldEDM_ID.ToString(), FieldAlias = TicketDocumentFieldNames.EDMDocumentID.ToString() }); #endregion #endregion EDMOnlineServiceReference.DocumentManagementClient client = new DocumentManagementClient(); Document doc = new EDMOnlineServiceReference.Document(); try { List <TicketTable> ticketDocuments = new List <TicketTable>(); var response = client.DocumentSearch(credentials, companyID, documentType, searchDatas, resultDatas, dataFormat); var responseData = JObject.Parse(response.Data).ToString(); ticketDocuments = JsonConvert.DeserializeAnonymousType(responseData, new { Tables = (List <TicketTable>)null }).Tables; return(ticketDocuments); } catch (Exception ex) { _loggingManager.Log.Error(ex, ex.Source); throw; } }
public Stream dowlande(string authToken, string pathe, Node node) { //Create the DocumentManagement service client DocumentManagementClient docManClient = new DocumentManagementClient(); CWS.DocumentManagement.OTAuthentication otAuth = new CWS.DocumentManagement.OTAuthentication(); otAuth.AuthenticationToken = authToken; ContentServiceClient contentServiceClient = new ContentServiceClient(); CWS.ContentService.OTAuthentication otAuthConServices = new CWS.ContentService.OTAuthentication(); otAuthConServices.AuthenticationToken = authToken; //string fileName=null; string contextID = null; try { contextID = docManClient.GetVersionContentsContext(ref otAuth, node.ID, 0); } catch (FaultException e) { MessageBox.Show(e.Message); } finally { docManClient.Close(); } Stream downloadStream = null; try { downloadStream = contentServiceClient.DownloadContent(ref otAuthConServices, contextID); } catch (FaultException e) { MessageBox.Show(e.Message); } finally { contentServiceClient.Close(); } /*FileStream fileStream = null; * try * { * string path = Path.GetDirectoryName(Application.ExecutablePath).Replace(@"bin\Debug", string.Empty); * fileName = Path.Combine(path.Replace(@"bin\Debug", string.Empty), @"GED_image\" + node.Name + ".tif"); * if (File.Exists(fileName)) * { * File.Delete(fileName); * } * fileStream = new FileStream(fileName, FileMode.Create); * byte[] buffer = new byte[BUFFER_SIZE]; * long fileSize = 0; * for (int read = downloadStream.Read(buffer, 0, buffer.Length); read > 0; read = downloadStream.Read(buffer, 0, buffer.Length)) * { * fileStream.Write(buffer, 0, read); * fileSize += read; * } * } * catch (Exception e) * { * //MessageBox.Show(e.Message); * } * finally * { * if (fileStream != null) * { * fileStream.Close(); * } * downloadStream.Close(); * }*/ return(downloadStream); }
private long UploadFile(long parentId, string path,DoWorkEventArgs e) { if (_worker.CancellationPending){ e.Cancel = true; return -1; } ContentServiceClient contentService=new ContentServiceClient(); DocumentManagementClient docMan = new DocumentManagementClient(); FileInfo info = new FileInfo(path); _worker.ReportProgress(_counter, new {CurrentFile=info.Name}); FileAtts fileAtts = new FileAtts { CreatedDate = info.CreationTime, FileName = info.Name, FileSize = info.Length, ModifiedDate = info.LastWriteTime }; var stream = new FileStream(path,FileMode.Open,FileAccess.Read,FileShare.Read); ProgressStream pStream = new ProgressStream(stream); pStream.ProgressChanged += pStream_ProgressChanged; try { bool isVersionAdded = false; var res = docMan.GetNodeByName(ref _otAuthentication, parentId, info.Name); string contextId; if (res == null) { contextId=docMan.CreateDocumentContext(ref _otAuthentication, parentId, info.Name, null, false, null); } else { contextId = docMan.AddVersionContext(ref _otAuthentication, res.ID, null); isVersionAdded = true; } var id = contentService.UploadContent(ref _otAuthentication, contextId, fileAtts, pStream); ++_counter; _worker.ReportProgress(_counter,new {Message=isVersionAdded ? string.Format("{{{0}}} - Version {1} added.", id, info.Name) : string.Format("{{{0}}} - Document {1} added.", id, info.Name)}); } catch (Exception ex) { _worker.ReportProgress(_counter, new {Message=ex.ToString()}); } finally { contentService.Close(); docMan.Close(); stream.Close(); } return -1; }
private long CreateFolder(long parentId, string path) { DirectoryInfo info = new DirectoryInfo(path); _worker.ReportProgress(_counter, new {CurrentFile=info.Name}); DocumentManagementClient documentManagementClient = new DocumentManagementClient(); var node = documentManagementClient.GetNodeByName(ref _otAuthentication, parentId, info.Name); if (node == null) { var createFolderRes = documentManagementClient.CreateFolder(ref _otAuthentication, parentId, info.Name, null, null); documentManagementClient.Close(); node = createFolderRes; ++_counter; _worker.ReportProgress(_counter, new{Message=string.Format("{{{0}}} - Folder {1} added.", node.ID, info.Name)}); } else { ++_counter; _worker.ReportProgress(_counter, new{Message=string.Format("{{{0}}} - Folder {1} already exits.",node.ID,info.Name)}); } return node.ID; }