Exemple #1
0
        private static NetworkUser parseNetworkUser(string xml)
        {
            xml = XmlEncryption.decryptXml(xml);

            XmlDocument x = new XmlDocument();

            x.LoadXml(xml);
            XmlNode user      = x.SelectSingleNode("envelope/user");
            XmlNode computer  = x.SelectSingleNode("envelope/computer");
            XmlNode ip        = x.SelectSingleNode("envelope/ip");
            XmlNode message   = x.SelectSingleNode("envelope/message");
            XmlNode presence  = x.SelectSingleNode("envelope/presence");
            XmlNode icon      = x.SelectSingleNode("envelope/icon");
            XmlNode timestamp = x.SelectSingleNode("envelope/timestamp");

            //byte[] imgBits = Convert.FromBase64String(icon.InnerText);
            //MemoryStream ms = new MemoryStream(imgBits);
            //Image img = Image.FromStream(ms);
            //ms.Close();

            Lan.NetworkUser nc = new Lan.NetworkUser();
            nc.UserName     = user.InnerText;
            nc.ComputerName = computer.InnerText;
            nc.IPAddress    = IPAddress.Parse(ip.InnerText);
            nc.Presence     = (Presence)Enum.Parse(typeof(Presence), presence.InnerText);
            nc.TimeStamp    = DateTime.Parse(timestamp.InnerText);
            nc.UserUniqueId = (nc.UserName + nc.ComputerName);

            // nc.Icon = img;
            return(nc);
        }
Exemple #2
0
        private static void returnNewMessage(string envelope)
        {
            envelope = XmlEncryption.decryptXml(envelope);

            XmlDocument x = new XmlDocument();

            x.LoadXml(envelope);
            XmlNode user     = x.SelectSingleNode("envelope/user");
            XmlNode computer = x.SelectSingleNode("envelope/computer");
            XmlNode ip       = x.SelectSingleNode("envelope/ip");
            string  message  = ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(x.SelectSingleNode("envelope/message").InnerText));
            XmlNode presence = x.SelectSingleNode("envelope/presence");
            XmlNode dateSent = x.SelectSingleNode("envelope/timestamp");

            Lan.NetworkUser nc = new Lan.NetworkUser();
            nc.UserName     = user.InnerText;
            nc.ComputerName = computer.InnerText;
            nc.IPAddress    = IPAddress.Parse(ip.InnerText);
            nc.Presence     = (Lan.Presence)Enum.Parse(typeof(Lan.Presence), presence.InnerText);
            nc.TimeStamp    = DateTime.Parse(dateSent.InnerText);
            nc.UserUniqueId = (nc.UserName + nc.ComputerName).ToLower();

            if (NewMessage != null)
            {
                NewMessage(nc, message);
            }
        }
Exemple #3
0
        //adds task to xml file...
        public static void AddTask(Task Task)
        {
            try
            {
                XmlDocument xdocEn = new XmlDocument();
                xdocEn.Load(fil);

                XmlDocument xdoc = new XmlDocument();
                xdoc.LoadXml(XmlEncryption.decryptXml(xdocEn.InnerXml));


                XmlNode tasksNode = xdoc.SelectSingleNode("Tasks");

                XmlElement taskNode = xdoc.CreateElement("Task");


                XmlAttribute taskTaskId = xdoc.CreateAttribute("TaskId");
                taskTaskId.InnerText = getNewId().ToString();
                taskNode.Attributes.Append(taskTaskId);

                XmlElement taskTitleNode = xdoc.CreateElement("TaskTitle");
                taskTitleNode.InnerText = Task.TaskTitle;
                taskNode.AppendChild(taskTitleNode);

                XmlElement taskTaskDetails = xdoc.CreateElement("TaskDetails");
                taskTaskDetails.InnerText = Task.TaskDetails;
                taskNode.AppendChild(taskTaskDetails);

                XmlElement taskTaskStatus = xdoc.CreateElement("TaskStatus");
                taskTaskStatus.InnerText = Enum.GetName(typeof(TaskStatus), Task.TaskStatus);
                taskNode.AppendChild(taskTaskStatus);

                XmlElement taskLastEditDate = xdoc.CreateElement("LastEditDate");
                taskLastEditDate.InnerText = Task.LastEditDate.ToString();
                taskNode.AppendChild(taskLastEditDate);

                XmlElement taskLastEditBy = xdoc.CreateElement("LastEditBy");
                taskLastEditBy.InnerText = Task.LastEditBy;
                taskNode.AppendChild(taskLastEditBy);

                tasksNode.AppendChild(taskNode);

                xdoc.InnerXml = XmlEncryption.encryptXml(xdoc.InnerXml);

                xdoc.Save(fil);
            }
            catch (Exception ex)
            {
            }
        }
Exemple #4
0
        public static void DeleteTask(string Id)
        {
            XmlDocument xdocEn = new XmlDocument();

            xdocEn.Load(fil);

            XmlDocument xdoc      = new XmlDocument();
            string      decRypted = XmlEncryption.decryptXml(xdocEn.InnerXml);

            xdoc.LoadXml(decRypted);

            XmlNode task = xdoc.SelectSingleNode("Tasks/Task[@TaskId='" + Id + "']");

            xdoc.DocumentElement.RemoveChild(task);

            xdoc.InnerXml = XmlEncryption.encryptXml(xdoc.InnerXml);
            xdoc.Save(fil);
        }
Exemple #5
0
        private static List <Task> getTasksFromXml()
        {
            List <Task> tasks = new List <Task>();

            try
            {
                if (!File.Exists(fil))
                {
                    return(null);
                }

                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(fil);
                XmlDocument xx = new XmlDocument();
                xx.LoadXml(XmlEncryption.decryptXml(xdoc.InnerXml));

                XmlNodeList tasksNodes = xx.SelectNodes("Tasks/Task");

                if (tasksNodes != null)
                {
                    for (int i = 0; i < tasksNodes.Count; i++)
                    {
                        XmlNode task = tasksNodes[i];

                        Task t = new Task();
                        t.LastEditBy   = task.SelectSingleNode("LastEditBy").InnerText;
                        t.LastEditDate = DateTime.Parse(task.SelectSingleNode("LastEditDate").InnerText);
                        t.TaskDetails  = task.SelectSingleNode("TaskDetails").InnerText;
                        t.TaskId       = task.Attributes["TaskId"].InnerText;
                        t.TaskStatus   = (TaskStatus)Enum.Parse(typeof(TaskStatus), task.SelectSingleNode("TaskStatus").InnerText);
                        t.TaskTitle    = task.SelectSingleNode("TaskTitle").InnerText;
                        tasks.Add(t);
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }

            return(tasks);
        }
Exemple #6
0
        public static void UpdateTask(Task Task)
        {
            XmlDocument xdocEn = new XmlDocument();

            xdocEn.Load(fil);

            XmlDocument xdoc = new XmlDocument();

            xdoc.Load(XmlEncryption.decryptXml(xdocEn.InnerXml));

            XmlNode task = xdoc.SelectSingleNode("Tasks/Task[@TaskId='" + Task.TaskId + "']");

            task.SelectSingleNode("TaskDetails").InnerText  = Task.TaskDetails;
            task.SelectSingleNode("LastEditBy").InnerText   = Task.LastEditBy;
            task.SelectSingleNode("LastEditDate").InnerText = Task.LastEditDate.ToString();
            task.SelectSingleNode("TaskStatus").InnerText   = Enum.GetName(typeof(TasksLocalShare.TaskStatus), Task.TaskStatus);

            xdoc.InnerXml = XmlEncryption.encryptXml(xdoc.InnerXml);
            xdoc.Save(fil);
        }