Esempio n. 1
0
        public static bool Launch(string type, PublicationInformation publicationInformation)
        {
            string xhtmlFile = publicationInformation.DefaultXhtmlFileWithPath;

            CreateVerbose(publicationInformation);
            var localType = type.Replace(@"\", "/").ToLower();

            try
            {
                //Code to call PathwayExport Commandline Utility -commented for now
                string mainXhtmlFile = Path.GetFileNameWithoutExtension(publicationInformation.DefaultXhtmlFileWithPath);

                if (mainXhtmlFile.ToLower() == "flexrev")
                {
                    publicationInformation.IsReversalExist = false;
                }

                StringBuilder sb = new StringBuilder();
                sb.Append("\"");
                sb.Append(publicationInformation.DefaultXhtmlFileWithPath);
                sb.Append(",\" ");
                sb.Append("\"");
                sb.Append(publicationInformation.DefaultCssFileWithPath);
                if (publicationInformation.IsReversalExist)
                {
                    sb.Append(",\" ");
                    sb.Append("\"");
                    sb.Append(Path.Combine(Path.GetDirectoryName(publicationInformation.DefaultXhtmlFileWithPath), "FlexRev.xhtml"));
                    sb.Append(",\" ");
                    sb.Append("\"");
                    sb.Append(publicationInformation.DefaultRevCssFileWithPath);
                    sb.Append("\"");
                }
                else
                {
                    sb.Append("\"");
                }

                Common.SaveInputType(publicationInformation.ProjectInputType);

                string dbName   = Common.IsUnixOS() ? Param.DatabaseName.Replace(" ", "\\ ").Replace("'", "\\'") : Param.DatabaseName;
                string argument = string.Format("--target \"{0}\" --directory \"{1}\" --files {2} --nunit {3} --database \"{4}\"", type.Replace(@"\", "/").ToLower(), publicationInformation.DictionaryPath, sb.ToString(), Common.Testing.ToString(), dbName);

                string pathwayExportFile = Path.Combine(Common.GetApplicationPath(), "PathwayExport.exe");

                if (!File.Exists(pathwayExportFile))
                {
                    pathwayExportFile = Path.Combine(Common.GetApplicationPath(), "Export", "PathwayExport.exe");
                }

                var cmd = Common.IsUnixOS()?
                          "/usr/bin/PathwayExport": pathwayExportFile;

                if (HasPathwayExportBatchRegistryValueForCurrentUserRegistry())
                {
                    var batchFullName = Path.Combine(publicationInformation.DictionaryPath, "PathwayExport.bat");
                    using (var sw = new StreamWriter(batchFullName))
                    {
                        sw.WriteLine("\"" + cmd + "\" " + argument);
                        sw.Close();
                    }
                    MessageBox.Show(@"Batch command written to " + batchFullName + @" since PathwayExportBatch variable present");
                    if (Common.IsUnixOS())
                    {
                        SubProcess.Run("", "nautilus", Common.HandleSpaceinLinuxPath(publicationInformation.DictionaryPath), false);
                    }
                    else
                    {
                        SubProcess.Run(publicationInformation.DictionaryPath, "explorer.exe", publicationInformation.DictionaryPath,
                                       false);
                    }
                }
                else
                {
                    SubProcess.WindowStyle = ProcessWindowStyle.Minimized;
                    SubProcess.Run(publicationInformation.DictionaryPath, cmd, argument, true);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                publicationInformation.DefaultXhtmlFileWithPath = xhtmlFile;
                ShowVerbose(publicationInformation);
            }
            return(true);
        }