/// <summary> /// Checkin one document /// </summary> /// <param name="parentId">Parent ID</param> /// <param name="fname">File path</param> /// <param name="index">Index-th. document</param> /// <param name="count">Number of documents</param> /// <returns></returns> protected virtual bool checkinNewDocument(string parentId, string fname, int index, int count) { FWDocument doc = Conn.Content.CreateDocument(parentId, MaskId); doc.Version.File = fname; CheckinEventArgs e = new CheckinEventArgs(); e.Cancel = false; e.CancelAll = false; e.Sord = doc; e.Index = index; e.Count = count; e.ParentId = parentId; e.File = fname; OnBeforeCheckin(e); if (!e.Cancel && !e.CancelAll) { doc.Checkin(); OnAfterCheckin(e); } return(e.CancelAll); }
/// <summary> /// Opens the document file. /// </summary> /// <param name="doc">Document object</param> /// <seealso cref="OpenFile"/> public virtual void Open(FWDocument doc) { string file = FWSordUtils.GetDocumentFile(doc); if (null != file) { OpenFile(file); } }
/// <summary> /// Create a new document, set/add index values. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createDocument_Click(object sender, EventArgs e) { FWFolder folder = conn.Content.GetFolder(edObjId.Text); FWDocument doc = conn.Content.CreateDocument(Convert.ToString(folder.Id), "Email"); doc.Version.File = "c:\\elofsinst.log"; doc.ObjKeys["ELOOUTL1"].Value = "*****@*****.**"; doc.ObjKeys["ELOOUTL2"].Value = "*****@*****.**"; doc.Checkin(); }
public static string GetDocumentFile(FWSord sord) { string documentFile = null; if (sord is FWDocument) { FWDocument doc = sord as FWDocument; int encryptionSet = doc.Core.details.encryptionSet; if (encryptionSet > 0) { if (doc.Conn.Session.EncrPasswords[encryptionSet.ToString()] != null) { return(doc.File); } // Anzeige eines Dialogs zur Eingabe des Verschlüsselungspassworts if (doc.Conn != null && doc.Conn.Ix != null) { EncryptionPasswordDialog dlg = new EncryptionPasswordDialog(encryptionSet); if (dlg.ShowDialog() == DialogResult.OK) { try { string key = Convert.ToString(encryptionSet); doc.Conn.Session.EncrPasswords[key] = dlg.Password; doc.Conn.Session.EncrPasswords.Checkin(); doc = doc.Conn.Content.GetDocument(doc.Id); documentFile = doc.File; } catch (Exception exc) { if (sord.Conn.IsException(exc, IXExceptionC.INVALID_CRYPT_KEY)) { string key = Convert.ToString(encryptionSet); doc.Conn.Session.EncrPasswords[key] = null; IXExceptionData exceptionData = sord.Conn.Ix.parseException(exc.ToString()); MessageBox.Show(exceptionData.message, "ELO", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } else { documentFile = doc.File; } } return(documentFile); }
/// <summary> /// Try to read a document. /// </summary> /// <param name="objId">Object ID</param> /// <param name="accessMode">A combination of the FWAccessMode constants.</param> /// <returns>Null, if throwEx=false and the document does not exist. /// Otherwise a FWDocument object is returned.</returns> public override FWDocument TryGetDocument(String objId, FWAccessModes accessMode) { FWDocument xdoc = null; if (FWLockMode.HasLock(accessMode)) { try { // The document must be checked out via ELOFS. // Thus we have to find out the file system path of the document first. // call checkoutDoc to read the archive path Sord sord = Conn.Ix.checkoutDoc(objId, null, new EditInfoZ(0L, new SordZ(SordC.mbId | SordC.mbType | SordC.mbLockId | SordC.mbRefPaths | SordC.mbDocVersionMembers)), LockC.NO).sord; if (sord.id == 1 || sord.type < SordC.LBT_DOCUMENT) { throw new InvalidOperationException("Object " + objId + " is not a document."); } // checkout: set file attribute archive, reset file attribute read-only String winPath = GetFileSystemPath(sord, sord.docVersion); FileAttributes attrs = File.GetAttributes(winPath); attrs |= FileAttributes.Archive; attrs &= ~FileAttributes.ReadOnly; File.SetAttributes(winPath, attrs); // get all required values xdoc = base.TryGetDocument(objId, FWAccessModes.Nothing); } catch (Exception e) { if ((accessMode & FWAccessModes.MustExist) != 0) { throw e; } if (e.Message.IndexOf("[ELOIX:" + IXExceptionC.NOT_FOUND) < 0) { throw e; } } } else { xdoc = base.TryGetDocument(objId, accessMode); } return(xdoc); }
/// <summary> /// Checkout/checkin document. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkoutDocument_Click(object sender, EventArgs e) { try { FWSord sord = conn.Content.GetSord(edObjId.Text); ArcPath[] arcPath = sord.RefPaths; Sord sord2 = conn.Ix.checkoutSord(edObjId.Text, EditInfoC.mbAll, LockC.NO).sord; ArcPath[] arcPath2 = sord2.refPaths; // Get document locked FWDocument doc = conn.Content.LockDocument(edObjId.Text); if (doc == null) { return; } // Download the documents file String file = doc.File; // same as doc.Version.File // Start application to edit the file System.Diagnostics.Process.Start(file); if (MessageBox.Show("Checkin?", "Checkin or unlock", MessageBoxButtons.YesNo) == DialogResult.Yes) { MD5 md5 = new MD5(doc.File); if (!md5.ToString().Equals(doc.Version.Core.md5)) { doc.Version.Version = conn.DateToIso(DateTime.Now); doc.Version.Comment = "New version " + doc.Version.Version; doc.Checkin(); } else { doc.Unlock(); } } else { doc.Unlock(); } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
void _arcTreeContextMenu_Opening(object sender, CancelEventArgs e) { Point p = arcTreeView1.PointToClient(MousePosition); TreeNode activeTreeNode = arcTreeView1.GetNodeAt(p); if (activeTreeNode == null) { e.Cancel = true; return; } FWSord sord = arcTreeView1.GetSordFromNode(activeTreeNode); sord = sord.Conn.Content.GetSord(sord.Id); if (sord is FWDocument) { ToolStripMenuItem tsmiReferences = (ToolStripMenuItem)_arcTreeContextMenu.Items[0]; if (tsmiReferences == null) { return; } tsmiReferences.DropDownItems.Clear(); FWDocument document = sord as FWDocument; EloixClient.IndexServer.ArcPath[] refPaths = sord.RefPaths; foreach (EloixClient.IndexServer.ArcPath refPath in refPaths) { ToolStripMenuItem tsmi = new ToolStripMenuItem(); //tsmi.Text = arcTreeView1.GetAbsoluteArcPathString(refPath, document.Id, document.Name, nodePath[0], "//"); //BuildRefPathString(nodePath[0], refPath.path, _activeTreeNode.Text); //tsmi.Tag = _arcTreeViewEx.GetAbsoluteArcPathString(refPath, document.Id, document.Name, nodePath[0]); tsmi.Text = sord.ArcPathString; //tsmi.Click += new EventHandler(tsmiRefPath_Click); //IdName[] idNames = refPath.path; //if ((idNames.Length == 0 && nodePath.Count == 2) || (idNames.Length > 0 && nodePath.Count > 2 && idNames[idNames.Length - 1].name.Equals(nodePath[nodePath.Count - 2]))) //{ // tsmi.Checked = true; //} tsmiReferences.DropDownItems.Add(tsmi); } } }
/// <summary> /// Display document /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bnShowDoc_Click(object sender, EventArgs e) { try { // Get document object FWDocument doc = conn.Content.GetDocument(edObjId.Text); // Download the current version into a temporary directory String file = doc.File; // Start Explorer to display the document file System.Diagnostics.Process.Start(file); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
private void btnCreateDocFromTempl_Click(object sender, EventArgs e) { string name = "test-" + conn.DateToIso(DateTime.Now); // Archiveintrag für neues Dokument ohne Datei anlegen FWDocument doc = conn.Content.CreateDocument("1", "Email"); doc.Name = name; doc.ObjKeys["ELOOUTL1"].Value = "*****@*****.**"; doc.ObjKeys["ELOOUTL2"].Value = "*****@*****.**"; doc.Checkin(); // Vorlage ermitteln FWDocument templ = conn.Content.GetDocument("21318"); // Vorlagedatei dem Dokument zuordnen conn.Content.ApplyDocumentTemplate(doc, templ); // .... Dokument ändern, Programm neu starten // Dokument aus dem Checkout-Verzeichnis ermitteln string[] filesCo = conn.Content.CheckedOutDocumentsManager.GetCheckedoutFiles(new string[] { "xml" }); foreach (string destFile in filesCo) { if (destFile.IndexOf(name) >= 0) { doc = conn.Content.DownloadManager.GetFWDocumentFromFile(destFile); //Einchecken doc.Checkin(); } } }
/// <summary> /// Return a FWDocument for the given file. /// </summary> /// <param name="file">Controlled file</param> /// <returns>FWDocument object</returns> public override FWDocument GetFWDocumentFromFile(string file) { FWDocument doc = null; try { if (IsControlledFile(file)) { FSConnection conn = (FSConnection)ifc.Conn; string driveAndArc = conn.Config.Drive + "\\" + conn.ArcName; if (file.Length >= driveAndArc.Length) { string arcPath = file.Substring(driveAndArc.Length); string objId = "FSPATH:" + arcPath; try { doc = ifc.Conn.Content.GetDocument(objId); } catch (Exception e) { if (ifc.Conn.Ix.parseException(e.Message).exceptionType != IXExceptionC.NOT_FOUND) { throw e; } String dir = System.IO.Path.GetDirectoryName(file); if (dir.Length >= driveAndArc.Length) { string arcDir = dir.Substring(driveAndArc.Length); doc = ifc.Conn.Content.CreateDocument("FSPATH:" + arcDir, ""); } } } } } catch { } return(doc); }
/// <summary> /// Creates a ListViewItem for the given Sord object. /// </summary> /// <param name="objT">Sord object</param> /// <returns>ListViewItem object</returns> protected override ListViewItem makeItem(Object objT) { FWSord sord = (FWSord)objT; ListViewItem li = new ListViewItem(); if (Conn != null && objT != null) { String fname = sord.Name; if (sord is FWDocument) { String ext = ((FWDocument)sord).Version.Core.ext; if (ext != null && ext.Length != 0) { fname += "." + ext; } } li.ForeColor = sord.RGBColor; //li.Text = fname; li.Text = sord.Name; li.ImageIndex = sord.ImageIndex; if (sord.XDate.Ticks == 0) { li.SubItems.Add(""); } else if (sord.XDate.Hour == 0 && sord.XDate.Minute == 0) { li.SubItems.Add(sord.XDate.ToString("d")); } else { li.SubItems.Add(sord.XDate.ToString("g")); } //li.SubItems.Add(sord.XDate.Ticks != 0 ? sord.XDate.ToString("g") : ""); li.SubItems.Add(sord.IDate.ToString()); //EloixClient.IndexServerFW.MasterData.FWDocMask docMask = Conn.MasterData.DocMasks.GetValueOrDefault(sord.MaskId, Conn.MasterData.DocMasks[0]); EloixClient.IndexServerFW.MasterData.FWDocMask docMask = Conn.MasterData.DocMasks[sord.MaskId]; //li.SubItems.Add(Conn.MasterData.DocMasks[sord.MaskId].Name); li.SubItems.Add(docMask.Name); li.SubItems.Add(sord.OwnerName); FWDocument doc = (sord is FWDocument) ? (FWDocument)sord : null; if (doc != null) { li.SubItems.Add(doc.Version.Version); if (doc.Version.CreateDate.Ticks == 0) { li.SubItems.Add(""); } else if (doc.Version.CreateDate.Hour == 0 && doc.Version.CreateDate.Minute == 0) { li.SubItems.Add(doc.Version.CreateDate.ToString("d")); } else { li.SubItems.Add(doc.Version.CreateDate.ToString("g")); } //li.SubItems.Add(doc.Version.CreateDate.Ticks != 0 ? doc.Version.CreateDate.ToString("g") : ""); li.SubItems.Add(doc.Version.OwnerName); li.SubItems.Add(doc.Version.SizeKB); } else { li.SubItems.Add(""); li.SubItems.Add(""); li.SubItems.Add(""); li.SubItems.Add(""); } li.SubItems.Add(sord.ArcPathString); li.SubItems.Add(sord.LockName); if (this.ShowObjKeyColumns) { for (int colIdx = 11; colIdx < this.Columns.Count; colIdx++) { ColumnHeaderTag htag = (ColumnHeaderTag)this.Columns[colIdx].Tag; FWCompareSordByObjKey <FWSord> compByObjKey = (FWCompareSordByObjKey <FWSord>)htag.compareObject; FWObjKey okey = sord.ObjKeys[compByObjKey.groupName]; li.SubItems.Add(okey != null ? (String)okey.Value : ""); } } li.Tag = sord; } return(li); }
public static string DocumentFile(FWDocVersion docVersion, FWDocument document) { string documentFile = null; int encryptionSet = docVersion.Core.encryptionSet; if (encryptionSet > 0) { bool keyExists = false; if (docVersion.Conn.Session.EncrPasswords[encryptionSet.ToString()] != null) { //return docVersion.File; keyExists = true; } // Anzeige eines Dialogs zur Eingabe des Verschlüsselungspassworts if (docVersion.Conn != null && docVersion.Conn.Ix != null) { EncryptionPasswordDialog dlg = new EncryptionPasswordDialog(encryptionSet); if (keyExists || dlg.ShowDialog() == DialogResult.OK) { try { if (!keyExists) { string key = Convert.ToString(encryptionSet); docVersion.Conn.Session.EncrPasswords[key] = dlg.Password; docVersion.Conn.Session.EncrPasswords.Checkin(); document.Checkin(); } document = document.Conn.Content.GetSord(document.Id) as FWDocument; foreach (FWDocVersion version in document.Versions) { if (version.Id == docVersion.Id) { docVersion = version; break; } } documentFile = docVersion.File; } catch (Exception exc) { if (document.Conn.IsException(exc, IXExceptionC.INVALID_CRYPT_KEY)) { string key = Convert.ToString(encryptionSet); docVersion.Conn.Session.EncrPasswords[key] = null; IXExceptionData exceptionData = document.Conn.Ix.parseException(exc.ToString()); MessageBox.Show(exceptionData.message, "ELO", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } } else { documentFile = docVersion.File; } return(documentFile); }
public override FWDocument ApplyDocumentTemplate(FWDocument doc, FWDocument templ) { throw new NotImplementedException(); }
public override string makeTempFilePath(FWDocument document) { throw new NotImplementedException(); }