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 optionalInstall = new Models.MunkiManifestOptionInstall()
            {
                Name = dataKey.Value.ToString(),
                ManifestTemplateId = ManifestTemplate.Id,
            };

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

            var condition = (TextBox)row.FindControl("txtCondition");
            optionalInstall.Condition = condition.Text;
            if (BLL.MunkiOptionalInstall.AddOptionalInstallToTemplate(optionalInstall)) updateCount++;
        }

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

        PopulateGrid();
    }
Ejemplo n.º 2
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 optionalInstall = new Models.MunkiManifestOptionInstall()
            {
                Name = dataKey.Value.ToString(),
                ManifestTemplateId = ManifestTemplate.Id,
            };



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

            var condition = (TextBox)row.FindControl("txtCondition");
            optionalInstall.Condition = condition.Text;
            if (BLL.MunkiOptionalInstall.AddOptionalInstallToTemplate(optionalInstall))
            {
                updateCount++;
            }
        }

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



        PopulateGrid();
    }