/* Load Regions (cached) * @param ctx context */ private static void LoadAllRegions(Ctx ctx) { s_regions = new CCache <String, MRegion>("C_Region", 100); String sql = "SELECT * FROM C_Region WHERE IsActive='Y'"; try { DataSet stmt = DataBase.DB.ExecuteDataset(sql, null, null); for (int i = 0; i < stmt.Tables[0].Rows.Count; i++) { DataRow rs = stmt.Tables[0].Rows[i]; MRegion r = new MRegion(ctx, rs, null); s_regions.Add(r.GetC_Region_ID().ToString(), r); if (r.IsDefault()) { s_default = r; } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } _log.Fine(s_regions.Count + " - default=" + s_default); }
/** * Get Language specific Message Map * @param ad_language Language Key * @return HashMap of Language */ public CCache <String, String> GetMsgMap(String ad_language) { String AD_Language = ad_language; if (AD_Language == null || AD_Language.Length == 0) { AD_Language = Language.GetBaseAD_Language(); } // Do we have the language ? CCache <String, String> retValue = (CCache <String, String>)_languages[AD_Language]; if (retValue != null && retValue.Size() > 0) { return(retValue); } // Load Language retValue = InitMsg(AD_Language); if (retValue != null) { _languages.Add(AD_Language, retValue); return(retValue); } return(retValue); } // getMsgMap
} // isLoaded /** * Lookup term * @param AD_Language language * @param text text * @return translated term or null */ private String Lookup(String AD_Language, String text) { if (text == null) { return(null); } if (AD_Language == null || AD_Language.Length == 0) { return(text); } // hardcoded trl if (text.Equals("/") || text.Equals("\\")) { return(System.IO.Path.DirectorySeparatorChar.ToString()); } if (text.Equals(";") || text.Equals(":")) { //return File.pathSeparator; return(System.IO.Path.PathSeparator.ToString()); } CCache <String, String> langMap = GetMsgMap(AD_Language); if (langMap == null) { return(null); } return((String)langMap[text]); } // lookup
/// <summary> /// Create Conversion Matrix (Client) /// </summary> /// <param name="ctx"></param> private static void CreateRates(Ctx ctx) { _conversions = new CCache <Point, Decimal>("C_UOMConversion", 20); // String sql = MRole.GetDefault(ctx, false).AddAccessSQL( "SELECT C_UOM_ID, C_UOM_To_ID, MultiplyRate, DivideRate " + "FROM C_UOM_Conversion " + "WHERE IsActive='Y' AND M_Product_ID IS NULL", "C_UOM_Conversion", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); DataTable dt = null; IDataReader idr = null; try { idr = DataBase.DB.ExecuteReader(sql, null, null); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { Point p = new Point(Utility.Util.GetValueOfInt(dr[0]), Utility.Util.GetValueOfInt(dr[1])); Decimal mr = Utility.Util.GetValueOfDecimal(dr[2]); Decimal deci = Utility.Util.GetValueOfDecimal(dr[3]); if (mr != null) { _conversions.Add(p, mr); } // reverse if (deci == null && mr != null) { deci = Decimal.Round(Decimal.Divide(Env.ONE, mr), 2);//, MidpointRounding.AwayFromZero); } if (deci != null) { _conversions.Add(new Point(p.Y, p.X), deci); } } } catch (Exception e) { if (idr != null) { idr.Close(); idr = null; } _log.Log(Level.SEVERE, sql, e); } finally { if (idr != null) { idr.Close(); } dt = null; } }
/// <summary> /// Load active Countries (no summary). /// Set Default Language to Client Language /// </summary> /// <param name="ctx">Ctx</param> private static void LoadAllCountries(Ctx ctx) { MClient client = MClient.Get(ctx); MLanguage lang = MLanguage.Get(ctx, client.GetAD_Language()); MCountry usa = null; // int countryID = Util.GetValueOfInt(ctx.Get("P|C_Country_ID")); s_countries = new CCache <String, MCountry>("C_Country", 250); String sql = "SELECT * FROM C_Country WHERE IsActive='Y' AND IsSummary='N'"; try { DataSet ds = DataBase.DB.ExecuteDataset(sql, null, null); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; MCountry c = new MCountry(ctx, dr, null); s_countries.Add(c.GetC_Country_ID().ToString(), c); // Country code of Client Language if (lang != null && lang.GetCountryCode().Equals(c.GetCountryCode()) && _default == null) { _default = c; } else if (countryID == c.GetC_Country_ID()) { _default = c; } if (c.GetC_Country_ID() == 100) // USA { usa = c; } } } catch (Exception e) { _log.Log(Level.SEVERE, sql, e); } if (_default == null) { _default = usa; } _log.Fine("#" + s_countries.Size() + " - Default=" + _default); }
/** * Reset Message cache */ public void Reset() { if (_languages == null) { return; } // clear all languages IEnumerator <CCache <String, String> > iterator = _languages.Values.GetEnumerator(); //if (iterator != null) //{ // CCache<String, String> hm = iterator.Current; // hm.clear(); //} while (iterator.MoveNext()) { CCache <String, String> hm = iterator.Current; hm.Clear(); } _languages.Clear(); } // reset
/// <summary> /// Get Locator from Cache /// </summary> /// <param name="ctx">context</param> /// <param name="M_Locator_ID">id</param> /// <returns>MLocator</returns> public static MLocator Get(Ctx ctx, int M_Locator_ID) { if (cache == null) { cache = new CCache <int, MLocator>("M_Locator", 20); } int key = M_Locator_ID; MLocator retValue = null; if (cache.ContainsKey(key)) { retValue = (MLocator)cache[key]; } if (retValue != null) { return(retValue); } retValue = new MLocator(ctx, M_Locator_ID, null); if (retValue.Get_ID() != 0) { cache.Add(key, retValue); } return(retValue); }
public JavaScriptResult Application() { //var s = Codec.DecryptStringAES(); StringBuilder sb = new StringBuilder(); Ctx ctx = Session["ctx"] as Ctx; if (ctx.GetSecureKey() == "") { ctx.SetSecureKey(SecureEngineBridge.GetRandomKey()); } // ctx.SetApplicationUrl(@Url.Content("~/")); ctx.SetIsSSL(Request.Url.Scheme == Uri.UriSchemeHttps); //lakhwinder string fullUrl = Request.Url.AbsoluteUri.Remove(Request.Url.AbsoluteUri.LastIndexOf('/')); //fullUrl = fullUrl.Remove(fullUrl.LastIndexOf('/')); //fullUrl = fullUrl.Remove(fullUrl.LastIndexOf('/')); fullUrl = fullUrl.Remove(fullUrl.IndexOf("VIS/Resource")); ctx.SetApplicationUrl(fullUrl); SecureEngine.Encrypt("a"); CCache <string, string> msgs = Msg.Get().GetMsgMap(ctx.GetAD_Language()); sb.Append("; var VIS = {"); sb.Append("Application: {contextUrl:'").Append(@Url.Content("~/")).Append("',").Append(" contextFullUrl:'").Append(fullUrl).Append("',") .Append("isMobile:").Append(Request.Browser.IsMobileDevice ? "1" : "0") .Append(", isRTL:").Append(ctx.GetIsRightToLeft() ? "1" : "0") .Append(", isBasicDB:").Append(ctx.GetIsBasicDB() ? "1" : "0") .Append(", isSSL:").Append((Request.Url.Scheme != Uri.UriSchemeHttps ? "0" :"1")) //TODO .Append("},"); sb.Append("I18N: { }, context: { }"); sb.Append("};"); sb.Append("VIS.Consts={"); /* Table */ sb.Append("'ACCESSLEVEL_Organization' : '1','ACCESSLEVEL_ClientOnly' : '2','ACCESSLEVEL_ClientPlusOrganization' : '3' ,'ACCESSLEVEL_SystemOnly' : '4'"); sb.Append(", 'ACCESSLEVEL_SystemPlusClient' : '6','ACCESSLEVEL_All' : '7'"); sb.Append(", 'ACCESSTYPERULE_Accessing' : 'A', 'ACCESSTYPERULE_Exporting' : 'E' , 'ACCESSTYPERULE_Reporting' : 'R'"); sb.Append("};"); /* USER */ sb.Append(" VIS.MUser = {"); sb.Append("'isAdministrator':'" + MUser.Get(ctx).IsAdministrator() + "', 'isUserEmployee':'" + MUser.GetIsEmployee(ctx, ctx.GetAD_User_ID()) + "' }; "); /* ROLE */ sb.Append(" VIS.MRole = {"); sb.Append(" 'vo' : " + Newtonsoft.Json.JsonConvert.SerializeObject(VIS.Helpers.RoleHelper.GetRole(VAdvantage.Model.MRole.GetDefault(ctx, false))) + " , "); sb.Append(" 'SQL_RW' : true, 'SQL_RO' : false, 'SQL_FULLYQUALIFIED' : true, 'SQL_NOTQUALIFIED' : false,'SUPERUSER_USER_ID' : 100, 'SYSTEM_USER_ID' : 0 "); sb.Append(", 'PREFERENCETYPE_Client':'C', 'PREFERENCETYPE_None':'N', 'PREFERENCETYPE_Organization':'O', 'PREFERENCETYPE_User':'******'"); sb.Append(", columnSynonym : { 'AD_User_ID': 'SalesRep_ID','C_ElementValue_ID':'Account_ID'}"); sb.Append("};"); /* CTX */ SetLoginContext(ctx); sb.Append(" VIS.context.ctx = ").Append(Newtonsoft.Json.JsonConvert.SerializeObject(ctx.GetMap())).Append("; "); /* Message */ sb.Append(" VIS.I18N.labels = { "); if (msgs != null) { int total = msgs.Keys.Count; foreach (var key in msgs.Keys) { --total; //if (key.Contains('\n') || key.Contains('\'') // || key.Contains('\"') || key.StartsWith("SC_") || key.Contains('\r')) //{ // continue; //} //if (msgs.Get(key).ToString().Contains('\n') || msgs.Get(key).ToString().Contains('\'') // || msgs.Get(key).ToString().Contains('\"') || msgs.Get(key).ToString().Contains('\r')) //{ // continue; //} string msg = (string)msgs.Get(key) ?? ""; msg = msg.Replace("\n", " ").Replace("\r", " ").Replace("\"", "'"); if (total == 0) { sb.Append("\"").Append(key).Append("\": ").Append("\"").Append(msg).Append("\""); } else { sb.Append("\"").Append(key).Append("\": ").Append("\"").Append(msg).Append("\", "); } } } sb.Append("};"); // sb.Append(" console.log(VIS.I18N.labels)"); //return View(); //System.Web.Optimization.JsMinify d = new System.Web.Optimization.JsMinify(); //d.Process( //Update Login Time var r = new ResourceManager(fullUrl, ctx.GetAD_Client_ID()); r.RunAsync(); r = null; return(JavaScript(sb.ToString())); }
CUDTUnited() { //m_Sockets(), //m_ControlLock(), //m_IDLock(), //m_SocketID(0), //m_TLSError(), //m_vMultiplexer(), //m_MultiplexerLock(), //m_pCache(null), //m_bClosing(false), //m_GCStopLock(), //m_GCStopCond(), //m_InitLock(), //m_bGCStatus(false), //m_GCThread(), //m_ClosedSockets() srand((int)CClock.getTime()); m_SocketID = 1 + (int)((1 << 30) * ((double)(rand()) / RAND_MAX)); m_ControlLock = new Mutex(); m_IDLock = new Mutex(); m_InitLock = new Mutex(); m_TLSError = TlsAlloc(); m_TLSLock = new Mutex(); m_pCache = new CCache(); }
internal CUDT() { // Initilize mutex and condition variables initSynch(); // Default UDT configurations m_iMSS = 1500; m_bSynSending = true; m_bSynRecving = true; m_iFlightFlagSize = 25600; m_iSndBufSize = 8192; m_iRcvBufSize = 8192; //Rcv buffer MUST NOT be bigger than Flight Flag size m_Linger = new LingerOption(1, 180); //m_Linger.l_onoff = 1; //m_Linger.l_linger = 180; m_iUDPSndBufSize = 65536; m_iUDPRcvBufSize = m_iRcvBufSize * m_iMSS; m_iIPversion = AF_INET; m_bRendezvous = false; m_iSndTimeOut = -1; m_iRcvTimeOut = -1; m_bReuseAddr = true; m_llMaxBW = -1; m_pCCFactory = new CCCFactory<CUDTCC>(); m_pCC = null; m_pCache = null; // Initial status m_bOpened = false; m_bListening = false; m_bConnected = false; m_bClosing = false; m_bShutdown = false; m_bBroken = false; }
internal CRNode m_pRNode; // node information for UDT list used in rcv queue #endregion #region constructor and desctructor CUDT(CUDT ancestor) { m_pSndBuffer = null; m_pRcvBuffer = null; m_pSndLossList = null; m_pRcvLossList = null; m_pACKWindow = null; m_pSndTimeWindow = null; m_pRcvTimeWindow = null; m_pSndQueue = null; m_pRcvQueue = null; m_pPeerAddr = null; m_pSNode = null; m_pRNode = null; // Initilize mutex and condition variables initSynch(); // Default UDT configurations m_iMSS = ancestor.m_iMSS; m_bSynSending = ancestor.m_bSynSending; m_bSynRecving = ancestor.m_bSynRecving; m_iFlightFlagSize = ancestor.m_iFlightFlagSize; m_iSndBufSize = ancestor.m_iSndBufSize; m_iRcvBufSize = ancestor.m_iRcvBufSize; m_Linger = ancestor.m_Linger; m_iUDPSndBufSize = ancestor.m_iUDPSndBufSize; m_iUDPRcvBufSize = ancestor.m_iUDPRcvBufSize; m_iSockType = ancestor.m_iSockType; m_iIPversion = ancestor.m_iIPversion; m_bRendezvous = ancestor.m_bRendezvous; m_iSndTimeOut = ancestor.m_iSndTimeOut; m_iRcvTimeOut = ancestor.m_iRcvTimeOut; m_bReuseAddr = true; // this must be true, because all accepted sockets shared the same port with the listener m_llMaxBW = ancestor.m_llMaxBW; m_pCCFactory = ancestor.m_pCCFactory.clone(); m_pCC = null; m_pCache = ancestor.m_pCache; // Initial status m_bOpened = false; m_bListening = false; m_bConnected = false; m_bClosing = false; m_bShutdown = false; m_bBroken = false; }
} // getMsgMap /** * Init message HashMap. * The initial call is from ALogin (ConfirmPanel init). * The second from Env.verifyLanguage. * @param AD_Language Language * @return Cache HashMap */ private CCache <String, String> InitMsg(String AD_Language) { // Trace.printStack(); CCache <String, String> msg = new CCache <String, String>("AD_Message", MAP_SIZE, 0); // if (!DataBase.DB.IsConnected()) { //s_log.log(Level.SEVERE, "No DB Connection"); // //ErrorLog.FillErrorLog("Msg.InitMsg(String AD_Language)", "No DB Connection ", "", Message.MessageType.ERROR); return(null); } string sqlQry = ""; IDataReader dr = null; try { //PreparedStatement pstmt = null; if (AD_Language == null || AD_Language.Length == 0 || Utility.Env.IsBaseLanguage(AD_Language, "AD_Language")) { sqlQry = "SELECT Value, MsgText, MsgTip FROM AD_Message"; dr = DataBase.DB.ExecuteReader(sqlQry); } else { sqlQry = "SELECT m.Value, t.MsgText, t.MsgTip " + "FROM AD_Message_Trl t, AD_Message m " + "WHERE m.AD_Message_ID=t.AD_Message_ID" + " AND t.AD_Language=@AD_Language"; SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@AD_Language", AD_Language); dr = DataBase.DB.ExecuteReader(sqlQry, param); } // get values while (dr.Read()) { String AD_Message = dr[0].ToString(); StringBuilder msgText = new StringBuilder(); String msgTip = null; msgText.Append(dr[1].ToString()); // if (dr.GetString(2) != DBNull.Value.ToString()) // { msgTip = dr[2].ToString(); // } // if (msgTip != null && msgTip.Length != 0) // messageTip on next line, if exists { msgText.Append(" ").Append(SEPARATOR).Append(msgTip); } msg.Add(AD_Message, msgText.ToString()); } dr.Close(); dr = null; //pstmt.close(); } catch (Exception e) { if (dr != null) { dr.Close(); dr = null; } _log.Log(Level.SEVERE, "initMsg", e); ////ErrorLog.FillErrorLog("Msg.InitMsg(String AD_Language)", sqlQry, e.Message, Message.MessageType.ERROR); return(null); } // if (msg.Size() < 100) { _log.Log(Level.SEVERE, "Too few (" + msg.Count + ") Records found for " + AD_Language); return(null); } _log.Info("Records=" + msg.Count + " - " + AD_Language); return(msg); }