Exemplo n.º 1
0
        private void CallProcess(int lead_id)
        {
            string sql           = "select ad_process_id from ad_process where name = 'C_Lead BPartner'";
            int    AD_Process_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_TrxName())); // 1000025;

            MPInstance instance = new MPInstance(GetCtx(), AD_Process_ID, GetRecord_ID());

            if (!instance.Save())
            {
                return;
            }

            ProcessInfo pi = new ProcessInfo("VInOutGen", AD_Process_ID);

            pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());

            // Add Parameter - Selection=Y
            MPInstancePara para = new MPInstancePara(instance, 10);

            // Add Parameter - M_Warehouse_ID=x
            para = new MPInstancePara(instance, 20);
            para.setParameter("_C_Lead_ID", lead_id);
            if (!para.Save())
            {
                String msg = "No DocAction Parameter added";  //  not translated
                // lblStatusInfo.Text = msg.ToString();
                log.Log(Level.SEVERE, msg);
                return;
            }

            //Execute Process
            //ASyncProcess asp=null;
            //ProcessCtl worker = new ProcessCtl(asp,pi, null);
            //worker.Run();     //  complete tasks in unlockUI / generateInvoice_complete
        }
        /// <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);
            }
        }
Exemplo n.º 3
0
        //public JsonResult SaveChangePassword(int AD_User_ID, string currentPws, string newPws)
        //{
        //    if (Session["Ctx"] != null)
        //    {
        //        var ctx = Session["ctx"] as Ctx;
        //        UserPreferenceModel obj = new UserPreferenceModel();
        //        var val = obj.SaveChangePassword(ctx, AD_User_ID, currentPws, newPws);
        //        return Json(new { result = val }, JsonRequestBehavior.AllowGet);
        //    }
        //    return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet);
        //}
        /// <summary>
        /// Change login user password
        /// </summary>
        /// <param name="AD_User_ID"></param>
        /// <param name="currentPws"></param>
        /// <param name="newPws"></param>
        /// <returns></returns>
        public JsonResult SaveChangePassword(int AD_User_ID, string currentPws, string newPws)
        {
            string message = string.Empty;

            if (Session["Ctx"] != null)
            {
                String msg = "";
                var    ctx = Session["ctx"] as Ctx;

                var AD_Process_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_PROCESS_ID  FROM AD_PROCESS WHERE NAME = 'Reset Your Password'", null, null)); // Get Reset Your Password process id
                // Prepare Process
                MPInstance instance = new MPInstance(ctx, AD_Process_ID, 0);                                                                                      // create object of MPInstance
                if (!instance.Save())
                {
                    msg = Msg.GetMsg(ctx, "ProcessNoInstance");
                    return(Json(new { result = msg }, JsonRequestBehavior.AllowGet));
                }
                VAdvantage.ProcessEngine.ProcessInfo pi = new VAdvantage.ProcessEngine.ProcessInfo("ChangePassword", AD_Process_ID);
                pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());
                pi.SetAD_User_ID(AD_User_ID);
                pi.SetAD_Client_ID(ctx.GetAD_Client_ID());
                // Add Parameter - CurrentPassword
                MPInstancePara para = new MPInstancePara(instance, 10);

                para.setParameter("CurrentPassword", currentPws);
                if (!para.Save())
                {
                    msg = "No Selection Parameter added";   //  not translated
                    // msg = Msg.GetMsg(ctx, "ProcessNoInstance");
                    return(Json(new { result = msg }, JsonRequestBehavior.AllowGet));
                }
                // Add Parameter - NewPassword
                para = new MPInstancePara(instance, 20);
                para.setParameter("NewPassword", newPws);
                if (!para.Save())
                {
                    msg = "No DocAction Parameter added";   //  not translated
                    // msg = Msg.GetMsg(ctx, "ProcessNoInstance");
                    return(Json(new { result = msg }, JsonRequestBehavior.AllowGet));
                }
                para = new MPInstancePara(instance, 30);
                para.setParameter("AD_User_ID", AD_User_ID);
                if (!para.Save())
                {
                    msg = "No DocAction Parameter added";  //  not translated
                    //msg = Msg.GetMsg(ctx, "ProcessNoInstance");
                    return(Json(new { result = msg }, JsonRequestBehavior.AllowGet));
                }
                ASyncProcess _parent = null;
                // Execute Process
                ProcessCtl worker = new ProcessCtl(ctx, _parent, pi, null);

                worker.Run();     //  complete tasks in unlockUI / generateInvoice_complete
                message = pi.GetSummary();
            }
            return(Json(new { result = message }, JsonRequestBehavior.AllowGet));
            //return Json(new { result = "ok" }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="AD_Column_ID"></param>
        /// <param name="AD_Table_ID"></param>
        /// <returns></returns>
        public string CreateMasterVersionTable(int AD_Column_ID, int AD_Table_ID)
        {
            int        AD_Process_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Process_ID FROM AD_Process WHERE Value = 'MasterDataVersions'", null, Get_Trx()));
            MPInstance instance      = new MPInstance(GetCtx(), AD_Process_ID, 0);

            if (!instance.Save())
            {
                log.Info(Msg.GetMsg(GetCtx(), "ProcessNoInstance"));
                return(Msg.GetMsg(GetCtx(), "ProcessNoInstance"));
            }

            ProcessInfo pi = new ProcessInfo("", AD_Process_ID);

            pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());
            pi.SetAD_Client_ID(GetCtx().GetAD_Client_ID());

            //	Add Parameters
            MPInstancePara para = new MPInstancePara(instance, 10);

            //para.setParameter("Selection", "Y");
            para.setParameter("AD_Table_ID", AD_Table_ID);
            if (!para.Save())
            {
                String msg = "Table parameter not found";
                log.Info(msg.ToString());
                //log.Log(Level.SEVERE, msg);
                return(msg.ToString());
            }

            para = new MPInstancePara(instance, 20);
            para.setParameter("AD_Column_ID", AD_Column_ID);
            if (!para.Save())
            {
                String msg = "Column parameter not found";
                log.Info(msg.ToString());
                //log.Log(Level.SEVERE, msg);
                return(msg.ToString());
            }

            ProcessCtl worker = new ProcessCtl(GetCtx(), null, pi, Get_Trx());

            worker.Run();
            string retMsg = pi.GetSummary();

            return("Test");
        }
        // vinay bhatt window id

        /// <summary>
        /// Excecute Process
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="AD_Process_ID"></param>
        /// <param name="Name"></param>
        /// <param name="AD_Table_ID"></param>
        /// <param name="Record_ID"></param>
        /// <param name="WindowNo"></param>
        /// <param name="fileType"></param>
        /// <param name="AD_Window_ID"></param>
        /// <returns></returns>
        internal static ProcessReportInfo Process(Ctx ctx, Dictionary <string, string> processInfo)
        {
            ProcessReportInfo ret      = new ProcessReportInfo();
            MPInstance        instance = null;

            try
            {
                instance = new MPInstance(ctx, Util.GetValueOfInt(processInfo["Process_ID"]), Util.GetValueOfInt(processInfo["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();

            //	Get Parameters (Dialog)
            //Check If Contaon Parameter

            List <GridField> fields = ProcessParameter.GetParametersList(ctx, Util.GetValueOfInt(processInfo["Process_ID"]), Util.GetValueOfInt(processInfo["WindowNo"]));

            if (fields.Count < 1) //no Parameter
            {
                processInfo["AD_PInstance_ID"] = ret.AD_PInstance_ID.ToString();
                ret = ExecuteProcessCommon(ctx, processInfo, null);
            }
            else
            {
                ret.ShowParameter = true;
                ret.ProcessFields = fields;
            }
            return(ret);
        }
Exemplo n.º 6
0
        internal static ProcessReportInfo Process(Ctx ctx, int AD_Process_ID, string Name, int AD_Table_ID, int Record_ID, int WindowNo, bool csv, bool pdf)
        {
            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();

            //	Get Parameters (Dialog)
            //Check If Contaon Parameter

            List <GridField> fields = ProcessParameter.GetParametersList(ctx, AD_Process_ID, WindowNo);

            if (fields.Count < 1) //no Parameter
            {
                ret = ExecuteProcess(ctx, AD_Process_ID, Name, ret.AD_PInstance_ID, AD_Table_ID, Record_ID, null, csv, pdf);
            }
            else
            {
                ret.ShowParameter = true;
                ret.ProcessFields = fields;
            }
            return(ret);
        }
        //public bool IsJavaProcess()
        //{
        //    String Classname = GetClassname();
        //    return (Classname != null && Classname.Length > 0);
        //}

        private bool StartProcess(String ProcedureName, MPInstance pInstance)
        {
            int AD_PInstance_ID = pInstance.GetAD_PInstance_ID();
            //  execute on this thread/connection
            String sql = "{call " + ProcedureName + "(@instanceid)}";

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@instanceid", AD_PInstance_ID);
                int i = DataBase.DB.ExecuteQuery(sql, param);
            }
            catch (Exception e)
            {
                log.Log(VAdvantage.Logging.Level.SEVERE, sql, e);
                pInstance.SetResult(MPInstance.RESULT_ERROR);
                pInstance.SetErrorMsg(e.Message);
                return(false);
            }
            pInstance.SetResult(MPInstance.RESULT_OK);
            return(true);
        }
        // Method added by mohit to get reports as byteArray. 19 April 2019

        /// <summary>
        /// Method to get byte array of report.
        /// </summary>
        /// <param name="ctx">Current Context.</param>
        /// <param name="AD_Process_ID">Process ID.</param>
        /// <param name="Name">Name of process.</param>
        /// <param name="AD_Table_ID">Table id for fetching report.</param>
        /// <param name="Record_ID">Record id.</param>
        /// <param name="WindowNo">Window Number if process fired from window.</param>
        /// <param name="recIDs">String of record id's/</param>
        /// <param name="fileType">Report type.</param>
        /// <param name="report">Out parameter to get byte array.</param>
        /// <returns>Returns Process Info list and report byte array.</returns>
        public Dictionary <string, object> GetReport(Ctx ctx, int AD_Process_ID, string Name, int AD_Table_ID, int Record_ID, int WindowNo, string recIDs, string fileType, out byte[] report, out string rptFilePath)
        {
            Dictionary <string, object> d = null;

            report      = null;
            rptFilePath = null;

            // Create PInstance
            MPInstance instance = null;

            try
            {
                instance = new MPInstance(ctx, AD_Process_ID, Record_ID);
            }
            catch (Exception e)
            {
                VLogger.Get().SaveError("GetReport-Instance Save", e.Message);
                return(d);
            }

            if (!instance.Save())
            {
                ValueNamePair vp = VLogger.RetrieveError();
                if (vp != null)
                {
                    VLogger.Get().SaveError("GetReport-Instance Save", vp.Name ?? vp.GetValue());
                }
                else
                {
                    VLogger.Get().SaveError("GetReport-Instance Save", "PInstanceNotSaved");
                }

                return(d);
            }

            // Culture.
            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);


            // Process info
            ProcessInfo pi = new ProcessInfo(Name, AD_Process_ID, AD_Table_ID, Record_ID, recIDs);

            pi.SetFileType(fileType);
            TryPrintFromDocType(pi);

            try
            {
                pi.SetAD_User_ID(ctx.GetAD_User_ID());
                pi.SetAD_Client_ID(ctx.GetAD_Client_ID());
                pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());
                ProcessCtl ctl = new ProcessCtl();
                d = new Dictionary <string, object>();
                d = ctl.Process(pi, ctx, out report, out rptFilePath);
                ctl.ReportString = null;
            }
            catch (Exception e)
            {
                VLogger.Get().SaveError("GetReport", e.Message);
                report = null;
            }
            return(d);
        }
Exemplo n.º 9
0
        ///**
        // *    Create PDF
        // *	@return File or null
        // */
        //public File createPDF ()
        //{
        //    try
        //    {
        //        File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf");
        //        return createPDF (temp);
        //    }
        //    catch (Exception e)
        //    {
        //        //log.severe("Could not create PDF - " + e.getMessage());
        //    }
        //    return null;
        //}	//	getPDF

        ///**
        // *    Create PDF file
        // *	@param file output file
        // *	@return file if success
        // */
        //public File createPDF (File file)
        //{
        ////	ReportEngine re = ReportEngine.Get (GetCtx(), ReportEngine.INVOICE, getC_Invoice_ID());
        ////	if (re == null)
        //        return null;
        ////	return re.getPDF(file);
        //}

        /// <summary>
        /// Create PDF
        /// </summary>
        /// <returns>File or null</returns>
        public FileInfo CreatePDF()
        {
            //try
            //{
            //    string fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo()
            //                        + ".txt"; //.pdf
            //    string filePath = Path.GetTempPath() + fileName;

            //    //File temp = File.createTempFile(Get_TableName() + Get_ID() + "_", ".pdf");
            //    //FileStream fOutStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);

            //    FileInfo temp = new FileInfo(filePath);
            //    if (!temp.Exists)
            //    {
            //        return CreatePDF(temp);
            //    }
            //}
            //catch (Exception e)
            //{
            //    log.Severe("Could not create PDF - " + e.Message);
            //}
            //return null;



            try
            {
                //string fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo()
                String fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo() + ".pdf";
                string filePath = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "TempDownload", fileName);

                int        processID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Process_Id FROM AD_Process WHERE VALUE='CashJournalReport'", null, null));
                MPInstance instance  = new MPInstance(GetCtx(), processID, GetC_Cash_ID());
                instance.Save();
                ProcessInfo pi = new ProcessInfo("", processID, Get_Table_ID(), GetC_Cash_ID());
                pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());

                ProcessCtl ctl = new ProcessCtl();
                ctl.IsArabicReportFromOutside = false;
                byte[]         report         = null;
                ReportEngine_N re             = null;
                Dictionary <string, object> d = ctl.Process(pi, GetCtx(), out report, out re);

                File.WriteAllBytes(filePath, report);
                return(new FileInfo(filePath));
                //re.GetView();
                //bool b = re.CreatePDF(filePath);

                //File temp = File.createTempFile(Get_TableName() + Get_ID() + "_", ".pdf");
                //FileStream fOutStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);

                //FileInfo temp = new FileInfo(filePath);

                //if (!temp.Exists)
                //{
                //    b = re.CreatePDF(filePath);
                //    if (b)
                //    {
                //        return new FileInfo(filePath);
                //    }
                //    return null;
                //}
                //else
                //    return temp;
            }
            catch (Exception e)
            {
                log.Severe("Could not create PDF - " + e.Message);
            }
            return(null);
        }
        /// <summary>
        /// Complete the Payment Record
        /// </summary>
        /// <param name="ctx">Context</param>
        /// <param name="Record_ID">C_Payment_ID</param>
        /// <param name="Process_ID">AD_Process_ID</param>
        /// <param name="DocAction">Documnet Action</param>
        /// <returns>return message</returns>
        public string CompletePayment(Ctx ctx, int Record_ID, int Process_ID, string DocAction)
        {
            string result = "";
            MRole  role   = MRole.Get(ctx, ctx.GetAD_Role_ID());

            if (Util.GetValueOfBool(role.GetProcessAccess(Process_ID)))
            {
                DB.ExecuteQuery("UPDATE C_Payment SET DocAction = '" + DocAction + "' WHERE C_Payment_ID = " + Record_ID);

                MProcess   proc = new MProcess(ctx, Process_ID, null);
                MPInstance pin  = new MPInstance(proc, Record_ID);
                if (!pin.Save())
                {
                    ValueNamePair vnp      = VLogger.RetrieveError();
                    string        errorMsg = "";
                    if (vnp != null)
                    {
                        errorMsg = vnp.GetName();
                        if (errorMsg == "")
                        {
                            errorMsg = vnp.GetValue();
                        }
                    }
                    if (errorMsg == "")
                    {
                        result = Msg.GetMsg(ctx, "DocNotCompleted");
                    }

                    return(result);
                }

                MPInstancePara para = new MPInstancePara(pin, 20);
                para.setParameter("DocAction", DocAction);
                if (!para.Save())
                {
                    //String msg = "No DocAction Parameter added"; // not translated
                }
                ProcessInfo pi = new ProcessInfo("WF", Process_ID);
                pi.SetAD_User_ID(ctx.GetAD_User_ID());
                pi.SetAD_Client_ID(ctx.GetAD_Client_ID());
                pi.SetAD_PInstance_ID(pin.GetAD_PInstance_ID());
                pi.SetRecord_ID(Record_ID);
                pi.SetTable_ID(335); //AD_Table_ID=335 for C_Payment

                ProcessCtl worker = new ProcessCtl(ctx, null, pi, null);
                worker.Run();

                if (pi.IsError())
                {
                    ValueNamePair vnp      = VLogger.RetrieveError();
                    string        errorMsg = "";
                    if (vnp != null)
                    {
                        errorMsg = vnp.GetName();
                        if (errorMsg == "")
                        {
                            errorMsg = vnp.GetValue();
                        }
                    }

                    if (errorMsg == "")
                    {
                        errorMsg = pi.GetSummary();
                    }

                    if (errorMsg == "")
                    {
                        errorMsg = Msg.GetMsg(ctx, "DocNotCompleted");
                    }
                    result = errorMsg;
                    return(result);
                }
                else
                {
                    result = "";
                }
            }
            else
            {
                result = Msg.GetMsg(ctx, "NoAccess");
                return(result);
            }
            return(result);
        }
        /// <summary>
        /// This function executes when user select record (one OR more) from window and click print button.
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="AD_Process_ID"></param>
        /// <param name="Name"></param>
        /// <param name="AD_Table_ID"></param>
        /// <param name="Record_ID"></param>
        /// <param name="WindowNo"></param>
        /// <param name="recIDs"></param>
        /// <param name="fileType"></param>
        /// <returns></returns>
        public static ProcessReportInfo GeneratePrint(Ctx ctx, int AD_Process_ID, string Name, int AD_Table_ID, int Record_ID, int WindowNo, string recIDs, string fileType)
        {
            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();



            //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);
            ////////////////
            ProcessInfo pi = new ProcessInfo(Name, AD_Process_ID, AD_Table_ID, Record_ID, recIDs);

            pi.SetFileType(fileType);
            TryPrintFromDocType(pi);
            //if (ret != null)
            //{
            //    return ret;
            //}


            ret = new ProcessReportInfo();
            ret.AD_PInstance_ID = instance.GetAD_PInstance_ID();
            byte[] report      = null;
            string rptFilePath = null;

            // ProcessReportInfo rep = new ProcessReportInfo();
            try
            {
                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);
                //ctl.SetFileType(fileType);
                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();
                ret.TotalRecords    = pi.GetTotalRecords();
                ret.IsReportFormat  = pi.GetIsReportFormat();
                ret.IsTelerikReport = pi.GetIsTelerik();
                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);
            // VAdvantage.Classes.CleanUp.Get().Start();
            return(ret);
        }
Exemplo n.º 12
0
        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);
        }