示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string connStr = "Data Source=.\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=SSPI;";

        using (SqlConnection conn = new SqlConnection(connStr))
        {
            SqlCommand command = new SqlCommand("select * from customers", conn);
            conn.Open();
            DataSet ds = new DataSet();
            ds.DataSetName = "Customers";
            ds.Load(command.ExecuteReader(), LoadOption.OverwriteChanges, "Customer");
            //Response.ContentType = "text/xml";
            //ds.WriteXml(Response.OutputStream);

            //Added in Listing 13-15
            XmlDataDocument doc = new XmlDataDocument(ds);
            doc.DataSet.EnforceConstraints = false;
            XmlNode node = doc.SelectSingleNode(@"//Customer[CustomerID = 'ANATR']/ContactTitle");
            node.InnerText = "Boss";
            doc.DataSet.EnforceConstraints = true;

            DataRow dr = doc.GetRowFromElement((XmlElement)node.ParentNode);
            Response.Write(dr["ContactName"].ToString() + " is the ");
            Response.Write(dr["ContactTitle"].ToString());
        }
    }
示例#2
0
        public void AddLink(string title, string uri)
        {
            XmlDocument doc = new XmlDataDocument();
            doc.Load("RssLinks.xml");
            XmlNode rootNode = doc.SelectSingleNode("links");

            XmlNode linkNode = doc.CreateElement("link");

            XmlNode titleNode = doc.CreateElement("title");
            XmlText titleText = doc.CreateTextNode(title);
            titleNode.AppendChild(titleText);

            XmlNode uriNode = doc.CreateElement("uri");
            XmlText uriText = doc.CreateTextNode(uri);
            uriNode.AppendChild(uriText);

            XmlNode defaultshowNode = doc.CreateElement("defaultshow");
            XmlText defaultshowText = doc.CreateTextNode("false");
            defaultshowNode.AppendChild(defaultshowText);

            linkNode.AppendChild(titleNode);
            linkNode.AppendChild(uriNode);
            linkNode.AppendChild(defaultshowNode);

            rootNode.AppendChild(linkNode);

            doc.Save("RssLinks.xml");
        }
示例#3
0
    public void loaddata()
    {
        XmlDataDocument xml = new XmlDataDocument();
        xml.Load(Server.MapPath("~/" + "ad.xml"));

        XmlNodeList nodes = xml.SelectSingleNode("ttt").ChildNodes;

        DataTable dt = new DataTable();

        dt.Columns.Add("index", typeof(string));
        dt.Columns.Add("src", typeof(string));
        dt.Columns.Add("href", typeof(string));
        dt.Columns.Add("target", typeof(string));

        foreach (XmlNode node in nodes)
        {
            DataRow row = dt.NewRow();

            row["href"] = node.Attributes["href"].Value;
            row["src"] = node.Attributes["src"].Value;
            dt.Rows.Add(row);
        }

        DataList4.DataSource = dt;
        DataList4.DataBind();
    }
        static void Main(string[] args)
        {
            string strConn = "Data Source=localhost;Initial Catalog=booksourcedb;Integrated Security=True";
              string strSql = "SELECT * FROM book";
              SqlDataAdapter dataAdapter = new SqlDataAdapter(strSql, strConn);

              DataSet dataSet = new DataSet("booklist");
              dataAdapter.Fill(dataSet, "book");

              XmlDataDocument xdd = new XmlDataDocument(dataSet);

              string xpath = "/booklist/book[bid='b2']";
              XmlElement eBook = (XmlElement)xdd.SelectSingleNode(xpath);

              Console.WriteLine("bid = " + eBook.ChildNodes[0].InnerText);
              Console.WriteLine("kind = " + eBook.ChildNodes[1].InnerText);
              Console.WriteLine("title = " + eBook.ChildNodes[2].InnerText);
              Console.WriteLine("publisher = " + eBook.ChildNodes[3].InnerText);
              Console.WriteLine("price = " + eBook.ChildNodes[4].InnerText);
        }
 private void AddWebConfigNodes(string xPath, ref XmlDataDocument xmlDoc, ref WebConfigModifications webConfigMods, ref SPWebApplication webApp)
 {
     foreach (XmlNode node in xmlDoc.SelectSingleNode(xPath))
     {
         if (node.NodeType != XmlNodeType.Comment)
         {
             webConfigMods.AddWebConfigNode(webApp, xPath, node, node.Attributes);
         }
     }
 }
示例#6
0
        public NavigationSearchData(string xmltag)
        {
            Id = "";
            FieldId = "";
            Action = "";
            SqlOperator = "";
            SearchFrom = "";
            SearchTo = "";
            SqlType = "";
            SearchField = "";
            SqlField = "";
            ControlType = "";
            Static = "";
            Dependency = "";
            if (xmltag.Trim().StartsWith("<tag"))
            {
                var xdoc = new XmlDataDocument();
                xdoc.LoadXml(xmltag);
                var nodtag = xdoc.SelectSingleNode("tag");
                if (nodtag != null)
                {
                    if (nodtag.Attributes["search"] != null)
                    {
                        SearchField = nodtag.Attributes["search"].Value;
                        var s = SearchField.Split('/');
                        FieldId = s[s.Count() - 1];
                        ControlType = s[s.Count() - 2];
                    }
                    if (nodtag.Attributes["id"] != null) Id = nodtag.Attributes["id"].Value;
                    if (nodtag.Attributes["action"] != null) Action = nodtag.Attributes["action"].Value;
                    if (nodtag.Attributes["sqloperator"] != null) SqlOperator = nodtag.Attributes["sqloperator"].Value;
                    if (nodtag.Attributes["searchfrom"] != null) SearchFrom = nodtag.Attributes["searchfrom"].Value;
                    if (nodtag.Attributes["searchto"] != null) SearchTo = nodtag.Attributes["searchto"].Value;
                    if (nodtag.Attributes["sqltype"] != null) SqlType = nodtag.Attributes["sqltype"].Value;
                    if (nodtag.Attributes["sqlfield"] != null) SqlField = nodtag.Attributes["sqlfield"].Value;
                    if (nodtag.Attributes["static"] != null) Static = nodtag.Attributes["static"].Value;
                    if (nodtag.Attributes["dependency"] != null) Dependency = nodtag.Attributes["dependency"].Value;

                }
            }
        }
示例#7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="soft"></param>
        public override void Build(CommuniSoft soft)
        {
            System.Collections.Hashtable idStationMap = new System.Collections.Hashtable();
            // build station
            //
            foreach (DataRow stationDR in _stationDataTable.Rows)
            {
                bool isStationDeleted = false;
                if (stationDR["Deleted"] != DBNull.Value)
                {
                    isStationDeleted = Convert.ToBoolean(stationDR["Deleted"]);
                }

                if (!isStationDeleted)
                {
                    string stationName = stationDR["Name"].ToString();
                    bool isExistStation = soft.HardwareManager.Stations.ExistName(stationName, null);
                    if (!isExistStation)
                    {
                        string xml = stationDR["CommuniTypeContent"].ToString().Trim();
                        if (xml.Length == 0)
                        {
                            // TODO: 2010-09-17
                            // log error info
                            //
                            continue;
                        }

                        int stationID = (int)stationDR["StationID"];

                        XmlDataDocument doc = new XmlDataDocument();
                        doc.LoadXml(xml);
                        XmlNode node = doc.SelectSingleNode("socketcommunitype");
                        CommuniType communiType = Xdgk.Communi.XmlBuilder.XmlSocketCommuniBuilder.Build(node);

                        Station station = new Station(stationName, communiType);
                        station.ID = stationID;
                        idStationMap.Add(stationID, station);
                        soft.HardwareManager.Stations.Add(station);
                    }
                }
            }

            // build device
            //
            foreach (DataRow deviceDR in _deviceDataTable.Rows)
            {
                bool isDeviceDeleted = false;
                if (deviceDR["deleted"] != DBNull.Value)
                {
                    isDeviceDeleted = Convert.ToBoolean(deviceDR["Deleted"]);
                }

                if (isDeviceDeleted)
                {
                    continue;
                }

                int stationID = (int)deviceDR["StationID"];
                int deviceID = (int)deviceDR["DeviceID"];
                string deviceType = deviceDR["DeviceType"].ToString();
                string addressString = deviceDR["Address"].ToString().Trim();

                if (addressString.Length == 0)
                    continue;

                int address = Convert.ToInt32(addressString);

                Station st = idStationMap[stationID] as Station;
                if (st == null)
                {
                    continue;
                }

                //DeviceDefine dd = soft.DeviceDefineCollection.FindDeviceDefine(deviceType);
                DeviceDefine dd = soft.DeviceDefineManager.DeviceDefineCollection.FindDeviceDefine(deviceType);
                if (dd == null)
                {
                    bool exist = soft.UnDefineDeviceType.Exist(deviceType);
                    if (!exist)
                    {
                        soft.UnDefineDeviceType.Add(deviceType);
                        string msg = string.Format(strings.UnDefineDeviceType, deviceType);
                        NUnit.UiKit.UserMessage.Display(msg);
                    }
                    continue;
                }

                //Xdgk.Communi.Device device = new Device(dd, "", address);
                Xdgk.Communi.Device device = DeviceFactory.Create(dd, "", address);

                //Xdgk.Communi.Device device = new Device(deviceType, address);
                //string t = soft.OperaFactory.DeviceDefineCollection.GetDeviceText(deviceType);
                //device.Text = t;
                device.ID = deviceID;

                //Station st = soft.HardwareManager.GetStation(stationName);
                st.Devices.Add(device);
            }

            //
            //
            StationCollection rainStations = this.CreateRainStations(soft);
            foreach ( Station item in rainStations )
            {
                soft.HardwareManager.Stations.Add(item);
            }
        }
示例#8
0
        public System.Collections.ArrayList listUsers()
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();

            string cmd = "listUsers";
            ErrorCode = ERR_CODE_UNKNOWN_RESPONSE;
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;    //default error message

            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command={1}&session_id={2}", httpUri.AbsoluteUri, cmd, SessionId));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null)
                    return null;

                XmlDataDocument doc = new XmlDataDocument();

                doc.LoadXml(resp);

                XmlElement element = doc.DocumentElement;
                if (element.Name == "CSL")
                {
                    XmlNode node = doc.SelectSingleNode("CSL/Command");
                    if (node != null)
                    {
                        if (node.InnerXml.Equals("listUsers", StringComparison.OrdinalIgnoreCase))
                        {
                            node = doc.SelectSingleNode("CSL/Account");
                            if (node != null)
                            {
                                while (node != null)
                                {
                                    USER_INFO info = new USER_INFO();

                                    XmlAttributeCollection atts = node.Attributes;
                                    info.username = atts.GetNamedItem("username").Value;
                                    //info.password = atts.GetNamedItem("password").Value;
                                    info.desc = atts.GetNamedItem("desc").Value;
                                    info.level = int.Parse(atts.GetNamedItem("level").Value);

                                    list.Add(info);
                                    node = node.NextSibling;
                                }
                                ErrorCode = ERR_CODE_NO_ERROR;
                                ErrorMsg = "";

                                return list;
                            }

                            node = doc.SelectSingleNode("CSL/Error");
                            if (node != null)
                            {
                                //<Error>
                                foreach (XmlAttribute att in node.Attributes)
                                {
                                    if (att.Name.Equals("msg", StringComparison.OrdinalIgnoreCase))
                                    {
                                        ErrorMsg = att.InnerXml.Substring(6).Trim();
                                    }
                                    else if (att.Name.Equals("code", StringComparison.OrdinalIgnoreCase))
                                    {
                                        Int32.TryParse(att.InnerXml, out ErrorCode);
                                    }
                                }
                                return null;
                            }
                        }
                    }
                }
            }
            catch (WebException wex)
            {
                ErrorMsg = wex.Message;
                return null;
            }
            ErrorMsg = ERR_MSG_UNKNOWN_RESPONSE;
            return null;
        }
示例#9
0
        public System.Collections.ArrayList getTagDataAllBanks()
        {
            System.Collections.ArrayList tags = new System.Collections.ArrayList();
            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command=getCaptureTagsRaw&mode=getAllBanks&session_id={1}", httpUri.AbsoluteUri, SessionId));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null)
                    return null;

                XmlDataDocument doc = new XmlDataDocument();

                doc.LoadXml(resp);

                XmlElement element = doc.DocumentElement;
                if (element.Name == "CSL")
                {
                    XmlNode node = doc.SelectSingleNode("CSL/Command");
                    if (node != null)
                    {
                        if (node.InnerXml.Equals("getcapturetagsraw", StringComparison.OrdinalIgnoreCase))
                        {
                            node = doc.SelectSingleNode("CSL/TagList/tagAllBanks");
                            if (node != null)
                            {
                                //<Ack>
                                TAG_MULTI_BANKS tag;
                                while (node != null)
                                {
                                    tag = new TAG_MULTI_BANKS();
                                    foreach (XmlAttribute att in node.Attributes)
                                    {
                                        if (att.Name.Equals("capturepoint_id", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.CapturePointId = att.InnerXml.Trim();
                                        }
                                        else if (att.Name.Equals("freq", StringComparison.OrdinalIgnoreCase))
                                        {
                                            if (att.InnerXml != null)
                                            {
                                                double d;
                                                if (double.TryParse(att.InnerXml, out d))
                                                {
                                                    tag.Frequency = d * 0.05 + 860.0;
                                                }
                                            }
                                        }
                                        else if (att.Name.Equals("index", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.Index = att.InnerXml.Trim();
                                        }
                                        else if (att.Name.Equals("rssi", StringComparison.OrdinalIgnoreCase))
                                        {
                                            if (att.InnerXml != null)
                                            {
                                                double d;
                                                double.TryParse(att.InnerXml, out d);
                                            }
                                        }
                                        else if (att.Name.Equals("bank1", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.EPC = att.InnerXml.Trim().Substring(8);
                                        }
                                        else if (att.Name.Equals("bank2", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.TID = att.InnerXml.Trim();
                                        }
                                        else if (att.Name.Equals("bank3", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.UserMemory = att.InnerXml.Trim();
                                        }
                                        else if (att.Name.Equals("time", StringComparison.OrdinalIgnoreCase))
                                        {
                                            int.TryParse(att.InnerXml, out tag.Time);
                                        }
                                    }
                                    tag.ApiTimeStampUTC = DateTime.UtcNow;
                                    tags.Add(tag);
                                    node = node.NextSibling;
                                }
                                ErrorCode = ERR_CODE_NO_ERROR;
                                ErrorMsg = "";
                                return tags;
                            }
                            node = doc.SelectSingleNode("CSL/Error");
                            if (node != null)
                            {
                                //<Error>
                                foreach (XmlAttribute att in node.Attributes)
                                {
                                    if (att.Name.Equals("msg", StringComparison.OrdinalIgnoreCase))
                                    {
                                        ErrorMsg = att.InnerXml.Substring(6).Trim();
                                    }
                                    else if (att.Name.Equals("code", StringComparison.OrdinalIgnoreCase))
                                    {
                                        Int32.TryParse(att.InnerXml, out ErrorCode);
                                    }
                                }
                                return null;
                            }
                        }
                    }
                }
            }
            catch (WebException wex)
            {
                ErrorMsg = wex.Message;
                return null;
            }
            ErrorMsg = "Invalid isOnline response.";
            return null;
        }
示例#10
0
        public System.Collections.ArrayList getCaptureTagsRaw(string mode)
        {
            System.Collections.ArrayList tags = new System.Collections.ArrayList();
            try
            {
                StringBuilder sbReq = new StringBuilder();

                sbReq.Append(String.Format("{0}API?command=getCaptureTagsRaw&mode={1}&session_id={2}", httpUri.AbsoluteUri, mode, SessionId));

                string resp = sendHTTPRequest(sbReq.ToString());
                if (resp == null)
                    return null;

                XmlDataDocument doc = new XmlDataDocument();

                doc.LoadXml(resp);

                XmlElement element = doc.DocumentElement;
                if (element.Name == "CSL")
                {
                    XmlNode node = doc.SelectSingleNode("CSL/Command");
                    if (node != null)
                    {
                        if (node.InnerXml.Equals("getcapturetagsraw", StringComparison.OrdinalIgnoreCase))
                        {
                            node = doc.SelectSingleNode("CSL/TagList/tagEPC");
                            if (node != null)
                            {
                                //<Ack>
                                TAG tag;
                                while (node != null)
                                {
                                    tag = new TAG();
                                    foreach (XmlAttribute att in node.Attributes)
                                    {
                                        if (att.Name.Equals("capturepoint_id", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.Antenna = att.InnerXml;
                                        }
                                        else if (att.Name.Equals("capturepoint_name", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.CapturePointId = att.InnerXml;
                                        }
                                        else if (att.Name.Equals("freq", StringComparison.OrdinalIgnoreCase))
                                        {
                                            if (att.InnerXml != null)
                                            {
                                                double d;
                                                if (double.TryParse(att.InnerXml, out d))
                                                {
                                                    tag.Frequency = d * 0.05 + 860.0;
                                                }
                                            }
                                        }
                                        else if (att.Name.Equals("index", StringComparison.OrdinalIgnoreCase))
                                        {
                                            string s = att.InnerXml;
                                            if (s.Length > 1)
                                            {
                                                tag.Index = s.Substring(1);
                                                tag.session = s.Substring(0, 1);
                                            }

                                        }
                                        else if (att.Name.Equals("rssi", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.RSSI = double.Parse(att.InnerXml);
                                        }
                                        else if (att.Name.Equals("tag_id", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.TagOrigId = att.InnerXml;
                                        }
                                        else if (att.Name.Equals("time", StringComparison.OrdinalIgnoreCase))
                                        {
                                            int.TryParse(att.InnerXml, out tag.Time);
                                        }
                                        else if (att.Name.Equals("event_id", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.EventId = att.InnerXml;
                                        }
                                        else if (att.Name.Equals("reader_ip", StringComparison.OrdinalIgnoreCase))
                                        {
                                            tag.ServerIp = att.InnerXml;
                                        }
                                    }
                                    tag.ApiTimeStampUTC = DateTime.UtcNow;
                                    tag.ServerIp = httpUri.Host;
                                    tags.Add(tag);
                                    node = node.NextSibling;
                                }
                                ErrorCode = ERR_CODE_NO_ERROR;
                                ErrorMsg = "";
                                return tags;
                            }
                            node = doc.SelectSingleNode("CSL/Error");
                            if (node != null)
                            {
                                //<Error>
                                foreach (XmlAttribute att in node.Attributes)
                                {
                                    if (att.Name.Equals("msg", StringComparison.OrdinalIgnoreCase))
                                    {
                                        ErrorMsg = att.InnerXml.Substring(6).Trim();
                                    }
                                    else if (att.Name.Equals("code", StringComparison.OrdinalIgnoreCase))
                                    {
                                        Int32.TryParse(att.InnerXml, out ErrorCode);
                                    }
                                }
                                return null;
                            }
                        }
                    }
                }
            }
            catch (WebException wex)
            {
                ErrorMsg = wex.Message;
                return null;
            }
            ErrorMsg = "Invalid isOnline response.";
            return null;
        }
示例#11
0
    private void Populate_ViewCalendar(EkContentCol contentdata)
    {
        System.Web.UI.WebControls.BoundColumn colBound = new System.Web.UI.WebControls.BoundColumn();
        string strTag;
        string strtag1;
        string imageDirection = string.Empty;
        if (Request.QueryString["orderbydirection"] == null)
            direction = "desc";
        else if (Request.QueryString["orderbydirection"] == "desc")
        {
            imageDirection = "&nbsp;<img src=\"" + _ContentApi.ApplicationPath + "images/ui/icons/arrowHeadDownGrey.png\" \" />";
            direction = "asc";
        }
        else if (Request.QueryString["orderbydirection"] == "asc")
        {
            imageDirection = "&nbsp;<img src=\"" + _ContentApi.ApplicationPath + "images/ui/icons/arrowHeadUpGrey.png\" \" />";
            direction = "desc";
        }
        strTag = "<a href=\"content.aspx?LangType=" + _ContentLanguage + "&action=" + _PageAction + "&orderbydirection=" + direction + "&orderby=";
        strtag1 = "&id=" + _Id + (_ContentTypeQuerystringParam != "" ? "&" + _ContentTypeUrlParam + "=" + _ContentTypeQuerystringParam : "") + "\" title=\"" + _MessageHelper.GetMessage("click to sort msg") + "\">";

        colBound.DataField = "TITLE";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "title")
            colBound.HeaderText = strTag + "Title" + strtag1 + _MessageHelper.GetMessage("generic title") + imageDirection + "</a> ";
        else
            colBound.HeaderText = strTag + "Title" + strtag1 + _MessageHelper.GetMessage("generic title") + "</a>";

        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.CssClass = "left";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "FIRSTOCCURENCE";
        colBound.HeaderText = _MessageHelper.GetMessage("webcalendar first occurence");
        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.CssClass = "left";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "TYPE";
        colBound.HeaderText = _MessageHelper.GetMessage("lbl event type");
        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.CssClass = "left";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "LANGUAGE";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "language")
            colBound.HeaderText = strTag + "language" + strtag1 + _MessageHelper.GetMessage("generic language") + imageDirection + "</a>";
           else
           colBound.HeaderText = strTag + "language" + strtag1 + _MessageHelper.GetMessage("generic language") + "</a>";
        colBound.HeaderStyle.CssClass = "title-header center";
        colBound.ItemStyle.CssClass = "center";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "ID";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "id")
            colBound.HeaderText = strTag + "ID" + strtag1 + _MessageHelper.GetMessage("generic ID") + imageDirection + "</a>";
        else
            colBound.HeaderText = strTag + "ID" + strtag1 + _MessageHelper.GetMessage("generic ID") + "</a>";

        colBound.HeaderStyle.CssClass = "title-header center";
        colBound.ItemStyle.CssClass = "center";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "STATUS";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "status")
            colBound.HeaderText = strTag + "status" + strtag1 + _MessageHelper.GetMessage("generic Status") + imageDirection + "</a>";
        else
            colBound.HeaderText = strTag + "status" + strtag1 + _MessageHelper.GetMessage("generic Status") + "</a>";

        colBound.HeaderStyle.CssClass = "title-header center";
        colBound.ItemStyle.CssClass = "center";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "DATEMODIFIED";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "datemodified")
            colBound.HeaderText = strTag + "DateModified" + strtag1 + _MessageHelper.GetMessage("generic Date Modified") + imageDirection + "</a>";
        else
            colBound.HeaderText = strTag + "DateModified" + strtag1 + _MessageHelper.GetMessage("generic Date Modified") + "</a>";

        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.CssClass = "left";
        FolderDataGrid.Columns.Add(colBound);

        colBound = new System.Web.UI.WebControls.BoundColumn();
        colBound.DataField = "EDITORNAME";
        if (!string.IsNullOrEmpty(Request.QueryString["orderby"]) && Request.QueryString["orderby"].ToString().ToLower() == "editor")
            colBound.HeaderText = strTag + "editor" + strtag1 + _MessageHelper.GetMessage("generic Last Editor") + imageDirection + "</a>";
        else
            colBound.HeaderText = strTag + "editor" + strtag1 + _MessageHelper.GetMessage("generic Last Editor") + "</a>";

        colBound.HeaderStyle.CssClass = "title-header";
        colBound.ItemStyle.CssClass = "left";
        FolderDataGrid.Columns.Add(colBound);

        DataTable dt = new DataTable();
        DataRow dr;

        dt.Columns.Add(new DataColumn("TITLE", typeof(string)));
        dt.Columns.Add(new DataColumn("FIRSTOCCURENCE", typeof(string)));
        dt.Columns.Add(new DataColumn("TYPE", typeof(string)));
        dt.Columns.Add(new DataColumn("LANGUAGE", typeof(string)));
        dt.Columns.Add(new DataColumn("ID", typeof(long)));
        dt.Columns.Add(new DataColumn("STATUS", typeof(string)));
        dt.Columns.Add(new DataColumn("DATEMODIFIED", typeof(string)));
        dt.Columns.Add(new DataColumn("EDITORNAME", typeof(string)));

        string ViewUrl = "";
        int i;

        for (i = 0; i <= contentdata.Count - 1; i++)
        {
            dr = dt.NewRow();

            //dmsMenuGuid is created to uniquely identify menu element component in the DOM,
            //just in case there is more than one menu that contains the same contentId & language
            //This case is known to apply in non-Workarea implementations of the DmsMenu but is
            //implemented for ALL DmsMenus, including the Workarea
            string dmsMenuGuid;
            dmsMenuGuid = (string)(System.Guid.NewGuid().ToString());
            string makeUnique = (string)(contentdata.get_Item(i).Id + contentdata.get_Item(i).Language + dmsMenuGuid);
            string contentStatus = contentdata.get_Item(i).ContentStatus;
            //If (contentdata.get_Item(i).ContentStatus = "A") Then
            dr[0] = "<div class=\"ektron dmsWrapper\"";
            dr[0] = dr[0] + " id=\"dmsWrapper" + makeUnique + "\">";
            dr[0] = dr[0] + "<p class=\"dmsItemWrapper\"";
            dr[0] = dr[0] + " id=\"dmsItemWrapper" + makeUnique + "\"";
            dr[0] = dr[0] + " title=\"View Menu\"";
            dr[0] = dr[0] + " style=\"overflow:visible;\"";
            dr[0] = dr[0] + ">";
            dr[0] = dr[0] + "<input type=\"hidden\" value=\'{\"id\":" + contentdata.get_Item(i).Id + ",";
            dr[0] = dr[0] + "\"parentId\":" + contentdata.get_Item(i).FolderId + ",";
            dr[0] = dr[0] + "\"languageId\":" + contentdata.get_Item(i).Language + ",";
            dr[0] = dr[0] + "\"status\":\"" + contentStatus + "\",";
            dr[0] = dr[0] + "\"guid\":\"" + dmsMenuGuid + "\",";
            dr[0] = dr[0] + "\"communityDocumentsMenu\":\"\",";
            dr[0] = dr[0] + "\"contentType\":" + Convert.ToInt32(contentdata.get_Item(i).ContentType) + ",";
            dr[0] = dr[0] + "\"dmsSubtype\":\"\"}\'";
            dr[0] = dr[0] + " id=\"dmsContentInfo" + makeUnique + "\" />";
            dr[0] = dr[0] + "<img src=\"" + _ContentApi.ApplicationPath + "images/ui/icons/calendarViewDay.png\" onclick=\"event.cancelBubble=true;\" />";
            dr[0] = dr[0] + "<a";
            dr[0] = dr[0] + " id=\"dmsViewItemAnchor" + makeUnique + "\"";
            dr[0] = dr[0] + " class=\"dmsViewItemAnchor\"";
            dr[0] = dr[0] + " onclick=\"event.cancelBubble=true;\"";
            if (contentdata.get_Item(i).ContentStatus == "A")
            {
                ViewUrl = (string)("content.aspx?action=View&folder_id=" + _Id + "&id=" + contentdata.get_Item(i).Id + "&LangType=" + contentdata.get_Item(i).Language + "&callerpage=content.aspx&origurl=" + EkFunctions.UrlEncode(Request.ServerVariables["QUERY_STRING"]));
            }
            else
            {
                ViewUrl = (string)("content.aspx?action=ViewStaged&folder_id=" + _Id + "&id=" + contentdata.get_Item(i).Id + "&LangType=" + contentdata.get_Item(i).Language + "&callerpage=content.aspx&origurl=" + EkFunctions.UrlEncode(Request.ServerVariables["QUERY_STRING"]));
            }
            dr[0] = dr[0] + " href=\"" + ViewUrl + "\"";
            dr[0] = dr[0] + " title=\"View " + contentdata.get_Item(i).Title + "\"";
            dr[0] = dr[0] + ">";
            dr[0] = dr[0] + contentdata.get_Item(i).Title;
            dr[0] = dr[0] + "</a>";
            dr[0] = dr[0] + "</p>";
            dr[0] = dr[0] + "</div>";

            System.Xml.XmlDataDocument xd = new System.Xml.XmlDataDocument();
            try
            {
                xd.LoadXml(contentdata.get_Item(i).Html);
                System.Xml.XmlNode UTCstartDTXn = xd.SelectSingleNode("/root/StartTime");
                if (UTCstartDTXn != null)
                {
                    System.Xml.XmlNode alldayXn = xd.SelectSingleNode("/root/IsAllDay");
                    bool alldayBool = false;
                    DateTime UTCstartDT = new DateTime();
                    System.Globalization.CultureInfo ENci = new System.Globalization.CultureInfo(1033);
                    System.Globalization.CultureInfo userCi = EkFunctions.GetCultureInfo(_ContentApi.RequestInformationRef.UserCulture.ToString());
                    Ektron.Cms.Common.Calendar.TimeZoneInfo userTzi;

                    UTCstartDT = DateTime.ParseExact(UTCstartDTXn.InnerText, "s", ENci.DateTimeFormat);
                    userTzi = Ektron.Cms.Common.Calendar.TimeZoneInfo.GetTimeZoneInfo(_ContentApi.RequestInformationRef.UserTimeZone);
                    DateTime LocalstartDT = userTzi.ConvertUtcToTimeZone(UTCstartDT);
                    bool.TryParse(alldayXn.InnerText, out alldayBool);

                    if (!(LocalstartDT.Hour == 0 && LocalstartDT.Minute == 0) && !alldayBool)
                    {
                        if (userCi.DateTimeFormat.PMDesignator == string.Empty) //no ampm designator
                        {
                            dr[1] = LocalstartDT.ToString("ddd, MMM d yyyy hh:mm", userCi.DateTimeFormat) + " (" + userTzi.StandardName + ")"; //first occurence
                        }
                        else
                        {
                            dr[1] = LocalstartDT.ToString("ddd, MMM d yyyy h:mm tt", userCi.DateTimeFormat) + " (" + userTzi.StandardName + ")"; //first occurence
                        }
                    }
                    else if (alldayBool)
                    {
                        dr[1] = UTCstartDT.ToString("ddd, MMM d yyyy", userCi.DateTimeFormat); //first occurence
                    }
                    else
                    {
                        dr[1] = LocalstartDT.ToString("ddd, MMM d yyyy", userCi.DateTimeFormat) + " (" + userTzi.StandardName + ")"; //first occurence
                    }
                }
                System.Xml.XmlNode isvarianceXn = xd.SelectSingleNode("/root/IsVariance");
                System.Xml.XmlNode isCancelledXn = xd.SelectSingleNode("/root/IsCancelled");
                if (isvarianceXn != null)
                {
                    bool isvariance = bool.Parse(isvarianceXn.InnerText);
                    bool isCancelled = bool.Parse(isCancelledXn.InnerText);
                    if (isvariance && isCancelled)
                    {
                        dr[2] = "Variance - Cancelled occurence";
                    }
                    else if (isvariance && !isCancelled)
                    {
                        dr[2] = "Variance - Extra occurence";
                    }
                    else
                    {
                        dr[2] = "Original";
                    }
                }
            }
            catch
            {
                dr[1] = "Start Time could not be extracted.";
            }

            string LanguageDescription = Ektron.Cms.API.JS.Escape(contentdata.get_Item(i).LanguageDescription);
            dr[3] = "<a href=\"#ShowTip" + contentdata.get_Item(i).LanguageDescription + "\" onmouseover=\"ddrivetip(\'" + LanguageDescription + "\',\'ADC5EF\', 100);\" onmouseout=\"hideddrivetip()\" style=\"text-decoration:none;\">" + "<img src=\'" + _LocalizationApi.GetFlagUrlByLanguageID(contentdata.get_Item(i).Language) + "\' />" + "</a>";
            dr[4] = contentdata.get_Item(i).Id;
            dr[5] = _StyleHelper.StatusWithToolTip(contentStatus);
            dr[6] = contentdata.get_Item(i).DateModified.ToString();
            dr[7] = contentdata.get_Item(i).LastEditorLname + ", " + contentdata.get_Item(i).LastEditorFname;
            dt.Rows.Add(dr);
        }

        DataView dv = new DataView(dt);
        FolderDataGrid.DataSource = dv;
        FolderDataGrid.DataBind();
        //        _PagingTotalPagesNumber = 1
    }
示例#12
0
文件: Class1.cs 项目: hkiaipc/c2
        /// <summary>
        /// 
        /// </summary>
        /// <param name="stationSource"></param>
        /// <returns></returns>
        public Xdgk.Communi.Station Create(object stationSource)
        {
            if (stationSource == null)
            {
                throw new ArgumentNullException("stationSource");
            }

            DataRow stationDR = stationSource as DataRow;
            if (stationDR == null)
            {
                string msg = string.Format("stationSource is not a data row");
                throw new ArgumentException(msg);
            }

            int stationID = (int)stationDR["StationID"];
            string stationName = stationDR["Name"].ToString();
            string xml = stationDR["CommuniTypeContent"].ToString().Trim();

            if (xml.Length == 0)
            {
                // TODO: 2010-09-17
                // log error info
                //
                //continue;
            }

            XmlDataDocument doc = new XmlDataDocument();
            doc.LoadXml(xml);
            XmlNode node = doc.SelectSingleNode("socketcommunitype");
            CommuniType communiType = Xdgk.Communi.XmlBuilder.XmlSocketCommuniBuilder.Build(node);

            Station station = new Station(stationName, communiType);
            station.ID = stationID;

            return station;
        }