Esempio n. 1
0
        /// <summary>
        /// Adds a new version object initialized with the values from the given DocVersion object.
        /// </summary>
        /// <param name="dv">DocVersion object</param>
        /// <returns>The newly created version object</returns>
        internal FWDocVersion InternalAdd(DocVersion dv)
        {
            FWDocVersion ver = ifc.ClassFactory.NewDocVersion(dv, sord, typeVal);

            docs.Add(ver);
            return(ver);
        }
Esempio n. 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ifc">Content interface object</param>
 /// <param name="dv">Internal document version object</param>
 /// <param name="sord">Sord object</param>
 /// <param name="type">Version type</param>
 public FWDocVersion(FWContentInterface ifc, DocVersion dv, FWSord sord, FWDocVersionType type)
     : base(ifc)
 {
     this.typeVal = type;
     this.dvVal   = dv;
     this.sord    = sord;
     updateInternalData(false);
 }
Esempio n. 3
0
 /// <summary>
 /// Extracts the DocVersion objects wrapped by the framework objects into an array.
 /// </summary>
 /// <param name="xdvs">Collection of framework version objects.</param>
 /// <returns>Array of DocVersion objects.</returns>
 protected virtual DocVersion[] extractInternalVersionObjects(List <FWDocVersion> xdvs)
 {
     DocVersion[] dvs = new DocVersion[xdvs.Count];
     for (int i = 0; i < xdvs.Count; i++)
     {
         dvs[i] = xdvs[i].Core;
     }
     return(dvs);
 }
Esempio n. 4
0
        /// <summary>
        /// Read the working version of the document and attachment.
        /// </summary>
        protected virtual void readWorkVersion()
        {
            if (haveReadWorkVersion)
            {
                return;
            }
            haveReadWorkVersion = true;

            // Existing object?
            if (sordVal.id >= 0)
            {
                // read versions
                long      editC = EditInfoC.mbDocumentMembers | EditInfoC.mbSignatureMembers | EditInfoC.mbAttachmentMembers;
                EditInfoZ editZ = new EditInfoZ(editC, new SordZ(0));

                EditInfo ed = Conn.Ix.checkoutDoc(sordVal.guid, null, editZ, LockC.NO);

                // object has versions and/or attachments
                if (ed.document != null)
                {
                    // The current working versions might have been set by
                    // a previsious call to Version.File=c:/hello.txt.
                    // Thus do not overwrite the current working versions.

                    FWDocVersion wver = docs.WorkVersion;
                    FWDocVersion watt = atts.WorkVersion;

                    if (ed.document.docs != null && ed.document.docs.Length != 0)
                    {
                        DocVersion dv = ed.document.docs[0];
                        if (wver == null)
                        {
                            // ANPASSUNG
                            if (dv.workVersion)  // <-- Diese Zeile wurde eingefügt
                            {
                                wver = docs.InternalAdd(dv);
                            }
                        }
                        else if (wver.Signature == null)
                        {
                            wver.Signature = ClassFactory.NewDocVersion(dv.sig, this, FWDocVersionType.TYPE_SIGNATURE);
                        }
                    }

                    if (watt == null)
                    {
                        if (ed.document.atts != null && ed.document.atts.Length != 0)
                        {
                            DocVersion dv = ed.document.atts[0];
                            watt = atts.InternalAdd(dv);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        public static SortedDictionary <string, bool> GetRules(IXConnection ixConn, List <string> jsTexts, string package)
        {
            String parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/" + package + "/ELOas Base/Direct";

            if (package.Equals(""))
            {
                parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/ELOas Base/Direct";
            }

            List <Sord> sordRuleInfo = RepoUtils.FindChildren(parentId, ixConn, true);
            SortedDictionary <string, bool> dicRules = new SortedDictionary <string, bool>();

            foreach (Sord s in sordRuleInfo)
            {
                string   objId    = s.id + "";
                EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO);
                if (editInfo.document.docs.Length > 0)
                {
                    DocVersion dv          = editInfo.document.docs[0];
                    string     url         = dv.url;
                    Stream     inputStream = ixConn.Download(url, 0, -1);
                    string     xmlText     = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd();

                    try
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(xmlText);
                        string rulesetname = "";
                        foreach (XmlNode nameNode in doc.SelectNodes("ruleset/base/name"))
                        {
                            foreach (XmlNode subNode in nameNode.ChildNodes)
                            {
                                switch (subNode.Name)
                                {
                                case "#text":
                                    rulesetname = subNode.InnerText;
                                    break;
                                }
                            }
                        }
                        if (!dicRules.ContainsKey(rulesetname))
                        {
                            bool match = Unittests.Match(ixConn, rulesetname, package, jsTexts);
                            dicRules.Add(rulesetname, match);
                        }
                    }
                    catch (XmlException e)
                    {
                        Debug.WriteLine("Exception: {0}", e.Message);
                    }
                }
            }
            ;
            return(dicRules);
        }
Esempio n. 6
0
        public static SortedDictionary <string, bool> GetRFs(IXConnection ixConn, List <string> jsTexts, string package)
        {
            String parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/" + package + "/IndexServer Scripting Base";

            if (package.Equals(""))
            {
                parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/IndexServer Scripting Base/_ALL/business_solutions";
            }
            List <Sord> sordRFInfo = RepoUtils.FindChildren(parentId, ixConn, true);
            SortedDictionary <string, bool> dicRFs = new SortedDictionary <string, bool>();

            foreach (Sord s in sordRFInfo)
            {
                string   objId    = s.id + "";
                EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO);
                if (editInfo.document.docs.Length > 0)
                {
                    DocVersion dv          = editInfo.document.docs[0];
                    string     url         = dv.url;
                    Stream     inputStream = ixConn.Download(url, 0, -1);
                    string     jsText      = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd();
                    string[]   jsLines     = jsText.Split('\n');
                    foreach (string line in jsLines)
                    {
                        if (line.Contains("function RF_"))
                        {
                            string[] rf      = line.Split();
                            string   rfName  = rf[1];
                            string[] rfNames = rfName.Split('(');
                            rfName = rfNames[0];
                            if (!rfName.Equals("*"))
                            {
                                if (!dicRFs.ContainsKey(rfName))
                                {
                                    bool match = Unittests.Match(ixConn, rfName, package, jsTexts);
                                    dicRFs.Add(rfName, match);
                                }
                            }
                        }
                    }
                }
            }
            ;
            return(dicRFs);
        }
Esempio n. 7
0
        /// <summary>
        /// Implements the abstract function of FWCompareSord.
        /// </summary>
        /// <param name="o1">First object</param>
        /// <param name="o2">Second object</param>
        /// <returns>0, if o1 equal o2, 1 if o1 is greater than o2, -1 if o1 is less than o2.</returns>
        protected override int internalCompare(T o1, T o2)
        {
            DocVersion d1 = o1.Core.docVersion, d2 = o2.Core.docVersion;

            if (d1 != null && d2 != null)
            {
                return(CompareDocVersion(d1, d2));
            }
            if (d1 != null && d2 == null)
            {
                return(-1);
            }
            if (d1 == null && d2 != null)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 8
0
        /// <summary>
        /// Makes a file system path in ELOFS for the given Sord object.
        /// </summary>
        /// <param name="sord">Sord object with valid sord.refPaths</param>
        /// <returns>File system path</returns>
        public String GetFileSystemPath(Sord sord, DocVersion dv)
        {
            FSConnection fsConn  = (FSConnection)Conn;
            String       winPath = fsConn.Config.Drive + "\\" + FSFileHelper.EscapeFileName(fsConn.ArcName);

            IdName[] arcPathObjs = sord.refPaths[0].path;
            for (int i = 0; i < arcPathObjs.Length; i++)
            {
                winPath += "\\" + FSFileHelper.EscapeFileName(arcPathObjs[i].name);
            }

            winPath += "\\" + FSFileHelper.EscapeFileName(sord.name);

            if (dv != null)
            {
                winPath += ".";
                winPath += dv.ext;
            }

            return(winPath);
        }
Esempio n. 9
0
        public static List <string> LoadTextDocs(String parentId, IXConnection ixConn)
        {
            List <Sord>   sordRFInfo = RepoUtils.FindChildren(parentId, ixConn, true);
            List <string> docTexts   = new List <string>();

            foreach (Sord s in sordRFInfo)
            {
                string   objId    = s.id + "";
                EditInfo editInfo = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO);
                if (editInfo.document.docs.Length > 0)
                {
                    DocVersion dv          = editInfo.document.docs[0];
                    string     url         = dv.url;
                    Stream     inputStream = ixConn.Download(url, 0, -1);
                    string     docText     = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd();
                    docTexts.Add(docText);
                }
            }
            ;
            return(docTexts);
        }
Esempio n. 10
0
 /// <summary>
 /// Converts the values from the internal document version object.
 /// </summary>
 /// <param name="save">true, to save into the internal document object</param>
 protected virtual void updateInternalData(bool save)
 {
     if (save)
     {
     }
     else
     {
         if (dvVal != null)
         {
             if (dvVal.sig != null)
             {
                 if (this.sigVal == null)
                 {
                     this.sigVal = ClassFactory.NewDocVersion(dvVal.sig, sord, FWDocVersionType.TYPE_SIGNATURE);
                 }
                 else
                 {
                     this.sigVal.Core = dvVal.sig;
                 }
             }
             if (dvVal.preview != null)
             {
                 if (this.previewVal == null)
                 {
                     this.previewVal = ClassFactory.NewDocVersion(dvVal.preview, sord, FWDocVersionType.TYPE_PREVIEW);
                 }
                 else
                 {
                     this.previewVal.Core = dvVal.preview;
                 }
             }
         }
         else
         {
             dvVal = new DocVersion();
             dvVal.encryptionSet = sord.Core.details.encryptionSet;
             dvVal.pathId        = sord.Core.path;
         }
     }
 }
Esempio n. 11
0
        static Dictionary <string, string> GetUnittestApp(IXConnection ixConn)
        {
            String      parentId = "ARCPATH[(E10E1000-E100-E100-E100-E10E10E10E00)]:/Business Solutions/development/ELOapps/ClientInfos";
            List <Sord> sordELOappsClientInfo = RepoUtils.FindChildren(parentId, ixConn, false);
            string      configApp             = "";
            string      configId = "";

            foreach (Sord s in sordELOappsClientInfo)
            {
                string     objId       = s.id + "";
                EditInfo   editInfo    = ixConn.Ix.checkoutDoc(objId, null, EditInfoC.mbSordDoc, LockC.NO);
                DocVersion dv          = editInfo.document.docs[0];
                string     url         = dv.url;
                Stream     inputStream = ixConn.Download(url, 0, -1);
                string     jsonString  = new StreamReader(inputStream, Encoding.UTF8).ReadToEnd();
                jsonString = jsonString.Replace("namespace", "namespace1");
                JsonConfig config = JsonConfig.ReadToObject(jsonString);

                string webId = config.web.id;

                if (webId != null)
                {
                    if (webId.Contains("UnitTests"))
                    {
                        configApp = config.web.namespace1 + "." + config.web.id;
                        configId  = config.id;
                    }
                }
            }
            ;
            Dictionary <string, string> dicApp = new Dictionary <string, string>();

            dicApp.Add("configApp", configApp);
            dicApp.Add("configId", configId);

            return(dicApp);
        }
Esempio n. 12
0
 /// <summary>
 /// Implements the abstract function of FWCompareSord.
 /// </summary>
 /// <param name="d1">First object</param>
 /// <param name="d2">Second object</param>
 /// <returns>0, if o1 equal o2, 1 if o1 is greater than o2, -1 if o1 is less than o2.</returns>
 public override int CompareDocVersion(DocVersion d1, DocVersion d2)
 {
     return(Math.Sign(d1.size - d2.size));
 }
Esempio n. 13
0
 /// <summary>
 /// Implements the abstract function of FWCompareSord.
 /// </summary>
 /// <param name="d1">First object</param>
 /// <param name="d2">Second object</param>
 /// <returns>0, if o1 equal o2, 1 if o1 is greater than o2, -1 if o1 is less than o2.</returns>
 public override int CompareDocVersion(DocVersion d1, DocVersion d2)
 {
     return(String.Compare(d1.ownerName, d2.ownerName));
 }
Esempio n. 14
0
 /// <summary>
 /// Create new FWDocVersion object.
 /// </summary>
 /// <param name="dv">DocVersion object</param>
 /// <param name="sord">Sord object.</param>
 /// <param name="type">Type of version object: version, attachment, etc.</param>
 /// <returns>FWDocVersion object</returns>
 public virtual FWDocVersion NewDocVersion(DocVersion dv, FWSord sord, FWDocVersionType type)
 {
     return(new FWDocVersion(ifc, dv, sord, type));
 }
Esempio n. 15
0
 protected bool Equals(DocVersion other)
 {
     return(string.Equals(Tag, other.Tag));
 }
Esempio n. 16
0
        private static void FindChildren(IXConnection conn, string arcPath, string winPath, bool exportReferences, string maskName)
        {
            FindInfo   fi = null;
            FindResult fr = null;

            try
            {
                EditInfo ed       = conn.Ix.checkoutSord(arcPath, EditInfoC.mbOnlyId, LockC.NO);
                int      parentId = ed.sord.id;

                fi = new FindInfo();
                fi.findChildren          = new FindChildren();
                fi.findChildren.parentId = Convert.ToString(parentId);
                fi.findChildren.endLevel = 1;
                SordZ sordZ = SordC.mbMin;


                int idx = 0;
                fr = conn.Ix.findFirstSords(fi, 1000, sordZ);
                while (true)
                {
                    foreach (Sord sord in fr.sords)
                    {
                        bool isFolder    = sord.type < SordC.LBT_DOCUMENT;
                        bool isDocument  = sord.type >= SordC.LBT_DOCUMENT && sord.type <= SordC.LBT_DOCUMENT_MAX;
                        bool isReference = sord.parentId != parentId;

                        bool doExportScript = false;
                        // Keine Referenzen ausgeben
                        if (!exportReferences)
                        {
                            if (!isReference)
                            {
                                doExportScript = true;
                            }
                        }
                        // Referenzen mit ausgeben
                        else
                        {
                            doExportScript = true;
                        }

                        // Prüfen, ob bestimmte Verschlagwortungsmaske angegeben
                        if (doExportScript && isDocument)
                        {
                            if (maskName.Trim().Equals(""))
                            {
                                doExportScript = true;
                            }
                            else
                            {
                                if (sord.maskName.Equals(maskName))
                                {
                                    doExportScript = true;
                                }
                                else
                                {
                                    doExportScript = false;
                                }
                            }
                        }

                        if (doExportScript)
                        {
                            // Wenn Ordner rekursiv aufrufen
                            if (isFolder)
                            {
                                // Neuen Ordner in Windows anlegen, falls noch nicht vorhanden
                                string subFolderPath = winPath + "\\" + sord.name;
                                if (!Directory.Exists(subFolderPath))
                                {
                                    try
                                    {
                                        Directory.CreateDirectory(subFolderPath);
                                    }
                                    catch (System.IO.PathTooLongException e)
                                    {
                                        Console.WriteLine("Exception: " + e.Message + " " + subFolderPath);
                                        Debug.WriteLine("Exception: " + e.Message + " " + subFolderPath);
                                        return;
                                    }
                                }
                                FindChildren(conn, arcPath + "/" + sord.name, subFolderPath, exportReferences, maskName);
                            }

                            // Wenn Dokument Pfad und Name ausgeben
                            if (isDocument)
                            {
                                // Dokument aus Archiv downloaden und in Windows anlegen
                                ed = conn.Ix.checkoutDoc(Convert.ToString(sord.id), null, EditInfoC.mbDocument, LockC.NO);
                                DocVersion dv      = ed.document.docs[0];
                                String     outFile = winPath + "\\" + sord.name + "." + dv.ext;
                                if (File.Exists(outFile))
                                {
                                    File.Delete(outFile);
                                }
                                try
                                {
                                    conn.Download(dv.url, outFile);
                                    Console.WriteLine("Arcpath=" + arcPath + "/" + sord.name + "  Maskname=" + sord.maskName);
                                    Debug.WriteLine("Arcpath=" + arcPath + "/" + sord.name + "  Maskname=" + sord.maskName);
                                }
                                catch (System.IO.PathTooLongException e)
                                {
                                    Console.WriteLine("Exception: " + e.Message + " " + outFile);
                                    Debug.WriteLine("Exception: " + e.Message + " " + outFile);
                                    return;
                                }
                            }
                        }
                    }
                    if (!fr.moreResults)
                    {
                        break;
                    }
                    idx += fr.sords.Length;
                    fr   = conn.Ix.findNextSords(fr.searchId, idx, 1000, sordZ);
                }
            }
            catch (byps.BException e)
            {
                if (e.Source != null)
                {
                    Console.WriteLine("byps.BException message: {0}", e.Message);
                    Debug.WriteLine("byps.BException message: {0}", e.Message);
                }
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                if (e.Source != null)
                {
                    Console.WriteLine("System.IO.DirectoryNotFoundException message: {0}", e.Message);
                    Debug.WriteLine("System.IO.DirectoryNotFoundException message: {0}", e.Message);
                }
            }
            catch (System.NotSupportedException e)
            {
                if (e.Source != null)
                {
                    Console.WriteLine("System.NotSupportedException message: {0}", e.Message);
                    Debug.WriteLine("System.NotSupportedException message: {0}", e.Message);
                }
            }
            finally
            {
                if (fr != null)
                {
                    conn.Ix.findClose(fr.searchId);
                }
            }
        }
Esempio n. 17
0
 public abstract void onFileUploadBuildResponse(IXServerEventsContext ec, DocVersion dv, String fileName, HttpRequestInfo requestInfo, HttpResponseInfo responseInfo);
Esempio n. 18
0
 /// <summary>
 /// Compare function.
 /// </summary>
 /// <param name="d1">First object</param>
 /// <param name="d2">Second object</param>
 /// <returns></returns>
 public virtual int CompareDocVersion(DocVersion d1, DocVersion d2)
 {
     return(String.Compare(d1.version, d2.version));
 }
Esempio n. 19
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ifc">Content interface object</param>
 /// <param name="dv">DocVersion object</param>
 /// <param name="sord">Sord object</param>
 /// <param name="type">Type of DocVersion object (version, attachment, signature, preview). </param>
 public FSDocVersion(FSContentInterface ifc, DocVersion dv, FWSord sord, FWDocVersionType type)
     : base(ifc, dv, sord, type)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Implements the abstract function of FWCompareSord.
 /// </summary>
 /// <param name="d1">First object</param>
 /// <param name="d2">Second object</param>
 /// <returns>0, if o1 equal o2, 1 if o1 is greater than o2, -1 if o1 is less than o2.</returns>
 public override int CompareDocVersion(DocVersion d1, DocVersion d2)
 {
     return(String.Compare(d1.createDateIso, d2.createDateIso));
 }
Esempio n. 21
0
 /// <summary>
 /// Create new FWDocVersion object.
 /// </summary>
 /// <param name="dv">DocVersion object</param>
 /// <param name="sord">Sord object.</param>
 /// <param name="type">Type of version object: version, attachment, etc.</param>
 /// <returns>FWDocVersion object</returns>
 public override FWDocVersion NewDocVersion(DocVersion dv, FWSord sord, FWDocVersionType type)
 {
     return(new FSDocVersion((FSContentInterface)ifc, dv, sord, type));
 }
Esempio n. 22
0
        public async Task ImportAllBranches()
        {
            var branches = await _githubDataRepository.GetBranches();

            var        versions       = new List <DocVersion>();
            DocVersion defaultVersion = null;

            foreach (var branch in branches)
            {
                _dataRepository.DeleteBranch(branch.Name);

                var version = new DocVersion(BranchNameToPathString(branch.Name), branch.Name);

                versions.Add(version);
                if (branch.IsDefault)
                {
                    defaultVersion = version;
                }

                var archive = await _githubDataRepository.GetArchive(branch);

                using (var memoryStream = new MemoryStream(archive))
                    using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress))
                        using (var tarReader = new TarReader(gzipStream))
                        {
                            string rootDirectory = null;
                            while (tarReader.Next() is var entry && entry != null)
                            {
                                if (entry.Header.Flag == TarHeaderFlag.Directory && rootDirectory == null)
                                {
                                    rootDirectory = entry.Header.Name;
                                }
                                if (entry.Header.Flag == TarHeaderFlag.NormalFile)
                                {
                                    if (Path.GetExtension(entry.Header.Name) == ".md")
                                    {
                                        using (var streamReader = new StreamReader(entry))
                                        {
                                            var markdown = streamReader.ReadToEnd();

                                            var meta = ParseMeta(ref markdown);

                                            // Parse markdown
                                            var document = Markdig.Markdown.Parse(markdown,
                                                                                  new MarkdownPipelineBuilder()
                                                                                  .UseAdvancedExtensions()
                                                                                  .UsePipeTables()
                                                                                  .Build());

                                            var sw       = new StringWriter();
                                            var renderer = new CustomHtmlRenderer(sw);
                                            renderer.Render(document);
                                            sw.Flush();
                                            var html = sw.ToString();

                                            var file = new DocFile
                                            {
                                                Content = html,
                                                Meta    = meta
                                            };

                                            var docPath = entry.Header.Name;

                                            if (rootDirectory != null && docPath.StartsWith(rootDirectory))
                                            {
                                                docPath = docPath.Substring(rootDirectory.Length).TrimStart('/', '\\');
                                            }

                                            var fileName = Path.GetFileNameWithoutExtension(docPath);
                                            docPath = Path.Combine(Path.GetDirectoryName(docPath), fileName);

                                            if (fileName == "index")
                                            {
                                                version.DefaultPage = meta.RedirectPage;
                                            }

                                            meta.LastModification = entry.Header.LastModification ?? DateTime.UtcNow;
                                            meta.EditUrl          = $"{_githubDataRepository.PublicUrl}/blob/{branch.Name}/{docPath}.md";
                                            meta.Title            = meta.Title ?? fileName.Replace('-', ' ');

                                            _dataRepository.StoreDocFile(branch.Name, docPath, file);
                                        }
                                    }
                                    else
                                    {
                                        var assetPath = entry.Header.Name;

                                        if (rootDirectory != null && assetPath.StartsWith(rootDirectory))
                                        {
                                            assetPath = assetPath.Substring(rootDirectory.Length).TrimStart('/', '\\');
                                        }

                                        assetPath = assetPath.ToLower();

                                        // Skip unaccepted asset types
                                        if (_options.Value.AcceptedAssets.Contains(Path.GetExtension(assetPath)))
                                        {
                                            _dataRepository.StoreAsset(branch.Name, assetPath, entry);
                                        }
                                    }
                                }
                            }
                        }
            }

            var docConfig = new DocConfiguration
            {
                Versions       = versions.ToArray(),
                DefaultVersion = defaultVersion
            };

            _dataRepository.StoreDocConfiguration(docConfig);
        }