예제 #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="AListenerBasePort">Base port to listen on.  The actual port used will be the first available one in a range of ports starting here</param>
        /// <param name="AGuiForm">The form that owns this class and handles messages</param>
        /// <param name="AWebSiteList">A list of WebSite objects that are to be reported to the Manager</param>
        public ServerManagerListener(Int32 AListenerBasePort, IOPWebServerManagerActions AGuiForm, WebSites AWebSiteList)
        {
            _listenerBasePort = AListenerBasePort;
            _guiForm = AGuiForm;

            _webSites = AWebSiteList;
        }
예제 #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            //read in the site info from the settings xml file
            _webSites = new WebSites();
            _webSites.Read(out _startAutomatically, out _hideAtStartup, out _allowRemoteConnections);

            // Create a listener for ServerManager messages
            _managerListener = new ServerManagerListener(Program.SERVER_MANAGER_BASE_PORT, this, _webSites);
            _managerListener.StartListening();

            // Create the help site and start the server unless another instance of the app has already done it
            _helpSite = Program.CreateHelpWebSite();

            if (!Program.PortIsInUse(_helpSite.Port, false) && (_helpSite.PhysicalPath != String.Empty))
            {
                _helpSite.WebServer = new Server(_helpSite.Port, _helpSite.VirtualPath, _helpSite.PhysicalPath, _helpSite.DefaultPage, false, false);
            }

            //Populate the list box and update the link label
            UpdateUI();

            //If we are set to start the servers automatically, do it now
            if (_startAutomatically)
            {
                toolStripStatusLabel.Text = StartOrStopAll(true);
            }
            else
            {
                //otherwise just update the tray icon text
                notifyIcon.Text = Program.ApplicationTitleAndVersion;
                notifyIcon.Text += "\r\nStopped";
            }
        }
예제 #3
0
        public CategoryMenuDTO GetRandomCategory(Langs l, WebSites w)
        {
            long   languageId = Utils.getLanguage(l);
            var    list       = unitOfWork.CategoryRepository.Get(c => true).AsEnumerable().Where(c => (long)getWebsite(c.Id) == (long)w);
            Random random     = new Random();
            long   seed       = random.Next();

            list = list.OrderBy(s => (~(s.Id & seed)) & (s.Id | seed)); // ^ seed);
            if (!list.Any())
            {
                return(null);
            }
            var first = list.First();

            Mapper.Initialize(cfg => cfg.CreateMap <Category, CategoryMenuDTO>()
                              .ForMember(dest => dest.EnglishName, opt =>
                                         opt.MapFrom(src => src.CategoryDescriptions.Where(dsc => dsc.LanguageId == (long)Langs.English).FirstOrDefault().Name)
                                         )
                              .ForMember(dest => dest.Name, opt =>
                                         opt.MapFrom(src => src.CategoryDescriptions.Where(dsc => dsc.LanguageId == (long)l).FirstOrDefault().Name))
                              .ForMember(dest => dest.ImageUrl, opt =>
                                         opt.MapFrom(src => src.ImageUrl ?? DefaultImages.Category)
                                         ).ForMember(dest => dest.Banner, opt =>
                                                     opt.MapFrom(src => src.Banner ?? DefaultImages.Banner)
                                                     )
                              );

            //CategoryMenuDTO menuCategoryDTO = Mapper.Map<Category, CategoryMenuDTO>(first);
            CategoryMenuDTO menuCategoryDTO = Mapper.Map <Category, CategoryMenuDTO>(first, opt =>
                                                                                     opt.AfterMap((src, dest) => dest.Name = src.CategoryDescriptions.Where(dsc => dsc.LanguageId == (long)l).FirstOrDefault().Name));

            return(menuCategoryDTO);
        }
        public static List <ScoringFunctionResult> GetRecentProducts(int count, WebSites webSite, AggregateFilter filters, ContentTypeQuota quota)
        {
            string      queryUniquestring;
            IMongoQuery query = GetQuery(webSite, quota, filters, out queryUniquestring);

            return(quota != null?GetRecentProductsWithQuery(query, quota.Id, count) : GetRecentProductsWithQuery(query, null, count));
        }
예제 #5
0
        public List <CategoryPathDTO> GetAllPathsByWebsite(WebSites website, Langs l)
        {
            List <CategoryPathDTO> paths = new List <CategoryPathDTO>();

            paths.AddRange(getSubPathCategories((long)website, l));
            return(paths);
        }
        public RebuildListForm(WebSites webSites)
        {
            InitializeComponent();
            InitializeDgv();

            AcceptButton = backButton;
            DialogResult = DialogResult.None;
            FormClosed  += RebuildListForm_FormClosed;

            _progressIndicator       = new Progress <KeyValuePair <string, KeyValuePair <string, int> > >(ReportProgress);
            _cancellationTokenSource = new CancellationTokenSource();
            _webSites = webSites;

            _webSites.GetNamesList("toRebuild").ForEach(name =>
            {
                var allCount = _webSites.GetWebSiteByName(name).DomainLists.HtmlFilesList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.ImgsList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.JsFilesList["available"].Count +
                               _webSites.GetWebSiteByName(name).DomainLists.CssFilesList["available"].Count;
                dashboardDgv.Rows.Add(name,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.HtmlFilesList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.ImgsList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.JsFilesList["available"].Count,
                                      0, _webSites.GetWebSiteByName(name).DomainLists.CssFilesList["available"].Count,
                                      0, allCount);
            });

            UpdateStatusCount(dashboardDgv.Rows.Count);

            previewButton.Enabled        = false;
            previewBrowserButton.Enabled = false;
            previewButton.Click         += previewButton_Click;
            previewBrowserButton.Click  += previewButton_Click;
        }
        void CreateWebSite()
        {
            var newWebSite = WebSiteViewModel.CreateNew(this.webSiteManager, this.mediator);

            WebSites.Add(newWebSite);
            SetActiveWebSite(newWebSite);
        }
        void ClearInvalidedWebSite()
        {
            var tobeRemoved = new List <WebSiteViewModel>();

            foreach (var webSite in WebSites)
            {
                if (!webSite.IsValid)
                {
                    tobeRemoved.Add(webSite);
                }
            }
            if (tobeRemoved.Count <= 0)
            {
                return;
            }
            if (MessageBox.Show($"Are you sure to clear the invalided websites? total:{tobeRemoved.Count}"
                                , "confirm"
                                , MessageBoxButton.YesNo
                                , MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                foreach (var viewModel in tobeRemoved)
                {
                    webSiteManager.Remove(viewModel.WebSiteId);
                    WebSites.Remove(viewModel);
                }
            }
        }
예제 #9
0
 public VideoInfo(Video video)
 {
     FileExtension = video.FileExtension;
     Format        = video.Format;
     FullName      = video.FullName;
     Title         = video.Title;
     WebSite       = video.WebSite;
 }
예제 #10
0
        public CategoryMenuDTO GetAll(Langs l, WebSites w)
        {
            CategoryMenuDTO ctmDTO = GetAll(l);

            ctmDTO.SubCategories =
                ctmDTO.SubCategories.AsEnumerable().Where(c => c.Id == (long)w).FirstOrDefault().SubCategories;
            return(ctmDTO);
        }
예제 #11
0
        /// <summary>
        /// Constructor
        /// </summary>
        public SitePropertiesDialog(OpenMode mode, WebSites Sites, string ActiveSiteKey)
        {
            _openMode = mode;
            _webSites = Sites;
            _activeSitekey = ActiveSiteKey;

            InitializeComponent();
        }
        public RebuiltForm(WebSites webSites)
        {
            InitializeComponent();
            InitializeGrid();
            statusLabel.Text = string.Empty;

            _webSites = webSites;

            FillGrid();
        }
예제 #13
0
        /// <summary>
        /// 编辑站点数据
        /// </summary>
        /// <param name="model">站点实体</param>
        /// <returns></returns>
        public static int Edit(WebSites model)
        {
            string strSql = string.Format
                                (@"UPDATE WebSites SET Name='{1}', WebUrl='{2}', ContentName='{3}', HeaderName='{4}', NextName='{5}'
                , NextTitle='{6}', Valid='{7}', UrlCombine='{8}', Encoding='{9}' WHERE (Id = '{0}');"
                                , model.Id, model.Name, model.WebUrl, model.ContentName, model.HeaderName, model.NextName
                                , model.NextTitle, model.Valid, model.UrlCombine, model.Encoding);

            return(DbHelperSql.ExecuteSql(strSql));
        }
예제 #14
0
        /// <summary>
        /// 添加站点数据
        /// </summary>
        /// <remarks>创建人:李海玉   创建时间:2018-06-02</remarks>
        /// <param name="model">站点实体</param>
        /// <returns></returns>
        public static int Add(WebSites model)
        {
            string strSql = string.Format
                                (@"INSERT INTO WebSites
                    (Name, WebUrl, ContentName, HeaderName, NextName, NextTitle, Valid, UrlCombine, Encoding) 
                    VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}');"
                                , model.Name, model.WebUrl, model.ContentName, model.HeaderName, model.NextName
                                , model.NextTitle, model.Valid, model.UrlCombine, model.Encoding);

            return(DbHelperSql.ExecuteSql(strSql));
        }
        public List <DesignerDTO> GetAllDesigners(WebSites w)
        {
            List <DesignerDTO> designerDtos = new List <DesignerDTO>();
            var designers = unitOfWork.DesignerRepository.Get(c => c.Products.Any()).AsEnumerable().Where(c => (long)getWebsite(c.Id) == (long)w).ToList();

            foreach (var designer in designers)
            {
                designerDtos.Add(GetDesigner(designer.Descriptions.FirstOrDefault(d => d.LanguageId == (long)Langs.English).Text, Langs.English));
            }
            return(designerDtos);
        }
        void SetActiveWebSite(WebSiteViewModel webSite)
        {
            Debug.Assert(WebSites.Contains(webSite));

            ICollectionView collectionView = CollectionViewSource.GetDefaultView(WebSites);

            if (collectionView != null)
            {
                collectionView.MoveCurrentTo(webSite);
            }
        }
        public void GenerateWeb()
        {
            WebSites w = new WebSites();

            w.SourceName = ((Book)rand.Next(0, 5)).ToString();
            w.AuthorName = ((Author)rand.Next(0, 5)).ToString();
            w.Link       = ((Link)rand.Next(0, 5)).ToString();
            w.Annotation = "Not available";

            pub.Add(w);
        }
예제 #18
0
        public CategoryMenuDTO GetLatestCategory(Langs l, WebSites w)
        {
            var category = unitOfWork.ProductRepository.Get(c => c.Status && c.Id > 3)
                           .AsEnumerable().Where(c => (long)getWebsite(c.CategoryId) == (long)w)
                           .OrderByDescending(c => c.DateAdded).FirstOrDefault();

            if (category == null)
            {
                return(null);
            }
            return(GetCategory(category.CategoryId, l));
        }
예제 #19
0
        public List <ProductDTO> GetLatestProducts(Langs l, Currency c, WebSites w)
        {
            List <long> productIds = unitOfWork.ProductRepository.Get(cc => true).AsEnumerable()
                                     .Where(cc => (long)_categoryService.getWebsite(cc.CategoryId) == (long)w)
                                     .OrderByDescending(cc => cc.DateAdded).Select(cc => cc.Id).ToList();
            List <ProductDTO> products = new List <ProductDTO>();

            for (int i = 0; i < Math.Min(productIds.Count, 8); i++)
            {
                products.Add(GetProduct(productIds[i], l, c));
            }
            return(products);
        }
        private static IMongoQuery GetQuery(WebSites webSite, ContentTypeQuota quota, AggregateFilter filters, out string queryUniqueString)
        {
            IMongoQuery        query   = null;
            List <IMongoQuery> queries = new List <IMongoQuery>();
            StringBuilder      sb      = new StringBuilder("w" + ((int)webSite).ToString());

            if (quota != null)
            {
                sb.Append("q" + quota.Id.ToString());
                foreach (var filter in quota.Values.Values)
                {
                    queries.Add(Query.EQ(filter.MongoName, GetFilterValue(filter.Value, filter.IsString)));
                    Log.Debug("ProductDataAccess.GetQuery", "quota filter", queries.Last());
                }
            }

            if (filters != null && filters.Filters != null)
            {
                //TODO Replace GetHashCode and Fibonacci approach by other way
                string filterStr = filters.ToString();
                sb.Append(filterStr.GetHashCode());
                for (int i = 0; i < Fibonacci.Length; i++)
                {
                    if (filterStr.Length < Fibonacci[i])
                    {
                        sb.Append(filterStr[Fibonacci[i]]);
                    }
                    else
                    {
                        break;
                    }
                }

                queries.AddRange(GetFilterQuery(filters));
            }

            queryUniqueString = sb.ToString();
            Log.Debug("ProductDataAccess.GetQuery", "queryUniqueString", queryUniqueString);

            // only active products
            queries.Add(Query.EQ("ItemStatus", 1));

            // final query
            var webSiteId = (int)webSite;

            queries.Add(Query.EQ(WebSiteIdField, new BsonInt32(webSiteId)));
            query = Query.And(queries);
            Log.Debug("ProductDataAccess.GetQuery", "Final query", query.ToJson());
            return(query);
        }
        private async void InitializeWebSites()
        {
            rebuiltToolStripMenuItem.Enabled = false;
            checkButton.Enabled = false;
            statusLabel.Text    = @"Check for rebuilt websites...";

            _webSites = new WebSites();
            await Task.Run(() => _webSites.CheckForRebuiltWebSitesAsync());

            rebuiltToolStripMenuItem.Enabled = true;
            checkButton.Enabled = true;
            var count = _webSites.Lists.ContainsKey("rebuilt") ? _webSites.Lists["rebuilt"].Count : 0;

            statusLabel.Text = @"You have " + count + (count == 1 ? @" rebuilt website." : @" rebuilt websites.");
        }
        public static List <ScoringFunctionResult> GetRandomProducts(int count, WebSites webSite, AggregateFilter filters, ContentTypeQuota quota)
        {
            Log.Debug("ProductDataAccess.GetRandomItems", "parameters", count, webSite);
            string queryUniquestring;

            IMongoQuery       query = GetQuery(webSite, quota, filters, out queryUniquestring);
            RedisSet <string> cache = GetRedisSet(query, queryUniquestring);
            var set = cache.GetRandomItems(count, x => x);

            return(quota != null?set.Select(sfr => new ScoringFunctionResult()
            {
                ItemId = int.Parse(sfr), QuotaId = quota.Id
            }).ToList() : set.Select(sfr => new ScoringFunctionResult()
            {
                ItemId = int.Parse(sfr)
            }).ToList());
        }
        void ConnectClick(object Sender, RoutedEventArgs e)
        {
            SetPassword();
            blogger = Utils.InitializeBlogger(ProviderInfo);
            IEnumerable <BlogInfo> blogs = blogger.GetUsersBlogs();

            if (blogs == null)
            {
                return;
            }
            WebSites.Clear();
            foreach (BlogInfo blog in blogs)
            {
                WebSites.Add(blog);
            }
            BlogsLoaded = true;
        }
예제 #24
0
        public List <SlideDTO> GetSlidesByWebSite(WebSites website)
        {
            var slides = _unitOfWork.SlideRepository.Get(c => c.WebSite == (long)website).ToList();

            var slidesDtos = new List <SlideDTO>();

            foreach (var slide in slides)
            {
                var slideDto = new SlideDTO();
                slideDto.Id       = slide.Id;
                slideDto.ImageUrl = slide.ImageUrl;
                slideDto.Url      = slide.Url;
                slideDto.WebSite  = website;
                slidesDtos.Add(slideDto);
            }

            return(slidesDtos);
        }
예제 #25
0
        public MainPageProductsDTO GetMainPageProducts(Langs l, Currency currency, WebSites w)
        {
            MainPageProductsDTO mainPageProductsDTO = new MainPageProductsDTO();

            mainPageProductsDTO.MainCategories = _categoryService.GetRandomCategories(l, w).AsEnumerable()
                                                 .Where(c => GetRandomFive(GetCategoryProducts(c.Id, l, currency)).Count >= 5).Take(3).ToList();


            foreach (var categoryMenuDto in mainPageProductsDTO.MainCategories)
            {
                var products = GetRandomFive(GetCategoryProducts(categoryMenuDto.Id, l, currency));
                mainPageProductsDTO.Products.Add(products);
            }
            //mainPageProductsDTO.Women = GetRandomFive(GetCategoryProducts((long)BaseCategories.Women, l, currency));
            //mainPageProductsDTO.Men = GetRandomFive(GetCategoryProducts((long)BaseCategories.Men, l, currency));
            //mainPageProductsDTO.Babe = GetRandomFive(GetCategoryProducts((long)BaseCategories.Babe, l, currency));
            return(mainPageProductsDTO);
        }
예제 #26
0
        public List <CategoryMenuDTO> GetRandomCategories(Langs l, WebSites w)
        {
            List <long>            ids  = unitOfWork.CategoryRepository.Get(c => true).Select(c => c.Id).ToList();
            List <CategoryMenuDTO> list = new List <CategoryMenuDTO>();

            foreach (var id in ids)
            {
                if (unitOfWork.CategoryRepository.Get(c => c.ParentId == id).Count() == 0 &&
                    (long)getWebsite(id) == (long)w)
                {
                    list.Add(GetCategory(id, l));
                }
            }

            Random random = new Random();
            int    seed   = random.Next();

            list = list.OrderBy(s => (~(s.Id & seed)) & (s.Id | seed)).ToList(); // ^ seed);

            //return list.Take(Math.Min(list.Count,3)).ToList();
            return(list);
        }
예제 #27
0
 public List <CategoryManegerDTO> GetAllManegerCategories(Sorts sb, WebSites w)
 {
     return(GetAllManegerCategories(sb).AsEnumerable().Where(c => (long)getWebsite(c.Id) == (long)w).ToList());
 }
예제 #28
0
        /// <summary>
        /// Update/create bindings for all host names in the certificate
        /// </summary>
        /// <param name="target"></param>
        /// <param name="flags"></param>
        /// <param name="thumbprint"></param>
        /// <param name="store"></param>
        public void AddOrUpdateBindings(Target target, SSLFlags flags, CertificateInfo newCertificate, CertificateInfo oldCertificate)
        {
            try
            {
                var allBindings = WebSites.
                                  SelectMany(site => site.Bindings, (site, binding) => new { site, binding }).
                                  ToList();

                var bindingsUpdated = 0;
                var found           = new List <string>();
                var oldThumbprint   = oldCertificate?.Certificate?.GetCertHash();
                if (oldThumbprint != null)
                {
                    var siteBindings = allBindings.
                                       Where(sb => StructuralComparisons.StructuralEqualityComparer.Equals(sb.binding.CertificateHash, oldThumbprint)).
                                       ToList();

                    // Update all bindings created using the previous certificate
                    foreach (var sb in siteBindings)
                    {
                        try
                        {
                            UpdateBinding(sb.site,
                                          sb.binding,
                                          flags,
                                          newCertificate.Certificate.GetCertHash(),
                                          newCertificate.Store?.Name);
                            found.Add(sb.binding.Host);
                            bindingsUpdated += 1;
                        }
                        catch (Exception ex)
                        {
                            _log.Error(ex, "Error updating binding {host}", sb.binding.BindingInformation);
                            throw;
                        }
                    }
                }

                // Find all hostnames which are not covered by any of the already updated
                // bindings yet, because we will want to make sure that those are accessable
                // in the target site
                var targetSite            = GetWebSite(target.InstallationSiteId ?? target.TargetSiteId ?? -1);
                IEnumerable <string> todo = target.GetHosts(true);
                while (todo.Count() > 0)
                {
                    // Filter by previously matched bindings
                    todo = todo.Where(host => !found.Any(binding => Fits(binding, host, flags) > 0));
                    if (todo.Count() > 0)
                    {
                        var current = todo.First();
                        try
                        {
                            var binding = AddOrUpdateBindings(
                                targetSite,
                                current,
                                flags,
                                newCertificate.Certificate.GetCertHash(),
                                newCertificate.Store?.Name,
                                target.SSLPort,
                                true);

                            // Allow a single newly created binding to match with
                            // multiple hostnames on the todo list, e.g. the *.example.com binding
                            // matches with both a.example.com and b.example.com
                            found.Add(binding);
                            bindingsUpdated += 1;
                        }
                        catch (Exception ex)
                        {
                            _log.Error(ex, "Error creating binding {host}: {ex}", current, ex.Message);

                            // Prevent infinite retry loop, we just skip the domain when
                            // an error happens creating a new binding for it. User can
                            // always change/add the bindings manually after all.
                            found.Add(current);
                        }
                    }
                }

                if (bindingsUpdated > 0)
                {
                    _log.Information("Committing {count} {type} binding changes to IIS", bindingsUpdated, "https");
                    Commit();
                    _log.Information("IIS will serve the new certificates after the Application Pool IdleTimeout has been reached.");
                }
                else
                {
                    _log.Warning("No bindings have been changed");
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error installing");
                throw;
            }
        }
예제 #29
0
        /// <summary>
        /// Update/create bindings for all host names in the certificate
        /// </summary>
        /// <param name="target"></param>
        /// <param name="flags"></param>
        /// <param name="thumbprint"></param>
        /// <param name="store"></param>
        public void AddOrUpdateBindings(IEnumerable <string> identifiers, BindingOptions bindingOptions, byte[] oldThumbprint)
        {
            // Helper function to get updated sites
            IEnumerable <(IISSiteWrapper site, Binding binding)> GetAllSites() => WebSites.
            SelectMany(site => site.Site.Bindings, (site, binding) => (site, binding)).
            ToList();

            try
            {
                var allBindings     = GetAllSites();
                var bindingsUpdated = 0;
                var found           = new List <string>();
                if (oldThumbprint != null)
                {
                    var siteBindings = allBindings.
                                       Where(sb => StructuralComparisons.StructuralEqualityComparer.Equals(sb.binding.CertificateHash, oldThumbprint)).
                                       ToList();

                    // Update all bindings created using the previous certificate
                    foreach (var(site, binding) in siteBindings)
                    {
                        try
                        {
                            UpdateBinding(site.Site, binding, bindingOptions);
                            found.Add(binding.Host);
                            bindingsUpdated += 1;
                        }
                        catch (Exception ex)
                        {
                            _log.Error(ex, "Error updating binding {host}", binding.BindingInformation);
                            throw;
                        }
                    }
                }

                // Find all hostnames which are not covered by any of the already updated
                // bindings yet, because we will want to make sure that those are accessable
                // in the target site
                var targetSite            = GetWebSite(bindingOptions.SiteId ?? -1);
                IEnumerable <string> todo = identifiers;
                while (todo.Any())
                {
                    // Filter by previously matched bindings
                    todo = todo.Where(cert => !found.Any(iis => Fits(iis, cert, bindingOptions.Flags) > 0));
                    if (!todo.Any())
                    {
                        break;
                    }

                    allBindings = GetAllSites();
                    var current = todo.First();
                    try
                    {
                        var binding = AddOrUpdateBindings(
                            allBindings.Select(x => x.binding).ToArray(),
                            targetSite,
                            bindingOptions.WithHost(current),
                            !bindingOptions.Flags.HasFlag(SSLFlags.CentralSSL));

                        // Allow a single newly created binding to match with
                        // multiple hostnames on the todo list, e.g. the *.example.com binding
                        // matches with both a.example.com and b.example.com
                        if (binding == null)
                        {
                            // We were unable to create the binding because it would
                            // lead to a duplicate. Pretend that we did add it to
                            // still be able to get out of the loop;
                            found.Add(current);
                        }
                        else
                        {
                            found.Add(binding);
                            bindingsUpdated += 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        _log.Error(ex, "Error creating binding {host}: {ex}", current, ex.Message);

                        // Prevent infinite retry loop, we just skip the domain when
                        // an error happens creating a new binding for it. User can
                        // always change/add the bindings manually after all.
                        found.Add(current);
                    }
                }

                if (bindingsUpdated > 0)
                {
                    _log.Information("Committing {count} {type} binding changes to IIS", bindingsUpdated, "https");
                    Commit();
                }
                else
                {
                    _log.Warning("No bindings have been changed");
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error installing");
                throw;
            }
        }
예제 #30
0
 public List <CategoryPathDTO> GetAllPaths(Langs l, WebSites w)
 {
     return(GetAllPaths(l).AsEnumerable().Where(c => (long)getWebsite(c.CategoryId) == (long)w).ToList());
 }
        public List <ProductDTO> FilterByName(string prefix, long categoryId, Langs l, Currency currency, WebSites w)
        {
            List <long> productIds = new List <long>();

            if (categoryId > 0)
            {
                productIds = unitOfWork.ProductRepository.Get(op => op.Status == true && ((op.CategoryId == categoryId) ||
                                                                                          (op.Category.ParentId != null &&
                                                                                           op.Category.ParentId == categoryId) ||
                                                                                          (op.Category.ParentId != null &&
                                                                                           op.Category.ParentCategory.ParentId != null &&
                                                                                           op.Category.ParentCategory.ParentId == categoryId)))
                             .AsEnumerable().Where(p => _categoryService.getWebsite(p.CategoryId) == w)
                             .Select(c => c.Id)
                             .ToList();
                ;
            }
            List <long> productNameIds =
                unitOfWork.ProductDescriptionRepository.Get(
                    pd => pd.Name.ToLower().Contains(prefix.ToLower()) && pd.LanguageId == (long)l)
                .AsEnumerable().Where(p => _categoryService.getWebsite(p.Product.CategoryId) == w)
                .Select(pd => pd.ProductId).ToList();

            if (categoryId > 0)
            {
                productIds = productIds.Intersect(productNameIds).ToList();
            }
            else
            {
                productIds = productNameIds;
            }
            List <ProductDTO> products = new List <ProductDTO>();

            for (int i = 0; i < productIds.Count; i++)
            {
                ProductDTO dto = productService.GetProduct(productIds[i], l, currency);
                if (dto != null)
                {
                    products.Add(dto);
                }
            }

            return(products);
        }
예제 #32
0
 public static WebSiteFactory GetInstance(WebSites web)
 {
     return GetInstance(web.GetValue());
 }
예제 #33
0
 /// <summary>
 /// 编辑站点数据
 /// </summary>
 /// <param name="model">站点实体</param>
 /// <returns></returns>
 public int Edit(WebSites model)
 {
     return(WebDal.Edit(model));
 }
예제 #34
0
        /// <summary>
        /// This is the constructor that is used when command line parameters are used
        /// </summary>
        /// <param name="PhysicalPath"></param>
        /// <param name="VirtualPath"></param>
        /// <param name="Port"></param>
        /// <param name="DefaultPage"></param>
        /// <param name="AllowRemoteConnection"></param>
        /// <param name="LogPageRequests"></param>
        public SmallUIForm(string PhysicalPath, string VirtualPath, int Port, string DefaultPage, bool AllowRemoteConnection, bool LogPageRequests)
        {
            InitializeComponent();

            _webSite.PhysicalPath = PhysicalPath;
            _webSite.VirtualPath = VirtualPath;
            _webSite.Port = Port;
            _webSite.DefaultPage = DefaultPage;
            _webSite.LogPageRequests = LogPageRequests;

            _allowRemoteConnection = AllowRemoteConnection;

            txtPhysicalPath.Text = _webSite.PhysicalPath;
            txtVirtualPath.Text = _webSite.VirtualPath.Substring(1);
            txtPortNumber.Text = _webSite.Port.ToString();
            txtDefaultPage.Text = _webSite.DefaultPage;

            linkLabel.Text = _webSite.Url;
            chkAllowRemoteConnection.Checked = _allowRemoteConnection;
            chkLogPageRequests.Checked = _webSite.LogPageRequests;

            // Create a listener for ServerManager messages
            _webSites = new WebSites();
            _webSites.Add("FormSite", _webSite);
            _managerListener = new ServerManagerListener(Program.SERVER_MANAGER_BASE_PORT, this, _webSites);
            _managerListener.StartListening();

            // Create the help site and start the server unless another instance of the app has already done it
            _helpSite = Program.CreateHelpWebSite();

            if (!Program.PortIsInUse(_helpSite.Port, false) && (_helpSite.PhysicalPath != String.Empty))
            {
                _helpSite.WebServer = new Server(_helpSite.Port, _helpSite.VirtualPath, _helpSite.PhysicalPath, _helpSite.DefaultPage, false, false);
            }

            // Set the main window title
            this.Text = String.Format("{0} [{1}]", Program.ApplicationTitle, _webSite.Port.ToString());
        }
예제 #35
0
        public List <CategoryManegerDTO> Filter(string arabicName, string englishName, bool?status, WebSites w, long id, DateTime?dateAdded, DateTime?dateModefied, Sorts s)
        {
            List <long> categoryIds = unitOfWork.CategoryRepository.Get(c => true).AsEnumerable().Where(c => getWebsite(c.Id) == w).Select(c => c.Id).ToList();

            if (!String.IsNullOrEmpty(arabicName))
            {
                FilterName(ref categoryIds, arabicName, Langs.Arabic);
            }
            if (!String.IsNullOrEmpty(englishName))
            {
                FilterName(ref categoryIds, englishName, Langs.English);
            }
            if (status != null)
            {
                FilterStatus(ref categoryIds, status.Value);
            }
            if (id != null && id != 0)
            {
                FilterId(ref categoryIds, id);
            }

            if (dateAdded != null)
            {
                FilterDate(ref categoryIds, dateAdded.Value, true);
            }
            if (dateModefied != null)
            {
                FilterDate(ref categoryIds, dateModefied.Value, false);
            }


            List <CategoryManegerDTO> categories = new List <CategoryManegerDTO>();

            for (int i = 0; i < categoryIds.Count; i++)
            {
                categories.Add(GetCategoryManagerById(categoryIds[i]));
            }
            sortCategories(ref categories, s);
            return(categories);
        }