Ejemplo n.º 1
0
 // Return the openkm document path
 public static String getOpenKMPath(String localFilename, MSOpenKMCore.ws.folder fld)
 {
     try
     {
         return fld.path + "/" + localFilename.Substring(localFilename.LastIndexOf(@"\") + 1);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 2
0
 // get the document name
 public static String getDocumentName(MSOpenKMCore.ws.document doc)
 {
     try
     {
         return doc.path.Substring(doc.path.LastIndexOf("/") + 1);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 3
0
 // Return the folder name, text before last "/" character
 public static String getFolderName(MSOpenKMCore.ws.folder folderNode)
 {
     try
     {
         return folderNode.path.Substring(folderNode.path.LastIndexOf("/") + 1);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 4
0
 // Evaluates enabled buttons by permisions
 private void evaluateEnabledButtonByPermissions(MSOpenKMCore.ws.folder fld)
 {
     if (Util.hasWritePermission(fld))
     {
         accept.Enabled = true;
     }
     else
     {
         accept.Enabled = false;
     }
 }
Ejemplo n.º 5
0
        // returns file name that not exist in disk
        public String getFilenameWithoutCollision(MSOpenKMCore.ws.document doc)
        {
            try
            {
                String fileName = getConfigPath() + @"\" + Util.getDocumentName(doc); // Default path name
                String docNamePart1 = fileName.Substring(0, fileName.LastIndexOf("."));
                String docNamePart2 = fileName.Substring(fileName.LastIndexOf("."));

                int count = 1;
                while (File.Exists(fileName))
                {
                    fileName = docNamePart1 + "_" + count + docNamePart2;
                    count++;
                }

                return fileName;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 6
0
 // Evaluates enabled buttons by permisions
 private void evaluateEnabledButtonByPermissions(MSOpenKMCore.ws.folder fld, MSOpenKMCore.ws.document doc)
 {
     if (Util.hasWritePermission(fld, doc) && !doc.locked && !doc.checkedOut)
     {
         edit.Enabled = true;
     }
     else
     {
         edit.Enabled = false;
     }
 }
Ejemplo n.º 7
0
 // Return if a user has folder has write permissions
 public static bool hasWritePermission(MSOpenKMCore.ws.folder fld)
 {
     try
     {
         return ((fld.permissions & OKMPermissions.WRITE) == OKMPermissions.WRITE);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Ejemplo n.º 8
0
        // Return if document is valid to be opened with ms word
        public static bool isDocumentValidToOpenWithMSWord(MSOpenKMCore.ws.document doc)
        {
            bool valid = false;
            String[] WORD_EXTENSIONS = new String[15] {"doc","dot","xml","html",
                                                       "htm","mht","mhtml","rtf",
                                                       "txt","scd","olk","pab",
                                                       "wri","wpd","wpd"};

            String docExtension = getDocumentExtension(doc);
            foreach (String extension in WORD_EXTENSIONS)
            {
                if (docExtension.Equals(extension))
                {
                    valid = true;
                    break;
                }
            }

            // Special case, document could start with doc*
            if (!valid)
            {
                if (docExtension.StartsWith("doc"))
                {
                    valid = true;
                }
            }

            return valid;
        }
Ejemplo n.º 9
0
        // Return if document is valid to be opened with ms visio
        public static bool isDocumentValidToOpenWithMSVisio(MSOpenKMCore.ws.document doc)
        {
            bool valid = false;
            String[] VISIO_EXTENSIONS = new String[9] { "vsd", "vxd", "vss", "vsx", "vst", "vtx", "vsw", "svg", "svgz" };

            String docExtension = getDocumentExtension(doc);
            foreach (String extension in VISIO_EXTENSIONS)
            {
                if (docExtension.Equals(extension))
                {
                    valid = true;
                    break;
                }
            }

            // Special case, document could start with vs* v?x
            if (!valid)
            {
                if (docExtension.StartsWith("vs"))
                {
                    valid = true;
                }
            }
            if (!valid)
            {
                if (docExtension.StartsWith("v") && docExtension.Length == 3 && docExtension.EndsWith("x"))
                {
                    valid = true;
                }
            }

            return valid;
        }
Ejemplo n.º 10
0
        // Return if document is valid to be opened with ms excel
        public static bool isDocumentValidToOpenWithMSPowerPoint(MSOpenKMCore.ws.document doc)
        {
            bool valid = false;
            String[] POWERPOINT_EXTENSIONS = new String[9] {"htm","html","mht","mhtml","txt","rtf","doc","wpd","wps"};

            String docExtension = getDocumentExtension(doc);
            foreach (String extension in POWERPOINT_EXTENSIONS)
            {
                if (docExtension.Equals(extension))
                {
                    valid = true;
                    break;
                }
            }

            // Special case, document could start with pps* ppt* pot*
            if (!valid)
            {
                if (docExtension.StartsWith("pps"))
                {
                    valid = true;
                }
            }
            if (!valid)
            {
                if (docExtension.StartsWith("ppt"))
                {
                    valid = true;
                }
            }
            if (!valid)
            {
                if (docExtension.StartsWith("pot"))
                {
                    valid = true;
                }
            }

            return valid;
        }
Ejemplo n.º 11
0
        // Return if document is valid to be opened with ms excel
        public static bool isDocumentValidToOpenWithMSExcel(MSOpenKMCore.ws.document doc)
        {
            bool valid = false;
            String[] EXCEL_EXTENSIONS = new String[16] {"xls","xlt","htm","html","mht","mhtml","xml",
                                                       "xla","xlm","xlc","xlw","odc","uxdc","prn",
                                                       "txt","csv"};

            String docExtension = getDocumentExtension(doc);
            foreach (String extension in EXCEL_EXTENSIONS)
            {
                if (docExtension.Equals(extension))
                {
                    valid = true;
                    break;
                }
            }

            // Special case, document could start with xl*
            if (!valid)
            {
                if (docExtension.StartsWith("xl"))
                {
                    valid = true;
                }
            }

            return valid;
        }
Ejemplo n.º 12
0
 // Return if a user document has write permissions
 public static bool hasWritePermission(MSOpenKMCore.ws.folder fatherFld, MSOpenKMCore.ws.document doc)
 {
     try
     {
         // Must have permission to write in folders and in document
         return ((fatherFld.permissions & OKMPermissions.WRITE) == OKMPermissions.WRITE) &
                ((doc.permissions & OKMPermissions.WRITE) == OKMPermissions.WRITE);
     }
     catch (Exception e)
     {
         throw e;
     }
 }