/*Unit Implementation in Web Services - End*/
        //Method to fetch the table module details
        /*Unit Implementation in Web Services - Begin*/
        //Added a new parameter - strUnit
        public List<table> getTableData(double dStnLat, double dStnLong, int iAtl, int iMaxDist, int iMaxAltDiff, IRuleSets objIRuleset, string strNode, string strNodeName, string strCultureCode, string strServiceName, string strModuleName, string strLangID,string strUnit)
        {
            DataSet dsTbl = new DataSet();
            objTableSvc.setTableWebServiceValues(dStnLat, dStnLong, iAtl, iMaxDist, iMaxAltDiff);
            /*Unit Implementation in Web Services - Begin*/
            dsTbl = objTblPre.getTableDataForService(strNode, strNodeName, objIRuleset, strServiceName, strModuleName, strCultureCode, strUnit);
            /*Unit Implementation in Web Services - End*/
            List<table> tablelist = new List<table>();
            table tbl;
            tableRow tr = new tableRow();
            tableCell tc;
            HeaderRow hr1 = new HeaderRow();
            HeaderRow hr2 = new HeaderRow();
            HeaderCell hc;

            if (dsTbl.Tables[0].TableName.ToLower().Contains("header") && dsTbl.Tables.Count == 2)
            {
                tbl = new table();
                tbl.HeaderRows = new List<HeaderRow>();
                tbl.TableName = dsTbl.Tables[1].TableName;

                hr1.HeaderCells = new List<HeaderCell>();
                hr2.HeaderCells = new List<HeaderCell>();
                int count = 0;
                string day = "";
                string prevVal = "";
                foreach (DataRow dr in dsTbl.Tables[0].Rows)
                {
                    if (count == 0)
                    {
                        hc = new HeaderCell();
                        hc.Value = "";
                        hc.Colspan = "1";
                        hr1.HeaderCells.Add(hc);
                        hc = new HeaderCell();
                        hc.Value = "";
                        hc.Colspan = "1";
                        hr2.HeaderCells.Add(hc);
                    }
                    if (prevVal != dr[0].ToString().Split(',')[0] && !(dr[0].ToString().Split(',')[1].EndsWith("0")))
                    {
                        hc = new HeaderCell();
                        day = DateTime.Parse(dr[0].ToString().Split(',')[0].ToString()).DayOfWeek.ToString();
                        hc.Value = day;
                        hc.Colspan = dr[1].ToString();
                        hr1.HeaderCells.Add(hc);
                        prevVal = dr[0].ToString().Split(',')[0];
                    }
                    HeaderCell hc1 = new HeaderCell();
                    hc1.Value = dr[0].ToString().Split(',')[1].ToString();
                    hc1.Colspan = "1";
                    hr2.HeaderCells.Add(hc1);
                    count++;
                }
                tbl.HeaderRows.Add(hr1);
                tbl.HeaderRows.Add(hr2);

                tbl.tableRows = new List<tableRow>();
                foreach (DataRow dr in dsTbl.Tables[1].Rows)
                {
                    tr = new tableRow();
                    tr.tableCells = new List<tableCell>();
                    for (int i = 0; i < (dsTbl.Tables[1].Columns.Count/3); i++)
                    {
                        tc = new tableCell();
                        tc.Value = dr[0 + (i * 3)].ToString();
                        tc.ToolTip = dr[1 + (i * 3)].ToString();
                        tc.bgColor = dr[2 + (i * 3)].ToString();
                        if (i == 0)
                        {
                            tc.Color = "";
                            tc.CellImage = "";
                        }
                        else
                        {
                            Color bgColor = new Color();
                            bgColor = ColorTranslator.FromHtml(tc.bgColor);
                            tc.Color = ColorTranslator.FromHtml("#" + objCommonUtil.ContrastColor(bgColor).Name).Name;
                            /********IM01144144 - New Agricast Webservices - icons URL - BEGIN ***************************/
                            //tc.CellImage = objCommonUtil.toBase64(GetImage(tc.Value, tc.Color, tc.bgColor));
                            tc.CellImage = GetImage(tc.Value, tc.Color, tc.bgColor);
                            /********IM01144144 - New Agricast Webservices - icons URL - END ***************************/
                        }
                        if (i == 0)
                            tc.Header = "true";
                        else
                            tc.Header = "";
                        tr.tableCells.Add(tc);
                    }
                    tbl.tableRows.Add(tr);
                }

                tablelist.Add(tbl);
            }
            else
            {
                foreach (DataTable dt in dsTbl.Tables)
                {
                    tbl = new table();
                    tbl.HeaderRows = new List<HeaderRow>();
                    tbl.TableName = dt.TableName.ToString();

                    hr1.HeaderCells = new List<HeaderCell>();
                    for (int i = 0; i < (dt.Columns.Count / 3);i++ )
                    {
                        hc = new HeaderCell();
                        if (i == 0)
                            hc.Value = objLocSearchSvc.getTranslatedText("hour", strLangID);
                        else
                            hc.Value = (i-1).ToString();
                        hc.Colspan = "1";
                        hr1.HeaderCells.Add(hc);
                    }
                    tbl.HeaderRows.Add(hr1);

                    tbl.tableRows = new List<tableRow>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        tr = new tableRow();
                        tr.tableCells = new List<tableCell>();
                        for (int i = 0; i < (dr.Table.Columns.Count/3); i++)
                        {
                            tc = new tableCell();
                            tc.Value = dr[0 + (i * 3)].ToString();
                            tc.ToolTip = dr[1 + (i * 3)].ToString();
                            tc.bgColor = dr[2 + (i * 3)].ToString();
                            if (i == 0)
                            {
                                tc.Color = "";
                                tc.CellImage = "";
                            }
                            else
                            {
                                Color bgColor = new Color();
                                bgColor = ColorTranslator.FromHtml(tc.bgColor);
                                tc.Color = ColorTranslator.FromHtml("#" + objCommonUtil.ContrastColor(bgColor).Name).Name;
                                /********IM01144144 - New Agricast Webservices - icons URL - BEGIN ***************************/
                                //tc.CellImage =  objCommonUtil.toBase64(GetImage(tc.Value, tc.Color, tc.bgColor));
                                tc.CellImage = GetImage(tc.Value, tc.Color, tc.bgColor);
                                /********IM01144144 - New Agricast Webservices - icons URL - END ***************************/
                            }
                            if (i == 0)
                                tc.Header = "true";
                            else
                                tc.Header = "";
                            tr.tableCells.Add(tc);
                        }
                        tbl.tableRows.Add(tr);
                    }

                    tablelist.Add(tbl);
                }
            }
             return tablelist;
        }
Example #2
0
    //----------------------------------------------------------------
    //----------------------------------------------------------------

    private void ParseNode(XmlNode Node, uItem ParentItem)
    {
        List <uItem> ParentItems = null;

        if (ParentItem is mainMenuItem)
        {
            ParentItems = (ParentItem as mainMenuItem).Items;
        }
        if (ParentItem is subMenuItemSingle)
        {
            ParentItems = (ParentItem as subMenuItemSingle).Items;
        }
        if (ParentItem is subMenuItemExtra)
        {
            ParentItems = (ParentItem as subMenuItemExtra).Items;
        }
        if ((ParentItems == null) || (Node == null))
        {
            return;
        }

        for (int childInd = 0; childInd < Node.ChildNodes.Count; childInd++)
        {
            XmlNode childNode = Node.ChildNodes[childInd];
            switch (childNode.Name)
            {
            case "subitem": {
                string            itemText   = GetLocalizedTextFromAttribute(childNode, "text");
                float             itemHeight = GetFloatFromAttribute(childNode, "height", itemHeightSingle);
                subMenuItemSingle subItem    = AddSubMenuItemSingle(ParentItems, itemText, itemHeight);
                subItem.Items = new List <uItem> ();
                ParseNode(childNode, subItem);
            } break;

            case "subitemextra": {
                string           itemText      = GetLocalizedTextFromAttribute(childNode, "text");
                string           itemTextExtra = GetLocalizedTextFromAttribute(childNode, "extratext");
                float            itemHeight    = GetFloatFromAttribute(childNode, "height", itemHeightExtra);
                subMenuItemExtra subItem       = AddSubMenuItemExtra(ParentItems, itemText, itemTextExtra, itemHeight);
                subItem.Items = new List <uItem> ();
                ParseNode(childNode, subItem);
            } break;

            case "textitem": {
                string itemText   = GetLocalizedTextFromAttribute(childNode, "text");
                float  itemHeight = GetFloatFromAttribute(childNode, "height", itemHeightText);
                AddTextInfoItem(ParentItems, itemText, itemHeight);
            } break;

            case "mapitem": {
                string CenterCoord = GetTextFromAttribute(childNode, "center");
                string MarkCoord   = GetTextFromAttribute(childNode, "mark");
                float  itemHeight  = GetFloatFromAttribute(childNode, "height", itemHeightMap);
                AddMapItem(ParentItems, CenterCoord, MarkCoord, itemHeight);
            } break;

            case "phone": {
                string itemText   = GetLocalizedTextFromAttribute(childNode, "text");
                string callNumber = GetTextFromAttribute(childNode, "callnum");
                float  itemHeight = GetFloatFromAttribute(childNode, "height", itemHeightCall);
                AddCallInfoItem(ParentItems, itemText, callNumber, itemHeight);
            } break;

            case "link": {
                string itemText   = GetLocalizedTextFromAttribute(childNode, "text");
                string inetLink   = GetLocalizedTextFromAttribute(childNode, "link");
                float  itemHeight = GetFloatFromAttribute(childNode, "height", itemHeightLink);
                AddInetLinkItem(ParentItems, itemText, inetLink, itemHeight);
            } break;

            case "table": {
                float rowHeight = GetFloatFromAttribute(childNode, "rowheight", rowHeightTable);

                List <List <tableCell> > table = new List <List <tableCell> >();

                for (int rowInd = 0; rowInd < childNode.ChildNodes.Count; rowInd++)
                {
                    XmlNode rowNode = childNode.ChildNodes[rowInd];
                    if (rowNode.Name != "row")
                    {
                        continue;
                    }
                    List <tableCell> tableRow = new List <tableCell>();
                    Color            rowColor = GetColorFromAttribute(rowNode, "rowcolor", themeManager.menuColor);
                    for (int col = rowNode.Attributes.Count - 1; col >= 0; col--)
                    {
                        string coltext = GetLocalizedTextFromAttribute(rowNode, "c" + (col + 1).ToString());
                        if (coltext != "")
                        {
                            tableCell Cell = new tableCell();
                            Cell.value = coltext;
                            Cell.color = rowColor;
                            tableRow.Add(Cell);
                        }
                    }
                    table.Add(tableRow);
                }

                AddTableItem(ParentItems, table, rowHeight);
            } break;

            case "calendar": {
                float itemHeight  = GetFloatFromAttribute(childNode, "height", itemHeightCalendar);
                int   monthId     = Convert.ToInt32(GetTextFromAttribute(childNode, "num"));
                int   monthDays   = Convert.ToInt32(GetTextFromAttribute(childNode, "days"));
                int   monthDayPos = Convert.ToInt32(GetTextFromAttribute(childNode, "daypos"));
                if ((monthId < 1) || (monthId > 12))
                {
                    monthId = 0;
                }
                if (monthDays < 28)
                {
                    monthDays = 28;
                }
                if (monthDays > 31)
                {
                    monthDays = 31;
                }
                if (monthDayPos < 0)
                {
                    monthDayPos = 0;
                }
                if (monthDayPos > 6)
                {
                    monthDayPos = 6;
                }

                List <int> days = new List <int>();
                for (int dayInd = 0; dayInd < childNode.ChildNodes.Count; dayInd++)
                {
                    XmlNode dayNode = childNode.ChildNodes[dayInd];
                    if (dayNode.Name != "day")
                    {
                        continue;
                    }

                    int dayId = Convert.ToInt32(dayNode.InnerText);
                    if ((dayId >= 1) && (dayId <= monthDays))
                    {
                        days.Add(dayId);
                    }
                }

                AddCalendarItem(ParentItems, month_names[monthId], monthDayPos, monthDays, days, itemHeight);
            } break;
            }
        }
    }