Exemple #1
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);
        }