Ejemplo n.º 1
0
        /// <summary>
        /// Create Process Instance from Process and create parameters
        /// </summary>
        /// <param name="process">process</param>
        /// <param name="Record_ID">Record</param>
        public MPInstance(MProcess process, int Record_ID)
            : this(process.GetCtx(), 0, null)
        {
            if (process.Get_ID() <= 0)
            {
                return;
            }
            SetAD_Process_ID(process.GetAD_Process_ID());
            SetRecord_ID(Record_ID);
            SetAD_User_ID(process.GetCtx().GetAD_User_ID());

            // PO Save below
            if (!Save())                //	need to save for parameters
            {
                throw new ArgumentException("Cannot Save");
            }

            //	Set Parameter Base Info
            MProcessPara[] para = process.GetParameters();
            for (int i = 0; i < para.Length; i++)
            {
                MPInstancePara pip = new MPInstancePara(this, para[i].GetSeqNo());
                pip.SetParameterName(para[i].GetColumnName());
                pip.SetInfo(para[i].GetName());
                pip.Save(); //  PO Save
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// After Save
 /// </summary>
 /// <param name="newRecord">new</param>
 /// <param name="success">success</param>
 /// <returns>success</returns>
 protected override bool AfterSave(bool newRecord, bool success)
 {
     //	Update Statistics
     if (!newRecord &&
         !IsProcessing() &&
         Is_ValueChanged("IsProcessing"))
     {
         //long ms = System.currentTimeMillis() - GetCreated().getTime();
         long ms      = CommonFunctions.CurrentTimeMillis() - GetCreated().Millisecond;
         int  seconds = (int)(ms / 1000);
         if (seconds < 1)
         {
             seconds = 1;
         }
         MProcess prc = MProcess.Get(GetCtx(), GetAD_Process_ID());
         prc.AddStatistics(seconds);
         if (prc.Get_ID() != 0 && prc.Save())
         {
             log.Fine("afterSave - Process Statistics updated Sec=" + seconds);
         }
         else
         {
             log.Warning("afterSave - Process Statistics not updated");
         }
     }
     return(success);
 }