示例#1
0
        protected override void OnError(EventArgs e)
        {
            Exception lastError = Server.GetLastError();

            if ((lastError != null) && (lastError is PathTooLongException))
            {
                //let it be handled elsewhere (global.asax.cs)
                return;
            }

            string exceptionUrl       = string.Empty;
            string exceptionIpAddress = string.Empty;

            if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Request != null)
                {
                    exceptionUrl       = String.Format("{0} - {1}", CultureInfo.CurrentCulture, HttpContext.Current.Request.RawUrl);
                    exceptionIpAddress = SiteUtils.GetIP4Address();
                }
            }

            if (lastError != null)
            {
                log.Error(String.Format("{0}-{1}", exceptionIpAddress, exceptionUrl), lastError);
            }



            int siteCount = DatabaseHelper.ExistingSiteCount();

            if (siteCount == 0)
            {
                Server.ClearError();

                log.Info("no sites or no database found in application error so try to redirect to Setup Page");

                try
                {
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Redirect(String.Format("{0}/Setup/Default.aspx", WebUtils.GetSiteRoot()));
                }
                catch (HttpException) { }
            }

            bool upgradeNeeded = CSetup.UpgradeIsNeeded();

            if (upgradeNeeded)
            {
                try
                {
                    log.Info("detected need for upgrade so redirecting to setup");

                    Server.ClearError();
                    HttpContext.Current.Response.Clear();
                    HttpContext.Current.Response.Redirect(String.Format("{0}/Setup/Default.aspx", WebUtils.GetSiteRoot()));
                }
                catch (HttpException) { }
            }
        }
示例#2
0
        private void LoadSettings()
        {
            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();
            CSetup.EnsureFolderGalleryFolder(siteSettings);

            pageId   = WebUtils.ParseInt32FromQueryString("PageId", -1);
            moduleId = WebUtils.ParseInt32FromQueryString("mid", -1);
            basePath = "~/Data/Sites/"
                       + siteSettings.SiteId.ToString(CultureInfo.InvariantCulture)
                       + "/FolderGalleries/";

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);

            allowEditUsersToChangeFolderPath = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "AllowEditUsersToChangeFolderPath", allowEditUsersToChangeFolderPath);

            allowEditUsersToUpload = WebUtils.ParseBoolFromHashtable(
                moduleSettings, "AllowEditUsersToUpload", allowEditUsersToUpload);

            if (!WebUser.IsAdminOrContentAdmin)
            {
                pnlUpload.Visible = allowEditUsersToUpload;
                pnlEdit.Visible   = allowEditUsersToChangeFolderPath;
            }
        }
示例#3
0
    protected void OnCongasRhythmsBoxChanged(object sender, EventArgs e)
    {
        ComboBox           box        = sender as ComboBox;
        CONGA_RHYTHMS_TYPE rhythmType =
            CSetup.GetEnumFromStr_CongaRhythmsType(box.ActiveText);

        SoundLibraryInterface.SetInstrumentRhythm(
            (uint)INSTRUMENTS_TYPE.INSTRUMENT_CONGAS,
            (short)rhythmType);
    }
示例#4
0
        private void CreateSiteAndAdminUser()
        {
            WritePageContent(SetupResource.CreatingSiteMessage, true);
            SiteSettings newSite = CSetup.CreateNewSite();

            CSetup.CreateDefaultSiteFolders(newSite.SiteId);
            CSetup.CreateOrRestoreSiteSkins(newSite.SiteId);
            WritePageContent(SetupResource.CreatingRolesAndAdminUserMessage, true);
            CSetup.CreateRequiredRolesAndAdminUser(newSite);
        }
示例#5
0
        private void SetPrint_Form_Load(object sender, EventArgs e)
        {
            if (_configTable != null)
            {
                _tabTable = new Dictionary <TabItem, CSetup>();
                IDictionaryEnumerator dicEnum = _configTable.GetEnumerator();
                while (dicEnum.MoveNext())
                {
                    DictionaryEntry ent = dicEnum.Entry;

                    TabItem tab = new TabItem();
                    tab.Text   = (string)ent.Key;
                    tab.Click += new EventHandler(tab_Click);

                    SettingPair set  = (SettingPair)ent.Value;
                    CSetup      temp = new CSetup(set);

                    CSettings     csetting = (CSettings)temp.Settings;
                    PrintSettings psetting = csetting.PrintConfig;

                    TabControlPanel tabControlPanel = new TabControlPanel();

                    tab.AttachedControl = tabControlPanel;

                    tabControlPanel.Dock     = System.Windows.Forms.DockStyle.Fill;
                    tabControlPanel.Location = new System.Drawing.Point(0, 26);
                    tabControlPanel.Name     = (string)ent.Key;
                    tabControlPanel.Size     = new System.Drawing.Size(409, 440);
                    tabControlPanel.TabItem  = tab;

                    PrintSetupPanel prtSetPane = new PrintSetupPanel();

                    tabControlPanel.Controls.Add(prtSetPane);

                    tabCtrl.Controls.Add(tabControlPanel);

                    this.tabCtrl.Tabs.Add(tab);

                    _tabTable.Add(tab, temp);
                }

                if (this.tabCtrl.Tabs.Count > 0)
                {
                    _currentSetup = _tabTable[this.tabCtrl.SelectedTab];

                    _currentSetupPanel = (PrintSetupPanel)this.tabCtrl.SelectedPanel.Controls[0];

                    CSettings     csetting = (CSettings)_currentSetup.Settings;
                    PrintSettings settings = csetting.PrintConfig;

                    _currentSetupPanel.SetValues(settings);
                    InitializePrintFormComponent(settings);
                }
            }
        }
示例#6
0
        void tab_Click(object sender, EventArgs e)
        {
            _currentSetup      = _tabTable[(TabItem)sender];
            _currentSetupPanel = (PrintSetupPanel)this.tabCtrl.SelectedPanel.Controls[0];

            CSettings     csetting = (CSettings)_currentSetup.Settings;
            PrintSettings settings = csetting.PrintConfig;

            _currentSetupPanel.SetValues(settings);
            InitializePrintFormComponent(settings);
        }
示例#7
0
        private void PopulateTemplateList()
        {
            List <LetterHtmlTemplate> LetterHtmlTemplateList = LetterHtmlTemplate.GetAll(siteSettings.SiteGuid);

            if (LetterHtmlTemplateList.Count == 0)
            {
                CSetup.CreateDefaultLetterTemplates(siteSettings.SiteGuid);

                LetterHtmlTemplateList = LetterHtmlTemplate.GetAll(siteSettings.SiteGuid);
            }

            ddTemplates.DataSource = LetterHtmlTemplateList;
            ddTemplates.DataBind();
        }
示例#8
0
    //private Button cowbellButton;

    public MainWindow() : base(Gtk.WindowType.Toplevel)
    {
        Build();
        SoundLibraryInterface.SetBeatsPerMinute((uint)bpmSlider.Value);
        SoundLibraryInterface.SetMasterVolume((float)masterVolumeSlider.Value);

        AssignImageToButton(ref claveButton, "SalsaMusicalityGUI.claves.jpg");
        AssignImageToButton(ref cowbellButton, "SalsaMusicalityGUI.cowbell.jpg");
        AssignImageToButton(ref bongosButton, "SalsaMusicalityGUI.bongos.jpg");
        AssignImageToButton(ref congasButton, "SalsaMusicalityGUI.congas.jpg");

        // Populate the clave rhythms box
        for (CLAVE_RHYTHMS_TYPE i = 0; i < CLAVE_RHYTHMS_TYPE.NUM_CLAVE_RHYTHMS; i++)
        {
            claveRhythmsBox.InsertText((int)i, CSetup.GetStr_ClaveRhythmsType(i));
        }

        Gtk.TreeIter iter;
        claveRhythmsBox.Model.IterNthChild(out iter, (int)CLAVE_RHYTHMS_TYPE.CLA_SON_2_3);
        claveRhythmsBox.SetActiveIter(iter);

        // Populate the conga rhythms box
        for (CONGA_RHYTHMS_TYPE i = 0; i < CONGA_RHYTHMS_TYPE.NUM_CONGA_RHYTHMS; i++)
        {
            congasRhythmsBox.InsertText((int)i, CSetup.GetStr_CongaRhythmsType(i));
        }

        congasRhythmsBox.Model.IterNthChild(out iter, (int)CONGA_RHYTHMS_TYPE.CON_BASIC_OFFBEAT);
        congasRhythmsBox.SetActiveIter(iter);

        // Populate the cowbell rhythms box
        for (COWBELL_RHYTHMS_TYPE i = 0; i < COWBELL_RHYTHMS_TYPE.NUM_COWBELL_RHYTHMS; i++)
        {
            cowbellRhythmsBox.InsertText((int)i, CSetup.GetStr_CowbellRhythmsType(i));
        }

        cowbellRhythmsBox.Model.IterNthChild(out iter, (int)COWBELL_RHYTHMS_TYPE.COW_DOWN_BEATS);
        cowbellRhythmsBox.SetActiveIter(iter);

        // Populate the bongos rhythms box
        for (BONGO_RHYTHMS_TYPE i = 0; i < BONGO_RHYTHMS_TYPE.NUM_BONGO_RHYTHMS; i++)
        {
            bongosRhythmsBox.InsertText((int)i, CSetup.GetStr_BongosRhythmsType(i));
        }

        bongosRhythmsBox.Model.IterNthChild(out iter, (int)BONGO_RHYTHMS_TYPE.BON_MARTILLO);
        bongosRhythmsBox.SetActiveIter(iter);
    }
        private void LoadSettings()
        {
            appRoot = WebUtils.GetApplicationRoot();

            moduleSettings = ModuleSettings.GetModuleSettings(moduleId);


            lnkCancel.NavigateUrl = SiteUtils.GetCurrentPageUrl();

            CSetup.VerifyGalleryFolders(siteSettings.SiteId, moduleId);

            if (WebConfigSettings.ImageGalleryUseMediaFolder)
            {
                imageFolderPath = HttpContext.Current.Server.MapPath("~/Data/Sites/"
                                                                     + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/");

                thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/media/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            }
            else
            {
                imageFolderPath = HttpContext.Current.Server.MapPath("~/Data/Sites/"
                                                                     + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/");

                thumbnailBaseUrl = ImageSiteRoot + "/Data/Sites/" + siteSettings.SiteId.ToInvariantString() + "/GalleryImages/" + moduleId.ToInvariantString() + "/Thumbnails/";
            }

            fullSizeImageFolderPath = imageFolderPath + "FullSizeImages" + Path.DirectorySeparatorChar;



            webImageHeightSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GalleryWebImageHeightSetting", -1);

            webImageWidthSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GalleryWebImageWidthSetting", -1);

            thumbNailHeightSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GalleryThumbnailHeightSetting", -1);

            thumbNailWidthSetting = WebUtils.ParseInt32FromHashtable(
                moduleSettings, "GalleryThumbnailWidthSetting", -1);


            edDescription.WebEditor.ToolBar = ToolBar.Full;
        }
        private void BindGrid()
        {
            List <LetterHtmlTemplate> LetterHtmlTemplateList
                = LetterHtmlTemplate.GetPage(
                      siteSettings.SiteGuid,
                      pageNumber,
                      pageSize,
                      out totalPages);

            if (LetterHtmlTemplateList.Count == 0)
            {
                CSetup.CreateDefaultLetterTemplates(siteSettings.SiteGuid);

                LetterHtmlTemplateList
                    = LetterHtmlTemplate.GetPage(
                          siteSettings.SiteGuid,
                          pageNumber,
                          pageSize,
                          out totalPages);
            }


            if (this.totalPages > 1)
            {
                string pageUrl = SiteUtils.GetNavigationSiteRoot()
                                 + "/eletter/LetterTemplates.aspx?pagenumber={0}";

                pgrLetterHtmlTemplate.PageURLFormat = pageUrl;
                pgrLetterHtmlTemplate.ShowFirstLast = true;
                pgrLetterHtmlTemplate.CurrentIndex  = pageNumber;
                pgrLetterHtmlTemplate.PageSize      = pageSize;
                pgrLetterHtmlTemplate.PageCount     = totalPages;
            }
            else
            {
                pgrLetterHtmlTemplate.Visible = false;
            }

            grdLetterHtmlTemplate.DataSource = LetterHtmlTemplateList;
            grdLetterHtmlTemplate.PageIndex  = pageNumber;
            grdLetterHtmlTemplate.PageSize   = pageSize;
            grdLetterHtmlTemplate.DataBind();
        }
示例#11
0
        private bool CoreSystemIsReady()
        {
            bool result = true;

            if (!canAccessDatabase)
            {
                return(false);
            }

            if (!DatabaseHelper.SchemaHasBeenCreated())
            {
                return(false);
            }

            if (CSetup.UpgradeIsNeeded())
            {
                return(false);
            }



            return(result);
        }
示例#12
0
        private string GetFolderDetailsHtml()
        {
            StringBuilder folderErrors = new StringBuilder();
            string        crlf         = "\r\n";

            folderErrors.Append(
                SetupResource.DataFolderNotWritableMessage.Replace(crlf, "<br />")
                + "<h3>" + SetupResource.FolderDetailsLabel + "</h3>");

            String pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/test.config");

            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataRootNotWritableMessage));
            }

            pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/Sites/1/test.config");
            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataSiteFolderNotWritableMessage));
            }

            pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/Sites/1/systemfiles/test.config");
            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataSystemFilesFolderNotWritableMessage));
            }

            pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/Sites/1/index/test.config");
            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataSiteIndexFolderNotWritableMessage));
            }

            pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/Sites/1/SharedFiles/test.config");
            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataSharedFilesFolderNotWritableMessage));
            }

            pathToTestFile = HttpContext.Current.Server.MapPath("~/Data/Sites/1/SharedFiles/History/test.config");
            try
            {
                CSetup.TouchTestFile(pathToTestFile);
            }
            catch (UnauthorizedAccessException)
            {
                folderErrors.Append(String.Format("<li>{0}</li>", SetupResource.DataSharedFilesHistoryFolderNotWritableMessage));
            }

            return(folderErrors.ToString());
        }
示例#13
0
        private void ProbeSystem()
        {
            WritePageContent(
                SetupResource.ProbingSystemMessage,
                false);

            dbPlatform           = DatabaseHelper.DBPlatform();
            dataFolderIsWritable = CSetup.DataFolderIsWritable();

            if (dataFolderIsWritable)
            {
                WritePageContent(
                    SetupResource.FileSystemPermissionsOKMesage,
                    false);
            }
            else
            {
                WritePageContent(
                    SetupResource.FileSystemPermissionProblemsMessage,
                    false);

                WritePageContent(
                    String.Format("<div>{0}</div>", GetFolderDetailsHtml()),
                    false);
            }

            canAccessDatabase = DatabaseHelper.CanAccessDatabase();

            if (canAccessDatabase)
            {
                WritePageContent(
                    dbPlatform
                    + " " + SetupResource.DatabaseConnectionOKMessage,
                    false);
            }
            else
            {
                string dbError = string.Format(
                    SetupResource.FailedToConnectToDatabase,
                    dbPlatform);

                WritePageContent(String.Format("<div>{0}</div>", dbError), false);

                showConnectionError = ConfigHelper.GetBoolProperty("ShowConnectionErrorOnSetup", false);


                if (showConnectionError)
                {
                    WritePageContent(
                        String.Format("<div>{0}</div>", DatabaseHelper.GetConnectionError(null)),
                        false);
                }
            }


            if (canAccessDatabase)
            {
                canAlterSchema = DatabaseHelper.CanAlterSchema(null);

                if (canAlterSchema)
                {
                    WritePageContent(
                        SetupResource.DatabaseCanAlterSchemaMessage,
                        false);
                }
                else
                {
                    WritePageContent(
                        String.Format("<div>{0}</div>", SetupResource.CantAlterSchemaWarning),
                        false);
                }

                schemaHasBeenCreated = DatabaseHelper.SchemaHasBeenCreated();

                if (schemaHasBeenCreated)
                {
                    WritePageContent(
                        SetupResource.DatabaseSchemaAlreadyExistsMessage,
                        false);


                    needSchemaUpgrade = CSetup.UpgradeIsNeeded();

                    if (needSchemaUpgrade)
                    {
                        WritePageContent(
                            SetupResource.DatabaseSchemaNeedsUpgradeMessage,
                            false);
                    }
                    else
                    {
                        WritePageContent(
                            SetupResource.DatabaseSchemaUpToDateMessage,
                            false);
                    }

                    existingSiteCount = DatabaseHelper.ExistingSiteCount();

                    WritePageContent(
                        string.Format(
                            SetupResource.ExistingSiteCountMessageMessage,
                            existingSiteCount.ToString()),
                        false);
                }
                else
                {
                    WritePageContent(
                        SetupResource.DatabaseSchemaNotCreatedYetMessage,
                        false);
                }
            }

            if (!CSetup.RunningInFullTrust())
            {
                // inform of Medium trust configuration issues
                WritePageContent(
                    String.Format("<b>{0}</b><br />{1}<br /><br />", SetupResource.MediumTrustGeneralMessage, GetDataAccessMediumTrustMessage()),
                    false);
            }
        }
示例#14
0
        private bool RunUpgradeScripts(
            Guid applicationId,
            string applicationName,
            string pathToScriptFolder,
            Version versionToStopAt)
        {
            bool result = true;

            if (!Directory.Exists(pathToScriptFolder))
            {
                WritePageContent(
                    String.Format("{0} {1}", pathToScriptFolder, SetupResource.ScriptFolderNotFoundMessage),
                    false);

                return(false);
            }

            DirectoryInfo directoryInfo
                = new DirectoryInfo(pathToScriptFolder);

            FileInfo[] scriptFiles = directoryInfo.GetFiles("*.config");
            Array.Sort(scriptFiles, UIHelper.CompareFileNames);

            if (scriptFiles.Length == 0)
            {
                return(false);
            }


            Version currentSchemaVersion
                = DatabaseHelper.GetSchemaVersion(applicationId);

            foreach (FileInfo scriptFile in scriptFiles)
            {
                Version scriptVersion
                    = DatabaseHelper.ParseVersionFromFileName(scriptFile.Name);

                if (
                    (scriptVersion != null) &&
                    (scriptVersion > currentSchemaVersion) &&
                    (versionToStopAt == null || (scriptVersion <= versionToStopAt))
                    // commented out 2007-08-26
                    // script is still logged if it fails but version
                    // isn't updated. This was blocking the script from
                    // running again unless user deleted row from cy_SchemaScriptHistory
                    //&& (!DatabaseHelper.SchemaScriptHasBeenRun(
                    //        applicationID,
                    //        scriptFile.Name)
                    //    )
                    )
                {
                    string message = string.Format(
                        SetupResource.RunningScriptMessage,
                        applicationName,
                        scriptFile.Name.Replace(".config", string.Empty));

                    WritePageContent(
                        message,
                        true);

                    string errorMessage
                        = DatabaseHelper.RunScript(
                              applicationId,
                              scriptFile,
                              null);

                    if (errorMessage.Length > 0)
                    {
                        WritePageContent(errorMessage, true);
                        return(false);
                    }

                    if (string.Equals(applicationName, "Cynthia-core", StringComparison.InvariantCultureIgnoreCase))
                    {
                        CSetup.DoPostScriptTasks(scriptVersion, null);
                    }

                    Version newVersion
                        = DatabaseHelper.ParseVersionFromFileName(scriptFile.Name);

                    if (
                        (applicationName != null) &&
                        (newVersion != null)
                        )
                    {
                        DatabaseHelper.UpdateSchemaVersion(
                            applicationId,
                            applicationName,
                            newVersion.Major,
                            newVersion.Minor,
                            newVersion.Build,
                            newVersion.Revision);

                        DatabaseHelper.AddSchemaScriptHistory(
                            applicationId,
                            scriptFile.Name,
                            DateTime.UtcNow,
                            false,
                            string.Empty,
                            string.Empty);

                        if (errorMessage.Length == 0)
                        {
                            currentSchemaVersion = newVersion;
                        }
                    }
                }
            }

            return(result);
        }
示例#15
0
        private void Sound_Test_Form_Load(object sender, EventArgs e)
        {
            if (_configTable != null)
            {
                _tabTable = new Dictionary <TabItem, CSetup>();
                IDictionaryEnumerator dicEnum = _configTable.GetEnumerator();
                while (dicEnum.MoveNext())
                {
                    DictionaryEntry ent = dicEnum.Entry;

                    TabItem tab = new TabItem();
                    tab.Text   = (string)ent.Key;
                    tab.Click += new EventHandler(tabCtrl_Click);

                    SettingPair set  = (SettingPair)ent.Value;
                    CSetup      temp = new CSetup(set);

                    TabControlPanel tabControlPanel = new TabControlPanel();

                    tab.AttachedControl = tabControlPanel;

                    tabControlPanel.Dock     = System.Windows.Forms.DockStyle.Fill;
                    tabControlPanel.Location = new System.Drawing.Point(0, 26);
                    tabControlPanel.Name     = (string)ent.Key;
                    tabControlPanel.Size     = new System.Drawing.Size(306, 150);
                    tabControlPanel.TabItem  = tab;

                    //Ìí¼Ó×Ô¼ºµÄ¿Ø¼þ
                    GroupBox tempGroupBox = new GroupBox();
                    tempGroupBox.Dock = DockStyle.Fill;
                    tempGroupBox.Name = "tempGroupBox";
                    tempGroupBox.Text = "ÓïÒôÉèÖÃ";

                    Label tempLabel = new Label();
                    tempLabel.Location = new Point(10, 17);
                    tempLabel.Size     = new Size(300, 20);
                    tempLabel.Text     = "ÇëÑ¡ÔñÉùÒô£¬²¢ÊäÈë²âÊÔÓï¾ä¡£";
                    tempGroupBox.Controls.Add(tempLabel);

                    ComboBox tempComboBox = new ComboBox();
                    int      i            = 0;
                    foreach (ISpeechObjectToken spObj in spObjs)
                    {
                        tempComboBox.Items.Add(spObj.GetDescription(i++));
                    }
                    try
                    {
                        tempComboBox.SelectedIndex = ((CSettings)temp.Settings).SoundConfig.VoiceIndex;
                    }
                    catch
                    {}
                    tempComboBox.DropDownStyle         = ComboBoxStyle.DropDownList;
                    tempComboBox.Name                  = "comboBox";
                    tempComboBox.Location              = new Point(20, 40);
                    tempComboBox.Size                  = new Size(260, 20);
                    tempComboBox.SelectedIndexChanged += new EventHandler(comboBoxVoiceList_SelectedIndexChanged);
                    tempGroupBox.Controls.Add(tempComboBox);

                    TextBox tempTxtBox = new TextBox();
                    tempTxtBox.Name     = "txtBox";
                    tempTxtBox.Location = new Point(20, 80);
                    tempTxtBox.Size     = new Size(260, 20);
                    tempGroupBox.Controls.Add(tempTxtBox);

                    Button previewBtn = new Button();
                    previewBtn.Location = new Point(220, 120);
                    previewBtn.Size     = new Size(80, 25);
                    previewBtn.Text     = "²¥·ÅÉùÒô";
                    previewBtn.Click   += new EventHandler(buttonPreview_Click);
                    tempGroupBox.Controls.Add(previewBtn);

                    //×Ô¼ºµÄ¿Ø¼þÌí¼ÓÍê±Ï
                    tabControlPanel.Controls.Add(tempGroupBox);

                    tabCtrl.Controls.Add(tabControlPanel);

                    this.tabCtrl.Tabs.Add(tab);

                    _tabTable.Add(tab, temp);
                }

                if (this.tabCtrl.Tabs.Count > 0)
                {
                    _currentSetup      = _tabTable[this.tabCtrl.SelectedTab];
                    _currentVoiceIndex = ((ComboBox)tabCtrl.SelectedPanel.Controls.Find("comboBox", true)[0]).SelectedIndex;
                    _currentTxtBox     = (TextBox)tabCtrl.SelectedPanel.Controls.Find("txtBox", true)[0];
                }
            }
        }
示例#16
0
 private void LoadSettings()
 {
     CSetup.EnsureFolderGalleryFolder(SiteSettings);
 }
示例#17
0
        private void ExamFrm_Load(object sender, EventArgs e)
        {
            if (_pracConfig == null)
            {
                MessageBox.Show("ExamConfig属性未赋值。");
                this.Close();
                return;
            }

            if (IsExam)
            {
                this.Text = "考试窗口";
            }
            else
            {
                this.Text = "练习窗口";
            }

            //
            //读取设置文件,准备环境设置
            //
            //用哪个setting
            SettingPair sp = new SettingPair();

            sp.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.Setting.ClsFilePath, PracticeConfig.Setting.ClsName);
            sp.FilePath       = PracticeConfig.Setting.ConfigFilePath;

            ISettings setting  = new CSetup(sp).Settings;
            CSettings csetting = setting as CSettings;

            //
            //创建Monitor,Translator,StateManager。
            //准备考试核心引擎
            //
            //用哪个monitor
            AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Monitor.ClsFilePath, PracticeConfig.Monitor.ClsName);

            mon = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting);

            //用哪个translator
            AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.Translator.ClsFilePath, PracticeConfig.Translator.ClsName);

            translator = TranslatorFactory.CreateTranslater(transInfo, mon);

            //用哪个statemanager
            AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(PracticeConfig.StateManager.ClsFilePath, PracticeConfig.StateManager.ClsName);

            stateMgr = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting);

            //
            //创建考试启动停止控件
            //实现单会合考试
            examCtrl.Anchor = AnchorStyles.None;
            examCtrl.Dock   = DockStyle.Fill;
            this.paneExamCtrl.Controls.Add(examCtrl);

            //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize
            examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr);

            //初始化声音控件(基础声音控件类)
            SoundCtrl soundCtrl = new SoundCtrl();


            //初始化显示牌控件
            SettingPair spDisplay = new SettingPair();

            spDisplay.ImplementClass = AssemblyInfoFactory.GetType(PracticeConfig.LEDConfig.ClsFilePath, PracticeConfig.LEDConfig.ClsName);
            spDisplay.FilePath       = PracticeConfig.LEDConfig.ConfigFilePath;

            ISettings     dissettings    = new CSetup(spDisplay).Settings;
            DisplayConfig dispalySetting = dissettings as DisplayConfig;

            displaycomm = DisplayFactory.CreateDisplay(PracticeConfig.LED.ClsFilePath, PracticeConfig.LED.ClsName, dispalySetting);

            //初始化摄像头
            Camera camera = new Camera(0);

            camera.Anchor = AnchorStyles.None;
            camera.Dock   = DockStyle.Fill;
            this.groupPanelVideo.Controls.Add(camera);
            this.Move        += new EventHandler(camera.Camera_Move);
            this.FormClosing += new FormClosingEventHandler(camera.Camera_Closing);

            if (IsExam)
            {
                string[] cxs = ExamConfig.LicenseList.Split(new char[] { ';' });
                //初始化车型列表
                List <string> cxList = new List <string>(cxs);

                //用哪个Candidate Infomation Panel
                CandExamCtrl candExamPane;

                if (ExamConfig.HasQueue)
                {
                    //初始化排队列表
                    CandidateQuery candQuery = new CandidateQuery();
                    candQuery.Anchor = AnchorStyles.None;
                    candQuery.Dock   = DockStyle.Fill;
                    this.paneXQueueList.Controls.Add(candQuery);

                    candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { candQuery });
                }
                else
                {
                    candExamPane = (CandExamCtrl)CreateModule(ExamConfig.ExamCtrl.ClsFilePath, ExamConfig.ExamCtrl.ClsName, new object[] { });
                }

                candExamPane.Dock = DockStyle.Fill;
                candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList);
                this.groupPanelCandInfo.Controls.Add(candExamPane);

                //结果显示控件
                ExamResultPanel resultPanel = new ExamResultPanel();
                resultPanel.Anchor            = AnchorStyles.None;
                resultPanel.Dock              = DockStyle.Fill;
                candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText);
                this.paneXResult.Controls.Add(resultPanel);

                candExamPane.SoundChange         += new MessageDelegate(soundCtrl.PlayText);   //注册candExamCtrl的声音变化事件回调函数
                candExamPane.LEDDisplayChange    += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数
                candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel);    //注册candExamCtrl的摄像头变化事件回调函数
            }

            //创建考试状态显示面板
            //单会合考试级别扩展功能
            ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel();

            statePane.Anchor = AnchorStyles.None;
            statePane.InitializeExamComponent(stateMgr);
            this.paneXStatus.Controls.Add(statePane);

            //创建信号显示面板
            SignalDisplay signaldisplay = new SignalDisplay(mon);

            signaldisplay.Anchor = AnchorStyles.None;
            signaldisplay.Dock   = DockStyle.Fill;
            this.paneXSignalDisp.Controls.Add(signaldisplay);

            //用哪个DisplayPanel
            BaseModelDisplayPanel modelDisplayPane = (BaseModelDisplayPanel)CreateModule(PracticeConfig.ModelDisplay.ClsFilePath, PracticeConfig.ModelDisplay.ClsName, new object[] { });

            modelDisplayPane.Anchor = AnchorStyles.None;
            modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr);
            this.groupPanelModelDisp.Controls.Add(modelDisplayPane);
        }
示例#18
0
        private void RunSetup()
        {
            #region setup Cynthia-core

            if (!schemaHasBeenCreated)
            {
                if (canAlterSchema)
                {
                    CreateInitialSchema("Cynthia-core");
                    schemaHasBeenCreated = DatabaseHelper.SchemaHasBeenCreated();
                    if (schemaHasBeenCreated)
                    {
                        //recheck
                        needSchemaUpgrade = CSetup.UpgradeIsNeeded();
                    }
                }
            }

            if (
                (schemaHasBeenCreated) &&
                (needSchemaUpgrade) &&
                (canAlterSchema)
                )
            {
                needSchemaUpgrade = UpgradeSchema("Cynthia-core");
            }

            if (!CoreSystemIsReady())
            {
                return;
            }

            existingSiteCount = DatabaseHelper.ExistingSiteCount();
            if (existingSiteCount == 0)
            {
                CreateSiteAndAdminUser();
            }


            // look for new features or settings to install
            SetupFeatures("Cynthia-core");


            #endregion

            #region setup other applications

            // install other apps

            String pathToApplicationsFolder
                = HttpContext.Current.Server.MapPath(
                      "~/Setup/applications/");

            if (!Directory.Exists(pathToApplicationsFolder))
            {
                WritePageContent(
                    pathToApplicationsFolder
                    + " " + SetupResource.ScriptFolderNotFoundAddendum,
                    false);

                return;
            }

            DirectoryInfo appRootFolder
                = new DirectoryInfo(pathToApplicationsFolder);

            DirectoryInfo[] appFolders = appRootFolder.GetDirectories();

            foreach (DirectoryInfo appFolder in appFolders)
            {
                if (
                    (!string.Equals(appFolder.Name, "Cynthia-core", StringComparison.InvariantCultureIgnoreCase)) &&
                    (appFolder.Name.ToLower() != ".svn") &&
                    (appFolder.Name.ToLower() != "_svn")
                    )
                {
                    CreateInitialSchema(appFolder.Name);
                    UpgradeSchema(appFolder.Name);
                    SetupFeatures(appFolder.Name);
                }
            }

            #endregion

            WritePageContent(SetupResource.EnsuringFeaturesInAdminSites, true);
            ModuleDefinition.EnsureInstallationInAdminSites();

            SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();

            if (siteSettings != null)
            {
                if (PageSettings.GetCountOfPages(siteSettings.SiteId) == 0)
                {
                    WritePageContent(SetupResource.CreatingDefaultContent);
                    //SetupContentPages(siteSettings);
                    CSetup.SetupDefaultContentPages(siteSettings);
                }

                try
                {
                    int userCount = SiteUser.UserCount(siteSettings.SiteId);
                    if (userCount == 0)
                    {
                        CSetup.EnsureRolesAndAdminUser(siteSettings);
                    }
                }
                catch (Exception ex)
                {
                    log.Error("EnsureAdminUserAndRoles", ex);
                }

                CSetup.EnsureSkins(siteSettings.SiteId);
            }

            // in case control type controlsrc, regex or sort changed on the definition
            // update instance properties to match
            ThreadPool.QueueUserWorkItem(new WaitCallback(SyncDefinitions), null);
            //ModuleDefinition.SyncDefinitions();
            SiteSettings.EnsureExpandoSettings();
            CSetup.EnsureAdditionalSiteFolders();
        }
示例#19
0
        private bool RunSetupScript(
            Guid applicationId,
            string applicationName,
            string pathToScriptFolder,
            Version versionToStopAt)
        {
            bool result = true;

            if (!Directory.Exists(pathToScriptFolder))
            {
                WritePageContent(
                    pathToScriptFolder + " " + SetupResource.ScriptFolderNotFoundMessage,
                    false);

                return(false);
            }

            DirectoryInfo directoryInfo
                = new DirectoryInfo(pathToScriptFolder);

            FileInfo[] scriptFiles = directoryInfo.GetFiles("*.config");
            Array.Sort(scriptFiles, UIHelper.CompareFileNames);


            if (scriptFiles.Length == 0)
            {
                WritePageContent(
                    SetupResource.NoScriptsFilesFoundMessage
                    + " " + pathToScriptFolder,
                    false);

                return(false);
            }

            // We only want to run the highest version script from the /SchemaInstallationScripts/dbplatform folder
            // normally there is only 1 script in this folder, but if someone upgrades and then starts with a clean db
            // there can be more than one script because of the previous installs so we nned to make sure we only run the highest version found
            // since we sorted it the highest version is the last item in the array
            FileInfo scriptFile = scriptFiles[(scriptFiles.Length - 1)];

            Version currentSchemaVersion
                = DatabaseHelper.GetSchemaVersion(applicationId);


            Version scriptVersion
                = DatabaseHelper.ParseVersionFromFileName(scriptFile.Name);

            if (
                (scriptVersion != null) &&
                (scriptVersion > currentSchemaVersion) &&
                (versionToStopAt == null || (scriptVersion <= versionToStopAt))
                )
            {
                string message = string.Format(
                    SetupResource.RunningScriptMessage,
                    applicationName,
                    scriptFile.Name.Replace(".config", string.Empty));

                WritePageContent(
                    message,
                    true);

                string errorMessage
                    = DatabaseHelper.RunScript(
                          applicationId,
                          scriptFile,
                          null);

                if (errorMessage.Length > 0)
                {
                    WritePageContent(errorMessage, true);
                    return(false);
                }

                if (string.Equals(applicationName, "Cynthia-core", StringComparison.InvariantCultureIgnoreCase))
                {
                    CSetup.DoPostScriptTasks(scriptVersion, null);
                }

                Version newVersion
                    = DatabaseHelper.ParseVersionFromFileName(scriptFile.Name);

                if (
                    (applicationName != null) &&
                    (newVersion != null)
                    )
                {
                    DatabaseHelper.UpdateSchemaVersion(
                        applicationId,
                        applicationName,
                        newVersion.Major,
                        newVersion.Minor,
                        newVersion.Build,
                        newVersion.Revision);

                    DatabaseHelper.AddSchemaScriptHistory(
                        applicationId,
                        scriptFile.Name,
                        DateTime.UtcNow,
                        false,
                        string.Empty,
                        string.Empty);

                    if (errorMessage.Length == 0)
                    {
                        currentSchemaVersion = newVersion;
                    }
                }
            }


            return(result);
        }
示例#20
0
文件: Form1.cs 项目: wpmyj/Zhuangkao
        private void button4_Click(object sender, EventArgs e)
        {
            //
            //读取设置文件,准备环境设置
            //
            //用哪个setting
            SettingPair sp1 = new SettingPair();

            //sp1.ImplementClass = new MotorSignalSettings().GetType();
            sp1.ImplementClass = new TractorSignalSettings().GetType();
            sp1.FilePath       = "TractorSignal.config";

            ISettings setting  = new CSetup(sp1).Settings;
            CSettings csetting = setting as CSettings;

            //
            //创建Monitor,Translator,StateManager。
            //准备考试核心引擎
            //
            //用哪个monitor
            //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Motor.MotorMonitor));
            //AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.OldCarMonitor));
            AssemblyInfoPair monInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Share.Signal.Car.TractorMonitor));
            ISignalMonitor   mon     = SignalMonitorFactory.CreateSignalMonitor(monInfo, setting);

            //用哪个translator
            //AssemblyInfoPair transInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.MotorSignalTranslator));
            AssemblyInfoPair transInfo  = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.CarSignalTranslator));
            ITranslator      translator = TranslatorFactory.CreateTranslater(transInfo, mon);

            //用哪个statemanager
            //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.MotorState.MotorStateManager));
            //AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.PureLineCarState.CarStateManager));
            AssemblyInfoPair stateMgrInfo = AssemblyInfoFactory.GetAssemblyInfo(typeof(Cn.Youdundianzi.Exam.State.Tractor.TractorStateManager));
            IStateManager    stateMgr     = StateManagerFactory.CreateStateManager(stateMgrInfo, translator, setting);

            //
            //创建考试启动停止控件
            //实现单会合考试
            ExamCtrlPanel examCtrl = new ExamCtrlPanel();

            examCtrl.Location = new System.Drawing.Point(0, 0);
            this.ctrlPanel.Controls.Add(examCtrl);

            //ExamCtrl控件必须先被add到其父窗口中,然后再进行Initialize
            examCtrl.InitializeExamComponent(setting, mon, translator, stateMgr);

            //创建考试状态显示面板
            //单会合考试级别扩展功能
            ExamStatusDisplayPanel statePane = new ExamStatusDisplayPanel();

            statePane.Location    = new System.Drawing.Point(0, 100);
            statePane.BorderStyle = BorderStyle.Fixed3D;
            statePane.InitializeExamComponent(stateMgr);
            this.ctrlPanel.Controls.Add(statePane);

            //创建信号显示面板
            SignalDisplay signaldisplay = new SignalDisplay(mon);

            signaldisplay.Location = new System.Drawing.Point(0, 20);
            //sd.BorderStyle = BorderStyle.Fixed3D;
            this.ctrlPanel.Controls.Add(signaldisplay);


            //用哪个DisplayPanel
            //BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.CarModelDisplayPanel();
            BaseModelDisplayPanel modelDisplayPane = new Cn.Youdundianzi.Share.Module.ModelDisplay.Car.TractorModelDisplayPanel();

            modelDisplayPane.Location = new System.Drawing.Point(200, 0);
            modelDisplayPane.InitializeExamComponent(csetting, mon, stateMgr);
            this.ctrlPanel.Controls.Add(modelDisplayPane);

            /**
             * //初始化车型列表
             * List<string> cxList = new List<string>(2);
             * cxList.Add("A");
             * cxList.Add("B");
             *
             * //初始化排队列表
             * CandidateQuery candQuery = new CandidateQuery();
             * candQuery.Location = new System.Drawing.Point(550, 20);
             * //sd.BorderStyle = BorderStyle.Fixed3D;
             * this.ctrlPanel.Controls.Add(candQuery);
             *
             * //用哪个Candidate Infomation Panel
             * CandExamCtrl candExamPane = new Cn.Youdundianzi.Share.Module.CandidateInfo.LocalInputPanel();
             * candExamPane.Location = new System.Drawing.Point(0, 150);
             * candExamPane.InitializeCandExamCtrlComponent(examCtrl, csetting, cxList);
             * this.ctrlPanel.Controls.Add(candExamPane);
             *
             * //初始化声音控件(基础声音控件类)
             * SoundCtrl soundCtrl = new SoundCtrl();
             * candExamPane.SoundChange += new MessageDelegate(soundCtrl.PlayText);    //注册candExamCtrl的声音变化事件回调函数
             *
             * //初始化显示牌控件
             * //------------------------------------------------------------------------------
             * string LEDAssemblyFilePath = Application.StartupPath + "\\LEDDisplay.dll";
             *
             * SettingPair spDisplay = new SettingPair();
             * spDisplay.ImplementClass = AssemblyInfoFactory.GetType(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayConfigClass);
             * spDisplay.FilePath = csetting.DisplayPaneConfig.DisplayConfigFilePath;
             *
             * ISettings dissettings = new CSetup(spDisplay).Settings;
             * DisplayConfig dispalySetting = dissettings as DisplayConfig;
             * IDisplaycomm displaycomm = DisplayFactory.CreateDisplay(LEDAssemblyFilePath, csetting.DisplayPaneConfig.DisplayCommClass, dispalySetting);
             * candExamPane.LEDDisplayChange += new MessageDelegate(displaycomm.ShowText); //注册candExamCtrl的显示牌变化事件回调函数
             *
             *
             * //初始化摄像头
             * Camera camera = new Camera(0);
             * camera.Location = new System.Drawing.Point(200, 400);
             * camera.Size = new Size(400, 300);
             * camera.BorderStyle = BorderStyle.Fixed3D;
             * this.ctrlPanel.Controls.Add(camera);
             * candExamPane.CameraChannelChange += new IntegerDelegate(camera.SetChannel); //注册candExamCtrl的摄像头变化事件回调函数
             *
             * //结果显示控件
             * ExamResultPanel resultPanel = new ExamResultPanel();
             * resultPanel.Location = new System.Drawing.Point(0, 400);
             * resultPanel.Size = new Size(210, 110);
             * resultPanel.BorderStyle = BorderStyle.FixedSingle;
             * candExamPane.ExamResultReady += new ExamResultDelegate(resultPanel.SetResultText);
             **/
        }
示例#21
0
 private void tabCtrl_Click(object sender, EventArgs e)
 {
     _currentSetup      = _tabTable[(TabItem)sender];
     _currentVoiceIndex = ((ComboBox)tabCtrl.SelectedPanel.Controls.Find("comboBox", true)[0]).SelectedIndex;
     _currentTxtBox     = (TextBox)tabCtrl.SelectedPanel.Controls.Find("txtBox", true)[0];
 }