Exemplo n.º 1
0
        }       //	getFunctionValue

        /// <summary>
        /// Get value to be displayed
        /// </summary>
        /// <param name="language">current language</param>
        /// <returns></returns>
        public String GetValueDisplay(VAdvantage.Login.Language language)
        {
            if (_value == null)
            {
                return("");
            }
            String retValue = _value.ToString();

            if (_displayType == DisplayType.Location)
            {
                return(GetValueDisplay_Location());
            }
            else if (_columnName.Equals("C_BPartner_Location_ID") || _columnName.Equals("Bill_Location_ID"))
            {
                return(GetValueDisplay_BPLocation());
            }
            else if (_displayType == 0 || _value.GetType() == typeof(String) || _value.GetType() == typeof(NamePair))
            {
            }
            else if (language != null)  //	Optional formatting of Numbers and Dates
            {
                if (DisplayType.IsNumeric(_displayType))
                {
                    retValue = DisplayType.GetNumberFormat(_displayType).GetFormatedValue(_value);
                }
                if (DisplayType.IsDate(_displayType))
                {
                    //  retValue = DisplayType.GetDateFormat(_displayType).Format(_value);
                }
            }
            return(retValue);
        }       //	getValueDisplay
Exemplo n.º 2
0
        }       //	createStatement

        /// <summary>
        /// Get SQL Value
        /// </summary>
        /// <param name="value">string value</param>
        /// <returns>sql compliant value</returns>
        private String GetSQLValue(String value)
        {
            if (value == null || value.Length == 0 || value.Equals("NULL"))
            {
                return("NULL");
            }

            //	Data Types
            if (DisplayType.IsNumeric(_column.GetAD_Reference_ID()) ||
                DisplayType.IsID(_column.GetAD_Reference_ID()))
            {
                return(value);
            }
            if (DisplayType.YesNo == _column.GetAD_Reference_ID())
            {
                if (value.Equals("true"))
                {
                    return("'Y'");
                }
                else
                {
                    return("'N'");
                }
            }
            if (DisplayType.IsDate(_column.GetAD_Reference_ID()))
            {
                return(DataBase.DB.TO_DATE(Convert.ToDateTime(value)));
            }

            //	String, etc.
            return(DataBase.DB.TO_STRING(value));
        }       //	getSQLValue
Exemplo n.º 3
0
        }       //	getDisplayType

        public bool IsNumeric()
        {
            if (_displayType == 0)
            {
                return(_value.GetType() == typeof(Decimal));
            }
            return(DisplayType.IsNumeric(_displayType));
        }       //	isNumeric
Exemplo n.º 4
0
        /// <summary>
        /// Before Save
        /// </summary>
        /// <param name="newRecord"></param>
        /// <returns></returns>
        protected override bool BeforeSave(bool newRecord)
        {
            if (!CheckVersions(false))
            {
                return(false);
            }

            int displayType = GetAD_Reference_ID();

            //	Length
            if (DisplayType.IsLOB(displayType)) //	LOBs are 0
            {
                if (GetFieldLength() != 0)
                {
                    SetFieldLength(0);
                }
            }
            else if (GetFieldLength() == 0)
            {
                if (DisplayType.IsID(displayType))
                {
                    SetFieldLength(10);
                }
                else if (DisplayType.IsNumeric(displayType))
                {
                    SetFieldLength(14);
                }
                else if (DisplayType.IsDate(displayType))
                {
                    SetFieldLength(7);
                }
                else if (DisplayType.YesNo == displayType)
                {
                    SetFieldLength(1);
                }
                else
                {
                    log.SaveError("FillMandatory", Utility.Msg.GetElement(GetCtx(), "FieldLength"));
                    return(false);
                }
            }

            /** Views are not updateable
             * UPDATE AD_Column c
             * SET IsUpdateable='N', IsAlwaysUpdateable='N'
             * WHERE AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE IsView='Y')
             **/

            //	Virtual Column
            if (IsVirtualColumn())
            {
                if (IsMandatory())
                {
                    SetIsMandatory(false);
                }
                if (IsMandatoryUI())
                {
                    SetIsMandatoryUI(false);
                }
                if (IsUpdateable())
                {
                    SetIsUpdateable(false);
                }
            }
            //	Updateable/Mandatory
            if (IsParent() || IsKey())
            {
                SetIsUpdateable(false);
                SetIsMandatory(true);
            }
            if (IsAlwaysUpdateable() && !IsUpdateable())
            {
                SetIsAlwaysUpdateable(false);
            }
            //	Encrypted
            if (IsEncrypted())
            {
                int dt = GetAD_Reference_ID();
                if (IsKey() || IsParent() || IsStandardColumn() ||
                    IsVirtualColumn() || IsIdentifier() || IsTranslated() ||
                    DisplayType.IsLookup(dt) || DisplayType.IsLOB(dt) ||
                    "DocumentNo".ToLower().Equals(GetColumnName().ToLower()) ||
                    "Value".ToLower().Equals(GetColumnName().ToLower()) ||
                    "Name".ToLower().Equals(GetColumnName().ToLower()))
                {
                    log.Warning("Encryption not sensible - " + GetColumnName());
                    SetIsEncrypted(false);
                }
            }

            //	Sync Terminology
            if ((newRecord || Is_ValueChanged("AD_Element_ID")) &&
                GetAD_Element_ID() != 0)
            {
                _element = new M_Element(GetCtx(), GetAD_Element_ID(), Get_TrxName());
                SetColumnName(_element.GetColumnName());
                SetName(_element.GetName());
                SetDescription(_element.GetDescription());
                SetHelp(_element.GetHelp());
            }

            if (IsKey() && (newRecord || Is_ValueChanged("IsKey")))
            {
                SetConstraintType(null);
            }

            return(true);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get SQL Default Value
        /// </summary>
        /// Created By : Kiran Sangwan
        /// <returns>string default clause</returns>
        public string GetSQLDefaultValue()
        {
            string defaultValue = GetDefaultValue();
            string columnName   = GetColumnName();
            int    dt           = GetAD_Reference_ID();
            //
            string sql = "";

            if (columnName.Equals("CreatedBy") || columnName.Equals("UpdatedBy"))
            {
                sql = "0";
            }
            else if (columnName.Equals("Created") || columnName.Equals("Updated"))
            {
                if (DatabaseType.IsOracle || DatabaseType.IsPostgre)
                {
                    sql = "SYSDATE";
                }
                else
                {
                    sql = "CURRENT_TIMESTAMP";
                }
            }
            else if (defaultValue != null && defaultValue.Length > 0)
            {
                defaultValue = defaultValue.Trim();
                if (defaultValue.Equals("NULL"))
                {
                    sql = "NULL";
                }
                else if (defaultValue.StartsWith("@SQL="))
                {
                    s_log.Warning("Get sql default: " + defaultValue);  //	warning & ignore default
                }
                else
                {
                    int first = defaultValue.IndexOf("@");
                    if (first >= 0 && defaultValue.IndexOf("@", first + 1) >= 0)
                    {
                        s_log.Finer("Get default: (Unresolved Variable) " + defaultValue);
                    }
                    else if (defaultValue.Equals("-1"))
                    {
                        s_log.Finer("Get default: (invalid value) " + defaultValue);
                    }
                    else
                    {
                        if (DisplayType.IsText(dt) ||
                            DisplayType.List == dt ||
                            DisplayType.YesNo == dt ||
                            (DisplayType.Button == dt && !columnName.EndsWith("_ID")) ||
                            columnName.Equals("EntityType") ||
                            columnName.Equals("AD_Language") ||
                            columnName.Equals("DocBaseType")
                            )
                        {
                            //sql = DatabaseType.TO_STRING(defaultValue);
                            sql = GlobalVariable.TO_STRING(defaultValue);
                        }
                        else
                        {
                            sql = defaultValue;
                        }
                    }
                }
            }
            else if (columnName.Equals("IsActive"))
            {
                sql = "'Y'";
            }
            //	NO default value - set Data Type
            else
            {
                if (dt == DisplayType.YesNo)
                {
                    sql = "'N'";
                }
                else if (DisplayType.IsNumeric(dt) &&
                         (IsMandatory() || IsMandatoryUI()))
                {
                    sql = "0";
                }
            }
            return(sql);
        }
Exemplo n.º 6
0
        }       //	getColumnName

        /// <summary>
        /// Create Print Format Item from Column
        /// </summary>
        /// <param name="format">parent</param>
        /// <param name="AD_Column_ID">column</param>
        /// <param name="seqNo">sequence of display if 0 it is not printed</param>
        /// <returns>Format Item</returns>
        public static MPrintFormatItem CreateFromColumn(MPrintFormat format, int AD_Column_ID, int seqNo)
        {
            MPrintFormatItem pfi = new MPrintFormatItem(format.GetCtx(), 0, null);

            pfi.SetAD_PrintFormat_ID(format.GetAD_PrintFormat_ID());
            pfi.SetClientOrg(format);
            pfi.SetAD_Column_ID(AD_Column_ID);
            pfi.SetPrintFormatType(PRINTFORMATTYPE_Field);
            //SqlParameter[] param = null;

            //	translation is dome by trigger
            String sql = "SELECT c.ColumnName,e.Name,e.PrintName, "             //	1..3
                         + "c.AD_Reference_ID,c.IsKey,c.SeqNo "                 //	4..6
                         + "FROM AD_Column c, AD_Element e "
                         + "WHERE c.AD_Column_ID='" + AD_Column_ID + "'"
                         + " AND c.AD_Element_ID=e.AD_Element_ID";
            //	translate base entry if single language - trigger copies to trl tables

            //Boolean trl = !Env.IsMultiLingualDocument(format.GetCtx()) && !GlobalVariable.IsBaseLanguage();
            Boolean trl = !Env.IsMultiLingualDocument(format.GetCtx()) && !Language.IsBaseLanguage(Login.Language.GetBaseAD_Language());

            if (trl)
            {
                sql = "SELECT c.ColumnName,e.Name,e.PrintName, "                //	1..3
                      + "c.AD_Reference_ID,c.IsKey,c.SeqNo "                    //	4..6
                      + "FROM AD_Column c, AD_Element_Trl e "
                      + "WHERE c.AD_Column_ID='" + AD_Column_ID + "'"
                      + " AND c.AD_Element_ID=e.AD_Element_ID"
                      + " AND e.AD_Language='" + GlobalVariable.GetLanguageCode() + "'";
            }
            IDataReader dr = null;

            try
            {
                dr = SqlExec.ExecuteQuery.ExecuteReader(sql);
                if (dr.Read())
                {
                    String ColumnName = dr[0].ToString();
                    pfi.SetName(dr[1].ToString());
                    pfi.SetPrintName(dr[2].ToString());
                    int displayType = dr[3].ToString() != "" ? Utility.Util.GetValueOfInt(dr[3].ToString()) : 0;
                    if (DisplayType.IsNumeric(displayType))
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_TrailingRight);
                    }
                    else if (displayType == DisplayType.Text || displayType == DisplayType.Memo)
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_Block);
                    }
                    else
                    {
                        pfi.SetFieldAlignmentType(FIELDALIGNMENTTYPE_LeadingLeft);
                    }
                    Boolean isKey = "Y".Equals(dr[4].ToString());
                    //
                    if (isKey ||
                        ColumnName.StartsWith("Created") || ColumnName.StartsWith("Updated") ||
                        ColumnName.Equals("AD_Client_ID") || ColumnName.Equals("AD_Org_ID") ||
                        ColumnName.Equals("IsActive") || ColumnName.Equals("Export_ID") ||
                        displayType == DisplayType.Button || displayType == DisplayType.Binary ||
                        displayType == DisplayType.ID || displayType == DisplayType.Image ||
                        displayType == DisplayType.RowID ||
                        seqNo == 0)
                    {
                        pfi.SetIsPrinted(false);
                        pfi.SetSeqNo(0);
                    }
                    else
                    {
                        pfi.SetIsPrinted(true);
                        pfi.SetSeqNo(seqNo);
                    }
                    int idSeqNo = dr[5].ToString() != "" ? Utility.Util.GetValueOfInt(dr[5].ToString()) : 0;    //	IsIdentifier SortNo
                    if (idSeqNo > 0)
                    {
                        pfi.SetIsOrderBy(true);
                        pfi.SetSortNo(idSeqNo);
                    }
                }
                dr.Close();
            }
            catch (Exception e)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                s_log.Severe(e.ToString());
            }
            if (!pfi.Save())
            {
                return(null);
            }
            //	pfi.dump();
            return(pfi);
        }       //	createFromColumn
        //[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);
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        }       //	getTargetColumn

        /// <summary>
        /// Execute Auto Assignment
        /// </summary>
        /// <param name="po">PO to be modified</param>
        /// <returns>true if modified</returns>
        public bool ExecuteIt(PO po)
        {
            //	Check Column
            MColumn column     = GetTargetColumn();
            String  columnName = column.GetColumnName();
            int     index      = po.Get_ColumnIndex(columnName);

            if (index == -1)
            {
                throw new Exception(ToString() + ": AD_Column_ID not found");
            }
            //	Check Value
            Object value      = po.Get_Value(index);
            String assignRule = GetAssignRule();

            if (value == null && assignRule.Equals(ASSIGNRULE_OnlyIfNOTNULL))
            {
                return(false);
            }
            else if (value != null && assignRule.Equals(ASSIGNRULE_OnlyIfNULL))
            {
                return(false);
            }

            //	Check Criteria
            if (m_criteria == null)
            {
                GetCriteria(false);
            }
            bool modified = false;

            for (int i = 0; i < m_criteria.Length; i++)
            {
                MAssignCriteria criteria = m_criteria[i];
                if (criteria.IsMet(po))
                {
                    modified = true;
                    break;
                }
            }
            if (!modified)
            {
                return(false);
            }

            //	Assignment
            String methodName    = "set" + columnName;
            Type   parameterType = null;
            Object parameter     = null;
            int    displayType   = column.GetAD_Reference_ID();
            String valueString   = GetValueString();

            if (DisplayType.IsText(displayType) || displayType == DisplayType.List)
            {
                parameterType = typeof(string);
                parameter     = valueString;
            }
            else if (DisplayType.IsID(displayType) || displayType == DisplayType.Integer)
            {
                parameterType = typeof(int);
                if (GetRecord_ID() != 0)
                {
                    parameter = GetRecord_ID();
                }
                else if (valueString != null && valueString.Length > 0)
                {
                    try
                    {
                        parameter = int.Parse(valueString);
                    }
                    catch (Exception e)
                    {
                        log.Warning(ToString() + " " + e);
                        return(false);
                    }
                }
            }
            else if (DisplayType.IsNumeric(displayType))
            {
                parameterType = typeof(Decimal);
                if (valueString != null && valueString.Length > 0)
                {
                    try
                    {
                        parameter = Decimal.Parse(valueString);
                    }
                    catch (Exception e)
                    {
                        log.Warning(ToString() + " " + e);
                        return(false);
                    }
                }
            }
            else if (DisplayType.IsDate(displayType))
            {
                parameterType = typeof(DateTime);
                if (valueString != null && valueString.Length > 0)
                {
                    try
                    {
                        parameter = DateTime.Parse(valueString);
                    }
                    catch (Exception e)
                    {
                        log.Warning(ToString() + " " + e);
                        return(false);
                    }
                }
            }
            else if (displayType == DisplayType.YesNo)
            {
                parameterType = typeof(bool);
                parameter     = "Y".Equals(valueString);
            }
            else if (displayType == DisplayType.Button)
            {
                parameterType = typeof(string);
                parameter     = GetValueString();
            }
            else if (DisplayType.IsLOB(displayType))    //	CLOB is String
            {
                parameterType = typeof(byte[]);
                //	parameter = getValueString();
            }

            //	Assignment
            try
            {
                Type clazz = po.GetType();
                System.Reflection.MethodInfo method = clazz.GetMethod(methodName, new Type[] { parameterType });
                method.Invoke(po, new Object[] { parameter });
            }
            catch (Exception e)
            {
                log.Log(Level.WARNING, ToString(), e);
                //	fallback
                if (parameter is Boolean)
                {
                    po.Set_Value(index, valueString);
                }
                else
                {
                    po.Set_Value(index, parameter);
                }
                //	modified = false;
            }
            return(modified);
        }       //	executeIt