private List<HostingPlanQuotaInfo> GetWebQuotas(DataView dvQuotas)
		{
			List<HostingPlanQuotaInfo> quotas = new List<HostingPlanQuotaInfo>();
			foreach (DataRowView quotaRow in dvQuotas)
			{
				int quotaTypeId = (int)quotaRow["QuotaTypeID"];
				string quotaName = (string)quotaRow["QuotaName"];
				HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo();
				quota.QuotaId = (int)quotaRow["QuotaID"];
				quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1;
				if (quotaName == "Web.Asp" ||
					quotaName == "Web.AspNet11" ||
					quotaName == "Web.Php4" ||
					quotaName == "Web.Perl" ||
					quotaName == "Web.CgiBin" ||
					quotaName == "Web.SecuredFolders" ||
					quotaName == "Web.SharedSSL" ||
					quotaName == "Web.Python" ||
					quotaName == "Web.AppPools" ||
					quotaName == "Web.IPAddresses" ||
					quotaName == "Web.ColdFusion" ||
					quotaName == "Web.CFVirtualDirectories" ||
					quotaName == "Web.RemoteManagement")
					quota.QuotaValue = 0;

				quotas.Add(quota);
			}
			return quotas;
		}
		private List<HostingPlanQuotaInfo> GetOSQuotas(DataView dvQuotas)
		{
			List<HostingPlanQuotaInfo> quotas = new List<HostingPlanQuotaInfo>();
			foreach (DataRowView quotaRow in dvQuotas)
			{
				int quotaTypeId = (int)quotaRow["QuotaTypeID"];
				string quotaName = (string)quotaRow["QuotaName"];
				HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo();
				quota.QuotaId = (int)quotaRow["QuotaID"];
				quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1;
				if (quotaName == "OS.AppInstaller" ||
					quotaName == "OS.ExtraApplications")
					quota.QuotaValue = 0;

				quotas.Add(quota);
			}
			return quotas;
		}
        public void CollectFormData()
        {
            groups = new List<HostingPlanGroupInfo>();
            quotas = new List<HostingPlanQuotaInfo>();

            // gather info
            foreach (RepeaterItem item in dlGroups.Items)
            {
                Literal litGroupId = (Literal)item.FindControl("groupId");
                CheckBox chkEnabled = (CheckBox)item.FindControl("chkEnabled");
                CheckBox chkCountDiskspace = (CheckBox)item.FindControl("chkCountDiskspace");
                CheckBox chkCountBandwidth = (CheckBox)item.FindControl("chkCountBandwidth");

                if (!chkEnabled.Checked)
                    continue; // disabled group

                HostingPlanGroupInfo group = new HostingPlanGroupInfo();
                group.GroupId = Utils.ParseInt(litGroupId.Text, 0);
                group.Enabled = chkEnabled.Checked;
                group.CalculateDiskSpace = chkCountDiskspace.Checked;
                group.CalculateBandwidth = chkCountBandwidth.Checked;
                groups.Add(group);

                // iterate quotas
                DataList dlQuotas = (DataList)item.FindControl("dlQuotas");
                foreach (DataListItem quotaItem in dlQuotas.Items)
                {
                    QuotaEditor quotaEditor = (QuotaEditor)quotaItem.FindControl("quotaEditor");
                 
                    HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo();
                    quota.QuotaId = quotaEditor.QuotaId;
                    quota.QuotaValue = quotaEditor.QuotaValue;
                    quotas.Add(quota);
                }
            }
        }
		private List<HostingPlanQuotaInfo> GetGroupQuotas(int groupId, DataView dvQuotas)
		{
			List<HostingPlanQuotaInfo> quotas = new List<HostingPlanQuotaInfo>();
			//OS quotas
			if (groupId == 1)
				quotas = GetOSQuotas(dvQuotas);
			//Web quotas
			else if (groupId == 2)
				quotas = GetWebQuotas(dvQuotas);
			else
			{
				foreach (DataRowView quotaRow in dvQuotas)
				{
					int quotaTypeId = (int)quotaRow["QuotaTypeID"];
					HostingPlanQuotaInfo quota = new HostingPlanQuotaInfo();
					quota.QuotaId = (int)quotaRow["QuotaID"];
					quota.QuotaValue = (quotaTypeId == 1) ? 1 : -1;
					quotas.Add(quota);
				}
			}
			return quotas;
		}
Esempio n. 5
0
        private static string BuildPlanQuotasXml(HostingPlanGroupInfo[] groups, HostingPlanQuotaInfo[] quotas)
        {
            // build xml
            /*
            XML Format:

            <plan>
                <groups>
	                <group id="16" enabled="1" calculateDiskSpace="1" calculateBandwidth="1"/>
                </groups>
                <quotas>
	                <quota id="2" value="2"/>
                </quotas>
            </plan>

            */

            if (groups == null || quotas == null)
                return null;

            XmlDocument doc = new XmlDocument();
            XmlElement nodePlan = doc.CreateElement("plan");

            XmlElement nodeGroups = doc.CreateElement("groups");
            nodePlan.AppendChild(nodeGroups);
            XmlElement nodeQuotas = doc.CreateElement("quotas");
            nodePlan.AppendChild(nodeQuotas);

            // groups
            if (groups != null)
            {
                foreach (HostingPlanGroupInfo group in groups)
                {
                    XmlElement nodeGroup = doc.CreateElement("group");
                    nodeGroups.AppendChild(nodeGroup);
                    nodeGroup.SetAttribute("id", group.GroupId.ToString());
                    nodeGroup.SetAttribute("enabled", group.Enabled ? "1" : "0");
                    nodeGroup.SetAttribute("calculateDiskSpace", group.CalculateDiskSpace ? "1" : "0");
                    nodeGroup.SetAttribute("calculateBandwidth", group.CalculateBandwidth ? "1" : "0");
                }
            }

            // quotas
            if (quotas != null)
            {
                foreach (HostingPlanQuotaInfo quota in quotas)
                {
                    XmlElement nodeQuota = doc.CreateElement("quota");
                    nodeQuotas.AppendChild(nodeQuota);
                    nodeQuota.SetAttribute("id", quota.QuotaId.ToString());
                    nodeQuota.SetAttribute("value", quota.QuotaValue.ToString());
                }
            }

            return nodePlan.OuterXml;
        }