private String SaveTabData(HttpContext context) { try { //get uploaded params var ajaxInfo = GetAjaxFields(context); var tabid = ajaxInfo.GetXmlProperty("genxml/hidden/tabid"); var selectlang = ajaxInfo.GetXmlProperty("genxml/hidden/selectlang"); if (Utils.IsNumeric(tabid)) { var lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang"); if (selectlang == "") { selectlang = lang; } var tabData = new TabData(tabid, selectlang); //save data if (tabData.Exists) { var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml")); tabData.DataRecord.UpdateAjax(strIn); tabData.DataLangRecord.UpdateAjax(strIn); tabData.Save(); } } return(""); } catch (Exception ex) { return(ex.ToString()); } }
private void TranslateForm(HttpContext context) { try { var objCtrl = new NBrightDataController(); var settings = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "SETTINGS", "NBrightPL"); var clientId = settings.GetXmlProperty("genxml/textbox/bingclientid"); var clientSecret = settings.GetXmlProperty("genxml/textbox/bingclientsecret"); var headerValue = Utils.GetTranslatorHeaderValue(clientId, clientSecret); //get uploaded params var ajaxInfo = GetAjaxFields(context); var tabid = ajaxInfo.GetXmlProperty("genxml/hidden/tabid"); var selectlang = ajaxInfo.GetXmlProperty("genxml/hidden/lang"); var baselang = ajaxInfo.GetXmlProperty("genxml/hidden/baselangtrans"); if (selectlang == "") { selectlang = Utils.GetCurrentCulture(); } if (baselang == "") { baselang = Utils.GetCurrentCulture(); } if (Utils.IsNumeric(tabid) && (baselang != selectlang)) { var baseData = new TabData(tabid, baselang); var tabData = new TabData(tabid, selectlang); //save data if (tabData.Exists && baseData.Exists) { baselang = baselang.Substring(0, 2); selectlang = selectlang.Substring(0, 2); var nodList = baseData.DataLangRecord.XMLDoc.SelectNodes("genxml/textbox/*"); if (nodList != null) { foreach (XmlNode nod in nodList) { var newText = Utils.GetTranslatedText(headerValue, nod.InnerText, baselang, selectlang); tabData.DataLangRecord.SetXmlProperty("genxml/textbox/" + nod.Name, newText); } tabData.Save(); } } } } catch (Exception ex) { // ignore } }