예제 #1
0
        //
        //编写测试时,还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///Load 的测试
        ///</summary>
        public void LoadTestHelper <T>()
        {
            string        filePath = @"D:\SVN\Platform\TTSM2_Code\TestFramework\ConfigFiles\StationConfig.xml";
            StationConfig sc       = XmlConfigHelper.Load <StationConfig>(filePath);

            Assert.IsNotNull(sc);
        }
예제 #2
0
        /// <summary>
        ///Save 的测试
        ///</summary>
        public void SaveTestHelper <T>()
        {
            GlobalVariablesConfig gvcfg = new GlobalVariablesConfig();

            gvcfg.GloblaVariables.Add(new Variable("SN", ""));
            XmlConfigHelper.Save <GlobalVariablesConfig>(gvcfg, "GlobalVariables.xml");
        }
예제 #3
0
        private void CopyConfiguration(int sourceAppId, int targetAppId)
        {
            XmlConfigHelper configHelper = new XmlConfigHelper();

            Stream config = configHelper.GetZipConfig(Maps.Instance.GetAppNameById(sourceAppId), null);

            configHelper.UploadConfigFromFile(Maps.Instance.GetAppNameById(targetAppId), StreamToString(config));
        }
예제 #4
0
        public void Test_GetOptions()
        {
            string[] strs = XmlConfigHelper.GetOptions("CurrentLanguage");
            //Console.WriteLine(string.Join(",", strs));
            string s = System.AppDomain.CurrentDomain.ToString();


            Log4NetUtil.OutputMessage += Log4NetUtil_OutputMessage;
        }
예제 #5
0
        public void LoadGlobalVariables()
        {
            testEngineLogger.Log(string.Format("Loading global variables: {0}", Path.GetFullPath(globalVariablesCfgFile)), "LoadGlobalVariables");

            gvCfg = XmlConfigHelper.Load <GlobalVariablesConfig>(globalVariablesCfgFile);
            foreach (var item in gvCfg.GloblaVariables)
            {
                globalVars.Add(item.Name, item.Value);
            }
            testEngineLogger.Log("Success", "LoadGlobalVariables");
        }
예제 #6
0
파일: Comm.cs 프로젝트: ppkdch54/ZSJCMaster
        private void LoadPara()
        {
            XmlConfigHelper config = new XmlConfigHelper();

            config.Load("Application.config");
            PortName = config.ReadNodeValue("portName");
            BaudRate = int.Parse(config.ReadNodeValue("baudRate"));
            Parity   = (Parity)int.Parse(config.ReadNodeValue("parity"));
            DataBits = int.Parse(config.ReadNodeValue("dataBits"));
            StopBits = (StopBits)int.Parse(config.ReadNodeValue("stopBits"));
        }
예제 #7
0
        private void button_Confirm_Click(object sender, EventArgs e)
        {
            this.dataGridView_RFLossConfig.EndEdit();
            if (!CheckInstrAddr())
            {
                MessageBox.Show("输入仪表地址错误!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.textBox_InstrAddr.SelectAll();
                return;
            }

            XmlConfigHelper.Save <StationConfig>(sc, stationConfigFile);
            this.Close();
        }
예제 #8
0
 /// <summary>
 /// Returns a suffix for the generated artifacts which guarantees that they don't conflict with any
 /// existing artifacts in the project.
 /// </summary>
 private static string GetGeneratedArtifactSuffix(ConnectedServiceHandlerContext context, Project project, AuthenticationStrategy authStrategy)
 {
     using (XmlConfigHelper configHelper = context.CreateReadOnlyXmlConfigHelper())
     {
         return(GeneralUtilities.GetUniqueSuffix(suffix =>
         {
             string serviceName = SalesforceConnectedServiceHandler.GetServiceInstanceName(suffix);
             return configHelper.IsPrefixUsedInAppSettings(serviceName) ||
             (authStrategy == AuthenticationStrategy.WebServerFlow &&
              configHelper.IsHandlerNameUsed(Constants.OAuthRedirectHandlerNameFormat.FormatInvariantCulture(serviceName))) ||
             SalesforceConnectedServiceHandler.IsSuffixUsedInGeneratedFilesDirectories(context, serviceName, project);
         }));
     }
 }
예제 #9
0
        private void SaveConfig(object p)
        {
            XmlConfigHelper.GenerateConfigFile(
                BaseServerPath,
                CertificatePath,
                FtpPort,
                LoggerPath,
                PortMax,
                PortMin,
                ExternalIp,
                PortsOccupationRetries
                );

            UpdateFields(null);
        }
예제 #10
0
        public IHttpActionResult upload()
        {
            if (!IsAdmin())
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.ActionIsUnauthorized)));
            }

            string appname = string.Empty;

            try
            {
                appname = System.Web.HttpContext.Current.Items[Durados.Database.AppName].ToString();
                if (appname == Maps.DuradosAppName)
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, Messages.AppNameCannotBeNull)));
                }
            }
            catch (Exception ex)
            {
                return(ResponseMessage(Request.CreateResponse(HttpStatusCode.InternalServerError, Messages.AppNameCannotBeNull)));
            }
            try
            {
                string jsonPost = Request.Content.ReadAsStringAsync().Result;
                Dictionary <string, object> jsonPostDict = Durados.Web.Mvc.UI.Json.JsonSerializer.Deserialize(jsonPost);


                if (!jsonPostDict.ContainsKey("filename"))
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Conflict, "You must send the filename parameter")));
                }
                String filename = System.Web.HttpContext.Current.Server.UrlDecode((String)jsonPostDict["filename"]);
                if (!jsonPostDict.ContainsKey("filedata"))
                {
                    return(ResponseMessage(Request.CreateResponse(HttpStatusCode.Conflict, "You must send the filedata parameter")));
                }

                XmlConfigHelper configHelper = new XmlConfigHelper();

                string version = configHelper.UploadConfigFromFile(appname, (String)jsonPostDict["filedata"]);

                return(Ok(new { success = true, message = String.Format("Config Version {0} was succesfuly loaded to {1}", version, appname) }));
            }
            catch (Exception exception)
            {
                throw new BackAndApiUnexpectedResponseException(exception, this);
            }
        }
예제 #11
0
        private void ChangeSerialPortsParam(ExCommandParameter param)
        {
            var sender        = param.Sender as System.Windows.Controls.ComboBox;
            int selectedIndex = sender.SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }
            var             selectedItem = sender.SelectedItem as SettingWindowParamHelper;
            XmlConfigHelper config       = new XmlConfigHelper();

            config.Load("Application.config");
            config.UpdateNodeValue(selectedItem.ParamTypeName, selectedItem.Value.ToString());
            config.Save("Application.config");
        }
예제 #12
0
        private async void InitViewData()
        {
            _ViewDataDic.Clear();
            var list = await XmlConfigHelper.LoadXml(ConfigType.ViewDataConfig);

            foreach (XmlNode item in list.NodeList)
            {
                ViewItemData data = new ViewItemData();
                data.ID           = item.Attributes["ID"].Value;
                data.ValueX       = float.Parse(item.Attributes["X"].Value);
                data.ValueY       = float.Parse(item.Attributes["Y"].Value);
                data.Distance     = float.Parse(item.Attributes["Distance"].Value);
                data.TargetID     = item.Attributes["TargetID"].Value;
                data.Precondition = item.Attributes["Precondition"].Value;
                _ViewDataDic.Add(data.ID, data);
            }
        }
예제 #13
0
        private void StationSettings_Shown(object sender, EventArgs e)
        {
            sc = XmlConfigHelper.Load <StationConfig>(stationConfigFile);
            this.textBox_Comport.Text = sc.DutComport;

            cpEc = sc.EquipmentConfig.Find(x => x.InstrumentType.Equals("CP"));
            this.comboBox_ConnectType.Text = cpEc.ConnectionType.ToString();
            this.textBox_InstrAddr.Text    = cpEc.Address;

            psEc = sc.EquipmentConfig.Find(x => x.InstrumentType.Equals("PS"));
            this.textBox_PSAddr.Text = psEc.Address;

            foreach (var item in sc.RFNetLossConfigs)
            {
                string[] row = { item.BandName,                     item.UpLinkChannel.ToString(), item.UplinkLossMain.ToString("F2"), item.DownlinkLossMain.ToString("F2"),
                                 item.UplinkLossDiv.ToString("F2"), item.DownlinkLossDiv.ToString("F2") };
                this.dataGridView_RFLossConfig.Rows.Add(row);
            }
        }
예제 #14
0
        public void LoadTestSequence(string sequenceFilePath)
        {
            testEngineLogger.Log(string.Format("Loading TestSequence: {0}", sequenceFilePath), "LoadTestSequence");

            testSequence = XmlConfigHelper.Load <TestSequence>(sequenceFilePath);
            testModules.Clear();
            testModuleMgr.UnloadTestModules();
            // fetch used test modules of the sequence
            foreach (var item in testSequence.TestSteps)
            {
                if (!testModules.Contains(item.AssemblyName))
                {
                    testModules.Add(item.AssemblyName);
                }
            }
            LoadTestModules();
            MessengerEx.Notify(TestEngineMessages.TestSequenceLoaded, testSequence);
            testEngineLogger.Log("Success", "LoadTestSequence");
        }
예제 #15
0
        private void UpdateFields(object p)
        {
            try
            {
                var config = XmlConfigHelper.ParseSettings();

                BaseServerPath         = config.BaseDirectory;
                PortMax                = config.MaxPort.ToString();
                PortMin                = config.MinPort.ToString();
                ExternalIp             = config.ServerExternalIP;
                CertificatePath        = config.CertificateLocation;
                LoggerPath             = config.LoggingPath;
                FtpPort                = config.FtpControlPort.ToString();
                PortsOccupationRetries = config.PassiveConnectionRetryFor.ToString();
            }
            catch
            {
                PopupMessageQueue.Enqueue("Error updating fields: Configuration file is incorrect. Fix it and try again.");
            }
        }
예제 #16
0
        /// <summary>
        /// Inits App config file
        /// </summary>
        private static void InitAppConfig()
        {
            #region config.xml

            // =============== Reading SysFields.xml file
            // check if the XML file exists, if not create the XML file with default
            if (File.Exists(StrXmlFilename) == false)
            {
                XmlConfigHelper.CreateXML(StrXmlFilename);
            }
            if (File.Exists(StrXmlFilename))
            {
                // Check if root node in XML file exists; if it doesn't exist a new XML file is created with all application parameters
                if (XmlConfigHelper.CheckRootNode(StrXmlFilename) == false)
                {
                    XmlConfigHelper.CreateXML(StrXmlFilename);
                }
            }
            else
            {
                Console.WriteLine("The file {0} could not be located", StrXmlFilename);
            }

            //  check elements values in XML file
            XmlConfigHelper.CheckXML(StrXmlFilename);

            //  Read elements values in XML file
            XmlConfigHelper.ReadXML(StrXmlFilename);

            // Compose the right name for the log file, including date and time in the front
            _fileName                  = DateTime.Now.ToString("yyyy-MM-dd-HH.mm.ss_", CultureInfo.InvariantCulture) + XmlConfigHelper.FileNameLog;
            _folderPath                = XmlConfigHelper.FolderPath;
            _writeToLogFile            = Convert.ToBoolean(XmlConfigHelper.WriteToLogFile);
            _maxNumberRecordsInLogFile = Convert.ToInt32(XmlConfigHelper.MaxNumberRecordsInLogFile);
            _pollingSysParamsInterval  = Convert.ToInt32(XmlConfigHelper.PollingSysParamsInterval);
            _monitoredProcesses        = XmlConfigHelper.MonitoredProcesses.Split(';');

            #endregion
        }
예제 #17
0
        public static bool IsHandlerNameUsed(this XmlConfigHelper configHelper, string handlerName)
        {
            ConfigurationSection webServerSection = configHelper.Configuration.GetSection(ConfigHelperExtensions.WebServerSectionName);

            if (webServerSection == null)
            {
                return(false);
            }

            string webServerSectionRawXml = webServerSection.SectionInformation.GetRawXml();

            if (webServerSectionRawXml == null)
            {
                return(false);
            }

            XElement webServerElement = XElement.Parse(webServerSectionRawXml);

            return(webServerElement.Elements("handlers")
                   .SelectMany(handlersElement => handlersElement.Elements("add"))
                   .Any(addElement => addElement.Attribute("name").Value == handlerName));
        }
        /// <summary>
        /// Detects which authentication type/settings the service was previously configured with and
        /// initializes the view models accordingly.
        /// </summary>
        private void RestoreAuthenticationSettings()
        {
            using (XmlConfigHelper configHelper = context.CreateReadOnlyXmlConfigHelper())
            {
                ConfigurationKeyNames configKeys = new ConfigurationKeyNames(this.DesignerData.ServiceName);
                if (configHelper.GetAppSetting(configKeys.UserName) != null)
                {
                    this.runtimeAuthenticationTypeViewModel.RuntimeAuthStrategy = AuthenticationStrategy.UserNamePassword;
                }
                else
                {
                    this.runtimeAuthenticationTypeViewModel.RuntimeAuthStrategy = AuthenticationStrategy.WebServerFlow;

                    string myDomain = configHelper.GetAppSetting(configKeys.Domain);
                    this.runtimeAuthenticationConfigViewModel.IsCustomDomain =
                        myDomain != null && !string.Equals(myDomain, Constants.ProductionDomainUrl, StringComparison.OrdinalIgnoreCase);
                    if (this.runtimeAuthenticationConfigViewModel.IsCustomDomain)
                    {
                        this.runtimeAuthenticationConfigViewModel.MyDomainViewModel.MyDomain = myDomain;
                    }
                }
            }
        }
예제 #19
0
        public HttpResponseMessage download(string version = null)
        {
            XmlConfigHelper configHelper = new XmlConfigHelper();

            string appname;

            try
            {
                appname = System.Web.HttpContext.Current.Items[Durados.Database.AppName].ToString();
                if (appname == Maps.DuradosAppName)
                {
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, Messages.AppNameCannotBeNull));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, Messages.AppNameCannotBeNull));
            }



            System.IO.Stream    s = configHelper.GetZipConfig(appname, version);
            HttpResponseMessage response;

            if (s == null)
            {
                response = new HttpResponseMessage(HttpStatusCode.NotFound);
            }

            response         = new HttpResponseMessage(HttpStatusCode.OK);
            response.Content = new StreamContent(s);
            response.Content.Headers.ContentDisposition          = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentDisposition.FileName = Map.AppName + ".zip";

            return(response);
        }
예제 #20
0
 public void LoadStationConfig()
 {
     testEngineLogger.Log(string.Format("Loading station cfg file: {0}", Path.GetFullPath(stationConfigFile)), "LoadStationConfig");
     sc = XmlConfigHelper.Load <StationConfig>(stationConfigFile);
     testEngineLogger.Log("Success.", "LoadStationConfig");
 }