コード例 #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
        }
コード例 #2
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);
        }
コード例 #3
0
        /// <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");
        }
コード例 #4
0
        }       //	process

        /**
         *  Process It (sync)
         *	@param pi Process Info
         *	@param trx transaction
         *	@return true if OK
         */
        public bool ProcessIt(ProcessInfo pi, Trx trx)
        {
            if (pi.GetAD_PInstance_ID() == 0)
            {
                MPInstance pInstance = new MPInstance(this, pi.GetRecord_ID());
                //	Lock
                pInstance.SetIsProcessing(true);
                pInstance.Save();
            }

            bool ok = false;

            //	 Class
            String Classname = GetClassname();

            if (Classname != null && Classname.Length > 0)
            {
                ok = StartClass(Classname, pi, trx);
            }
            // checked if procedure is linked with Process
            // then execute procedure
            else if (GetProcedureName() != null && GetProcedureName().Trim().Length > 0)
            {
                ProcessCtl pc = new ProcessCtl(GetCtx(), null, pi, trx);
                ok = pc.StartDBProcess(GetProcedureName());
            }
            else
            {
                if (!IsReport())
                {
                    String msg = "No Classname for " + GetName();
                    pi.SetSummary(msg, ok);
                }
                else
                {
                    String msg = Msg.GetMsg(GetCtx(), "Success") + " " + GetValue();
                    pi.SetSummary(msg, ok);
                }
                //log.warning(msg);
            }

            return(ok);
        }
コード例 #5
0
        // 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);
        }
コード例 #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);
        }
コード例 #7
0
ファイル: MProcess.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        }       //	process

        /**
         *  Process It (sync)
         *	@param pi Process Info
         *	@param trx transaction
         *	@return true if OK
         */
        public bool ProcessIt(ProcessInfo pi, Trx trx)
        {
            if (pi.GetAD_PInstance_ID() == 0)
            {
                MPInstance pInstance = new MPInstance(this, pi.GetRecord_ID());
                //	Lock
                pInstance.SetIsProcessing(true);
                pInstance.Save();
            }

            bool ok = false;

            //	Java Class
            String Classname = GetClassname();

            if (Classname != null && Classname.Length > 0)
            {
                ok = StartClass(Classname, pi, trx);
            }
            else
            {
                if (!IsReport())
                {
                    String msg = "No Classname for " + GetName();
                    pi.SetSummary(msg, ok);
                }
                else
                {
                    String msg = Msg.GetMsg(GetCtx(), "Success") + " " + GetValue();
                    pi.SetSummary(msg, ok);
                }
                //log.warning(msg);
            }

            return(ok);
        }
コード例 #8
0
        // 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);
        }
コード例 #9
0
ファイル: MCash.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        ///**
        // *    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);
        }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
        /// <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);
        }
コード例 #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);
        }
コード例 #13
0
        //[MethodImpl(MethodImplOptions.Synchronized)]
        // vinay bhatt window id
        internal static ProcessReportInfo ExecuteProcess(Ctx ctx, Dictionary <string, string> processInfo, ProcessPara[] pList)
        {
            ProcessInfo pi = new ProcessInfo().FromList(processInfo);

            pi.SetAD_User_ID(ctx.GetAD_User_ID());
            pi.SetAD_Client_ID(ctx.GetAD_Client_ID());
            if (pi.GetAD_PInstance_ID() == 0)
            {
                MPInstance instance = null;
                instance = new MPInstance(ctx, Util.GetValueOfInt(processInfo["Process_ID"]), Util.GetValueOfInt(processInfo["Record_ID"]));

                if (!instance.Save())
                {
                }
                pi.SetAD_PInstance_ID(instance.Get_ID());
            }

            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, pi.GetAD_PInstance_ID(), i);
                    para.SetParameterName(pp.Name);

                    if (DisplayType.IsDate(pp.DisplayType))
                    {
                        if (pp.DisplayType == DisplayType.DateTime)
                        {
                            if (pp.Result != null)
                            {
                                para.SetP_Date_Time(Convert.ToDateTime(pp.Result));
                            }

                            if (pp.Result2 != null)
                            {
                                para.SetP_Date_Time_To(Convert.ToDateTime(pp.Result2));
                            }
                        }
                        if (pp.DisplayType == DisplayType.Time)
                        {
                            if (pp.Result != null)
                            {
                                para.SetP_Time(Convert.ToDateTime(pp.Result));
                            }

                            if (pp.Result2 != null)
                            {
                                para.SetP_Time_To(Convert.ToDateTime(pp.Result2));
                            }
                        }
                        else
                        {
                            if (pp.Result != null)
                            {
                                para.SetP_Date(Convert.ToDateTime(pp.Result).ToUniversalTime());
                            }

                            if (pp.Result2 != null)
                            {
                                para.SetP_Date_To(Convert.ToDateTime(pp.Result2).ToUniversalTime());
                            }
                        }
                    }

                    else if ((DisplayType.IsID(pp.DisplayType) || DisplayType.Integer == pp.DisplayType))
                    {
                        if (pp.Result != null)
                        {
                            if (DisplayType.IsLookup(pp.DisplayType) && pp.Result.Equals("-1"))
                            {
                                continue;
                            }

                            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 (DisplayType.IsLookup(pp.DisplayType) && pp.Result2.Equals("-1"))
                            {
                                continue;
                            }
                            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.SetAD_Process_Para_ID(pp.AD_Column_ID);

                    para.SetInfo(pp.Info);

                    if (pp.Info_To != null)
                    {
                        para.SetInfo_To(pp.Info_To);
                    }
                    para.Save();
                }
            }

            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);

            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);
                //pi.SetAD_Window_ID(AD_Window_ID);
                //pi.FileType = fileType;
                //report = null;

                pi.IsArabicReportFromOutside = false;
                ProcessCtl ctl = new ProcessCtl();

                //ctl.SetIsPrintCsv(csv);
                //ctl.SetFileType(fileType);
                //if (fileType == "P")
                //{
                //    ctl.SetIsPrintFormat(true);
                //}
                Dictionary <string, object> d = ctl.Process(pi, ctx, out report, out rptFilePath);
                rep = new ProcessReportInfo();
                rep.ReportProcessInfo = d;
                rep.Report            = report;

                //if (rep.Report != null)
                //{
                //    rep.byteString = Convert.ToBase64String(rep.Report);
                //}

                rep.ReportString = ctl.ReportString;
                //rep.AD_ReportView_ID = ctl.GetAD_ReportView_ID();
                rep.ReportFilePath = rptFilePath;
                // rep.IsRCReport = ctl.IsRCReport();
                // rep.TotalRecords = pi.GetTotalRecords();
                // rep.IsReportFormat = pi.GetIsReportFormat();
                // rep.IsTelerikReport = pi.GetIsTelerik();
                // rep.IsJasperReport = pi.GetIsJasperReport();
                //  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;
            //VAdvantage.Classes.CleanUp.Get().Start();
            return(rep);
        }