Exemple #1
0
 private void GetAdvertisments(SiteSetting siteSetting, ref List <Server.Entities.Advertisment> advertisments)
 {
     WriteLog("Start crawling from " + Environment.NewLine +
              siteSetting.name);
     CrawlAdvertisements(siteSetting, ref advertisments);
     WriteLog("Crawled all advertisments.");
 }
 public virtual ActionResult SiteSettings(SiteSetting model)
 {
     if (!ModelState.IsValid)
         return View(model);
     _siteSettingService.Save(model);
     return Json(new { MessageType = 1, MessageContent = "设置成功!" });
 }
Exemple #3
0
    private decimal?CrawlPrice(string advertismentText, SiteSetting siteSetting)
    {
        if (!string.IsNullOrEmpty(advertismentText))
        {
            string pricesRegexList = Settings.getPricesFormatsRegexTemplate();
            var    parsingRegex    = new Regex(pricesRegexList);

            var           matchCollection = parsingRegex.Matches(advertismentText);
            List <string> matchedPrices   =
                (from Match match in matchCollection
                 select match.Value).ToList();

            var     decimalRegex = new Regex(@"\d+");
            decimal price;
            foreach (string matchedPrice in matchedPrices)
            {
                Match decimalPriceMatch = decimalRegex.Match(matchedPrice.Replace(".", ""));
                if (decimal.TryParse(decimalPriceMatch.Value, out price))
                {
                    return(price);
                }
            }
        }

        return(null);
    }
Exemple #4
0
    private List <string> CrawlPhotos(HtmlNode advertismentContainerNode, SiteSetting siteSetting)
    {
        var imageUrls = new List <string>();

        var imagesList = advertismentContainerNode.Descendants("img").Where(img => img.Attributes["src"] != null);

        foreach (var image in imagesList)
        {
            if (settingsPhotosUrlsForRemoving != null &&
                (settingsPhotosUrlsForRemoving.Contains(image.Attributes["src"].Value) ||
                 image.Attributes["src"].Value.Contains(".gif")))
            {
                continue;
            }

            string sourceImageUrl;
            if (!image.Attributes["src"].Value.Contains("http://") &&
                !string.IsNullOrEmpty(siteSetting.containerListCurrentAdvUrlHost))
            {
                sourceImageUrl = siteSetting.containerListCurrentAdvUrlHost + image.Attributes["src"].Value;
            }
            else
            {
                sourceImageUrl = image.Attributes["src"].Value;
            }

            string siteImageUrl = sourceImageUrl;
            //SavePhotoToFTP(sourceImageUrl);
            image.Attributes["src"].Value = siteImageUrl;
            imageUrls.Add(siteImageUrl);
        }

        return(imageUrls);
    }
Exemple #5
0
    private List <string> GetRedirectListUrls(string listPageUrl, SiteSetting siteSetting)
    {
        var resultUrls = new List <string>();

        var    request     = (HttpWebRequest)WebRequest.Create(listPageUrl);
        Stream stream      = request.GetResponse().GetResponseStream();
        var    parsingPage = new HtmlDocument();

        parsingPage.Load(stream, Encoding.GetEncoding(siteSetting.encodingName));

        HtmlNodeCollection urlsContainers = parsingPage
                                            .DocumentNode
                                            .SelectNodes(siteSetting.containerListCurrentAdvUrl);

        if (urlsContainers != null)
        {
            foreach (HtmlNode urlContainer in urlsContainers)
            {
                if (urlContainer.Attributes["href"] != null)
                {
                    if (!string.IsNullOrEmpty(siteSetting.containerListCurrentAdvUrlHost))
                    {
                        resultUrls.Add(siteSetting.containerListCurrentAdvUrlHost + urlContainer.Attributes["href"].Value);
                    }
                    else
                    {
                        resultUrls.Add(urlContainer.Attributes["href"].Value);
                    }
                }
            }
        }

        return(resultUrls);
    }
        void callback(object args, DateTime dateTime)
        {
            object[]    arguments           = args as object[];
            SiteSetting siteSetting         = arguments[0] as SiteSetting;
            Folder      folder              = arguments[1] as Folder;
            ComboBox    ContentTypeComboBox = arguments[2] as ComboBox;

            IServiceManager    serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType);
            List <ContentType> contentTypes   = serviceManager.GetContentTypes(siteSetting, this.SelectedFolder, false);

            ContentTypeComboBox.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                ContentTypeComboBox.Items.Clear();
                foreach (ContentType contentType in contentTypes)
                {
                    ContentTypeComboBox.Items.Add(new { Name = contentType.Name, ID = contentType.ID });
                }

                if (ContentTypeComboBox.Items.Count > 0)
                {
                    if (string.IsNullOrEmpty(this.SelectedContentTypeID) == true)
                    {
                        ContentTypeComboBox.SelectedIndex = 0;
                    }
                    else
                    {
                        ContentTypeComboBox.SelectedValue = this.SelectedContentTypeID;
                    }
                }
                this.HideLoadingStatus("Ready");
            }));
        }
Exemple #7
0
        private void SelectLocationButton_Click(object sender, RoutedEventArgs e)
        {
            ExplorerLocation explorerLocation = (ExplorerLocation)this.Tag;
            SiteSetting      siteSetting      = (SiteSetting)SiteSettingComboBox.SelectedItem;
            Folder           rootFolder       = null;

            SiteContentSelections siteContentSelections = new SiteContentSelections();

            if (explorerLocation.Folder == null)
            {
                rootFolder = new SPWeb(siteSetting.Url, siteSetting.Url, siteSetting.ID, String.Empty, siteSetting.Url, siteSetting.Url);
                rootFolder.PublicFolder = true;
                //siteContentSelections.InitializeForm(siteSetting, rootFolder, false, null);
                siteContentSelections.InitializeForm(siteSetting, rootFolder, true, null);

                if (siteContentSelections.ShowDialog(this.ParentWindow, Languages.Translate("Site Content Selections")) == true)
                {
                    explorerLocation.Folder = siteContentSelections.SelectedFolder;
                    explorerLocation.BasicFolderDefinition = explorerLocation.Folder.GetBasicFolderDefinition();
                }
            }
            else
            {
                rootFolder = explorerLocation.Folder;
                //siteContentSelections.InitializeForm(siteSetting, rootFolder, false, null);
                siteContentSelections.InitializeForm(siteSetting, rootFolder, true, null);

                if (siteContentSelections.ShowDialog(this.ParentWindow, Languages.Translate("Site Content Selections")) == true)
                {
                    explorerLocation.Folder = siteContentSelections.SelectedFolder;
                    explorerLocation.BasicFolderDefinition = explorerLocation.Folder.GetBasicFolderDefinition();
                }
            }
        }
Exemple #8
0
    protected void BindData()
    {
        int pageIndex = GetUrlInt("p");

        if (pageIndex <= 0)
        {
            pageIndex = 1;
        }
        WebPager pager = SiteSetting.CreateWebPagerForGridView(gvData, pageIndex);

        pager.PageCSSName = "NotShowPage";
        pager.PageSize    = 10000;

        WebQuery query = new WebQuery();

        query.Fields        = OrderDetailInfo.AllFields;
        query.OrderBy       = "ID";
        query.PrimaryKey    = OrderDetailInfo.TablePrimaryKey;
        query.SqlCreateType = ControlSqlCreateType.RowNum;
        query.TableName     = OrderDetailInfo.TableOrViewName;
        query.Condition     = "AddMemberName='" + CurrentMember.UserName + "' And OrderNum='" + OrderNum + "'";

        gvData.Db    = TMS.Db.Helper;
        gvData.Query = query;
        gvData.CreateDataSource();
        gvData.DataBind();
    }
Exemple #9
0
        /// -------------------------------------------------------------------------------------------------
        /// <summary>
        ///     Saves the settings.
        /// </summary>
        /// <param name="config">
        ///     The config.
        /// </param>
        /// -------------------------------------------------------------------------------------------------

        public void SaveConfig(Config config = null)
        {
            if (config != null)
            {
                this.currentConfig = config;
            }

            using (SqlConfigContext configContext = new SqlConfigContext(this.nameOrConnectionString))
            {
                Dictionary <string, SiteSetting> settings = configContext.SiteSettings.Where(x => x.Name.StartsWith("Config.")).ToDictionary(x => x.Name, x => x);

                foreach (var property in Properties)
                {
                    string[]    propertyAccessors = property.Key.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries);
                    SiteSetting setting;
                    if (!settings.ContainsKey(property.Key))
                    {
                        setting      = new SiteSetting();
                        setting.Name = property.Key;
                        configContext.SiteSettings.Add(setting);
                    }
                    else
                    {
                        setting = settings[property.Key];
                    }

                    string propertyValue = SqlConfigProvider.GetPropertyValue(this.currentConfig, propertyAccessors.Skip(1).ToList());

                    setting.Value = string.IsNullOrWhiteSpace(propertyValue) ? string.Empty : propertyValue;
                }

                configContext.SaveChanges();
            }
        }
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            BreadcrumbItem selectedItem = bar.SelectedItem as BreadcrumbItem;

            if (selectedItem == null)
            {
                return;
            }

            Folder folder = null;

            selectedItem.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                folder = selectedItem.Tag as Folder;
            }));
            if (folder == null || folder.CanUpload() == false)
            {
                MessageBox.Show(Languages.Translate("Please select a folder or a library or a list (attachment enabled)"));
                return;
            }

            SiteSetting siteSetting = ConfigurationManager.GetInstance().GetSiteSetting(folder.SiteSettingID);

            FoldersManager.EditItemPropertyMappings(siteSetting, folder);
        }
Exemple #11
0
        protected void ParentWindow_OKButtonSelected(object sender, EventArgs e)
        {
            ExplorerLocation explorerLocation = (ExplorerLocation)this.Tag;

            explorerLocation.SiteSettingID           = (Guid)SiteSettingComboBox.SelectedValue;
            explorerLocation.AllowToSelectSubfolders = AllowToSelectSubFoldersCheckBox.IsChecked.Value;
            explorerLocation.ShowAll          = ShowAllRadioButton.IsChecked == true ? true : false;
            explorerLocation.ApplicationTypes = new List <ApplicationTypes>();
            if (GeneralATCheckBox.IsChecked == true)
            {
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.General);
            }
            if (WordATCheckBox.IsChecked == true)
            {
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Word);
            }
            if (ExcelATCheckBox.IsChecked == true)
            {
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Excel);
            }
            if (OutlookATCheckBox.IsChecked == true)
            {
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Outlook);
            }

            if (explorerLocation.ShowAll == true)
            {
                SiteSetting siteSetting = (SiteSetting)SiteSettingComboBox.SelectedItem;
                explorerLocation.Folder = new SPWeb(siteSetting.Url, siteSetting.Url, siteSetting.ID, String.Empty, siteSetting.Url, siteSetting.Url);
                explorerLocation.BasicFolderDefinition = explorerLocation.Folder.GetBasicFolderDefinition();
                explorerLocation.Folder.Selected       = true;
            }
        }
        private void SelectLocationButton_Click(object sender, RoutedEventArgs e)
        {
            TaskListLocation workflowLocation = (TaskListLocation)this.Tag;

            SiteSetting siteSetting = (SiteSetting)SiteSettingComboBox.SelectedItem;
            Folder      rootFolder  = null;


            SiteContentSelections siteContentSelections = new SiteContentSelections();

            rootFolder = new SPWeb(siteSetting.Url, siteSetting.Url, siteSetting.ID, String.Empty, siteSetting.Url, siteSetting.Url);
            rootFolder.PublicFolder = true;
            siteContentSelections.InitializeForm(siteSetting, rootFolder, true, new int[] { 107 });

            if (siteContentSelections.ShowDialog(this.ParentWindow, "Site Content Selections") == true)
            {
                workflowLocation.Folder = siteContentSelections.SelectedFolder;
                workflowLocation.BasicFolderDefinition = workflowLocation.Folder.GetBasicFolderDefinition();
                SelectedFolderLabel.Content            = workflowLocation.Folder.GetUrl();
            }
            //    if (workflowLocation.Folder == null)
            //    {
            //    }
            //else
            //{
            //    rootFolder = workflowLocation.Folder;
            //    siteContentSelections.InitializeForm(siteSetting, rootFolder, true, new int[] { 107 });
            //    if (siteContentSelections.ShowDialog(this.ParentWindow, "Site Content Selections") == true)
            //    {
            //        workflowLocation.Folder = siteContentSelections.SelectedFolder;
            //        workflowLocation.BasicFolderDefinition = workflowLocation.Folder.GetBasicFolderDefinition();
            //        SelectedFolderLabel.Content = workflowLocation.Folder.GetUrl();
            //    }
            //}
        }
Exemple #13
0
        public void Initialize(SiteSetting siteSetting, List <Folder> dataSource, int[] includedFolderTypes)
        {
            SiteSettings siteSettings = new SiteSettings();

            siteSettings.Add(siteSetting);
            this.Initialize(siteSettings, dataSource, includedFolderTypes);
        }
        public ActionResult Index()
        {
            List <Content> faaliyetler;

            using (var db = new EF_CONTEXT())
            {
                var settingEnum = SettingsENUM.HOMEPAGE_SHOW_CONTENT_LIMITATION.ToString();
                var setting     = db.SiteSettings.FirstOrDefault(s => s.ENUM == settingEnum);
                if (setting == null)
                {
                    setting = new SiteSetting()
                    {
                        Value = 24.ToString()
                    };
                }

                var limitation = int.Parse(setting.Value);
                faaliyetler = db.Contents
                              .Where(e => !e.CID.EndsWith("e"))

                              .OrderByDescending(e => e.On)
                              .Take(limitation)
                              .ToList();
            }
            return(View(new IndexViewModel()
            {
                Events = faaliyetler
            }));
        }
Exemple #15
0
        private void FoldersTreeView_ContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            TreeViewItem item = FindControls.FindParent <TreeViewItem>(e.OriginalSource as DependencyObject);

            if (item == null)
            {
                return;
            }

            TreeViewItem parentItem = item.Parent as TreeViewItem;

            if (parentItem == null)
            {
                parentItem = (TreeViewItem)((TreeView)item.Parent).Items[0];
            }

            Folder             folder            = item.Tag as Folder;
            Folder             parentFolder      = parentItem.Tag as Folder;
            SiteSetting        siteSetting       = ConfigurationManager.GetInstance().GetSiteSetting(folder.SiteSettingID);
            object             obj               = item.Tag;
            IConnectorMainView connectorExplorer = FindControls.FindParent <OutlookConnectorExplorer>(this);
            object             inspector         = connectorExplorer != null ? connectorExplorer.Inspector : null;

            ContextMenuManager.Instance.FillContextMenuItems(FoldersTreeView.ContextMenu, siteSetting, folder, inspector, parentFolder);
        }
        private void AddContextMenuItems(ItemCollection itemCollection, SiteSetting siteSetting, object item, SC_MenuItems menuItems, object inspector, object folder)
        {
            foreach (SC_MenuItem menuItem in menuItems)
            {
                if (menuItem.ID == (int)SC_MenuItemTypes.Separator)
                {
                    itemCollection.Add(new Separator());
                    continue;
                }

                MenuItem mi = new MenuItem();
                mi.Header = menuItem.Title;
                mi.Icon   = new System.Windows.Controls.Image
                {
                    Source = new BitmapImage(new Uri("/Sobiens.Connectors.WPF.Controls;component/Images/MenuItems/" + menuItem.Icon, UriKind.Relative))
                };
                mi.Tag = new object[] { menuItem.ID, siteSetting, item, inspector, folder };
                //mi.Click -= new System.Windows.RoutedEventHandler(mi_Click);
                //mi.Click += new System.Windows.RoutedEventHandler(mi_Click);

                itemCollection.Add(mi);

                AddContextMenuItems(mi.Items, siteSetting, item, menuItem.SubItems, inspector, folder);
            }
        }
        public void FillContextMenuItems(ContextMenu contextMenu, SiteSetting siteSetting, object item, object inspector, object folder)
        {
            SC_MenuItems menuItems;

            if (item as IItem != null)
            {
                menuItems = ApplicationContext.Current.GetItemMenuItems(siteSetting, (IItem)item);
            }
            else if (item as Folder != null)
            {
                menuItems = ApplicationContext.Current.GetFolderMenuItems(siteSetting, (Folder)item);
            }
            else if (item as Task != null)
            {
                menuItems = ApplicationContext.Current.GetTaskMenuItems(siteSetting, (Task)item);
            }
            else
            {
                menuItems = ApplicationContext.Current.GetItemVersionMenuItems(siteSetting, (ItemVersion)item);
            }

            contextMenu.Items.Clear();
            contextMenu.RemoveHandler(MenuItem.ClickEvent, new RoutedEventHandler(mi_Click));
            contextMenu.AddHandler(MenuItem.ClickEvent, new RoutedEventHandler(mi_Click));
            AddContextMenuItems(contextMenu.Items, siteSetting, item, menuItems, inspector, folder);
        }
Exemple #18
0
        public async Task Set(SiteSetting siteSetting)
        {
            var entity = _mapper.Map <Entities.SiteSetting>(siteSetting);

            entity.Id = 0;
            await _repository.Create(entity);
        }
        public Notification(IConfiguration configuration)
        {
            var mailSettings = new MailSetting();

            _configuration = configuration;

            mailSettings.Enabled          = Convert.ToBoolean(_configuration.GetSection("MailSetting").GetSection("Enabled").Value);
            mailSettings.FromName         = _configuration.GetSection("MailSetting").GetSection("FromName").Value;
            mailSettings.FromEmail        = _configuration.GetSection("MailSetting").GetSection("FromEmail").Value;
            mailSettings.Host             = _configuration.GetSection("MailSetting").GetSection("Host").Value;
            mailSettings.Port             = Convert.ToInt32(_configuration.GetSection("MailSetting").GetSection("Port").Value);
            mailSettings.EnableSsl        = Convert.ToBoolean(_configuration.GetSection("MailSetting").GetSection("EnableSsl").Value);
            mailSettings.IsAuthentication = Convert.ToBoolean(_configuration.GetSection("MailSetting").GetSection("IsAuthentication").Value);
            mailSettings.Username         = _configuration.GetSection("MailSetting").GetSection("Username").Value;
            mailSettings.Password         = _configuration.GetSection("MailSetting").GetSection("Password").Value;

            MailHelper = new MailHelper(mailSettings);

            _siteSetting = new SiteSetting()
            {
                SiteTitle  = _configuration.GetSection("SiteSetting").GetSection("SiteTitle").Value,
                WebsiteUrl = _configuration.GetSection("SiteSetting").GetSection("WebsiteUrl").Value
            };

            _mailSetting = mailSettings;
        }
        protected void ParentWindow_OKButtonSelected(object sender, EventArgs e)
        {
            TaskListLocation workflowLocation = (TaskListLocation)this.Tag;

            workflowLocation.SiteSettingID = (Guid)SiteSettingComboBox.SelectedValue;
            workflowLocation.Name          = TaskListNameTextBox.Text;

            workflowLocation.ApplicationTypes = new List <ApplicationTypes>();
            if (GeneralATCheckBox.IsChecked == true)
            {
                workflowLocation.ApplicationTypes.Add(ApplicationTypes.General);
            }
            if (WordATCheckBox.IsChecked == true)
            {
                workflowLocation.ApplicationTypes.Add(ApplicationTypes.Word);
            }
            if (ExcelATCheckBox.IsChecked == true)
            {
                workflowLocation.ApplicationTypes.Add(ApplicationTypes.Excel);
            }
            if (OutlookATCheckBox.IsChecked == true)
            {
                workflowLocation.ApplicationTypes.Add(ApplicationTypes.Outlook);
            }

            if (workflowLocation.ShowAll == true)
            {
                SiteSetting siteSetting = (SiteSetting)SiteSettingComboBox.SelectedItem;
                workflowLocation.Folder = new SPWeb(siteSetting.Url, siteSetting.Url, siteSetting.ID, String.Empty, siteSetting.Url, siteSetting.Url);
                workflowLocation.BasicFolderDefinition = workflowLocation.Folder.GetBasicFolderDefinition();
                workflowLocation.Folder.Selected       = true;
            }
        }
Exemple #21
0
        /// <summary>
        /// Save site setup
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel SaveCompanySetupModel(CompanySetupModel model)
        {
            ResponseModel response;
            var           setting = _siteSettingRepository.FetchFirst(s => s.Name.Equals(SettingNames.CompanySetupSetting));

            if (setting == null)
            {
                setting = new SiteSetting
                {
                    Name        = SettingNames.CompanySetupSetting,
                    Description = SettingNames.CompanySetupSetting,
                    Value       = SerializeUtilities.Serialize(model),
                    SettingType = "system"
                };

                response = _siteSettingRepository.Insert(setting);
            }
            else
            {
                setting.Value = SerializeUtilities.Serialize(model);
                response      = _siteSettingRepository.Update(setting);
            }

            return(response);
        }
Exemple #22
0
        private void DeleteUniquePermissionsRecursivelyButton_Click(object sender, RoutedEventArgs e)
        {
            SiteSetting sourceObjectSiteSetting = ApplicationContext.Current.Configuration.SiteSettings[SourceObject.SiteSettingID];

            ApplicationContext.Current.DeleteUniquePermissions(sourceObjectSiteSetting, SourceObject, true);
            MessageBox.Show("Completed");
        }
Exemple #23
0
        public void PopulateControls()
        {
            if (SourceObject == null)
            {
                return;
            }

            Folder sourceObject = SourceObject;

            try
            {
                SiteSetting sourceObjectSiteSetting = ApplicationContext.Current.Configuration.SiteSettings[SourceObject.SiteSettingID];
                FoldersTreeView.Items.Clear();
                //TreeViewItem rootNode = AddNode(FoldersTreeView.Items, "Items", "Items", Brushes.DarkBlue);
                TreeViewItem listNode   = AddNode(FoldersTreeView.Items, SourceObject.Title, SourceObject, Brushes.Black);
                TreeViewItem fieldsNode = AddNode(listNode.Items, "Fields", "Fields", Brushes.Black);
                AddLoadingNode(fieldsNode);

                TreeViewItem viewsNode             = AddNode(listNode.Items, "Views", null, Brushes.Black);
                TreeViewItem sharedWithMeViewsNode = AddNode(viewsNode.Items, "Shared with me", "Shared with me", Brushes.Black);
                TreeViewItem personalViewsNode     = AddNode(viewsNode.Items, "Personal views", "Personal views", Brushes.Black);
                AddLoadingNode(sharedWithMeViewsNode);
                AddLoadingNode(personalViewsNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured:" + ex.Message);
                Logger.Error(ex, ApplicationContext.Current.GetApplicationType().ToString());
            }
        }
Exemple #24
0
        public async Task SyncDirectory(SiteSetting site, string siteKey)
        {
            _logger.LogInformation($"Starting sync {siteKey}");
            try
            {
                _client.Host        = site.FtpServer;
                _client.Credentials = new System.Net.NetworkCredential(site.UserName, site.Password);
                await _client.ConnectAsync();

                await _client.DownloadFolderRecursive(site.RootFolder[0], site.DestinationFolder);

                _logger.LogInformation($"Finish sync {siteKey}");
            }
            catch (FtpException exc)
            {
                _logger.LogError(exc, $"Error processing site {siteKey}");
            }
            finally
            {
                if (_client.IsConnected)
                {
                    await _client.DisconnectAsync();
                }
            }
        }
        private void initUserAndRole(SiteSetting setting)
        {
            AddRole(setting.AdminRole, out var result);
            AddRole(setting.BackUser, out result);
            var name      = setting.Name.Trim().ToLower();
            var userCheck = userManager.FindByNameAsync(name).GetAsyncValue();

            if (userCheck == null)
            {
                var newUser = new TUser();
                newUser.Id = Guid.NewGuid().ToString();
                newUser.NormalizedEmail    = name;
                newUser.Email              = name;
                newUser.EmailConfirmed     = true;
                newUser.UserName           = name;
                newUser.NormalizedUserName = name;
                var userCreateResult = userManager.CreateAsync(newUser, setting.Password).GetAsyncValue();
                userManager.AddToRoleAsync(newUser, setting.AdminRole).GetAsyncValue();
                userManager.AddToRoleAsync(newUser, setting.BackUser).GetAsyncValue();
            }
            else
            {
                if (IsUserInRole(userCheck.NormalizedUserName, setting.AdminRole))
                {
                    userManager.AddToRoleAsync(userCheck, setting.AdminRole).GetAsyncValue();
                }
                if (IsUserInRole(userCheck.NormalizedUserName, setting.BackUser))
                {
                    userManager.AddToRoleAsync(userCheck, setting.BackUser).GetAsyncValue();
                }
            }
        }
Exemple #26
0
        public void SaveBanIp()
        {
            String bannedIp = ctx.Post("BannedIp");

            String[]      arrItem = bannedIp.Split('\n');
            StringBuilder sb      = new StringBuilder();

            foreach (String ip in arrItem)
            {
                if (strUtil.HasText(ip))
                {
                    sb.Append(ip);
                    sb.Append("/");
                }
            }

            String ips = sb.ToString().TrimEnd('/');

            config.Instance.Site.BannedIp = SiteSetting.GetArrayValueByString(ips);
            config.Instance.Site.Update("BannedIp", ips);

            String bannedIpInfo = ctx.Post("BannedIpInfo");

            config.Instance.Site.BannedIpInfo = bannedIpInfo;
            config.Instance.Site.Update("BannedIpInfo", bannedIpInfo);

            echoRedirect(lang("opok"));
        }
Exemple #27
0
        public static ResultData <int> SaveSiteConfig(SiteConfig config)
        {
            LogHelpers.LogHandler.Info("Start.");
            try
            {
                SiteSetting setting = new SiteSetting();
                setting.Type    = "SiteConfig";
                setting.XmlData = Utilities.XmlSerializeObject(config);

                var result = InsertOrUpdate(setting);
                if (result.Code >= 0)
                {
                    Utilities.MoveFile(config.Logo,
                                       Path.Combine(Utilities.UploadFilesTempDir(), "Logo"),
                                       Path.Combine(Utilities.UploadImagesDir(), "Logo"));
                }

                return(result);
            }
            catch (Exception ex)
            {
                LogHelpers.LogHandler.Error(ex.ToString());
                return(new ResultData <int>()
                {
                    Code = ex.HResult,
                    ErrorMessage = ex.Message
                });
            }
        }
Exemple #28
0
    protected void BindData()
    {
        string condition = "CostType='" + CostType.JoinGroup + "' And UserName='******'";

        DateTime dtBegin = GetUrlDateTime("bdate");
        DateTime dtEnd   = GetUrlDateTime("edate");


        if (dtBegin != DateTime.MinValue && dtEnd != DateTime.MinValue && dtBegin <= dtEnd)
        {
            condition = condition + " And AddTime>='" + dtBegin.ToStartString() + "' And AddTime<='" + dtEnd.ToEndString() + "'";
        }

        SiteSetting.CreateWebPagerForGridView(gvData, ArrowControlPageIndex);

        WebQuery query = new WebQuery();

        query.Fields        = "*";
        query.OrderBy       = "ID desc";
        query.PrimaryKey    = "ID";
        query.SqlCreateType = ControlSqlCreateType.RowNum;
        query.TableName     = "V_CostHistory";
        query.Condition     = condition;

        gvData.Db    = TMS.Db.Helper;
        gvData.Query = query;
        gvData.CreateDataSource();
        gvData.DataBind();

        tbBegin.Text = dtBegin == DateTime.MinValue ? "" : dtBegin.ToDateOnlyString();
        tbEnd.Text   = dtEnd == DateTime.MinValue ? "" : dtEnd.ToDateOnlyString();
    }
Exemple #29
0
        private static decimal CalculateShipping(SiteSetting settings, decimal subtotal)
        {
            var freeShippingThreshold = settings.FreeShippingThreshold ?? 0.0m;
            var flatShippingRate      = settings.FlatShippingRate ?? 0.0m;

            return(subtotal > freeShippingThreshold ? 0.0m : flatShippingRate);
        }
        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            SiteSetting siteSetting = new SiteSetting();

            siteSetting.ID = Guid.NewGuid();
            SiteSettingForm siteSettingForm = new SiteSettingForm();

            siteSettingForm.BindControls(siteSetting);
            if (siteSettingForm.ShowDialog(this.ParentWindow, Languages.Translate("Site Settings")) == true)
            {
                Configuration.SiteSettings.Add(siteSetting);
                ExplorerLocation explorerLocation = new ExplorerLocation();
                explorerLocation.ID = Guid.NewGuid();
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Excel);
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Outlook);
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.Word);
                explorerLocation.ApplicationTypes.Add(ApplicationTypes.General);
                explorerLocation.ShowAll               = true;
                explorerLocation.SiteSettingID         = siteSetting.ID;
                explorerLocation.Folder                = ApplicationContext.Current.GetRootFolder(siteSetting);
                explorerLocation.Folder.Selected       = true;
                explorerLocation.BasicFolderDefinition = explorerLocation.Folder.GetBasicFolderDefinition();
                Configuration.ExplorerConfiguration.ExplorerLocations.Add(explorerLocation);
                LoadSites();
                RefreshExplorerLocationsListBox();
            }
        }
Exemple #31
0
        /// <summary>
        /// Refreshes the node.
        /// </summary>
        /// <param name="node">The node.</param>
        private void RefreshNode(TreeViewItem item)
        {
            Folder folder = null;
            item.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                folder = (Folder)item.Tag;
            }));

            {

                SiteSetting siteSetting = ApplicationContext.Current.Configuration.SiteSettings[folder.SiteSettingID];
                List<Folder> subFolders = ApplicationContext.Current.GetSubFolders(siteSetting, folder, this.IncludedFolderTypes);
                folder.Folders = subFolders;
                item.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    FoldersTreeView.BeginInit();
                    item.Items.Clear();
                    foreach (Folder subFolder in subFolders)
                    {
                        subFolder.PublicFolder = this.AdministrativeView;
                        subFolder.Selected = false;
                        AddNode(item.Items, subFolder, siteSetting.ID);
                    }
                    FoldersTreeView.EndInit();
                }));
            }
        }
        protected void bUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                // Get the DNN user.
                try
                {
                    UserInfo ui = UserController.GetUserById(this.PortalId, this.UserId);
                    string fullname = atiSlimControl.FullName;
                    string[] nameparts = fullname.Split(' ');
                    string fname = string.Empty;
                    string lname = string.Empty;
                    if (nameparts.Length >= 2)
                    {
                        fname = nameparts[0];
                        lname = nameparts[1];
                    }
                    // TODO: we check if the user is trying to change their username
                    // Here is the query for it.  Right not we disable the UserName control
                    // update users set username='******' where username='******'
                    // update aspnet_Users set username='******' ,loweredusername='******' where username='******'
                    Affine.WebService.RegisterService regService = new WebService.RegisterService();

                    // TODO: need timezone control

                    regService.populateDnnUserInfo(PortalId, ref ui, fname, lname, atiUserName.Text, atiSlimControl.Email, atiPassword.Password, atiSlimControl.Postal, atiSlimControl.Address, null);
                    aqufitEntities entities = new aqufitEntities();
                    User us = entities.UserSettings.OfType<User>().Include("User2WorkoutType").Include("User2WorkoutType.WorkoutType").FirstOrDefault(s => s.UserKey == this.UserId && s.PortalKey == this.PortalId);
                    us = (User)populateUserSettings(us, ui);
                    if (!string.IsNullOrEmpty( hiddenIdentifier.Value ))
                    {
                        us.FBUid = Convert.ToInt64(hiddenIdentifier.Value);
                    }

                    // TODO: make this the same as the "GroupAdmin"
               //     UploadThemeBackground();
                    us.CssStyle = string.Empty;

                    if (!atiThemeEditor.BackgroundColor.IsEmpty)
                    {
                        us.CssStyle += "background-color: #" + atiThemeEditor.BackgroundColor.Name.Substring(2) + ";";
                    }
                    if (atiThemeEditor.IsTiled)
                    {
                        us.CssStyle += "background-repeat: repeat;";
                    }
                    else
                    {
                        us.CssStyle += "background-repeat:no-repeat; background-attachment:fixed;";
                    }
                    this.BackgroundImageUrl = ResolveUrl("~/DesktopModules/ATI_Base/services/images/profile.aspx") + "?u=" + us.UserKey + "&p=" + us.PortalKey + "&bg=1";
                  //  this.ProfileCSS = us.CssStyle;

                    foreach (CheckBox cb in atiWorkoutTypes.CheckBoxList)
                    {
                        if (!cb.Checked)
                        {
                            WorkoutType wt = entities.WorkoutType.First(w => w.Name == cb.Text);
                            User2WorkoutType u2wt = new User2WorkoutType() { WorkoutType = wt, UserSetting = us };
                            entities.AddToUser2WorkoutType(u2wt);
                        }
                        else
                        {
                            User2WorkoutType wt = us.User2WorkoutType.FirstOrDefault(w => w.WorkoutType.Name == cb.Text);
                            if (wt != null)
                            {
                                entities.DeleteObject(wt);
                            }
                        }
                    }
                    if (!cbAllowGroupEmails.Checked)
                    {
                        SiteSetting ss = new SiteSetting()
                        {
                            Name = "AllowHomeGroupEmail",
                            Value = "true",
                            UserSetting = entities.UserSettings.FirstOrDefault( u => u.Id == UserSettings.Id )
                        };
                        entities.AddToSiteSettings(ss);
                    }else{
                        // delete it if it exists
                        SiteSetting ss = entities.SiteSettings.FirstOrDefault(s => s.UserSetting.Id == UserSettings.Id && s.Name == "AllowHomeGroupEmail");
                        if (ss != null)
                        {
                            entities.DeleteObject(ss);
                        }
                    }
                    UserController.UpdateUser(this.PortalId, ui);
                    entities.SaveChanges();
                    litStatus.Text = "Your Changes have been saved.";
                  //  RadAjaxManager1.ResponseScripts.Add("alert('Your Changes have been saved');");
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.SuccessDialog.open('{\"html\":\"Your Changes have been saved.\"}');");
                }
                catch (Exception ex)
                {
                    RadAjaxManager1.ResponseScripts.Add("alert('" + ex.InnerException.Message.Replace("'", "").Replace("\"", "").Replace("\n", "") + "');");
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"" + ex.Message + "\"}');");
                }
            }
            else
            {
                RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\" Page Not Valid \"}');");
            }
        }
        private bool Register()
        {
            //Try
            // Only attempt a save/update if all form fields on the page are valid
            if (Page.IsValid)
            {
                // check required fields
                int UID = -1;
                UserInfo objUserInfo = UserController.GetUserByName(PortalId, atiUserName.Text);
                // if a user is found with that username, error. this prevents you from adding a username with the same name as a superuser.
                if (objUserInfo != null)
                {
                    RadAjaxManager1.ResponseScripts.Add("Aqufit.Windows.ErrorDialog.open('{\"html\":\"We already have an entry for the User Name.\"}');");
                    return false;
                }
                Affine.WebService.RegisterService regService = new WebService.RegisterService();
                double? timezone = null;
                if (!string.IsNullOrEmpty(atiSlimControl.LocLat))
                {
               //         timezone = regService.GetTimeZone(Convert.ToDouble(atiSlimControl.LocLat), Convert.ToDouble(atiSlimControl.LocLng));
                }
                UserInfo objNewUser = regService.InitialiseUser(PortalId);
                string fullname = atiSlimControl.FullName;
                string[] nameparts = fullname.Split(' ');
                string fname = string.Empty;
                string lname = string.Empty;
                if (nameparts.Length >= 2)
                {
                    fname = nameparts[0];
                    lname = nameparts[1];
                }

                regService.populateDnnUserInfo(PortalId, ref objNewUser, fname, lname, atiUserName.Text, atiSlimControl.Email, atiPassword.Password, atiSlimControl.Postal, atiSlimControl.Address, timezone);

                DotNetNuke.Security.Membership.UserCreateStatus userCreateStatus = UserController.CreateUser(ref objNewUser);
                if (userCreateStatus == DotNetNuke.Security.Membership.UserCreateStatus.Success)
                {
                    UID = objNewUser.UserID;
                    // DNN3 BUG
                    DotNetNuke.Services.Log.EventLog.EventLogController objEventLog = new DotNetNuke.Services.Log.EventLog.EventLogController();
                    objEventLog.AddLog(objNewUser, PortalSettings, objNewUser.UserID, atiSlimControl.Email, DotNetNuke.Services.Log.EventLog.EventLogController.EventLogType.USER_CREATED);

                    // send notification to portal administrator of new user registration
            //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationAdmin, PortalSettings);
            //            DotNetNuke.Services.Mail.Mail.SendMail(objNewUser, DotNetNuke.Services.Mail.MessageType.UserRegistrationPublic, PortalSettings);
                    DataCache.ClearUserCache(PortalId, objNewUser.Username);
                    UserController.UserLogin(PortalId, objNewUser, PortalSettings.PortalName, DotNetNuke.Services.Authentication.AuthenticationLoginBase.GetIPAddress(), true);

                    User us = new Data.User();
                    us = (User)populateUserSettings(us, objNewUser);
                    if (atiBodyComp.BirthDateVisible)
                    {
                        us.BirthDate = atiBodyComp.BirthDate;
                    }
                    SiteSetting tutorial = new SiteSetting()
                    {
                        UserSetting = us,
                        Name = "SiteIntro",
                        Value = "1"
                    };
                    entities.AddToUserSettings(us);
                    entities.SaveChanges();

                    us = entities.UserSettings.OfType<User>().FirstOrDefault( u => u.UserKey == objNewUser.UserID && u.PortalKey == objNewUser.PortalID );

                    // TODO: should have a populate function for these
                    BodyComposition bc = new BodyComposition()
                    {
                        UserSetting = us
                    };
                    if (atiBodyComp.FitnessLevelVisible)
                    {
                        bc.FitnessLevel = atiBodyComp.FitnessLevel;
                    }

                    // need height and weight conversions
                    if (atiBodyComp.WeightVisible)
                    {
                        bc.Weight = atiBodyComp.UserWeightInSystemDefault;
                    }
                    if( atiBodyComp.HeightVisible )
                    {
                        bc.Height = atiBodyComp.UserHeightInSystemDefault;
                    }
                    entities.AddToBodyComposition(bc);
                    entities.SaveChanges();

                    string body = "User registration recorded\n\n";
                           body += "ID: " + objNewUser.UserID + "\n";
                           body += "User: "******"\n";
                           body += "First Name: " + objNewUser.FirstName + "\n";
                           body += "Last Name: " + objNewUser.LastName + "\n";
                           body += "Email: " + objNewUser.Email + "\n";
                           body += "Portal: " + objNewUser.PortalID + "\n";
                           body += "User-Agent: " + Request.UserAgent + "\n\n";
             //           DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "NEW aqufit.com USER", body, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "User Signup: " + objNewUser.Username, body);

                    // where they brought here by a group?
                    long gid = Convert.ToInt64(hiddenGroupKey.Value);
                    if (gid > 0)
                    {   // if so then we auto add them to the group.
                        Data.Managers.LINQ.DataManager.Instance.JoinGroup(us.Id, gid, Utils.ConstsUtil.Relationships.GROUP_MEMBER);
                    }

                    // See if this person was invited by anyone.
                    ContactInvite invite = entities.ContactInvites.Include("UserSetting").FirstOrDefault(i => i.Email == us.UserEmail);
                    if (invite != null)
                    {   // this person was invited by someone so lets make them friends....
                        string stat = Affine.Data.Managers.LINQ.DataManager.Instance.AcceptFriendRequests(invite.UserSetting.Id, us.Id);
                        // TODO: assume success send for now
                    }
                    // TODO: look through a list of stored contacts to get a sugested friends list...
                }
                else
                { // registration error
                    string body = "User Registration Form FAILED (Us\n\n";
                    body += "ID: " + objNewUser.UserID + "\n";
                    body += "User: "******"\n";
                    body += "First Name: " + objNewUser.FirstName + "\n";
                    body += "Last Name: " + objNewUser.LastName + "\n";
                    body += "Email: " + objNewUser.Email + "\n";
                    body += "REGISTRATION ERROR: " + userCreateStatus.ToString() + "\n";
                    //  string errStr = userCreateStatus.ToString() + "\n\n" + atiSlimControl.ToString();
                  //  DotNetNuke.Services.Mail.Mail.SendMail("*****@*****.**", "*****@*****.**", "", "FAILED REGISTRATION", lErrorText.Text + errStr, "", "HTML", "", "", "", "");
                    Affine.Utils.GmailUtil gmail = new Utils.GmailUtil();
                    gmail.Send("*****@*****.**", "**FAIL** REGISTRATION FORM: " + objNewUser.Username, body);

                    litStatus.Text = "REGISTRATION ERROR: " + userCreateStatus.ToString();
                    return false;
                }
            }
            return true;
        }