Esempio n. 1
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    ClassSiteInfo.Provider.Remove(ClassId, siteId);
                }
            }
        }


        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems    = items.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            bool     falseValues = false;

            // Add all new items to site
            foreach (string item in newItems)
            {
                int siteId = ValidationHelper.GetInteger(item, 0);

                SiteInfo si = SiteInfo.Provider.Get(siteId);
                if (si != null)
                {
                    // Check license
                    if (CheckLicense && !CustomTableItemProvider.LicenseVersionCheck(si.DomainName, ObjectActionEnum.Insert))
                    {
                        if (ClassSiteInfo.Provider.Get(ClassId, siteId) == null)
                        {
                            // Show error message
                            ShowError(GetString("LicenseVersion.CustomTables"));
                            falseValues = true;
                            continue;
                        }
                    }

                    try
                    {
                        ClassSiteInfo.Provider.Add(ClassId, siteId);
                    }
                    catch (Exception ex)
                    {
                        // Show error message
                        ShowError(ex.Message);

                        return;
                    }
                }
            }

            // If some of sites could not be assigned reload selector value
            if (falseValues)
            {
                usSites.Value = GetClassSites();
                usSites.Reload(true);
            }
        }

        if (CheckLicense)
        {
            CustomTableItemProvider.ClearLicensesCount(true);
        }

        // Show message
        ShowChangesSaved();
    }
Esempio n. 2
0
    protected void SaveSites()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usSites.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    ClassSiteInfoProvider.RemoveClassFromSite(this.ClassId, siteId);
                }
            }
        }


        // Add new items
        items = DataHelper.GetNewItemsInList(currentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                bool falseValues = false;

                // Add all new items to site
                foreach (string item in newItems)
                {
                    int siteId = ValidationHelper.GetInteger(item, 0);

                    SiteInfo si = SiteInfoProvider.GetSiteInfo(siteId);
                    if (si != null)
                    {
                        // Check license
                        if (this.CheckLicense && !CustomTableItemProvider.LicenseVersionCheck(si.DomainName, FeatureEnum.CustomTables, VersionActionEnum.Insert))
                        {
                            if (ClassSiteInfoProvider.GetClassSiteInfo(this.ClassId, siteId) == null)
                            {
                                lblError.Visible = true;
                                lblError.Text    = GetString("LicenseVersion.CustomTables");
                                falseValues      = true;
                                continue;
                            }
                        }

                        try
                        {
                            ClassSiteInfoProvider.AddClassToSite(this.ClassId, siteId);
                        }
                        catch (Exception ex)
                        {
                            lblError.Visible = true;
                            lblError.Text    = ex.Message;
                            return;
                        }
                    }
                }

                // If some of sites could not be assigned reload selector value
                if (falseValues)
                {
                    usSites.Value = GetClassSites();
                    usSites.Reload(true);
                }
            }
        }

        if (this.CheckLicense)
        {
            CustomTableItemProvider.ClearCustomLicHash();
        }

        lblInfo.Visible = true;
        lblInfo.Text    = GetString("General.ChangesSaved");
    }