Пример #1
0
        public static void DeleteCustomUrl(Guid customUrlId)
        {
            using (CustomUrlTableAdapter adapter = new CustomUrlTableAdapter())
            {
                using (MasterDataSet.CustomUrlDataTable table = adapter.GetCustomUrl(customUrlId))
                {
                    if (table.Count > 0)
                    {
                        MasterDataSet.CustomUrlRow row = table[0];

                        if (row.IsInstanceIdNull())
                        {
                            RemoveOrganizationCustomUrlFromCache(row.OrganizationId);
                        }
                        else
                        {
                            RemoveInstanceCustomUrlFromCache(row.InstanceId);
                        }

                        row.Delete();

                        adapter.Update(table);
                    }
                }
            }
        }
Пример #2
0
        public static void UpdateCustomUrl(Guid customUrlId, string fullCustomUrl, string partialCustomUrl)
        {
            if (customUrlId == Guid.Empty)
            {
                return;
            }

            ValidatePartialCustomUrl(partialCustomUrl);

            using (CustomUrlTableAdapter adapter = new CustomUrlTableAdapter())
            {
                using (MasterDataSet.CustomUrlDataTable table = adapter.GetCustomUrls(null, null, fullCustomUrl, partialCustomUrl))
                {
                    MasterDataSet.CustomUrlRow row = null;
                    if (table.Count > 0)
                    {
                        if (table.Count == 1)
                        {
                            if (table[0].CustomUrlId == customUrlId)
                            {
                                row = table[0];
                            }
                            else
                            {
                                throw new ConstraintException(Resources.CustomUrlProvider_CustomUrlAlreadyExists);
                            }
                        }
                        else
                        {
                            throw new ConstraintException(Resources.CustomUrlProvider_CustomUrlAlreadyExists);
                        }
                    }

                    if (row == null)
                    {
                        row = GetCustomUrl(customUrlId);
                    }

                    if (!ValidateCustomUrl(fullCustomUrl) && !string.IsNullOrEmpty(fullCustomUrl) && (row != null && string.Compare(row.FullCustomUrl, fullCustomUrl, StringComparison.OrdinalIgnoreCase) != 0))
                    {
                        throw new ConstraintException(Resources.CustomUrlProvider_CustomUrlAlreadyExists);
                    }

                    if (!ValidateCustomUrl(partialCustomUrl) && !string.IsNullOrEmpty(partialCustomUrl) && (row != null && string.Compare(row.PartialCustomUrl, partialCustomUrl, StringComparison.OrdinalIgnoreCase) != 0))
                    {
                        throw new ConstraintException(Resources.CustomUrlProvider_CustomUrlAlreadyExists);
                    }

                    if (string.IsNullOrEmpty(fullCustomUrl))
                    {
                        fullCustomUrl = string.Empty;
                    }
                    if (string.IsNullOrEmpty(partialCustomUrl))
                    {
                        partialCustomUrl = string.Empty;
                    }

                    adapter.Update(customUrlId, fullCustomUrl, partialCustomUrl);

                    if (row.IsInstanceIdNull())
                    {
                        RemoveOrganizationCustomUrlFromCache(row.OrganizationId);
                    }
                    else
                    {
                        RemoveInstanceCustomUrlFromCache(row.InstanceId);
                    }
                }
            }
        }