/// <summary> /// Executes the package actions. /// </summary> /// <param name="executeModel">The execute model.</param> /// <returns></returns> public static IEnumerable<PackageActionResult> ExecutePackageActions(PackageActionExecuteModel executeModel) { var result = new List<PackageActionResult>(); try { var xmlDocument = helper.parseStringToXmlNode(string.Format("<actions>{0}</actions>", executeModel.Xml)); var nodeList = xmlDocument.SelectNodes("//Action"); if (nodeList.Count == 0) { result.Add(new PackageActionResult { Alias = "Error", Result = "Invalid action xml" }); } foreach (XmlNode node in nodeList) { var packageAlias = node.GetAttributeValueFromNode("alias"); if (string.IsNullOrWhiteSpace(packageAlias)) { result.Add(new PackageActionResult { Alias = "Error", Result = string.Format("Error parsing xml: {0}", node.OuterXml) }); break; } if (executeModel.InstallAction.Equals("install", StringComparison.InvariantCultureIgnoreCase)) { InstallAction(packageAlias, node, result); } else { UnInstallAction(packageAlias, node, result); } } } catch (Exception ex) { result.Add(new PackageActionResult { Alias = "Error", Result = string.Format("Error parsing xml: {0}",ex) }); } return result; }
public IEnumerable<PackageActionResult> ExecutePackageActions(PackageActionExecuteModel model) { return PackageActionService.ExecutePackageActions(model); }