public JsonResult PostImmediate(int AD_Client_ID, int AD_Table_ID, int Record_ID, bool force) { Ctx ctx = Session["ctx"] as Ctx; string res = ""; try { string clientName = ctx.GetAD_Org_Name() + "_" + ctx.GetAD_User_Name(); string storedPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, ""); storedPath += clientName; VLogMgt.Initialize(true, storedPath); MAcctSchema[] ass = MAcctSchema.GetClientAcctSchema(ctx, AD_Client_ID); res = Doc.PostImmediate(ass, AD_Table_ID, Record_ID, force, null); if (res == null || res.Trim().Length > 0) { res = "OK"; } } catch (Exception ex) { res += ex.Message; } return(Json(new { result = res }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Modal library load connection /// </summary> /// <param name="dbUserName"></param> /// <param name="dbPws"></param> /// <param name="dbPortNo"></param> /// <param name="dbService"></param> /// <param name="dbIP"></param> /// <param name="ProcessFilePath"></param> /// <returns></returns> public static string ReflectionIni(string dbUserName, string dbPws, string dbPortNo, string dbService, string dbIP, string ProcessFilePath) { string connection = ""; try { VLogMgt.Initialize(true, ProcessFilePath); //log = VLogger.GetVLogger("VAdvantage.Server.ViennaServerMgr"); // log.Info("Client Log***************************************************************"); VLogMgt.SetLevel(Level.ALL); connection = Ini.CreateConnectionString(dbIP, dbPortNo, dbUserName, dbPws, dbService); //Assembly asmShedular = Assembly.Load("ModelLibrary"); //Type objClass = asmShedular.GetType("VAdvantage.DataBase.Ini"); //Type[] parameterTypes = new Type[] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(string) }; //Object[] args = new Object[] { dbIP, dbPortNo, dbUserName, dbPws, dbService }; //MethodInfo m = objClass.GetMethod("CreateConnectionString", parameterTypes); //connection = (string)m.Invoke(null, args); //Type logClass = asmShedular.GetType("VAdvantage.Logging.VLogMgt"); //Type[] logPara = new Type[] { typeof(bool), typeof(string) }; //Object[] logArgs = new Object[] { true, ProcessFilePath }; //MethodInfo mlog = logClass.GetMethod("Initialize", logPara); //mlog.Invoke(null, logArgs); //log.Info("Connection String=" + connection); } catch (Exception ev) { VLogger.Get().SaveError("Connection Error", ev); } VLogger.Get().Info("================================>" + connection); return(connection); }
public static bool StartUp(bool isClient, bool isExternal) { bool OK = true; if (log != null) { return(true); } VLogMgt.Initialize(isClient); Ini.SetClient(isClient); //log = VLogger.GetVLogger(typeof(Framework.Program).FullName); //if (VAdvantage.DataBase.Ini.LoadProperties(isClient)) OK = true; VLogMgt.SetLevel(Ini.GetProperty(Ini.P_TRACELEVEL)); if (isClient && Ini.IsPropertyBool(Ini.P_TRACEFILE) && VLogFile.Get(false, null, isClient) == null) { if (!isExternal) { VLogMgt.AddHandler(VLogFile.Get(true, Ini.FindHome(), isClient)); } else { VLogMgt.AddHandler(VLogFile.Get(true, Environment.GetEnvironmentVariable("USERPROFILE"), isClient)); } } return(OK); }
/// <summary> /// Image Observer /// </summary> /// <param name="img"></param> /// <param name="infoflags"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="width"></param> /// <param name="height"></param> /// <returns></returns> public bool ImageUpdate(Image img, int infoflags, int x, int y, int width, int height) { // copied from java.awt.component //m_imageNotLoaded = (infoflags & (ALLBITS | ABORT)) == 0; if (VLogMgt.IsLevelFinest()) { log.Finest("Flags=" + infoflags + ", x=" + x + ", y=" + y + ", width=" + width + ", height=" + height + " - NotLoaded=" + m_imageNotLoaded); } return(m_imageNotLoaded); } // imageUpdate
} // getNext /// <summary> /// Only for test purpose /// </summary> public static void TestMain() { VAdvantage.DataBase.Ini.StartUp(true, true); VLogMgt.SetLevel(Level.FINE); MSchedule s = null; DateTime start = TimeUtil.GetDay(DateTime.Parse("11/26/2009 05:01:00 PM")); /** Test Case - Days **/ //s = new MSchedule(Env.GetContext(), 1000103, null); //PO.log.Info("*** Day 2 ***"); //s.SetScheduleType(SCHEDULETYPE_Frequency); //s.SetFrequencyType(FREQUENCYTYPE_Day); //s.SetFrequency(2); ////// start = new Timestamp(System.currentTimeMillis()); //s.GetNext(start, 10); ///** Test Case - Weekdays **/ //s = new MSchedule(Env.GetContext(), 0, null); //PO.log.Info("*** WeekDay Mo ***"); //s.SetScheduleType(SCHEDULETYPE_WeekDay); //s.SetWeekDay(WEEKDAY_Monday); //// start = new Timestamp(System.currentTimeMillis()); //s.GetNext(start, 92); /** Test Case - Hour **/ //s = new MSchedule(Env.GetContext(), 0, null); //PO.log.Info("*** Hour 5 ***"); //s.SetScheduleType(SCHEDULETYPE_Frequency); //s.SetFrequencyType(FREQUENCYTYPE_Hour); //s.SetFrequency(5); //// start = new Timestamp(System.currentTimeMillis()); //s.GetNext(start, 10); /** Test Case - Minutes **/ s = new MSchedule(Env.GetContext(), 1000201, null); //PO.log.Info("*** Minute 15 ***"); //s.SetScheduleType(SCHEDULETYPE_Frequency); //s.SetFrequencyType(FREQUENCYTYPE_Minute); //s.SetFrequency(15); //start = new Timestamp(System.currentTimeMillis()); s.GetNext(start, 10); }
/// <summary> /// Return the Form pointer of WindowNo - or null /// </summary> /// <param name="WindowNo"></param> /// <returns></returns> /// <summary> /// Exit System /// </summary> /// <param name="status"></param> public static void ExitEnv(int status) { // End Session MSession session = MSession.Get(Env.GetContext(), false); // finish if (session != null) { session.Logout(); } // Reset(true); // final cache reset _log.Info(""); // VLogMgt.Shutdown(); // if (VAdvantage.DataBase.Ini.IsClient()) { Environment.Exit(status); } } // close
/// <summary> /// Print info /// </summary> public void Info() { if (!VLogMgt.IsLevelFine()) { return; } //// OS //// OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); //// log.Fine(os.getName() + " " + os.getVersion() + " " + os.getArch() //// + " Processors=" + os.getAvailableProcessors()); //// Runtime //RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean(); //log.Fine(rt.getName() + " (" + rt.getVmVersion() + ") Up=" + TimeUtil.formatElapsed(rt.getUptime())); //// Memory //if (VLogMgt.IsLevelFiner()) //{ // List<MemoryPoolMXBean> list = ManagementFactory.getMemoryPoolMXBeans(); // Iterator<MemoryPoolMXBean> it = list.iterator(); // while (it.hasNext()) // { // MemoryPoolMXBean pool = (MemoryPoolMXBean)it.next(); // log.Finer(pool.getName() + " " + pool.getType() // + ": " + new CMemoryUsage(pool.getUsage())); // } //} //else //{ // MemoryMXBean memory = ManagementFactory.getMemoryMXBean(); // log.Fine("VM: " + new CMemoryUsage(memory.getNonHeapMemoryUsage())); // log.Fine("Heap: " + new CMemoryUsage(memory.getHeapMemoryUsage())); //} //// Thread //ThreadMXBean th = ManagementFactory.getThreadMXBean(); //log.Fine("Threads=" + th.getThreadCount() // + ", Peak=" + th.getPeakThreadCount() // + ", Demons=" + th.getDaemonThreadCount() // + ", Total=" + th.getTotalStartedThreadCount() //); }
public ActionResult Home() { Ctx ct = Session["ctx"] as Ctx; ViewBag.Current_Ad_Lang = ct.GetAD_Language(); objHomeHelp = new HomeHelper(); HomeModels HM = objHomeHelp.getHomeAlrtCount(ct); objHomeHelp = new HomeHelper(); HomeFolloUpsInfo fllInfo = objHomeHelp.getFolloUps(ct, 10, 1); HM.HomeFolloUpsInfo = fllInfo; ViewBag.lang = ct.GetAD_Language(); ViewBag.User_ID = ct.GetAD_User_ID(); ViewBag.isRTL = ct.GetIsRightToLeft(); string storedPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, ""); storedPath += "LOG_"; VLogMgt.Initialize(true, storedPath); return(PartialView(HM)); }
} // getCtx private bool StartEnvironment(bool doTrace) { //Program.StartUp(false, "ServerMgr"); //start up the ServerMgr class (Loads the initial value to run the application) if (doTrace) { VLogMgt.SetLevel(Level.ALL); //in case of server side, we will always open the trace to ALL } else { VLogMgt.SetLevel(Level.OFF); } log.Info(""); String Remote_Addr = "Unknown"; String Remote_Host = null; try { IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); if (ips.Length > 0) { Remote_Addr = ips[0].ToString(); //pick the one tht comes first (in case of multiple IP's) } Remote_Host = Dns.GetHostName(); } catch (Exception e) { log.Log(Level.SEVERE, "No Local Host", e); } // Set Session MSession session = MSession.Get(GetCtx(), "Z", true, Remote_Addr, Remote_Host, "Server"); // return(session != null); } // startEnvironment
/// <summary> ///Get Object of Key Value /// </summary> /// <param name="value"></param> /// <returns></returns> public override NamePair Get(Object value) { if (value == null) { return(null); } int M_AttributeSetInstance_ID = 0; if (value is int) { M_AttributeSetInstance_ID = (int)value; } else { try { M_AttributeSetInstance_ID = int.Parse(value.ToString()); } catch (Exception e) { log.Log(Level.SEVERE, "Value=" + value, e); } } if (M_AttributeSetInstance_ID == 0) { return(NO_INSTANCE); } // // Statement // if (ds == null) // String description = null; IDataReader dr = null; try { dr = DataBase.DB.ExecuteReader("SELECT Description " + "FROM M_AttributeSetInstance " + "WHERE M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID); if (dr.Read()) { description = dr[0].ToString(); if (description == null || description.Length == 0) { if (VLogMgt.IsLevelFinest()) { description = "{" + M_AttributeSetInstance_ID.ToString() + "}"; } else { description = ""; } } } dr.Close(); dr = null; } catch (Exception e) { if (dr != null) { dr.Close(); dr = null; } log.Log(Level.SEVERE, "get", e); } if (description == null) { return(null); } return(new KeyNamePair(M_AttributeSetInstance_ID, description)); }
/// <summary> /// Load LookUp data by second thread /// </summary> private void Load() { long startTime = CommonFunctions.CurrentTimeMillis();// System.currentTimeMillis(); string sql = _vInfo.query; // not validated if (!_vInfo.isValidated) { string validation = Utility.Env.ParseContext(GetCtx(), GetWindowNo(), _vInfo.validationCode, false); if (validation.Length == 0 && _vInfo.validationCode.Length > 0) { log.Fine(_vInfo.keyColumn + ": Loader NOT Validated: " + _vInfo.validationCode); return; } else { int posFrom = sql.LastIndexOf(" FROM "); bool hasWhere = sql.IndexOf(" WHERE ", posFrom) != -1; // int posOrder = sql.LastIndexOf(" ORDER BY "); if (posOrder != -1) { sql = sql.Substring(0, posOrder) + (hasWhere ? " AND " : " WHERE ") + validation + sql.Substring(posOrder); } else { sql += (hasWhere ? " AND " : " WHERE ") + validation; } if (VLogMgt.IsLevelFinest()) { log.Fine(_vInfo.keyColumn + ": Validation=" + validation); } } } //if (_loader.ThreadState == System.Threading.ThreadState.Suspended) //{ // return; //} if (VLogMgt.IsLevelFiner()) { GetCtx().SetContext(Env.WINDOW_MLOOKUP, _vInfo.column_ID, _vInfo.keyColumn, sql); } if (VLogMgt.IsLevelFinest()) { log.Fine(_vInfo.keyColumn + ": " + sql); } _lookup.Clear(); bool isNumber = _vInfo.keyColumn.EndsWith("_ID"); _hasInactive = false; int rows = 0; // KeyValuePair<string, Object> p = new KeyValuePair<string, Object>("", ""); System.Data.IDataReader dr = null; try { dr = SqlExec.ExecuteQuery.ExecuteReader(sql); _allLoaded = true; while (dr.Read()) { if (rows++ > MAX_ROWS) { log.Warning(_vInfo.keyColumn + ": Loader - Too many records"); _allLoaded = false; break; } string name = dr[2].ToString(); bool isActive = dr[3].ToString().Equals("Y"); if (!isActive) { name = INACTIVE_S + name + INACTIVE_E; _hasInactive = true; } if (isNumber) { // object key = dr[0]; int key = Utility.Util.GetValueOfInt(dr[0]); KeyNamePair p = new KeyNamePair(key, name); _lookup[key] = p; } else { string value = dr.GetString(1); ValueNamePair p = new ValueNamePair(value, name); _lookup.Add(value, p); } //KeyValuePair<string, string> p = new KeyValuePair<string, string>(); } dr.Close(); dr = null; } catch (System.Exception e) { if (dr != null) { dr.Close(); dr = null; } log.Log(Level.SEVERE, _vInfo.keyColumn + ": Loader - " + sql, e); ////Common.////ErrorLog.FillErrorLog("Mlookup.Load()",sql,e.Message,VAdvantage.Framework.Message.MessageType.ERROR); } int size = _lookup.Count; log.Finer(_vInfo.keyColumn + " (" + _vInfo.column_ID + "):" // + " ID=" + m_info.AD_Column_ID + " " + + " - Loader complete #" + size + " - all=" + _allLoaded + " - ms=" + (CommonFunctions.CurrentTimeMillis() - startTime)); //+ " (" + String.valueOf(System.currentTimeMillis() - startTime) + ")"); // if (m_allLoaded) MLookupCache.LoadEnd(_vInfo, _lookup, _allLoaded, _hasInactive); }
/// <summary> /// Get Data Direct from Table. /// </summary> /// <param name="key">key</param> /// <param name="saveInCache">save in cache for r/w</param> /// <param name="cacheLocal">cache locally for r/o</param> /// <returns></returns> public override NamePair GetDirect(Object key, bool saveInCache, bool cacheLocal) { // Nothing to query if (key == null || _vInfo.queryDirect == null || _vInfo.queryDirect.Length == 0) { return(null); } if (key.Equals(_directNullKey)) { return(null); } // NamePair directValue = null; if (_lookupDirect != null) // Lookup cache { object o = null; _lookupDirect.TryGetValue(key, out o); if (o != null && o is NamePair) { return((NamePair)o); } } log.Finer(_vInfo.keyColumn + ": " + key + ", SaveInCache=" + saveInCache + ",Local=" + cacheLocal); bool isNumber = _vInfo.keyColumn.EndsWith("_ID"); System.Data.IDataReader dr = null; try { // SELECT Key, Value, Name FROM ... System.Data.SqlClient.SqlParameter[] param = new System.Data.SqlClient.SqlParameter[1]; if (isNumber) { param[0] = new System.Data.SqlClient.SqlParameter("@key", int.Parse(key.ToString())); } else { param[0] = new System.Data.SqlClient.SqlParameter("@key", key.ToString()); } dr = SqlExec.ExecuteQuery.ExecuteReader(_vInfo.queryDirect, param); if (dr.Read()) { String name = dr[2].ToString(); if (isNumber) { int keyValue = Utility.Util.GetValueOfInt(dr[0]); //object keyValue = dr[0]; KeyNamePair p = new KeyNamePair(keyValue, name); if (saveInCache) // save if { _lookup.Add(keyValue, p); } directValue = p; } else { String value = dr.GetString(1); ValueNamePair p = new ValueNamePair(value, name); if (saveInCache) // save if { _lookup.Add(value, p); } directValue = p; } if (dr.Read()) { log.Log(Level.SEVERE, _vInfo.keyColumn + ": Not unique (first returned) for " + key + " SQL=" + _vInfo.queryDirect); } } else { _directNullKey = key; directValue = null; } if (VLogMgt.IsLevelFinest()) { log.Finest(_vInfo.keyColumn + ": " + directValue + " - " + _vInfo); } dr.Close(); dr = null; } catch (Exception e) { log.Log(Level.SEVERE, _vInfo.keyColumn + ": SQL=" + _vInfo.queryDirect + "; Key=" + key, e); if (dr != null) { dr.Close(); dr = null; } directValue = null; } // Cache Local if not added to R/W cache if (cacheLocal && !saveInCache && directValue != null) { if (_lookupDirect == null) { _lookupDirect = new Dictionary <object, object>(); } _lookupDirect.Add(key, directValue); } _hasInactive = true; return(directValue); }
} // prepare /// <summary> /// Process /// </summary> /// <returns> info</returns> protected override String DoIt() { if (_IsAllCurrencies) { _C_Currency_ID = 0; } log.Info("C_AcctSchema_ID=" + _C_AcctSchema_ID + ",C_ConversionTypeReval_ID=" + _C_ConversionTypeReval_ID + ",DateReval=" + _DateReval + ", APAR=" + _APAR + ", IsAllCurrencies=" + _IsAllCurrencies + ",C_Currency_ID=" + _C_Currency_ID + ", C_DocType_ID=" + _C_DocTypeReval_ID); // Parameter if (_DateReval == null) { _DateReval = DateTime.Now; //new Timestamp(System.currentTimeMillis()); } // Delete - just to be sure String sql = "DELETE FROM T_InvoiceGL WHERE AD_PInstance_ID=" + GetAD_PInstance_ID(); //jz FROM int no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (no > 0) { log.Info("Deleted #" + no); } // Insert Trx String dateStr = DataBase.DB.TO_DATE(_DateReval, true); sql = "INSERT INTO T_InvoiceGL (AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy, Updated,UpdatedBy," + " AD_PInstance_ID, C_Invoice_ID, GrandTotal, OpenAmt, " + " Fact_Acct_ID, AmtSourceBalance, AmtAcctBalance, " + " AmtRevalDr, AmtRevalCr, C_DocTypeReval_ID, IsAllCurrencies, " + " DateReval, C_ConversionTypeReval_ID, AmtRevalDrDiff, AmtRevalCrDiff, APAR) " // -- + "SELECT i.AD_Client_ID, i.AD_Org_ID, i.IsActive, i.Created,i.CreatedBy, i.Updated,i.UpdatedBy," + GetAD_PInstance_ID() + ", i.C_Invoice_ID, i.GrandTotal, invoiceOpen(i.C_Invoice_ID, 0), " + " fa.Fact_Acct_ID, fa.AmtSourceDr-fa.AmtSourceCr, fa.AmtAcctDr-fa.AmtAcctCr, " // AmtRevalDr, AmtRevalCr, + " currencyConvert(fa.AmtSourceDr, i.C_Currency_ID, a.C_Currency_ID, " + dateStr + ", " + _C_ConversionTypeReval_ID + ", i.AD_Client_ID, i.AD_Org_ID)," + " currencyConvert(fa.AmtSourceCr, i.C_Currency_ID, a.C_Currency_ID, " + dateStr + ", " + _C_ConversionTypeReval_ID + ", i.AD_Client_ID, i.AD_Org_ID)," + (_C_DocTypeReval_ID == 0 || _C_DocTypeReval_ID == -1 ? "NULL" : Utility.Util.GetValueOfString(_C_DocTypeReval_ID)) + ", " + (_IsAllCurrencies ? "'Y'," : "'N',") + dateStr + ", " + _C_ConversionTypeReval_ID + ", 0, 0, '" + _APAR + "' " // + "FROM C_Invoice_v i" + " INNER JOIN Fact_Acct fa ON (fa.AD_Table_ID=318 AND fa.Record_ID=i.C_Invoice_ID" + " AND (i.GrandTotal=fa.AmtSourceDr OR i.GrandTotal=fa.AmtSourceCr))" + " INNER JOIN C_AcctSchema a ON (fa.C_AcctSchema_ID=a.C_AcctSchema_ID) " + "WHERE i.IsPaid='N'" + " AND EXISTS (SELECT * FROM C_ElementValue ev " + "WHERE ev.C_ElementValue_ID=fa.Account_ID AND (ev.AccountType='A' OR ev.AccountType='L'))" + " AND fa.C_AcctSchema_ID=" + _C_AcctSchema_ID; if (!_IsAllCurrencies) { sql += " AND i.C_Currency_ID<>a.C_Currency_ID"; } if (ONLY_AR.Equals(_APAR)) { sql += " AND i.IsSOTrx='Y'"; } else if (ONLY_AP.Equals(_APAR)) { sql += " AND i.IsSOTrx='N'"; } if (!_IsAllCurrencies && _C_Currency_ID != 0 && _C_Currency_ID != -1) { sql += " AND i.C_Currency_ID=" + _C_Currency_ID; } no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (no != 0) { log.Info("Inserted #" + no); } else if (VLogMgt.IsLevelFiner()) { log.Warning("Inserted #" + no + " - " + sql); } else { log.Warning("Inserted #" + no); } // Calculate Difference sql = "UPDATE T_InvoiceGL gl " + "SET (AmtRevalDrDiff,AmtRevalCrDiff)=" + "(SELECT gl.AmtRevalDr-fa.AmtAcctDr, gl.AmtRevalCr-fa.AmtAcctCr " + "FROM Fact_Acct fa " + "WHERE gl.Fact_Acct_ID=fa.Fact_Acct_ID) " + "WHERE AD_PInstance_ID=" + GetAD_PInstance_ID(); int noT = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (noT > 0) { log.Config("Difference #" + noT); } // Percentage sql = "UPDATE T_InvoiceGL SET PercentGL = 100 " + "WHERE GrandTotal=OpenAmt AND AD_PInstance_ID=" + GetAD_PInstance_ID(); no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (no > 0) { log.Info("Not Paid #" + no); } sql = "UPDATE T_InvoiceGL SET PercentGL = ROUND(OpenAmt*100/GrandTotal,6) " + "WHERE GrandTotal<>OpenAmt AND GrandTotal <> 0 AND AD_PInstance_ID=" + GetAD_PInstance_ID(); no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (no > 0) { log.Info("Partial Paid #" + no); } sql = "UPDATE T_InvoiceGL SET AmtRevalDr = AmtRevalDr * PercentGL/100," + " AmtRevalCr = AmtRevalCr * PercentGL/100," + " AmtRevalDrDiff = AmtRevalDrDiff * PercentGL/100," + " AmtRevalCrDiff = AmtRevalCrDiff * PercentGL/100 " + "WHERE PercentGL <> 100 AND AD_PInstance_ID=" + GetAD_PInstance_ID(); no = DataBase.DB.ExecuteQuery(sql, null, Get_TrxName()); if (no > 0) { log.Config("Partial Calc #" + no); } // Create Document String info = ""; if (_C_DocTypeReval_ID != 0 && _C_DocTypeReval_ID != -1) { if (_C_Currency_ID != 0) { log.Warning("Can create Journal only for all currencies"); } else { info = CreateGLJournal(); } } return("#" + noT + info); } // doIt
/// <summary> /// Starts the process /// </summary> /// <param name="ctx">context</param> /// <param name="pi">ProcessInfo object</param> /// <returns></returns> public bool StartProcess(Ctx ctx, ProcessInfo pi, Trx trx) { // Preparation _pi = pi; PrepareCtx(ctx); //ctxContext = ctx == null ? Utility.Env.GetCtx() : ctx; _trx = trx; bool localTrx = _trx == null; if (localTrx) { _trx = Trx.GetTrx("SvrProcess"); } //trx = SqlExec.ExecuteQuery.GerServerTransaction(); String msg = null; bool success = true; try { Lock(); Prepare(); msg = DoIt(); } catch (Exception e) { msg = e.Message; if (msg == null) { msg = e.ToString(); } if (e.Message != null) { log.Log(Level.SEVERE, msg); } else if (VLogMgt.IsLevelFiner()) { log.Log(Level.WARNING, msg); } else { log.Warning(msg); } success = false; } if (localTrx && _trx != null) { if (success) { _trx.Commit(); } else { _trx.Rollback(); } _trx.Close(); _trx = null; } // Parse Variables msg = Utility.Msg.ParseTranslation(ctx, msg); _pi.SetSummary(msg, !success); ProcessInfoUtil.SaveLogToDB(_pi); Unlock(); return(success); }
public static ProcessReportInfo GeneratePrint(Ctx ctx, int AD_Process_ID, string Name, int AD_Table_ID, int Record_ID, int WindowNo, bool csv) { ProcessReportInfo ret = new ProcessReportInfo(); MPInstance instance = null; try { instance = new MPInstance(ctx, AD_Process_ID, Record_ID); } catch (Exception e) { ret.IsError = true; ret.Message = e.Message; return(ret); } if (!instance.Save()) { ret.IsError = true; ret.Message = Msg.GetMsg(ctx, "ProcessNoInstance"); return(ret); } ret.AD_PInstance_ID = instance.GetAD_PInstance_ID(); List <GridField> fields = ProcessParameter.GetParametersList(ctx, AD_Process_ID, WindowNo); if (fields.Count < 1) //no Parameter { //ReportEngine_N re = null; string lang = ctx.GetAD_Language().Replace("_", "-"); System.Globalization.CultureInfo original = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); ////////log///// string clientName = ctx.GetAD_Org_Name() + "_" + ctx.GetAD_User_Name(); string storedPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, ""); storedPath += clientName; VLogMgt.Initialize(true, storedPath); //////////////// byte[] report = null; string rptFilePath = null; // ProcessReportInfo rep = new ProcessReportInfo(); try { ProcessInfo pi = new ProcessInfo(Name, AD_Process_ID, AD_Table_ID, Record_ID); pi.SetAD_User_ID(ctx.GetAD_User_ID()); pi.SetAD_Client_ID(ctx.GetAD_Client_ID()); pi.SetAD_PInstance_ID(ret.AD_PInstance_ID); //report = null; ProcessCtl ctl = new ProcessCtl(); ctl.SetIsPrintFormat(true); ctl.IsArabicReportFromOutside = false; ctl.SetIsPrintCsv(csv); Dictionary <string, object> d = ctl.Process(pi, ctx, out report, out rptFilePath); //rep = new ProcessReportInfo(); ret.ReportProcessInfo = d; ret.Report = report; ret.ReportString = ctl.ReportString; ret.ReportFilePath = rptFilePath; ret.HTML = ctl.GetRptHtml(); ret.IsRCReport = ctl.IsRCReport(); ctl.ReportString = null; //Env.GetCtx().Clear(); } catch (Exception e) { ret.IsError = true; ret.Message = e.Message; } System.Threading.Thread.CurrentThread.CurrentCulture = original; System.Threading.Thread.CurrentThread.CurrentUICulture = original; //return ret; //ret = ExecuteProcess(ctx, AD_Process_ID, Name, ret.AD_PInstance_ID, AD_Table_ID, Record_ID, null,true); } else { ret.ShowParameter = true; ret.ProcessFields = fields; } return(ret); }
} // characters /// <summary> /// Receive notification of the end of an element. /// </summary> /// <param name="uri">name space</param> /// <param name="localName">name</param> /// <param name="qName">qualified name</param> public void EndElement(String uri, String localName, String qName) { if (qName.Equals(Translation.XML_TAG)) { } else if (qName.Equals(Translation.XML_ROW_TAG)) { _time = DateTime.Now; // Set section if (_sql.Length > 0) { _sql.Append(","); } _sql.Append("Updated=").Append(DataBase.DB.TO_DATE(_time, false)); if (!_isBaseLanguage) { if (_trl != null && ("Y".Equals(_trl) || "N".Equals(_trl))) { _sql.Append(",IsTranslated='").Append(_trl).Append("'"); } else { _sql.Append(",IsTranslated='Y'"); } } // Where section _sql.Append(" WHERE "); if (!_ByExportID || _curExportID == null) { _sql.Append(_TableName).Append("_ID=").Append(_curID); } else { string trlTable = _TableName; if (!_isBaseLanguage) { trlTable = _TableName + "_Trl"; } _sql.Append(_TableName).Append("_ID=").Append("(").Append(" SELECT ").Append(_TableName).Append("_ID ") .Append(" FROM ").Append(_TableName).Append(" WHERE Export_ID = '").Append(_curExportID).Append("' )"); } if (!_isBaseLanguage) { _sql.Append(" AND AD_Language='").Append(_AD_Language).Append("'"); } if (_AD_Client_ID >= 0) { _sql.Append(" AND AD_Client_ID=").Append(_AD_Client_ID); } // Update section _sql.Insert(0, _updateSQL); // Execute int no = DataBase.DB.ExecuteQuery(_sql.ToString(), null, null); if (no == 1) { if (VLogMgt.IsLevelFinest()) { log.Fine(_sql.ToString()); } _updateCount++; } else if (no == 0) { log.Warning("Not Found - " + _sql.ToString()); } else { log.Severe("Update Rows=" + no + " (Should be 1) - " + _sql.ToString()); } } else if (qName.Equals(Translation.XML_VALUE_TAG)) { if (_sql.Length > 0) { _sql.Append(","); } _sql.Append(_curColumnName).Append("=").Append(DataBase.DB.TO_STRING(_curValue.ToString())); _wordCount += Utility.Util.CountWords(_curValue.ToString()); } } // endElementtran
public override NamePair Get(object value) { if (value == null) { return(null); } int C_DimAmt_ID = 0; if (value is int) { C_DimAmt_ID = (int)value; } else { try { C_DimAmt_ID = int.Parse(value.ToString()); } catch (Exception e) { log.Log(Level.SEVERE, "Value=" + value, e); } } if (C_DimAmt_ID == 0) { return(NO_INSTANCE); } String description = null; IDataReader dr = null; try { dr = DataBase.DB.ExecuteReader("SELECT Amount " + "FROM C_DimAmt " + "WHERE C_DimAmt_ID=" + C_DimAmt_ID); if (dr.Read()) { description = dr[0].ToString(); if (description == null || description.Length == 0) { if (VLogMgt.IsLevelFinest()) { description = "{" + C_DimAmt_ID.ToString() + "}"; } else { description = ""; } } } dr.Close(); dr = null; } catch (Exception e) { if (dr != null) { dr.Close(); dr = null; } log.Log(Level.SEVERE, "get", e); } if (description == null) { return(null); } return(new KeyNamePair(C_DimAmt_ID, description)); }
internal static ProcessReportInfo ExecuteProcess(Ctx ctx, int AD_Process_ID, string Name, int AD_PInstance_ID, int AD_Table_ID, int Record_ID, ProcessPara[] pList, bool csv = false, bool pdf = false) { int vala = 0; if (pList != null && pList.Length > 0) //we have process parameter { for (int i = 0; i < pList.Length; i++) { var pp = pList[i]; // Create Parameter MPInstancePara para = new MPInstancePara(ctx, AD_PInstance_ID, i); para.SetParameterName(pp.Name); if (DisplayType.IsDate(pp.DisplayType)) { if (pp.Result != null) { para.SetP_Date(Convert.ToDateTime(pp.Result)); } if (pp.Result2 != null) { para.SetP_Date_To(Convert.ToDateTime(pp.Result2)); } } //else if (pp.Result is int || pp.Result2 is int) //{ // if (pp.Result != null) // { // para.SetP_Number(Convert.ToInt32(pp.Result)); // } // if (pp.Result2 != null) // { // para.SetP_Number_To(Convert.ToInt32(pp.Result2)); // } //} //else if (pp.Result is decimal || pp.Result2 is decimal) //{ // if (pp.Result != null) // { // para.SetP_Number(Convert.ToDecimal(pp.Result)); // } // if (pp.Result2 != null) // { // para.SetP_Number_To(Convert.ToDecimal(pp.Result2)); // } //} //// Boolean //else if (pp.Result is Boolean) //{ // Boolean bb = (Boolean)pp.Result; // String value = bb ? "Y" : "N"; // para.SetP_String(value); // // to does not make sense //} //********* else if ((DisplayType.IsID(pp.DisplayType) || DisplayType.Integer == pp.DisplayType)) { if (pp.Result != null) { if (int.TryParse(pp.Result.ToString(), out vala)) { para.SetP_Number(Convert.ToInt32(pp.Result)); } else { para.SetP_String(pp.Result.ToString()); } } if (pp.Result2 != null) { if (int.TryParse(pp.Result2.ToString(), out vala)) { para.SetP_Number_To(Convert.ToInt32(pp.Result2)); } else { para.SetP_String_To(pp.Result2.ToString()); } } } else if (DisplayType.IsNumeric(pp.DisplayType)) { if (pp.Result != null) { para.SetP_Number(Convert.ToDecimal(pp.Result)); } if (pp.Result2 != null) { para.SetP_Number_To(Convert.ToDecimal(pp.Result2)); } } else if (DisplayType.YesNo == pp.DisplayType) { Boolean bb = (Boolean)pp.Result; String value = bb ? "Y" : "N"; para.SetP_String(value); } //********* else { if (pp.Result != null) { para.SetP_String(pp.Result.ToString()); } if (pp.Result2 != null) { para.SetP_String_To(pp.Result.ToString()); } } para.SetInfo(pp.Info); if (pp.Info_To != null) { para.SetInfo_To(pp.Info_To); } para.Save(); } } // ReportEngine_N re = null; string lang = ctx.GetAD_Language().Replace("_", "-"); System.Globalization.CultureInfo original = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang); System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang); ////////log///// string clientName = ctx.GetAD_Org_Name() + "_" + ctx.GetAD_User_Name(); string storedPath = Path.Combine(HostingEnvironment.ApplicationPhysicalPath, ""); storedPath += clientName; VLogMgt.Initialize(true, storedPath); // VLogMgt.AddHandler(VLogFile.Get(true, storedPath, true)); //////////////// byte[] report = null; string rptFilePath = null; ProcessReportInfo rep = new ProcessReportInfo(); try { ProcessInfo pi = new ProcessInfo(Name, AD_Process_ID, AD_Table_ID, Record_ID); pi.SetAD_User_ID(ctx.GetAD_User_ID()); pi.SetAD_Client_ID(ctx.GetAD_Client_ID()); pi.SetAD_PInstance_ID(AD_PInstance_ID); //report = null; ProcessCtl ctl = new ProcessCtl(); ctl.IsArabicReportFromOutside = false; ctl.SetIsPrintCsv(csv); if (pdf) { ctl.SetIsPrintFormat(true); } Dictionary <string, object> d = ctl.Process(pi, ctx, out report, out rptFilePath); rep = new ProcessReportInfo(); rep.ReportProcessInfo = d; rep.Report = report; rep.ReportString = ctl.ReportString; rep.ReportFilePath = rptFilePath; rep.IsRCReport = ctl.IsRCReport(); // rep.AD_PrintFormat_ID = ctl.GetAD_PrintFormat_ID(); if (d.ContainsKey("AD_PrintFormat_ID")) { rep.AD_PrintFormat_ID = Convert.ToInt32(d["AD_PrintFormat_ID"]); } ctl.ReportString = null; rep.HTML = ctl.GetRptHtml(); rep.AD_Table_ID = ctl.GetReprortTableID(); //Env.GetCtx().Clear(); } catch (Exception e) { rep.IsError = true; rep.Message = e.Message; } System.Threading.Thread.CurrentThread.CurrentCulture = original; System.Threading.Thread.CurrentThread.CurrentUICulture = original; return(rep); }
} // validate /// <summary> /// Distribute Amount to Lines /// </summary> /// <param name="acct">account</param> /// <param name="Amt">amount</param> /// <param name="C_Currency_ID">currency</param> public void Distribute(MAccount acct, Decimal Amt, int C_Currency_ID) { log.Info("Amt=" + Amt + " - " + acct); GetLines(false); int precision = MCurrency.GetStdPrecision(GetCtx(), C_Currency_ID); // First Round Decimal total = Env.ZERO; int indexBiggest = -1; int indexZeroPercent = -1; for (int i = 0; i < _lines.Length; i++) { MDistributionLine dl = _lines[i]; if (!dl.IsActive()) { continue; } dl.SetAccount(acct); // Calculate Amount dl.CalculateAmt(Amt, precision); //total = total.add(dl.GetAmt()); total = Decimal.Add(total, dl.GetAmt()); // log.fine("distribute - Line=" + dl.getLine() + " - " + dl.getPercent() + "% " + dl.getAmt() + " - Total=" + total); // Remainder if (Env.Signum(dl.GetPercentDistribution()) == 0) { indexZeroPercent = i; } if (indexZeroPercent == -1) { if (indexBiggest == -1) { indexBiggest = i; } else if (dl.GetAmt().CompareTo(_lines[indexBiggest].GetAmt()) > 0) { indexBiggest = i; } } } // Adjust Remainder //Decimal difference = Amt.subtract(total); Decimal difference = Decimal.Subtract(Amt, total); if (difference.CompareTo(Env.ZERO) != 0) { if (indexZeroPercent != -1) { // log.fine("distribute - Difference=" + difference + " - 0%Line=" + _lines[indexZeroPercent]); _lines[indexZeroPercent].SetAmt(difference); } else if (indexBiggest != -1) { // log.fine("distribute - Difference=" + difference + " - MaxLine=" + _lines[indexBiggest] + " - " + _lines[indexBiggest].getAmt()); //_lines[indexBiggest].SetAmt (_lines[indexBiggest].GetAmt().add(difference)); _lines[indexBiggest].SetAmt(Decimal.Add(_lines[indexBiggest].GetAmt(), difference)); } else { log.Warning("Remaining Difference=" + difference); } } // if (VLogMgt.IsLevelFinest()) //if (CLogMgt.isLevelFinest()) { for (int i = 0; i < _lines.Length; i++) { if (_lines[i].IsActive()) { log.Fine("Amt=" + _lines[i].GetAmt() + " - " + _lines[i].GetAccount()); } } } } // distribute