コード例 #1
0
ファイル: MPInstance.cs プロジェクト: vuongthai91/ERP-CMR-DMS
 /// <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);
 }
コード例 #2
0
        /// <summary>
        /// Based on Report ID, Generate report and then save it in physcal location
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="_trx"></param>
        /// <param name="AD_TableID"></param>
        /// <param name="recordID"></param>
        /// <param name="AD_UserID"></param>
        /// <param name="AD_ClientID"></param>
        /// <param name="nodeName"></param>
        /// <param name="windowID"></param>
        /// <param name="WFActivity"></param>
        /// <returns>file info.</returns>
        public FileInfo GetPdfReportForMail(Ctx ctx, Trx _trx, int AD_TableID, int recordID, int AD_UserID, int AD_ClientID, string nodeName, int windowID, int WFActivity)
        {
            try
            {
                int reportID = GetDoctypeBasedReport(ctx, AD_TableID, recordID, windowID, WFActivity);

                if (reportID == 0)
                {
                    VLogger.Get().Warning("No Report found on DocType and Window Tab. For Table=" + AD_TableID);
                    return(null);
                }
                FileInfo temp    = null;
                MProcess process = MProcess.Get(ctx, reportID);

                ProcessInfo pi = new ProcessInfo(nodeName, reportID,
                                                 AD_TableID, recordID);
                pi.SetAD_User_ID(AD_UserID);
                pi.SetAD_Client_ID(AD_ClientID);
                MPInstance pInstance = new MPInstance(process, recordID);
                //FillParameter(pInstance, trx);
                pi.SetAD_PInstance_ID(pInstance.GetAD_PInstance_ID());

                if (process.GetIsCrystalReport() == "Y")
                {
                    pi.SetIsCrystal(true);
                }
                else
                {
                    pi.SetIsCrystal(false);
                }

                pi.SetAD_ReportFormat_ID(process.GetAD_ReportFormat_ID());
                pi.SetAD_ReportMaster_ID(process.GetAD_ReportMaster_ID());
                process.ProcessIt(pi, _trx);

                IReportEngine repo    = ReportRun(pi, ctx, _trx);
                byte[]        bytes   = repo.GetReportBytes();
                string        repPath = repo.GetReportFilePath(true, out bytes);

                repPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + repPath;
                ctx.SetContext("FetchingDocReport", "N");
                if (!string.IsNullOrEmpty(repPath))
                {
                    temp = new FileInfo(repPath);
                    if (temp.Exists)
                    {
                        return(temp);
                    }
                    return(null);
                }
                return(null);
            }
            catch
            {
                ctx.SetContext("FetchingDocReport", "N");
                return(null);
            }
        }