/// <summary>
        ///	Process
        /// </summary>
        /// <returns>message</returns>
        protected override String DoIt()
        {
            //log.info("C_PeriodControl_ID=" + _C_PeriodControl_ID);
            MPeriodControl pc = new MPeriodControl(GetCtx(), _C_PeriodControl_ID, Get_TrxName());

            if (pc.Get_ID() == 0)
            {
                throw new Exception("@NotFound@  @C_PeriodControl_ID@=" + _C_PeriodControl_ID);
            }
            //	Permanently closed
            if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.Equals(pc.GetPeriodStatus()))
            {
                throw new Exception("@PeriodStatus@ = " + pc.GetPeriodStatus());
            }
            //	No Action
            if (MPeriodControl.PERIODACTION_NoAction.Equals(pc.GetPeriodAction()))
            {
                return("@OK@");
            }
            //	Open
            if (MPeriodControl.PERIODACTION_OpenPeriod.Equals(pc.GetPeriodAction()))
            {
                pc.SetPeriodStatus(MPeriodControl.PERIODSTATUS_Open);
            }
            //	Close
            if (MPeriodControl.PERIODACTION_ClosePeriod.Equals(pc.GetPeriodAction()))
            {
                pc.SetPeriodStatus(MPeriodControl.PERIODSTATUS_Closed);
            }
            //	Close Permanently
            if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.Equals(pc.GetPeriodAction()))
            {
                pc.SetPeriodStatus(MPeriodControl.PERIODSTATUS_PermanentlyClosed);
            }
            pc.SetPeriodAction(MPeriodControl.PERIODACTION_NoAction);
            Boolean ok = pc.Save();

            //	Reset Cache
            CacheMgt.Get().Reset("C_PeriodControl", 0);
            CacheMgt.Get().Reset("C_Period", pc.GetC_Period_ID());
            if (!ok)
            {
                return("@Error@");
            }
            return("@OK@");
        }
Пример #2
0
        }       //	close

        /// <summary>
        /// Reset Cache
        /// </summary>
        /// <param name="finalCall">everything otherwise login data remains</param>
        public static void Reset(bool finalCall)
        {
            _log.Info("finalCall=" + finalCall);
            // CloseWindows();
            _sWindows.Clear();

            //	Clear all Context
            if (finalCall)
            {
                _sCtx.Clear();
            }
            else        //	clear window context only
            {
                Object[] keys = _sCtx.KeySet().ToArray();
                for (int i = 0; i < keys.Length; i++)
                {
                    String tag = keys[i].ToString();
                    //if (Character.isDigit(tag.charAt(0)))
                    if (char.IsDigit(Convert.ToChar(tag.Substring(0, Convert.ToInt32(tag.Length - (tag.Length - 1))))))
                    {
                        _sCtx.Remove(keys[i].ToString());
                    }
                }
            }

            //	Cache
            CacheMgt.Get().Reset();
            DataBase.DB.CloseTarget();
            //	Reset Role Access
            if (!finalCall)
            {
                //DataBase.DB.SetDBTarget(CConnection.get());
                //DataBase.DB.SetDBTarget(DataBase.DB.GetConnection());
                MRole defaultRole = MRole.GetDefault(_sCtx, false);
                if (defaultRole != null)
                {
                    defaultRole.LoadAccess(true);       //	Reload
                }
            }
        }
Пример #3
0
        /**
         *  Process
         *	@return message
         *	@throws Exception
         */
        protected override String DoIt()
        {
            //log.info("C_Period_ID=" + _C_Period_ID + ", PeriodAction=" + _PeriodAction);
            MPeriod period = new MPeriod(GetCtx(), _C_Period_ID, Get_TrxName());

            if (period.Get_ID() == 0)
            {
                throw new Exception("@NotFound@  @C_Period_ID@=" + _C_Period_ID);
            }

            StringBuilder sql = new StringBuilder("UPDATE C_PeriodControl ");

            sql.Append("SET PeriodStatus='");
            //	Open
            if (MPeriodControl.PERIODACTION_OpenPeriod.Equals(_PeriodAction))
            {
                sql.Append(MPeriodControl.PERIODSTATUS_Open);
            }
            //	Close
            else if (MPeriodControl.PERIODACTION_ClosePeriod.Equals(_PeriodAction))
            {
                sql.Append(MPeriodControl.PERIODSTATUS_Closed);
            }
            //	Close Permanently
            else if (MPeriodControl.PERIODACTION_PermanentlyClosePeriod.Equals(_PeriodAction))
            {
                sql.Append(MPeriodControl.PERIODSTATUS_PermanentlyClosed);
            }
            else
            {
                return("-");
            }
            //
            sql.Append("', PeriodAction='N', Updated=SysDate,UpdatedBy=").Append(GetAD_User_ID());
            //	WHERE
            sql.Append(" WHERE C_Period_ID=").Append(period.GetC_Period_ID())
            .Append(" AND PeriodStatus<>'P'")
            .Append(" AND PeriodStatus<>'").Append(_PeriodAction).Append("'");

            // if organization is selected then update period control of selected organizations
            if (!String.IsNullOrEmpty(_AD_Org_ID))
            {
                sql.Append(" AND AD_Org_ID IN (" + _AD_Org_ID + ")");
            }

            // if Document BaseType is selected then update period control for selected Document BaseType
            if (!String.IsNullOrEmpty(_docBaseType))
            {
                sql.Append(" AND DocBaseType IN (SELECT DocBaseType FROM C_DocBaseType WHERE C_DocBaseType_ID IN (" + _docBaseType + "))");
            }

            int no = DataBase.DB.ExecuteQuery(sql.ToString(), null, Get_TrxName());

            // Lokesh Chauhan 17-Dec-2013

            /* Change For setting date From in Balance Aggregation window
             * For Fact Account Balance updation */
            if (no >= 0)
            {
                if (MPeriodControl.PERIODACTION_ClosePeriod.Equals(_PeriodAction))
                {
                    try
                    {
                        string  sqlSchID = "SELECT C_AcctSchema_ID FROM C_AcctSchema WHERE IsActive = 'Y' AND AD_Client_ID = " + GetCtx().GetAD_Client_ID();
                        DataSet ds       = DB.ExecuteDataset(sqlSchID);

                        if (ds != null)
                        {
                            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                            {
                                int    C_AcctSchema_ID = Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_AcctSchema_ID"]);
                                string sqlUpd          = "UPDATE Fact_Accumulation SET DateFrom = " + DB.TO_DATE(period.GetStartDate().Value.AddDays(-1)) + " WHERE IsActive = 'Y' AND AD_Client_ID = " + GetCtx().GetAD_Client_ID();
                                no = DB.ExecuteQuery(sqlUpd, null, Get_TrxName());
                                if (Get_Trx().Commit())
                                {
                                    VAdvantage.Report.FinBalance.UpdateBalance(GetCtx(), C_AcctSchema_ID, period.GetStartDate().Value.AddDays(-1), Get_TrxName(), 0, this);
                                }
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }

            CacheMgt.Get().Reset("C_PeriodControl", 0);
            CacheMgt.Get().Reset("C_Period", _C_Period_ID);
            return("@Period Updated@ #" + no);
        }
Пример #4
0
 /// <summary>
 /// Cash Reset
 /// @ejb.interface-method view-type="both"
 /// </summary>
 /// <param name="tableName">table name</param>
 /// <param name="Record_ID">record or 0 for all</param>
 /// <returns>number of records reset</returns>
 public int CacheReset(String tableName, int Record_ID)
 {
     log.Config(tableName + " - " + Record_ID);
     _cacheResetCount++;
     return(CacheMgt.Get().Reset(tableName, Record_ID));
 }