Ejemplo n.º 1
0
        /// <summary>
        /// Return the corresponding process object based on the type of jenkins instance.
        /// </summary>
        /// <param name="fileName">the filename to be ran</param>
        /// <param name="arguments">the arguments for the process</param>
        /// <returns>the corresponding process type, based on the jenkins instance</returns>
        private object GetProcessTypeForCurrentSession(string fileName, string arguments)
        {
            try
            {
                if (!IsParentProcessRunningInUserSession())
                {
                    Process process = new Process();

                    InitProcess(process, fileName, arguments);

                    return(process);
                }

                ConsoleWriter.WriteLine("Starting ParallelRunner from service session!");

                // the process must be started in the user session
                ElevatedProcess elevatedProcess = new ElevatedProcess(fileName, arguments, Helper.GetSTInstallPath());
                return(elevatedProcess);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        private IList <StatusReportItem> ExecuteRemote(string[] patchesRoots, string selectedVersion, string patchSet, string command)
        {
            IEnumerable <string> args = new[] { "-h", $"\"{ConfigManager.DocumentPath}\"", "-d", $"\"{_dcsRoot}\"", command }
            .Concat(patchesRoots.Select(root => $"\"{Path.Combine(root, selectedVersion, patchSet)}\""));
            string myDirectory    = Directory.GetParent(Path.GetDirectoryName(Assembly.GetCallingAssembly().Location)).FullName;
            string executablePath = Path.Combine(myDirectory ?? "", "HeliosPatching.exe");

            using (ElevatedProcess elevated = new ElevatedProcess(executablePath, args))
            {
                if (!elevated.TryExecute())
                {
                    return(new StatusReportItem
                    {
                        Status =
                            $"Running the HeliosPatching.exe utility as administrator either failed or was canceled by the user.  No changes will be written to {LongDescription}",
                        Recommendation = "Try the patching operation again and give permission to execute HeliosPatching.exe as administrator",
                        Link = StatusReportItem.ProfileEditor,
                        Severity = StatusReportItem.SeverityCode.Warning
                                   // NOTE: configuration out of date indicates that this can be corrected by trying again
                    }.AsReport());
                }
                return(elevated.ReadResults());
            }
        }
 private void Write34_ElevatedProcess(string n, string ns, ElevatedProcess o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && (o.GetType() != typeof(ElevatedProcess)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.WriteStartElement(n, ns, o, false, null);
         if (needType)
         {
             base.WriteXsiType("ElevatedProcess", "");
         }
         base.WriteElementStringRaw("KeepAlive", "", XmlConvert.ToString(o.KeepAlive));
         base.WriteEndElement(o);
     }
 }
 private ElevatedProcess Read34_ElevatedProcess(bool isNullable, bool checkType)
 {
     XmlQualifiedName type = checkType ? base.GetXsiType() : null;
     bool flag = false;
     if (isNullable)
     {
         flag = base.ReadNull();
     }
     if ((checkType && (type != null)) && ((type.Name != this.id26_ElevatedProcess) || (type.Namespace != this.id2_Item)))
     {
         throw base.CreateUnknownTypeException(type);
     }
     if (flag)
     {
         return null;
     }
     ElevatedProcess o = new ElevatedProcess();
     bool[] flagArray = new bool[1];
     while (base.Reader.MoveToNextAttribute())
     {
         if (!base.IsXmlnsAttribute(base.Reader.Name))
         {
             base.UnknownNode(o);
         }
     }
     base.Reader.MoveToElement();
     if (base.Reader.IsEmptyElement)
     {
         base.Reader.Skip();
         return o;
     }
     base.Reader.ReadStartElement();
     base.Reader.MoveToContent();
     int whileIterations = 0;
     int readerCount = base.ReaderCount;
     while ((base.Reader.NodeType != XmlNodeType.EndElement) && (base.Reader.NodeType != XmlNodeType.None))
     {
         if (base.Reader.NodeType == XmlNodeType.Element)
         {
             if ((!flagArray[0] && (base.Reader.LocalName == this.id294_KeepAlive)) && (base.Reader.NamespaceURI == this.id2_Item))
             {
                 o.KeepAlive = XmlConvert.ToBoolean(base.Reader.ReadElementString());
                 flagArray[0] = true;
             }
             else
             {
                 base.UnknownNode(o, ":KeepAlive");
             }
         }
         else
         {
             base.UnknownNode(o, ":KeepAlive");
         }
         base.Reader.MoveToContent();
         base.CheckReaderCount(ref whileIterations, ref readerCount);
     }
     base.ReadEndElement();
     return o;
 }