Beispiel #1
0
    protected void buttonUpdate_OnClick(object sender, EventArgs e)
    {
        RequiresAuthorization(Authorizations.UpdateGlobal);

        var updateCount = 0;

        foreach (GridViewRow row in gvPkgInfos.Rows)
        {
            var enabled = (CheckBox)row.FindControl("chkSelector");
            if (enabled == null)
            {
                continue;
            }
            if (!enabled.Checked)
            {
                continue;
            }

            var dataKey = gvPkgInfos.DataKeys[row.RowIndex];
            if (dataKey == null)
            {
                continue;
            }

            var managedInstall = new Models.MunkiManifestManagedInstall
            {
                Name = dataKey.Value.ToString(),
                ManifestTemplateId = ManifestTemplate.Id,
            };

            var cbUseVersion = (CheckBox)row.FindControl("chkUseVersion");
            if (cbUseVersion.Checked)
            {
                managedInstall.Version        = row.Cells[2].Text;
                managedInstall.IncludeVersion = 1;
            }

            var condition = (TextBox)row.FindControl("txtCondition");
            managedInstall.Condition = condition.Text;

            if (BLL.MunkiManagedInstall.AddManagedInstallToTemplate(managedInstall))
            {
                updateCount++;
            }
        }

        if (updateCount > 0)
        {
            EndUserMessage = "Successfully Updated Managed Installs";
            ManifestTemplate.ChangesApplied = 0;
            BLL.MunkiManifestTemplate.UpdateManifest(ManifestTemplate);
        }
        else
        {
            EndUserMessage = "Could Not Update Managed Installs";
        }

        PopulateGrid();
    }
    protected void buttonUpdate_OnClick(object sender, EventArgs e)
    {
        RequiresAuthorization(Authorizations.UpdateGlobal);

        var updateCount = 0;
        foreach (GridViewRow row in gvPkgInfos.Rows)
        {
            var enabled = (CheckBox)row.FindControl("chkSelector");
            if (enabled == null) continue;
            if (!enabled.Checked) continue;

            var dataKey = gvPkgInfos.DataKeys[row.RowIndex];
            if (dataKey == null) continue;

            var managedInstall = new Models.MunkiManifestManagedInstall
            {
                Name = dataKey.Value.ToString(),
                ManifestTemplateId = ManifestTemplate.Id,
            };

            var cbUseVersion = (CheckBox)row.FindControl("chkUseVersion");
            if (cbUseVersion.Checked)
            {
                managedInstall.Version = row.Cells[2].Text;
                managedInstall.IncludeVersion = 1;
            }

            var condition = (TextBox)row.FindControl("txtCondition");
            managedInstall.Condition = condition.Text;

            if (BLL.MunkiManagedInstall.AddManagedInstallToTemplate(managedInstall)) updateCount++;
        }

        if (updateCount > 0)
        {
            EndUserMessage = "Successfully Updated Managed Installs";
            ManifestTemplate.ChangesApplied = 0;
            BLL.MunkiManifestTemplate.UpdateManifest(ManifestTemplate);
        }
        else
        {
            EndUserMessage = "Could Not Update Managed Installs";
        }

        PopulateGrid();
    }