예제 #1
0
 private static void CreateOKMYearFolder(OKMWebservice webservice, string token, string host, string user, string password, string dynamicDocPath)
 {
     try
     {
         if (!webservice.folderExist(token, dynamicDocPath))
         {
             webservice.createSimple(token, dynamicDocPath);
         }
     }
     catch (OKMWebserviceException okex)
     {
         // Re-obtaining OpenKM authentication token, and retrying...
         Console.WriteLine(okex.Message);
         Console.WriteLine(okex.Source);
         Console.WriteLine(okex.StackTrace);
         Console.WriteLine(okex.TargetSite);
         //Console.WriteLine("Re-obtaining OpenKM authentication token, and retrying CreateOKMYearFolder...");
         //Worker.LoginToOpenKMCommunityEdition(host, user, password, ref token, ref webservice);
         ////recurse
         //CreateOKMYearFolder(ref webservice, ref token, host, user,  password, dynamicDocPath);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine(ex.Source);
         Console.WriteLine(ex.StackTrace);
         Console.WriteLine(ex.TargetSite);
         //Console.WriteLine("Retrying CreateOKMYearFolder...");
         ////recurse
         //CreateOKMYearFolder(ref webservice, ref token, host, user, password, dynamicDocPath);
     }
 }
예제 #2
0
        private static void ProcessNonExistingFile(string path, Dictionary <string, string> metadata, OKMWebservice webservice, string token, string transformedPath)
        {
            if (!webservice.documentExists(token, transformedPath))
            {
                //webservice.createSimple(token, docPath + path.Substring(path.LastIndexOf(@"\") + 1), File.ReadAllBytes(path));
                // Upload the file to OpenKM
                webservice.createSimple(token, transformedPath, File.ReadAllBytes(path));


                //Add Property Group and set the properties in the Group
                webservice.addGroup(token, transformedPath, "okg:systemspecs_docuware_import");

                Dictionary <string, string> okmPropertiesMap = new Dictionary <string, string>();

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.companyname")) && (metadata.ContainsKey("COMPANY_NAME")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.companyname", metadata["COMPANY_NAME"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.productline")) && (metadata.ContainsKey("PRODUCT_LINE")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.productline", metadata["PRODUCT_LINE"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.subjectheading")) && (metadata.ContainsKey("SUBJECT_HEADING")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.subjectheading", metadata["SUBJECT_HEADING"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.documentdirection")) && (metadata.ContainsKey("INGOING_OUTGOING")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.documentdirection", metadata["INGOING_OUTGOING"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.documenttype")) && (metadata.ContainsKey("DOCUMENT_TYPE")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.documenttype", metadata["DOCUMENT_TYPE"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.referencenumber")) && (metadata.ContainsKey("REFERENCE_NUMBER")))
                {
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.referencenumber", metadata["REFERENCE_NUMBER"]);
                }

                if ((!okmPropertiesMap.ContainsKey("okp:systemspecs_docuware_import.date")) && (metadata.ContainsKey("DATE")))
                {
                    DateTime dateTime       = DateTime.Parse(metadata["DATE"], new System.Globalization.CultureInfo("en-US", true), System.Globalization.DateTimeStyles.AssumeLocal);
                    string   dateTimeString = dateTime.Year.ToString() + "0" + dateTime.Month.ToString() + "0" + dateTime.Day.ToString() + "000000";
                    okmPropertiesMap.Add("okp:systemspecs_docuware_import.date", dateTimeString);
                }

                webservice.setPropertiesSimple(token, transformedPath, "okg:systemspecs_docuware_import", okmPropertiesMap);

                Console.WriteLine("Uploaded file from '{0}' -> '{1}'.", path, transformedPath);
            }
            else
            {
                Console.WriteLine("File already exits: for transaction '{0}' -> '{1}'.", path, transformedPath);
            }

            //Handling omitted training property group
            //The above is not necessary again as search and eye inspection of the filesystem repository for Docuware revealed the above property group as the only consistent one.
        }