private void btnAddWS_WritingSystemAdded(object sender, EventArgs e)
        {
            IWritingSystem ws = btnAddWS.NewWritingSystem;

            if (ws != null)
            {
                string mapName = ws.LegacyMapping;
                var    wsi     = new WsInfo(ws.DisplayLabel, ws.Id, mapName);
                m_wsInfo.Add(wsi.KEY, wsi);

                // now select it for the ws combo box
                int index = cbWS.Items.Add(wsi);
                cbWS.SelectedIndex = index;

                // now if there's an encoding converter for the ws, select it
                if (String.IsNullOrEmpty(mapName))
                {
                    index = cbEC.FindStringExact(m_blankEC);
                }
                else
                {
                    index = cbEC.Items.Add(mapName);
                }
                cbEC.SelectedIndex = index;
            }
        }
Example #2
0
        private void ReloadWsCombo()
        {
            m_wsInfo.Clear();
            cbWS.ClearItems();
            cbWS.Sorted = true;
            foreach (var ws in m_cache.ServiceLocator.WritingSystemManager.WritingSystems)
            {
                var wsi = new WsInfo(ws.DisplayLabel, ws.Id, ws.LegacyMapping);
                m_wsInfo.Add(wsi.KEY, wsi);
                cbWS.Items.Add(wsi);
            }

            cbWS.Sorted = false;
            // Add the special "ignore" WsInfo
            cbWS.Items.Add(new WsInfo());
        }
 private void cbWS_SelectedValueChanged(object sender, System.EventArgs e)
 {
     // (Bev) when the user changes the FW writing system, select a new encoding converter
     if (m_wsInfo != null)
     {
         // (Bev) pick up the current writing system
         WsInfo wsi = cbWS.SelectedItem as WsInfo;
         if (wsi != null)
         {
             if (wsi.Map != null)
             {
                 // (Bev) this writing system has a default encoding converter
                 cbEC.Text = wsi.Map;
             }
             else
             {
                 // (Bev) defaults if the writing system is not associated with an encoding converter
                 // REVIEW: SHOULD THIS NAME BE LOCALIZED?
                 cbEC.Text = (m_LinguaLinksImport == true) ? "Windows1252<>Unicode" : m_blankEC;
             }
         }
     }
 }
Example #4
0
        private ArrayList GetOtherNamedWritingSystems()
        {
            ArrayList result = new ArrayList();

            try
            {
                // Convert from Set to List, since the Set can't sort.
                List <NamedWritingSystem> al = new List <NamedWritingSystem>(m_cache.LangProject.GetAllNamedWritingSystems().ToArray());
                al.Sort();
                foreach (NamedWritingSystem namedWs in al)
                {
                    // Make sure we only add language names (actually ICULocales in case any
                    // language names happen to be identical) that aren't already in the list box.
                    bool fFound = false;
                    foreach (DictionaryEntry entry in m_wsInfo)
                    {
                        WsInfo wsi = entry.Value as WsInfo;
                        if (wsi.Locale == namedWs.IcuLocale)
                        {
                            fFound = true;
                            break;
                        }
                    }
                    if (!fFound)
                    {
                        result.Add(namedWs);
                    }
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            result.Sort();
            return(result);
        }
Example #5
0
        private void CommonAddWS(bool isAnalysis, MenuItem selectedMI)
        {
            string icuLocal = "", mapName = "", wsName = "";
            bool   addWs = true;

            if (selectedMI.Text == LexTextControls.ks_DefineNew_)
            {
                using (WritingSystemWizard wiz = new WritingSystemWizard())
                {
                    wiz.Init(m_cache.LanguageWritingSystemFactoryAccessor, FwApp.App);
                    DialogResult dr = (DialogResult)wiz.ShowDialog();
                    if (dr == DialogResult.OK)
                    {
                        // The engine from the wizard isn't the real one, so it doesn't have an id.
                        IWritingSystem wsEngine = wiz.WritingSystem();
                        icuLocal = wsEngine.IcuLocale;
                        mapName  = wsEngine.LegacyMapping;
                        wsName   = wsEngine.LanguageName;
                    }
                    else
                    {
                        addWs = false;
                    }
                }
            }
            else
            {
                NamedWritingSystem namedWs  = selectedMI.Tag as NamedWritingSystem;
                ILgWritingSystem   wsEngine = namedWs.GetLgWritingSystem(m_cache);
                icuLocal = wsEngine.ICULocale;
                mapName  = wsEngine.LegacyMapping;
                wsName   = wsEngine.Name.BestAnalysisAlternative.Text;
            }

            if (addWs)
            {
                int ws = m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(icuLocal);
                // string wsName = ws.get_UiName(wsUser);
                WsInfo wsi = new WsInfo(ws, wsName, icuLocal, mapName);
                m_wsInfo.Add(wsi.KEY, wsi);

                // now select it for the ws combo box
                int index = cbWS.Items.Add(wsi);
                cbWS.SelectedIndex = index;

                // now if there's an encoding converter for the ws, select it
                if (mapName != null && mapName.Length > 0)
                {
                    index = cbEC.Items.Add(mapName);
                    cbEC.SelectedIndex = index;
                }
                else
                {
                    index = cbEC.FindStringExact(m_blankEC);
                    cbEC.SelectedIndex = index;
                }

                // now add the ws to the FDO list for it
                if (isAnalysis)
                {
                    m_cache.LangProject.AnalysisWssRC.Add(ws);
                    m_cache.LangProject.CurAnalysisWssRS.Append(ws);
                }
                else
                {
                    m_cache.LangProject.VernWssRC.Add(ws);
                    m_cache.LangProject.CurVernWssRS.Append(ws);
                }
            }
        }
		private void CommonAddWS(bool isAnalysis, MenuItem selectedMI)
		{
			string icuLocal = "", mapName = "", wsName = "";
			bool addWs = true;

			if (selectedMI.Text == LexTextControls.ks_DefineNew_)
			{
				using (WritingSystemWizard wiz = new WritingSystemWizard())
				{
					wiz.Init(m_cache.LanguageWritingSystemFactoryAccessor, FwApp.App);
					DialogResult dr = (DialogResult)wiz.ShowDialog();
					if (dr == DialogResult.OK)
					{
						// The engine from the wizard isn't the real one, so it doesn't have an id.
						IWritingSystem wsEngine = wiz.WritingSystem();
						icuLocal = wsEngine.IcuLocale;
						mapName = wsEngine.LegacyMapping;
						wsName = wsEngine.LanguageName;
					}
					else
						addWs = false;
				}
			}
			else
			{
				NamedWritingSystem namedWs = selectedMI.Tag as NamedWritingSystem;
				ILgWritingSystem wsEngine = namedWs.GetLgWritingSystem(m_cache);
				icuLocal = wsEngine.ICULocale;
				mapName = wsEngine.LegacyMapping;
				wsName = wsEngine.Name.BestAnalysisAlternative.Text;
			}

			if (addWs)
			{
				int ws = m_cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr(icuLocal);
				// string wsName = ws.get_UiName(wsUser);
				WsInfo wsi = new WsInfo(ws, wsName, icuLocal, mapName);
				m_wsInfo.Add(wsi.KEY, wsi);

				// now select it for the ws combo box
				int index = cbWS.Items.Add(wsi);
				cbWS.SelectedIndex = index;

				// now if there's an encoding converter for the ws, select it
				if (mapName != null && mapName.Length > 0)
				{
					index = cbEC.Items.Add(mapName);
					cbEC.SelectedIndex = index;
				}
				else
				{
					index = cbEC.FindStringExact(m_blankEC);
					cbEC.SelectedIndex = index;
				}

				// now add the ws to the FDO list for it
				if (isAnalysis)
				{
					m_cache.LangProject.AnalysisWssRC.Add(ws);
					m_cache.LangProject.CurAnalysisWssRS.Append(ws);
				}
				else
				{
					m_cache.LangProject.VernWssRC.Add(ws);
					m_cache.LangProject.CurVernWssRS.Append(ws);
				}
			}
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="NsiClientWSRest"/> class. 
        /// </summary>
        /// <param name="config">
        /// The config
        /// </param>
        public NsiClientWSRest(WsInfo config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(config.EndPoint))
            {
                throw new ArgumentException(Resources.ExceptionEndpointNotSet, "config");
            }

            // Getting nsiClientWs
            WsInfo wsInfo = new WsInfo(config.Config, SdmxSchemaEnumType.VersionTwo);
            this._nsiClientWs = new NsiClientWS(wsInfo);

            Logger.Info(Resources.InfoCreatingNsiClient);
            this._config = config;

            this._defaultHeader = new HeaderImpl("NSIClient", "NSIClient");
            Utils.PopulateHeaderFromSettings(this._defaultHeader);
        }
        private void LexImportWizardLanguage_Load(object sender, EventArgs e)
        {
            // (Bev) modify a few labels
            if (m_LinguaLinksImport)
            {
                Text             = LexTextControls.ksSpecifyFwWs;
                lblComment.Text  = LexTextControls.ksSpecifyFwWsDescription;
                lblLangDesc.Text = LexTextControls.ksLanguageDefinition;
            }
            else
            {
                if (m_AddUsage)
                {
                    Text = LexTextControls.ksAddLangMapping;
                }
                else
                {
                    Text = LexTextControls.ksModifyLangMapping;
                }
            }

            tbLangDesc.Text = m_LangDesc;

            // initialize the 'ws' combo box and the AddWs button with the data from the DB
            foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems)
            {
                var wsi = new WsInfo(ws.DisplayLabel, ws.Id, ws.LegacyMapping);
                m_wsInfo.Add(wsi.KEY, wsi);
                cbWS.Items.Add(wsi);
            }

            cbWS.Sorted = false;
            var wsiIgnore = new WsInfo();

            cbWS.Items.Add(wsiIgnore);
            btnAddWS.Initialize(m_cache, m_helpTopicProvider, m_app, m_stylesheet, m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems);

            // select the proper index if there is a valid writing system
            int index = 0;

            if (!string.IsNullOrEmpty(m_wsName))
            {
                index = cbWS.FindStringExact(m_wsName);
                if (index < 0)
                {
                    index = 0;
                }
            }
            cbWS.SelectedIndex = index;

            LoadEncodingConverters();

            index = 0;
            if (!string.IsNullOrEmpty(m_encConverter))
            {
                index = cbEC.FindStringExact(m_encConverter);
                if (index < 0)
                {
                    index = 0;
                }
            }
            cbEC.SelectedIndex = index;
        }
		private void UpdateLanguageCodes()
		{
			if (m_sLastXmlFileName != m_LinguaLinksXmlFileName.Text)
			{
				m_sLastXmlFileName = m_LinguaLinksXmlFileName.Text;
				listViewMapping.Items.Clear();
				btnImport.Enabled = false;
				// default to not enabled now that there are no items
				m_nextInput = m_LinguaLinksXmlFileName.Text;
				if (!File.Exists(m_nextInput))
				{
					MessageBox.Show(
						String.Format(ITextStrings.ksLLFileNotFound, m_nextInput),
						ITextStrings.ksLLImport,
						MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}

				m_startPhase = 1;
				string nameTest;
				if (m_nextInput.Length > 19)
				{
					nameTest = m_nextInput.Substring(m_nextInput.Length - 19, 19);
					if (nameTest == "\\LLPhase1Output.xml")
					{
						m_startPhase = 2;
					}
					else if (nameTest == "\\LLPhase2Output.xml")
					{
						m_startPhase = 3;
					}
					else if (nameTest == "\\LLPhase3Output.xml")
					{
						m_startPhase = 4;
					}
					else if (nameTest == "\\LLPhase4Output.xml")
					{
						m_startPhase = 5;
					}
					else if (nameTest == "\\LLPhase5Output.xml")
					{
						m_startPhase = 6;
					}
				}

				if (m_startPhase == 1)
				{
					using (StreamReader streamReader = File.OpenText(m_nextInput))
					{
						String input;

						bool inWritingSystem = false;
						bool inIcuLocale24 = false;
						bool inName24 = false;
						bool lineDone = false;
						bool formatOkay = false;
						int pos, pos1, pos2, pos3;
						string wsLLCode = "";
						string wsName = "";
						var wsInfo = new Dictionary<string, WsInfo>();

						//getting name for a writing system given the ICU code.
						foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems)
						{
							var wsi = new WsInfo(ws.DisplayLabel, ws.Id, string.IsNullOrEmpty(ws.LegacyMapping) ? "Windows1252<>Unicode" : ws.LegacyMapping);
							wsInfo.Add(wsi.KEY, wsi);
						}

						while ((input = streamReader.ReadLine()) != null)
						{
							lineDone = false;
							while (!lineDone)
							{
								if (!inWritingSystem)
								{
									pos = input.IndexOf("<LgWritingSystem");
									if (pos >= 0)
									{
										inWritingSystem = true;
										wsLLCode = "";
										wsName = "";
										if (input.Length >= pos + 21)
											input = input.Substring(pos + 21, input.Length - pos - 21);
										else
											input = input.Substring(pos + 16);
									}

								else
									{
										lineDone = true;
									}
								}
								if (inWritingSystem && !inIcuLocale24 && !inName24)
								{
									pos1 = input.IndexOf("</LgWritingSystem>");
									pos2 = input.IndexOf("<ICULocale24>");
									pos3 = input.IndexOf("<Name24>");
									if (pos1 < 0 && pos2 < 0 && pos3 < 0)
									{
										lineDone = true;
									}
									else if (pos1 >= 0 && (pos2 < 0 || pos2 > pos1) && (pos3 < 0 || pos3 > pos1))
									{
										input = input.Substring(pos1 + 18, input.Length - pos1 - 18);
										if (wsLLCode != "")
										{
											if (wsName == "")
											{
												wsName = "<" + wsLLCode + ">";
											}
											string wsFWName = "";
											string wsEC = "";
											string wsFWCode = "";

											foreach (KeyValuePair<string, WsInfo> kvp in wsInfo)
											{
												WsInfo wsi = kvp.Value;
												if (wsName == wsi.Name)
												{
													wsFWName = TsStringUtils.NormalizeToNFC(wsi.Name);
													wsEC = TsStringUtils.NormalizeToNFC(wsi.Map);
													wsFWCode = TsStringUtils.NormalizeToNFC(wsi.Id);
												}
											}

											if (wsFWName == "")
											{
												foreach (KeyValuePair<string, WsInfo> kvp in wsInfo)
												{
													WsInfo wsi = kvp.Value;
													if (BaseName(wsName) == BaseName(wsi.Name))
													{
														wsFWName = TsStringUtils.NormalizeToNFC(wsi.Name);
														wsEC = TsStringUtils.NormalizeToNFC(wsi.Map);
														wsFWCode = TsStringUtils.NormalizeToNFC(wsi.Id);
													}
												}
											}

											var lvItem = new ListViewItem(new[] { TsStringUtils.NormalizeToNFC(wsName), wsFWName, wsEC, TsStringUtils.NormalizeToNFC(wsLLCode), wsFWCode });
											lvItem.Tag = wsName;
											listViewMapping.Items.Add(lvItem);
											formatOkay = true;
										}
										inWritingSystem = false;
									}
									else if (pos2 >= 0 && (pos3 < 0 || pos3 > pos2))
									{
										input = input.Substring(pos2 + 13, input.Length - pos2 - 13);
										inIcuLocale24 = true;
									}
									else
									{
										input = input.Substring(pos3 + 8, input.Length - pos3 - 8);
										inName24 = true;
									}
								}
								if (inIcuLocale24)
								{
									pos = input.IndexOf(">");
									if (pos < 0)
									{
										lineDone = true;
									}
									else
									{
										input = input.Substring(pos + 1, input.Length - pos - 1);
										pos = input.IndexOf("<");
										wsLLCode = input.Substring(0, pos);
										input = input.Substring(pos, input.Length - pos);
										inIcuLocale24 = false;
									}
								}
								if (inName24)
								{
									pos = input.IndexOf(">");
									if (pos < 0)
									{
										lineDone = true;
									}
									else
									{
										input = input.Substring(pos + 1, input.Length - pos - 1);
										pos = input.IndexOf("<");
										wsName = input.Substring(0, pos);
										input = input.Substring(pos, input.Length - pos);
										inName24 = false;
									}
								}
							}
						}
						streamReader.Close();
						listViewMapping_SelectedIndexChanged();
						CheckImportEnabled();
						if (!formatOkay)
						{
							ShowFinishLabel();
							// update the button before showing the msg box just in case...
							MessageBox.Show(
							String.Format(ITextStrings.ksInvalidLLFile, m_nextInput),
							ITextStrings.ksLLImport,
							MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
							return;
						}
					}
				}
				else
				{
					btnImport.Enabled = true;
				}
				ShowFinishLabel();
			}
		}
Example #10
0
		private void UpdateLanguageCodes()
		{
			if (m_sLastXmlFileName != m_LinguaLinksXmlFileName.Text)
			{
				m_sLastXmlFileName = m_LinguaLinksXmlFileName.Text;
				listViewMapping.Items.Clear();
				btnImport.Enabled = false;	// default to not enabled now that there are no items
				m_nextInput = m_LinguaLinksXmlFileName.Text;
				if (!File.Exists(m_nextInput))
				{
					MessageBox.Show(
						String.Format(ITextStrings.ksLLFileNotFound, m_nextInput),
						ITextStrings.ksLLImport,
						MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}

				StringUtils.InitIcuDataDir();	// used for normalizing strings to NFC
				m_startPhase = 1;
				string nameTest;
				if (m_nextInput.Length > 19)
				{
					nameTest = m_nextInput.Substring(m_nextInput.Length - 19, 19);
					if (nameTest == "\\LLPhase1Output.xml")
					{
						m_startPhase = 2;
					}
					else if (nameTest == "\\LLPhase2Output.xml")
					{
						m_startPhase = 3;
					}
					else if (nameTest == "\\LLPhase3Output.xml")
					{
						m_startPhase = 4;
					}
				}

				if (m_startPhase == 1)
				{
					StreamReader streamReader = File.OpenText(m_nextInput);
					String input;

					bool inWritingSystem = false;
					bool inIcuLocale24 = false;
					bool inName24 = false;
					bool lineDone = false;
					bool formatOkay = false;
					int pos, pos1, pos2, pos3;
					string wsLLCode = "";
					string wsName = "";
					Dictionary<string, WsInfo> wsInfo = new Dictionary<string,WsInfo>();	// Dictioanry of wsInfo

					//getting name for a writing system given the ICU code.
					ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;
					int wsUser = wsf.UserWs;
					int wsVern = m_cache.DefaultVernWs;
					IWritingSystem ws = wsf.get_EngineOrNull(wsVern);

					// getting list of writing systems to eventually populate a list box
					int cws = wsf.NumberOfWs;
					using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
					{
						wsf.GetWritingSystems(ptr, cws);
						int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
						for (int iws = 0; iws < cws; iws++)
						{
							if (vws[iws] == 0)
								continue;
							ws = wsf.get_EngineOrNull(vws[iws]);
							if (ws == null)
								continue;
							string name = ws.get_UiName(wsUser);
							string icuLocal = ws.IcuLocale;
							string mapName = ws.LegacyMapping;
							if ((mapName == null) || (mapName == ""))
							{
								mapName = "Windows1252<>Unicode";	// REVIEW: SHOULD THIS NAME BE LOCALIZED?
							}
							WsInfo wsi = new WsInfo(vws[iws], name, icuLocal, mapName);
							wsInfo.Add(wsi.KEY, wsi);
						}
					}

					while ((input=streamReader.ReadLine())!=null)
					{
						lineDone = false;
						while (!lineDone)
						{
							if (!inWritingSystem)
							{
								pos = input.IndexOf("<LgWritingSystem");
								if (pos >= 0)
								{
									inWritingSystem = true;
									wsLLCode = "";
									wsName = "";
									if (input.Length >= pos + 21)
										input = input.Substring(pos + 21, input.Length - pos - 21);
									else
										input = input.Substring(pos + 16);
								}

								else
								{
									lineDone = true;
								}
							}
							if (inWritingSystem && !inIcuLocale24 && !inName24)
							{
								pos1 = input.IndexOf("</LgWritingSystem>");
								pos2 = input.IndexOf("<ICULocale24>");
								pos3 = input.IndexOf("<Name24>");
								if (pos1 < 0 && pos2 < 0 && pos3 < 0)
								{
									lineDone = true;
								}
								else if (pos1 >= 0 && (pos2 < 0 || pos2 > pos1) && (pos3 < 0 || pos3 > pos1))
								{
									input = input.Substring(pos1 + 18, input.Length - pos1 - 18);
									if (wsLLCode != "")
									{
										if (wsName == "")
										{
											wsName = "<" + wsLLCode + ">";
										}
										string wsFWName = "";
										string wsEC = "";
										string wsFWCode = "";

										foreach (KeyValuePair<string, WsInfo> kvp in wsInfo)
										{
											WsInfo wsi = kvp.Value;
											if (wsName == wsi.Name)
											{
												wsFWName = StringUtils.NormalizeToNFC(wsi.Name);
												wsEC = StringUtils.NormalizeToNFC(wsi.Map);
												wsFWCode = StringUtils.NormalizeToNFC(wsi.Locale);
											}
										}

										if (wsFWName == "")
										{
											foreach (KeyValuePair<string, WsInfo> kvp in wsInfo)
											{
												WsInfo wsi = kvp.Value;
												if (BaseName(wsName) == BaseName(wsi.Name))
												{
													wsFWName = StringUtils.NormalizeToNFC(wsi.Name);
													wsEC = StringUtils.NormalizeToNFC(wsi.Map);
													wsFWCode = StringUtils.NormalizeToNFC(wsi.Locale);
												}
											}
										}

										ListViewItem lvItem = new ListViewItem(new string[] {StringUtils.NormalizeToNFC(wsName), wsFWName, wsEC, StringUtils.NormalizeToNFC(wsLLCode), wsFWCode});
										lvItem.Tag = wsName;
										listViewMapping.Items.Add(lvItem);
										formatOkay = true;
									}
									inWritingSystem = false;
								}
								else if (pos2 >= 0 && (pos3 < 0 || pos3 > pos2))
								{
									input = input.Substring(pos2 + 13, input.Length - pos2 - 13);
									inIcuLocale24 = true;
								}
								else
								{
									input = input.Substring(pos3 + 8, input.Length - pos3 - 8);
									inName24 = true;
								}
							}
							if (inIcuLocale24)
							{
								pos = input.IndexOf(">");
								if (pos < 0)
								{
									lineDone = true;
								}
								else
								{
									input = input.Substring(pos + 1, input.Length - pos - 1);
									pos = input.IndexOf("<");
									wsLLCode = input.Substring(0, pos);
									input = input.Substring(pos, input.Length - pos);
									inIcuLocale24 = false;
								}
							}
							if (inName24)
							{
								pos = input.IndexOf(">");
								if (pos < 0)
								{
									lineDone = true;
								}
								else
								{
									input = input.Substring(pos + 1, input.Length - pos - 1);
									pos = input.IndexOf("<");
									wsName = input.Substring(0, pos);
									input = input.Substring(pos, input.Length - pos);
									inName24 = false;
								}
							}
						}
					}
					streamReader.Close();
					listViewMapping_SelectedIndexChanged();
					CheckImportEnabled();
					if (!formatOkay)
					{
						ShowFinishLabel();	// update the button before showing the msg box just in case...
						MessageBox.Show(
							String.Format(ITextStrings.ksInvalidLLFile, m_nextInput),
							ITextStrings.ksLLImport,
							MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
						return;
					}
				}
				else
				{
					btnImport.Enabled = true;
				}
				ShowFinishLabel();
			}
		}
Example #11
0
        private void LexImportWizardLanguage_Load(object sender, System.EventArgs e)
        {
            // (Bev) modify a few labels
            if (m_LinguaLinksImport)
            {
                this.Text        = LexTextControls.ksSpecifyFwWs;
                lblComment.Text  = LexTextControls.ksSpecifyFwWsDescription;
                lblLangDesc.Text = LexTextControls.ksLanguageDefinition;
            }
            else
            {
                if (m_AddUsage)
                {
                    this.Text = LexTextControls.ksAddLangMapping;
                }
                else
                {
                    this.Text = LexTextControls.ksModifyLangMapping;
                }
            }

            tbLangDesc.Text = m_LangDesc;

            //getting name for a writing system given the ICU code.
            ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;
            int            wsUser       = wsf.UserWs;
            int            wsVern       = m_cache.DefaultVernWs;
            IWritingSystem ws           = wsf.get_EngineOrNull(wsVern);

            m_wsiDefault = new WsInfo(wsVern, ws.get_UiName(wsVern), ws.IcuLocale, ws.LegacyMapping);

            // getting list of writing systems to populate a combo.
            int cws = wsf.NumberOfWs;

            using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
            {
                wsf.GetWritingSystems(ptr, cws);
                int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
                for (int iws = 0; iws < cws; iws++)
                {
                    if (vws[iws] == 0)
                    {
                        continue;
                    }
                    ws = wsf.get_EngineOrNull(vws[iws]);
                    if (ws == null)
                    {
                        continue;
                    }
                    string name     = ws.get_UiName(wsUser);
                    string icuLocal = ws.IcuLocale;
                    string mapName  = ws.LegacyMapping;
                    WsInfo wsi      = new WsInfo(vws[iws], name, icuLocal, mapName);
                    m_wsInfo.Add(wsi.KEY, wsi);
                }
            }

            // initialize the 'ws' combo box with the data from the DB
            foreach (DictionaryEntry entry in m_wsInfo)
            {
                WsInfo wsi = entry.Value as WsInfo;
                cbWS.Items.Add(wsi);
            }
            cbWS.Sorted = false;
            WsInfo wsiIgnore = new WsInfo();

            cbWS.Items.Add(wsiIgnore);

            // select the proper index if there is a valid writhing system
            int index = 0;

            if (m_wsName != null && m_wsName != "")
            {
                index = cbWS.FindStringExact(m_wsName);
                if (index < 0)
                {
                    index = 0;
                }
            }
            cbWS.SelectedIndex = index;

            LoadEncodingConverters();

            index = 0;
            if (m_encConverter != null && m_encConverter != "")
            {
                index = cbEC.FindStringExact(m_encConverter);
                if (index < 0)
                {
                    index = 0;
                }
            }
            cbEC.SelectedIndex = index;
        }
Example #12
0
        private void UpdateLanguageCodes()
        {
            if (m_sLastXmlFileName != m_LinguaLinksXmlFileName.Text)
            {
                m_sLastXmlFileName = m_LinguaLinksXmlFileName.Text;
                listViewMapping.Items.Clear();
                btnImport.Enabled = false;                      // default to not enabled now that there are no items
                m_nextInput       = m_LinguaLinksXmlFileName.Text;
                if (!File.Exists(m_nextInput))
                {
                    MessageBox.Show(
                        String.Format(ITextStrings.ksLLFileNotFound, m_nextInput),
                        ITextStrings.ksLLImport,
                        MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                StringUtils.InitIcuDataDir();                   // used for normalizing strings to NFC
                m_startPhase = 1;
                string nameTest;
                if (m_nextInput.Length > 19)
                {
                    nameTest = m_nextInput.Substring(m_nextInput.Length - 19, 19);
                    if (nameTest == "\\LLPhase1Output.xml")
                    {
                        m_startPhase = 2;
                    }
                    else if (nameTest == "\\LLPhase2Output.xml")
                    {
                        m_startPhase = 3;
                    }
                    else if (nameTest == "\\LLPhase3Output.xml")
                    {
                        m_startPhase = 4;
                    }
                }

                if (m_startPhase == 1)
                {
                    StreamReader streamReader = File.OpenText(m_nextInput);
                    String       input;

                    bool   inWritingSystem = false;
                    bool   inIcuLocale24 = false;
                    bool   inName24 = false;
                    bool   lineDone = false;
                    bool   formatOkay = false;
                    int    pos, pos1, pos2, pos3;
                    string wsLLCode                    = "";
                    string wsName                      = "";
                    Dictionary <string, WsInfo> wsInfo = new Dictionary <string, WsInfo>();                     // Dictioanry of wsInfo

                    //getting name for a writing system given the ICU code.
                    ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;
                    int            wsUser       = wsf.UserWs;
                    int            wsVern       = m_cache.DefaultVernWs;
                    IWritingSystem ws           = wsf.get_EngineOrNull(wsVern);

                    // getting list of writing systems to eventually populate a list box
                    int cws = wsf.NumberOfWs;
                    using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
                    {
                        wsf.GetWritingSystems(ptr, cws);
                        int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
                        for (int iws = 0; iws < cws; iws++)
                        {
                            if (vws[iws] == 0)
                            {
                                continue;
                            }
                            ws = wsf.get_EngineOrNull(vws[iws]);
                            if (ws == null)
                            {
                                continue;
                            }
                            string name     = ws.get_UiName(wsUser);
                            string icuLocal = ws.IcuLocale;
                            string mapName  = ws.LegacyMapping;
                            if ((mapName == null) || (mapName == ""))
                            {
                                mapName = "Windows1252<>Unicode";                                       // REVIEW: SHOULD THIS NAME BE LOCALIZED?
                            }
                            WsInfo wsi = new WsInfo(vws[iws], name, icuLocal, mapName);
                            wsInfo.Add(wsi.KEY, wsi);
                        }
                    }

                    while ((input = streamReader.ReadLine()) != null)
                    {
                        lineDone = false;
                        while (!lineDone)
                        {
                            if (!inWritingSystem)
                            {
                                pos = input.IndexOf("<LgWritingSystem");
                                if (pos >= 0)
                                {
                                    inWritingSystem = true;
                                    wsLLCode        = "";
                                    wsName          = "";
                                    if (input.Length >= pos + 21)
                                    {
                                        input = input.Substring(pos + 21, input.Length - pos - 21);
                                    }
                                    else
                                    {
                                        input = input.Substring(pos + 16);
                                    }
                                }

                                else
                                {
                                    lineDone = true;
                                }
                            }
                            if (inWritingSystem && !inIcuLocale24 && !inName24)
                            {
                                pos1 = input.IndexOf("</LgWritingSystem>");
                                pos2 = input.IndexOf("<ICULocale24>");
                                pos3 = input.IndexOf("<Name24>");
                                if (pos1 < 0 && pos2 < 0 && pos3 < 0)
                                {
                                    lineDone = true;
                                }
                                else if (pos1 >= 0 && (pos2 < 0 || pos2 > pos1) && (pos3 < 0 || pos3 > pos1))
                                {
                                    input = input.Substring(pos1 + 18, input.Length - pos1 - 18);
                                    if (wsLLCode != "")
                                    {
                                        if (wsName == "")
                                        {
                                            wsName = "<" + wsLLCode + ">";
                                        }
                                        string wsFWName = "";
                                        string wsEC     = "";
                                        string wsFWCode = "";

                                        foreach (KeyValuePair <string, WsInfo> kvp in wsInfo)
                                        {
                                            WsInfo wsi = kvp.Value;
                                            if (wsName == wsi.Name)
                                            {
                                                wsFWName = StringUtils.NormalizeToNFC(wsi.Name);
                                                wsEC     = StringUtils.NormalizeToNFC(wsi.Map);
                                                wsFWCode = StringUtils.NormalizeToNFC(wsi.Locale);
                                            }
                                        }

                                        if (wsFWName == "")
                                        {
                                            foreach (KeyValuePair <string, WsInfo> kvp in wsInfo)
                                            {
                                                WsInfo wsi = kvp.Value;
                                                if (BaseName(wsName) == BaseName(wsi.Name))
                                                {
                                                    wsFWName = StringUtils.NormalizeToNFC(wsi.Name);
                                                    wsEC     = StringUtils.NormalizeToNFC(wsi.Map);
                                                    wsFWCode = StringUtils.NormalizeToNFC(wsi.Locale);
                                                }
                                            }
                                        }

                                        ListViewItem lvItem = new ListViewItem(new string[] { StringUtils.NormalizeToNFC(wsName), wsFWName, wsEC, StringUtils.NormalizeToNFC(wsLLCode), wsFWCode });
                                        lvItem.Tag = wsName;
                                        listViewMapping.Items.Add(lvItem);
                                        formatOkay = true;
                                    }
                                    inWritingSystem = false;
                                }
                                else if (pos2 >= 0 && (pos3 < 0 || pos3 > pos2))
                                {
                                    input         = input.Substring(pos2 + 13, input.Length - pos2 - 13);
                                    inIcuLocale24 = true;
                                }
                                else
                                {
                                    input    = input.Substring(pos3 + 8, input.Length - pos3 - 8);
                                    inName24 = true;
                                }
                            }
                            if (inIcuLocale24)
                            {
                                pos = input.IndexOf(">");
                                if (pos < 0)
                                {
                                    lineDone = true;
                                }
                                else
                                {
                                    input         = input.Substring(pos + 1, input.Length - pos - 1);
                                    pos           = input.IndexOf("<");
                                    wsLLCode      = input.Substring(0, pos);
                                    input         = input.Substring(pos, input.Length - pos);
                                    inIcuLocale24 = false;
                                }
                            }
                            if (inName24)
                            {
                                pos = input.IndexOf(">");
                                if (pos < 0)
                                {
                                    lineDone = true;
                                }
                                else
                                {
                                    input    = input.Substring(pos + 1, input.Length - pos - 1);
                                    pos      = input.IndexOf("<");
                                    wsName   = input.Substring(0, pos);
                                    input    = input.Substring(pos, input.Length - pos);
                                    inName24 = false;
                                }
                            }
                        }
                    }
                    streamReader.Close();
                    listViewMapping_SelectedIndexChanged();
                    CheckImportEnabled();
                    if (!formatOkay)
                    {
                        ShowFinishLabel();                              // update the button before showing the msg box just in case...
                        MessageBox.Show(
                            String.Format(ITextStrings.ksInvalidLLFile, m_nextInput),
                            ITextStrings.ksLLImport,
                            MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        return;
                    }
                }
                else
                {
                    btnImport.Enabled = true;
                }
                ShowFinishLabel();
            }
        }
Example #13
0
        private void UpdateLanguageCodes()
        {
            if (m_sLastXmlFileName != m_LinguaLinksXmlFileName.Text)
            {
                m_sLastXmlFileName = m_LinguaLinksXmlFileName.Text;
                listViewMapping.Items.Clear();
                btnImport.Enabled = false;
                // default to not enabled now that there are no items
                m_nextInput = m_LinguaLinksXmlFileName.Text;
                if (!File.Exists(m_nextInput))
                {
                    MessageBox.Show(
                        String.Format(ITextStrings.ksLLFileNotFound, m_nextInput),
                        ITextStrings.ksLLImport,
                        MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                m_startPhase = 1;
                string nameTest;
                if (m_nextInput.Length > 19)
                {
                    nameTest = m_nextInput.Substring(m_nextInput.Length - 19, 19);
                    if (nameTest == "\\LLPhase1Output.xml")
                    {
                        m_startPhase = 2;
                    }
                    else if (nameTest == "\\LLPhase2Output.xml")
                    {
                        m_startPhase = 3;
                    }
                    else if (nameTest == "\\LLPhase3Output.xml")
                    {
                        m_startPhase = 4;
                    }
                    else if (nameTest == "\\LLPhase4Output.xml")
                    {
                        m_startPhase = 5;
                    }
                    else if (nameTest == "\\LLPhase5Output.xml")
                    {
                        m_startPhase = 6;
                    }
                }

                if (m_startPhase == 1)
                {
                    using (StreamReader streamReader = File.OpenText(m_nextInput))
                    {
                        String input;

                        bool   inWritingSystem = false;
                        bool   inIcuLocale24 = false;
                        bool   inName24 = false;
                        bool   lineDone = false;
                        bool   formatOkay = false;
                        int    pos, pos1, pos2, pos3;
                        string wsLLCode = "";
                        string wsName   = "";
                        var    wsInfo   = new Dictionary <string, WsInfo>();

                        //getting name for a writing system given the ICU code.
                        foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems)
                        {
                            var wsi = new WsInfo(ws.DisplayLabel, ws.Id, string.IsNullOrEmpty(ws.LegacyMapping) ? "Windows1252<>Unicode" : ws.LegacyMapping);
                            wsInfo.Add(wsi.KEY, wsi);
                        }

                        while ((input = streamReader.ReadLine()) != null)
                        {
                            lineDone = false;
                            while (!lineDone)
                            {
                                if (!inWritingSystem)
                                {
                                    pos = input.IndexOf("<LgWritingSystem");
                                    if (pos >= 0)
                                    {
                                        inWritingSystem = true;
                                        wsLLCode        = "";
                                        wsName          = "";
                                        if (input.Length >= pos + 21)
                                        {
                                            input = input.Substring(pos + 21, input.Length - pos - 21);
                                        }
                                        else
                                        {
                                            input = input.Substring(pos + 16);
                                        }
                                    }

                                    else
                                    {
                                        lineDone = true;
                                    }
                                }
                                if (inWritingSystem && !inIcuLocale24 && !inName24)
                                {
                                    pos1 = input.IndexOf("</LgWritingSystem>");
                                    pos2 = input.IndexOf("<ICULocale24>");
                                    pos3 = input.IndexOf("<Name24>");
                                    if (pos1 < 0 && pos2 < 0 && pos3 < 0)
                                    {
                                        lineDone = true;
                                    }
                                    else if (pos1 >= 0 && (pos2 < 0 || pos2 > pos1) && (pos3 < 0 || pos3 > pos1))
                                    {
                                        input = input.Substring(pos1 + 18, input.Length - pos1 - 18);
                                        if (wsLLCode != "")
                                        {
                                            if (wsName == "")
                                            {
                                                wsName = "<" + wsLLCode + ">";
                                            }
                                            string wsFWName = "";
                                            string wsEC     = "";
                                            string wsFWCode = "";

                                            foreach (KeyValuePair <string, WsInfo> kvp in wsInfo)
                                            {
                                                WsInfo wsi = kvp.Value;
                                                if (wsName == wsi.Name)
                                                {
                                                    wsFWName = TsStringUtils.NormalizeToNFC(wsi.Name);
                                                    wsEC     = TsStringUtils.NormalizeToNFC(wsi.Map);
                                                    wsFWCode = TsStringUtils.NormalizeToNFC(wsi.Id);
                                                }
                                            }

                                            if (wsFWName == "")
                                            {
                                                foreach (KeyValuePair <string, WsInfo> kvp in wsInfo)
                                                {
                                                    WsInfo wsi = kvp.Value;
                                                    if (BaseName(wsName) == BaseName(wsi.Name))
                                                    {
                                                        wsFWName = TsStringUtils.NormalizeToNFC(wsi.Name);
                                                        wsEC     = TsStringUtils.NormalizeToNFC(wsi.Map);
                                                        wsFWCode = TsStringUtils.NormalizeToNFC(wsi.Id);
                                                    }
                                                }
                                            }

                                            var lvItem = new ListViewItem(new[] { TsStringUtils.NormalizeToNFC(wsName), wsFWName, wsEC, TsStringUtils.NormalizeToNFC(wsLLCode), wsFWCode });
                                            lvItem.Tag = wsName;
                                            listViewMapping.Items.Add(lvItem);
                                            formatOkay = true;
                                        }
                                        inWritingSystem = false;
                                    }
                                    else if (pos2 >= 0 && (pos3 < 0 || pos3 > pos2))
                                    {
                                        input         = input.Substring(pos2 + 13, input.Length - pos2 - 13);
                                        inIcuLocale24 = true;
                                    }
                                    else
                                    {
                                        input    = input.Substring(pos3 + 8, input.Length - pos3 - 8);
                                        inName24 = true;
                                    }
                                }
                                if (inIcuLocale24)
                                {
                                    pos = input.IndexOf(">");
                                    if (pos < 0)
                                    {
                                        lineDone = true;
                                    }
                                    else
                                    {
                                        input         = input.Substring(pos + 1, input.Length - pos - 1);
                                        pos           = input.IndexOf("<");
                                        wsLLCode      = input.Substring(0, pos);
                                        input         = input.Substring(pos, input.Length - pos);
                                        inIcuLocale24 = false;
                                    }
                                }
                                if (inName24)
                                {
                                    pos = input.IndexOf(">");
                                    if (pos < 0)
                                    {
                                        lineDone = true;
                                    }
                                    else
                                    {
                                        input    = input.Substring(pos + 1, input.Length - pos - 1);
                                        pos      = input.IndexOf("<");
                                        wsName   = input.Substring(0, pos);
                                        input    = input.Substring(pos, input.Length - pos);
                                        inName24 = false;
                                    }
                                }
                            }
                        }
                        streamReader.Close();
                        listViewMapping_SelectedIndexChanged();
                        CheckImportEnabled();
                        if (!formatOkay)
                        {
                            ShowFinishLabel();
                            // update the button before showing the msg box just in case...
                            MessageBox.Show(
                                String.Format(ITextStrings.ksInvalidLLFile, m_nextInput),
                                ITextStrings.ksLLImport,
                                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                            return;
                        }
                    }
                }
                else
                {
                    btnImport.Enabled = true;
                }
                ShowFinishLabel();
            }
        }
 /// <summary>
 /// Log the SDMX-ML message stored in the stream.
 /// </summary>
 /// <param name="config">
 /// The config
 /// </param>
 /// <param name="request">
 /// The stream to the SDMX-ML message
 /// </param>
 public static void LogSdmx(WsInfo config, string request)
 {
     if (config.LogSDMX)
     {
         Logger.Info(request);
     }
 }
		private void LexImportWizardLanguage_Load(object sender, System.EventArgs e)
		{
			// (Bev) modify a few labels
			if (m_LinguaLinksImport)
			{
				this.Text = LexTextControls.ksSpecifyFwWs;
				lblComment.Text = LexTextControls.ksSpecifyFwWsDescription;
				lblLangDesc.Text = LexTextControls.ksLanguageDefinition;
			}
			else
			{
				if (m_AddUsage)
					this.Text = LexTextControls.ksAddLangMapping;
				else
					this.Text = LexTextControls.ksModifyLangMapping;
			}

			tbLangDesc.Text = m_LangDesc;

			//getting name for a writing system given the ICU code.
			ILgWritingSystemFactory wsf = m_cache.LanguageWritingSystemFactoryAccessor;
			int wsUser = wsf.UserWs;
			int wsVern = m_cache.DefaultVernWs;
			IWritingSystem ws = wsf.get_EngineOrNull(wsVern);
			m_wsiDefault = new WsInfo(wsVern, ws.get_UiName(wsVern), ws.IcuLocale, ws.LegacyMapping);

			// getting list of writing systems to populate a combo.
			int cws = wsf.NumberOfWs;
			using (ArrayPtr ptr = MarshalEx.ArrayToNative(cws, typeof(int)))
			{
				wsf.GetWritingSystems(ptr, cws);
				int[] vws = (int[])MarshalEx.NativeToArray(ptr, cws, typeof(int));
				for (int iws = 0; iws < cws; iws++)
				{
					if (vws[iws] == 0)
						continue;
					ws = wsf.get_EngineOrNull(vws[iws]);
					if (ws == null)
						continue;
					string name = ws.get_UiName(wsUser);
					string icuLocal = ws.IcuLocale;
					string mapName = ws.LegacyMapping;
					WsInfo wsi = new WsInfo(vws[iws], name, icuLocal, mapName);
					m_wsInfo.Add(wsi.KEY, wsi);
				}
			}

			// initialize the 'ws' combo box with the data from the DB
			foreach (DictionaryEntry entry in m_wsInfo)
			{
				WsInfo wsi = entry.Value as WsInfo;
				cbWS.Items.Add(wsi);
			}
			cbWS.Sorted = false;
			WsInfo wsiIgnore = new WsInfo();
			cbWS.Items.Add(wsiIgnore);

			// select the proper index if there is a valid writhing system
			int index = 0;
			if (m_wsName != null && m_wsName != "")
			{
				index = cbWS.FindStringExact(m_wsName);
				if (index < 0)
					index = 0;
			}
			cbWS.SelectedIndex = index;

			LoadEncodingConverters();

			index = 0;
			if (m_encConverter != null && m_encConverter != "")
			{
				index = cbEC.FindStringExact(m_encConverter);
				if (index < 0)
					index = 0;
			}
			cbEC.SelectedIndex = index;
		}
        /// <summary>
        /// The setup request info.
        /// </summary>
        /// <param name="endpoint">
        /// The endpoint.
        /// </param>
        /// <returns>
        /// The <see cref="WsInfo"/>.
        /// </returns>
        private static WsInfo SetupRequestInfo(Uri endpoint)
        {
            var info = new WsInfo { Endpoint = endpoint.AbsoluteUri };

            WSDLSettings wsdlSettings;
            try
            {
                wsdlSettings = new WSDLSettings(info.Endpoint + "?wsdl");
            }
            catch (Exception ex)
            {
                _log.Error("Error while retrieving WSDL", ex);
                throw;
            }

            info.WsdlSettings = wsdlSettings;
            info.TargetNamespace = wsdlSettings.TargetNamespace;
            return info;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SdmxWsClient"/> class. 
 /// Initializes a new instance of the <see cref="T:System.Object"/> class.
 /// </summary>
 /// <param name="endpoint">
 /// The endpoint.
 /// </param>
 /// <param name="sdmxSchema">
 /// The sdmx Schema.
 /// </param>
 public SdmxWsClient(Uri endpoint, SdmxSchemaEnumType sdmxSchema)
 {
     var info = SetupRequestInfo(endpoint);
     info.SdmxSchemaVersion = SdmxSchema.GetFromEnum(sdmxSchema);
     this._webServiceInfo = info;
     this._settings = Settings.Default;
 }
		private void btnAddWS_WritingSystemAdded(object sender, EventArgs e)
		{
			IWritingSystem ws = btnAddWS.NewWritingSystem;
			if (ws != null)
			{
				string mapName = ws.LegacyMapping;
				var wsi = new WsInfo(ws.DisplayLabel, ws.Id, mapName);
				m_wsInfo.Add(wsi.KEY, wsi);

				// now select it for the ws combo box
				int index = cbWS.Items.Add(wsi);
				cbWS.SelectedIndex = index;

				// now if there's an encoding converter for the ws, select it
				if (String.IsNullOrEmpty(mapName))
					index = cbEC.FindStringExact(m_blankEC);
				else
					index = cbEC.Items.Add(mapName);
				cbEC.SelectedIndex = index;
			}
		}
		private void LexImportWizardLanguage_Load(object sender, EventArgs e)
		{
			// (Bev) modify a few labels
			if (m_LinguaLinksImport)
			{
				Text = LexTextControls.ksSpecifyFwWs;
				lblComment.Text = LexTextControls.ksSpecifyFwWsDescription;
				lblLangDesc.Text = LexTextControls.ksLanguageDefinition;
			}
			else
			{
				if (m_AddUsage)
					Text = LexTextControls.ksAddLangMapping;
				else
					Text = LexTextControls.ksModifyLangMapping;
			}

			tbLangDesc.Text = m_LangDesc;

			// initialize the 'ws' combo box and the AddWs button with the data from the DB
			foreach (IWritingSystem ws in m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems)
			{
				var wsi = new WsInfo(ws.DisplayLabel, ws.Id, ws.LegacyMapping);
				m_wsInfo.Add(wsi.KEY, wsi);
				cbWS.Items.Add(wsi);
			}

			cbWS.Sorted = false;
			var wsiIgnore = new WsInfo();
			cbWS.Items.Add(wsiIgnore);
			btnAddWS.Initialize(m_cache, m_helpTopicProvider, m_app, m_stylesheet, m_cache.ServiceLocator.WritingSystemManager.LocalWritingSystems);

			// select the proper index if there is a valid writing system
			int index = 0;
			if (!string.IsNullOrEmpty(m_wsName))
			{
				index = cbWS.FindStringExact(m_wsName);
				if (index < 0)
					index = 0;
			}
			cbWS.SelectedIndex = index;

			LoadEncodingConverters();

			index = 0;
			if (!string.IsNullOrEmpty(m_encConverter))
			{
				index = cbEC.FindStringExact(m_encConverter);
				if (index < 0)
					index = 0;
			}
			cbEC.SelectedIndex = index;
		}
 /// <summary>
 /// Log the SDMX-ML message stored in the stream.
 /// </summary>
 /// <param name="config">
 /// The config
 /// </param>
 /// <param name="request">
 /// The stream to the SDMX-ML message
 /// </param>
 public static void LogSdmx(WsInfo config, XmlDocument request)
 {
     if (config.LogSDMX)
     {
         Logger.Info(request.InnerXml);
     }
 }
 /// <summary>
 /// Setter for NSI Client settings
 /// The settings are used for Proxy and HTTP authentication
 /// </summary>
 /// <param name="config">
 /// The NSI Client settings
 /// </param>
 public void SetConfig(WsInfo config)
 {
     this._config = config;
 }
 /// <summary>
 /// Log the SDMX-ML message stored in the stream.
 /// </summary>
 /// <param name="config">
 /// The config
 /// </param>
 /// <param name="tempFileName">
 /// The temporary file name
 /// </param>
 /// <param name="prefix">
 /// A prefix message to log before the SDMX-ML message
 /// </param>
 public static void LogSdmx(WsInfo config, string tempFileName, string prefix)
 {
     if (config.LogSDMX)
     {
         Logger.Info(prefix);
         using(var reader = new StreamReader(tempFileName, Encoding.UTF8))
         {
             Logger.Info(reader.ReadToEnd());
         }
     }
 }
Example #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NsiClientWS"/> class. 
        /// </summary>
        /// <param name="config">
        /// NSIClient settings
        /// </param>
        public NsiClientWS(WsInfo config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            if (string.IsNullOrEmpty(config.EndPoint))
            {
                throw new ArgumentException(Resources.ExceptionEndpointNotSet, "config");
            }

            Logger.Info(Resources.InfoCreatingNsiClient);
            this._config = config;
            Logger.Info(Resources.InfoGetWSDL);
            try
            {
                this._wsdlConfig = new WSDLSettings(config);
                Logger.Info(Resources.InfoWSDLSuccess);
            }
            catch (WebException ex)
            {
                throw NsiClientHelper.HandleWsdlException(config.EndPoint, ex, config.Wsdl);
            }
            catch (InvalidOperationException ex)
            {
                throw NsiClientHelper.HandleWsdlException(config.EndPoint, ex, config.Wsdl);
            }
            catch (UriFormatException ex)
            {
                throw NsiClientHelper.HandleWsdlException(config.EndPoint, ex, config.Wsdl);
            }

             this._defaultHeader = new HeaderImpl("NSIClient","NSIClient");
            Utils.PopulateHeaderFromSettings(this._defaultHeader);
        }