Beispiel #1
0
        public bool Delete(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, params object[] keys)
        {
            var obj         = new HomaBO().Get(connectionHandler, keys);
            var homaAliasBo = new HomaAliasBO();
            var list        = homaAliasBo.Where(connectionHandler, x => x.CongressId == obj.Id);

            foreach (var homaAliase in list)
            {
                if (!homaAliasBo.Delete(connectionHandler, homaAliase.Id))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }
            if (!new HomaBO().Delete(connectionHandler, keys))
            {
                throw new Exception(Resources.Congress.ErrorInDeleteCongress);
            }
            var webSiteTransactionalFacade =
                StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler);


            var byFilter = webSiteTransactionalFacade.Where(x => x.OwnerId == obj.OwnerId);

            if (byFilter != null)
            {
                foreach (var webSite in byFilter)
                {
                    if (!webSiteTransactionalFacade.Delete(webSite.Id))
                    {
                        throw new Exception("خطایی در حذف آمار سایت وجود دارد");
                    }
                }
            }
            else
            {
                if (
                    !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                        enterpriseNodeConnectionconnectionHandler).Delete(obj.OwnerId))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        public Homa GetUrlHomaId(IConnectionHandler connectionHandler, string authority, string url)
        {
            if (url == "/")
            {
                url = string.Empty;
            }
            var encrypt          = StringUtils.Encrypt(authority.ToLower());
            var predicateBuilder = new PredicateBuilder <Homa>();

            predicateBuilder.Or(x => x.InstallPath == encrypt);
            var homas = new HomaAliasBO().Select(connectionHandler, x => x.CongressId, x => x.Url == encrypt);

            if (homas.Any())
            {
                predicateBuilder.Or(x => x.Id.In(homas));
            }
            var urlHomaId = this.Where(connectionHandler, predicateBuilder.GetExpression());

            var areaNames =
                RouteTable.Routes.OfType <Route>()
                .Where(d => d.DataTokens != null && d.DataTokens.ContainsKey("area"))
                .Select(r => r.DataTokens["area"]).ToList();
            Homa homa = null;

            if (string.IsNullOrEmpty(url) ||
                (areaNames.Any(areaname => url.ToLower().StartsWith("/" + areaname.ToString().ToLower()))))
            {
                homa = urlHomaId.FirstOrDefault(x => string.IsNullOrEmpty(x.VirtualDirectory));
            }
            else
            {
                foreach (var variable in urlHomaId.Where(x => !string.IsNullOrEmpty(x.VirtualDirectory)))
                {
                    if (!url.ToLower().Contains(variable.VirtualDirectory.ToLower()))
                    {
                        continue;
                    }
                    homa = variable;
                    break;
                }
            }


            return(FillHoma(connectionHandler, homa));
        }
Beispiel #3
0
        public bool Insert(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, Homa homa,
                           HttpPostedFileBase file, List <HomaAlias> homaAliases)
        {
            if (
                !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                    enterpriseNodeConnectionconnectionHandler)
                .Insert(homa.Owner, file))
            {
                throw new Exception("خطایی در ذخیره اطلاعات شخصی صاحب همایش وجود دارد");
            }
            homa.OwnerId = homa.Owner.Id;
            if (!this.Insert(connectionHandler, homa))
            {
                throw new Exception(Resources.Congress.ErrorInSaveCongress);
            }
            var homaAliasBo = new HomaAliasBO();

            foreach (var homaAliase in homaAliases)
            {
                homaAliase.CongressId = homa.Id;
                homaAliase.Homa       = homa;
                if (!homaAliasBo.Insert(connectionHandler, homaAliase))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }

            if (
                !StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler)
                .Modify(
                    StringUtils.Decrypt(homa.InstallPath) +
                    (string.IsNullOrEmpty(homa.VirtualDirectory) ? "" : homa.VirtualDirectory),
                    homa.CongressTitle, homa.OwnerId))
            {
                throw new Exception(Resources.Congress.ErrorInSaveCongress);
            }
            return(true);
        }
Beispiel #4
0
        public bool Update(IConnectionHandler connectionHandler,
                           IConnectionHandler enterpriseNodeConnectionconnectionHandler,
                           IConnectionHandler statisticConnectionconnectionHandler, Homa homa,

                           HttpPostedFileBase file, List <HomaAlias> homaAliases)
        {
            if (
                !EnterpriseNodeComponent.Instance.EnterpriseNodeTransactionalFacade(
                    enterpriseNodeConnectionconnectionHandler)
                .Update(homa.Owner, file))
            {
                return(false);
            }



            if (!new HomaBO().Update(connectionHandler, homa))
            {
                throw new Exception(Resources.Congress.ErrorInEditCongress);
            }
            var homaAliasBo = new HomaAliasBO();
            var list        = homaAliasBo.Where(connectionHandler, x => x.CongressId == homa.Id);

            foreach (var homaAliase in homaAliases)
            {
                var homaAlias = homaAliasBo.Get(connectionHandler, homaAliase.Id);
                if (homaAlias == null)
                {
                    homaAliase.CongressId = homa.Id;
                    homaAliase.Homa       = homa;
                    if (!homaAliasBo.Insert(connectionHandler, homaAliase))
                    {
                        throw new Exception(Resources.Congress.ErrorInSaveCongress);
                    }
                }
                else
                {
                    homaAliase.Homa = homa;
                    if (!homaAliasBo.Update(connectionHandler, homaAliase))
                    {
                        throw new Exception(Resources.Congress.ErrorInSaveCongress);
                    }
                }
            }
            foreach (var homaAliase in list)
            {
                if (homaAliases.Any(x => x.Id == homaAliase.Id))
                {
                    continue;
                }
                if (!homaAliasBo.Delete(connectionHandler, homaAliase.Id))
                {
                    throw new Exception(Resources.Congress.ErrorInSaveCongress);
                }
            }

            if (!StatisticComponents.Instance.WebSiteTransactionalFacade(statisticConnectionconnectionHandler)
                .Modify(StringUtils.Decrypt(homa.InstallPath), homa.CongressTitle, homa.OwnerId))
            {
                throw new Exception(Resources.Congress.ErrorInEditCongress);
            }
            return(true);
        }