Пример #1
0
        //Used for the search filter, this returns the rows that contains the search value
        public static int[] DataTableIndexOf(SAPbouiCOM.DataTable oDT, string ColumnUID, string SearchValue)
        {
            int[]  iResult = null;
            string sDT     = oDT.SerializeAsXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_DataOnly).ToUpper();
            //Normalize the SearchValue first : \, [, ^, $, the period or dot .,  |,  ?,  *,  +,  (,  )
            string NormSearchValue = SearchValue.ToUpper().Replace("\\", "\\\\");

            NormSearchValue = NormSearchValue.Replace("[", "\\[");
            NormSearchValue = NormSearchValue.Replace("^", "\\^");
            NormSearchValue = NormSearchValue.Replace("$", "\\$");
            NormSearchValue = NormSearchValue.Replace(".", "\\.");
            NormSearchValue = NormSearchValue.Replace("|", "\\|");
            NormSearchValue = NormSearchValue.Replace("?", "\\?");
            NormSearchValue = NormSearchValue.Replace("*", "\\*");
            NormSearchValue = NormSearchValue.Replace("+", "\\+");
            NormSearchValue = NormSearchValue.Replace("(", "\\(");
            NormSearchValue = NormSearchValue.Replace(")", "\\)");


            string SearchString = string.Format("<Cell><ColumnUid>{0}</ColumnUid><Value>{1}".ToUpper(), ColumnUID.ToUpper(), NormSearchValue);

            System.Text.RegularExpressions.Regex           oRegex   = new System.Text.RegularExpressions.Regex(SearchString);
            System.Text.RegularExpressions.MatchCollection oMatches = oRegex.Matches(sDT);

            iResult = new int[oMatches.Count];
            for (int i = 0; i < oMatches.Count; i++)
            {
                System.Text.RegularExpressions.Match oMatch = oMatches[i];
                SearchString = "<ROW>";
                oRegex       = new System.Text.RegularExpressions.Regex(SearchString);
                System.Text.RegularExpressions.MatchCollection oRowMatches = oRegex.Matches(sDT.Substring(0, oMatch.Index));

                iResult[i] = oRowMatches.Count - 1;
            }

            if (iResult.Length == 0)
            {
                return(null);
            }
            else
            {
                return(iResult);
            }
        }
Пример #2
0
        public static void toggleSelectCheckBox(SAPbouiCOM.ItemEvent pVal, string dtName, string CellNumber)
        {
            SAPbouiCOM.DataTable variable     = null;
            SAPbouiCOM.Form      variable1    = null;
            XmlDocument          xmlDocument  = null;
            XmlNodeList          xmlNodeLists = null;

            try
            {
                xmlDocument = new XmlDocument();
                variable1   = MainObject.Instance.B1Application.Forms.Item(pVal.FormUID);
                variable    = variable1.DataSources.DataTables.Item(dtName);
                xmlDocument.LoadXml(variable.SerializeAsXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_DataOnly));
                xmlNodeLists = xmlDocument.SelectNodes("/DataTable/Rows/Row/Cells/Cell[" + CellNumber + "]/Value");
                if (xmlNodeLists.Count > 0)
                {
                    foreach (XmlNode xmlNodes in xmlNodeLists)
                    {
                        if (xmlNodes.InnerText != "Y")
                        {
                            xmlNodes.InnerText = "Y";
                        }
                        else
                        {
                            xmlNodes.InnerText = "N";
                        }
                    }
                }
                variable.LoadSerializedXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_DataOnly, xmlDocument.InnerXml);
            }
            catch (COMException cOMException1)
            {
                COMException cOMException = cOMException1;
                Exception    exception    = new Exception(Convert.ToString(string.Concat(new object[] { "COM Error::", cOMException.ErrorCode, "::", cOMException.Message, "::", cOMException.StackTrace })));
                _Logger.Error("", exception);
            }
            catch (Exception exception2)
            {
                Exception exception1 = exception2;
                _Logger.Error("", exception2);
            }
        }
Пример #3
0
 internal static string ExportDTXML(SAPbouiCOM.Form form, string dtName)
 {
     SAPbouiCOM.DataTable dt = form.DataSources.DataTables.Item(dtName);
     Assert.IsNotNull(dt);
     return(dt.SerializeAsXML(SAPbouiCOM.BoDataTableXmlSelect.dxs_DataOnly));
 }