示例#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);
        }
        /// <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");
        }
        /// <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);
        }
        //[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());

            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);
        }
示例#6
0
        internal static ProcessReportInfo ExecuteProcess(Ctx ctx, int AD_Process_ID, string Name, int AD_PInstance_ID, int AD_Table_ID, int Record_ID, ProcessPara[] pList, bool csv = false, bool pdf = false)
        {
            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, AD_PInstance_ID, i);
                    para.SetParameterName(pp.Name);

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

                        if (pp.Result2 != null)
                        {
                            para.SetP_Date_To(Convert.ToDateTime(pp.Result2));
                        }
                    }
                    //else if (pp.Result is int || pp.Result2 is int)
                    //{
                    //    if (pp.Result != null)
                    //    {
                    //        para.SetP_Number(Convert.ToInt32(pp.Result));
                    //    }

                    //    if (pp.Result2 != null)
                    //    {
                    //        para.SetP_Number_To(Convert.ToInt32(pp.Result2));
                    //    }
                    //}
                    //else if (pp.Result is decimal || pp.Result2 is decimal)
                    //{
                    //    if (pp.Result != null)
                    //    {
                    //        para.SetP_Number(Convert.ToDecimal(pp.Result));
                    //    }
                    //    if (pp.Result2 != null)
                    //    {
                    //        para.SetP_Number_To(Convert.ToDecimal(pp.Result2));
                    //    }
                    //}
                    ////	Boolean
                    //else if (pp.Result is Boolean)
                    //{
                    //    Boolean bb = (Boolean)pp.Result;
                    //    String value = bb ? "Y" : "N";
                    //    para.SetP_String(value);
                    //    //	to does not make sense
                    //}
                    //*********
                    else if ((DisplayType.IsID(pp.DisplayType) || DisplayType.Integer == pp.DisplayType))
                    {
                        if (pp.Result != null)
                        {
                            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 (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.SetInfo(pp.Info);
                    if (pp.Info_To != null)
                    {
                        para.SetInfo_To(pp.Info_To);
                    }
                    para.Save();
                }
            }

            // 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);
            // VLogMgt.AddHandler(VLogFile.Get(true, storedPath, true));
            ////////////////

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

                //report = null;
                ProcessCtl ctl = new ProcessCtl();
                ctl.IsArabicReportFromOutside = false;
                ctl.SetIsPrintCsv(csv);
                if (pdf)
                {
                    ctl.SetIsPrintFormat(true);
                }
                Dictionary <string, object> d = ctl.Process(pi, ctx, out report, out rptFilePath);
                rep = new ProcessReportInfo();
                rep.ReportProcessInfo = d;
                rep.Report            = report;
                rep.ReportString      = ctl.ReportString;
                rep.ReportFilePath    = rptFilePath;
                rep.IsRCReport        = ctl.IsRCReport();
                //  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;

            return(rep);
        }