Esempio n. 1
0
        public override Response NewResponse(XmlNode responseNode)
        {
            XmlNode n = responseNode;

            ArrayList tags = new ArrayList();

            for (int i = 0; i < n.ChildNodes.Count; i++)
            {
                XmlNode child = n.ChildNodes.Item(i);
                if (!child.Name.ToLower().Equals(MailService.E_TAG))
                {
                    continue;
                }

                Tag t = new Tag();
                t.Id          = XmlUtil.AttributeValue(child.Attributes, MailService.A_ID);
                t.Name        = XmlUtil.AttributeValue(child.Attributes, MailService.A_NAME);
                t.Color       = XmlUtil.AttributeValue(child.Attributes, MailService.A_COLOR);
                t.UnreadCount = XmlUtil.AttributeValue(child.Attributes, MailService.A_UNREAD_COUNT);

                tags.Add(t);
            }

            if (tags.Count == 0)
            {
                return(new GetTagResponse(null));
            }

            return(new GetTagResponse((Tag[])tags.ToArray(tags[0].GetType())));
        }
Esempio n. 2
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var attendees = new List <Attendee>();
            //取得 Msg 的參與人員
            var attendeeNodes = responseNode.SelectNodes($"//{MailService.NS_PREFIX}:at", XmlUtil.NamespaceManager);

            if (attendeeNodes != null)
            {
                foreach (XmlNode attendeeNode in attendeeNodes)
                {
                    string displayName = XmlUtil.AttributeValue(attendeeNode.Attributes, MailService.A_DISPLAY_NAME);
                    string email       = XmlUtil.AttributeValue(attendeeNode.Attributes, MailService.A_EMAIL);
                    string userType    = XmlUtil.AttributeValue(attendeeNode.Attributes, MailService.A_CUTYPE);
                    attendees.Add(new Attendee
                    {
                        DisplayName = displayName,
                        Email       = email,
                        UserType    = $"{userType}"
                    });
                }
            }

            var res = new GetMsgResponse(attendees);

            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 3
0
        private ApptSummary ApptNodeToApptSummary(XmlNode node)
        {
            //node is the appt node
            ApptSummary summary = new ApptSummary();

            summary.ItemId   = XmlUtil.AttributeValue(node.Attributes, MailService.A_ID);
            summary.Name     = XmlUtil.AttributeValue(node.Attributes, MailService.A_NAME);
            summary.Location = XmlUtil.AttributeValue(node.Attributes, MailService.A_LOCATION);
            summary.InvId    = XmlUtil.AttributeValue(node.Attributes, MailService.A_INV_ID);
            summary.CompNum  = XmlUtil.AttributeValue(node.Attributes, MailService.A_COMP_NUM);

            XmlNode fragmentNode = node.SelectSingleNode(MailService.NS_PREFIX + ":" + MailService.E_FRAGMENT, XmlUtil.NamespaceManager);

            if (fragmentNode != null)
            {
                summary.Fragment = fragmentNode.InnerText;
            }

            ArrayList   instanceList = new ArrayList();
            XmlNodeList iNodes       = node.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_INSTANCE, XmlUtil.NamespaceManager);

            for (int i = 0; i < iNodes.Count; i++)
            {
                XmlNode             iNode   = iNodes.Item(i);
                String              s       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_START);
                Int64               seconds = Int64.Parse(s);
                DateTime            start   = DateUtil.GmtSecondsToLocalTime(seconds);
                ApptSummaryInstance asi     = new ApptSummaryInstance(start);
                instanceList.Add(asi);
            }

            summary.Instances = instanceList;
            return(summary);
        }
Esempio n. 4
0
        public override Response NewResponse(XmlNode responseNode)
        {
            //match
            //email="rainmaker ho (亂馬客)" <*****@*****.**>
            //取得所有match的內容
            var matchsList = new List <Attendee>();
            //取得 Conflicts 的人員(會議室、車子...)
            var matchNodes = responseNode.SelectNodes($"//{MailService.NS_PREFIX}:match", XmlUtil.NamespaceManager);

            if (matchNodes != null)
            {
                foreach (XmlNode matchNode in matchNodes)
                {
                    var email    = XmlUtil.AttributeValue(matchNode.Attributes, "email");
                    var username = Regex.Match(email, "\"(.*)\"").Groups[1].Value;
                    if (!string.IsNullOrWhiteSpace(username))
                    {
                        var usermail = Regex.Match(email, @"<(.*)>").Groups[1].Value;
                        var user     = new Attendee();
                        user.DisplayName = username;
                        user.Email       = usermail;
                        matchsList.Add(user);
                    }
                }
            }
            var res = new AutoCompleteResponse(matchsList);

            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 5
0
        private Folder NodeToFolder(XmlNode parent)
        {
            XmlAttributeCollection attrs = parent.Attributes;

            Folder f;

            if (parent.Name.ToLower().Equals("search"))
            {
                SearchFolder sf = new SearchFolder();
                sf.Query  = XmlUtil.AttributeValue(attrs, MailService.A_QUERY);
                sf.Types  = XmlUtil.AttributeValue(attrs, MailService.A_TYPES);
                sf.SortBy = XmlUtil.AttributeValue(attrs, MailService.A_SORT_BY);
                f         = sf;
            }
            else
            {
                f = new Folder();
            }

            f.Id             = XmlUtil.AttributeValue(attrs, MailService.A_ID);
            f.Name           = XmlUtil.AttributeValue(attrs, MailService.A_NAME);
            f.ParentFolderId = XmlUtil.AttributeValue(attrs, MailService.A_PARENT_FOLDER_ID);
            f.Color          = XmlUtil.AttributeValue(attrs, MailService.A_COLOR);
            f.UnreadCount    = XmlUtil.AttributeValue(attrs, MailService.A_UNREAD_COUNT);
            f.NumMessages    = XmlUtil.AttributeValue(attrs, MailService.A_ITEM_COUNT);
            f.View           = XmlUtil.AttributeValue(attrs, MailService.A_VIEW);

            for (int i = 0; i < parent.ChildNodes.Count; i++)
            {
                XmlNode child = parent.ChildNodes.Item(i);
                f.Children.Add(NodeToFolder(child));
            }

            return(f);
        }
Esempio n. 6
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var appts     = new List <SearchResult>();
            var apptNodes = responseNode.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_APPOINTMENT, XmlUtil.NamespaceManager);

            foreach (XmlNode apptNode in apptNodes)
            {
                var appt = new SearchResult();
                appt.Name     = XmlUtil.AttributeValue(apptNode.Attributes, MailService.A_NAME);
                appt.Location = XmlUtil.AttributeValue(apptNode.Attributes, MailService.A_LOCATION);
                appt.Duration = Convert.ToInt64(XmlUtil.AttributeValue(apptNode.Attributes, MailService.A_DURATION));
                var instNode = apptNode.SelectSingleNode(MailService.NS_PREFIX + ":" + MailService.E_INSTANCE, XmlUtil.NamespaceManager);
                if (instNode != null)
                {
                    String s       = XmlUtil.AttributeValue(instNode.Attributes, MailService.A_START);
                    Int64  seconds = Int64.Parse(s);
                    appt.StartTime = DateUtil.GmtSecondsToLocalTime(seconds);
                    appt.EndTime   = appt.StartTime.AddMilliseconds(appt.Duration);
                }
                appt.ModifySequence  = XmlUtil.AttributeValue(apptNode.Attributes, MailService.A_MODIFY_SEQUENCE);
                appt.InviteMessageId = XmlUtil.AttributeValue(apptNode.Attributes, MailService.A_INV_ID);

                var orNode = apptNode.SelectSingleNode(MailService.NS_PREFIX + ":" + MailService.E_ORGANIZER, XmlUtil.NamespaceManager);
                if (orNode != null)
                {
                    appt.Organizer = new Attendee
                    {
                        DisplayName = XmlUtil.AttributeValue(orNode.Attributes, MailService.A_DISPLAY_NAME),
                        Email       = XmlUtil.AttributeValue(orNode.Attributes, MailService.A_EMAIL)
                    };
                }
                appts.Add(appt);
            }
            return(new SearchResponse(appts));
        }
Esempio n. 7
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var invId = XmlUtil.AttributeValue(responseNode.Attributes, MailService.A_INV_ID);
            var res   = new SendInviteReplyResponse(invId);

            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 8
0
        public static Workinghours ParseNodeInfo2Workinghours(XmlNode responseNode)
        {
            var workinghours = new Workinghours();
            var usrNodes     = responseNode.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_USR, XmlUtil.NamespaceManager);

            foreach (XmlNode usrNode in usrNodes)
            {
                var usr       = new Usr(XmlUtil.AttributeValue(usrNode.Attributes, MailService.A_ID));
                var usrFNodes = usrNode.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_F, XmlUtil.NamespaceManager);
                for (int i = 0; i < usrFNodes.Count; i++)
                {
                    XmlNode  iNode   = usrFNodes.Item(i);
                    String   s       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_START);
                    Int64    seconds = Int64.Parse(s);
                    DateTime start   = DateUtil.GmtSecondsToLocalTime(seconds);
                    String   e       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_END);
                    seconds = Int64.Parse(e);
                    DateTime end = DateUtil.GmtSecondsToLocalTime(seconds);
                    usr.Fs.Add(new Duration {
                        s = start, e = end
                    });
                }

                var usrBNodes = usrNode.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_B, XmlUtil.NamespaceManager);
                for (int i = 0; i < usrBNodes.Count; i++)
                {
                    XmlNode  iNode   = usrBNodes.Item(i);
                    String   s       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_START);
                    Int64    seconds = Int64.Parse(s);
                    DateTime start   = DateUtil.GmtSecondsToLocalTime(seconds);
                    String   e       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_END);
                    seconds = Int64.Parse(e);
                    DateTime end = DateUtil.GmtSecondsToLocalTime(seconds);
                    usr.Bs.Add(new Duration {
                        s = start, e = end
                    });
                }

                var usrUNodes = usrNode.SelectNodes(MailService.NS_PREFIX + ":" + MailService.E_U, XmlUtil.NamespaceManager);
                for (int i = 0; i < usrUNodes.Count; i++)
                {
                    XmlNode  iNode   = usrUNodes.Item(i);
                    String   s       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_START);
                    Int64    seconds = Int64.Parse(s);
                    DateTime start   = DateUtil.GmtSecondsToLocalTime(seconds);
                    String   e       = XmlUtil.AttributeValue(iNode.Attributes, MailService.A_END);
                    seconds = Int64.Parse(e);
                    DateTime end = DateUtil.GmtSecondsToLocalTime(seconds);
                    usr.Us.Add(new Duration {
                        s = start, e = end
                    });
                }
                workinghours.Users.Add(usr);
            }
            return(workinghours);
        }
Esempio n. 9
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var calItemId       = XmlUtil.AttributeValue(responseNode.Attributes, MailService.A_CAL_ITEM_ID);
            var inviteMessageId = XmlUtil.AttributeValue(responseNode.Attributes, MailService.A_INV_ID);
            var appResponse     = new AppointmentResponse {
                Id = calItemId, InviteMessageId = inviteMessageId
            };

            var res = new CreateAppointmentResponse(appResponse);

            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 10
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var res = new GetShareInfoResponse();

            if (responseNode.ChildNodes.Count > 0)
            {
                var mId       = XmlUtil.AttributeValue(responseNode.ChildNodes[0].Attributes, AccountService.A_M_ID);
                var ownerId   = XmlUtil.AttributeValue(responseNode.ChildNodes[0].Attributes, AccountService.A_OWNER_ID);
                var ownerName = XmlUtil.AttributeValue(responseNode.ChildNodes[0].Attributes, AccountService.A_OWNER_NAME);
                res.MountpointId = mId;
                res.OwnerId      = ownerId;
                res.OwnerName    = ownerName;
            }
            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 11
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var calresList = new List <CalendarResource>();

            foreach (XmlNode calResource in responseNode.ChildNodes)
            {
                var calres = new CalendarResource {
                    id = XmlUtil.AttributeValue(calResource.Attributes, AccountService.A_ID)
                };
                foreach (XmlNode attrNode  in calResource.ChildNodes)
                {
                    calres.AttributesList.Add(XmlUtil.AttributeValue(attrNode.Attributes, AccountService.A_ATTRNAME), attrNode.InnerText);
                }
                calresList.Add(calres);
            }
            return(new SearchCalendarResourcesResponse(calresList));
        }
Esempio n. 12
0
        public Notification(XmlNode notifyNode)
        {
            sequenceToken = XmlUtil.AttributeValue(
                notifyNode.Attributes,
                ZimbraService.A_NOTIFY_SEQUENCE);

            XmlNodeList newMsgNodes = notifyNode.SelectNodes(
                ZimbraService.NS_PREFIX + ":" + ZimbraService.E_CREATED + "/" +
                ZimbraService.NS_PREFIX + ":" + ZimbraService.E_MSG,
                XmlUtil.NamespaceManager);

            createdMessages = new MessageSummary[newMsgNodes.Count];
            for (int i = 0; i < newMsgNodes.Count; i++)
            {
                MessageSummary s = new MessageSummary();

                XmlNode msgNode = newMsgNodes[i];
                s.itemId         = XmlUtil.AttributeValue(msgNode.Attributes, ZimbraService.A_ID);
                s.parentFolderId = XmlUtil.AttributeValue(msgNode.Attributes, ZimbraService.A_PARENT_FOLDER_ID);

                XmlNode emailNode = msgNode.SelectSingleNode(ZimbraService.NS_PREFIX + ":" + ZimbraService.E_EMAIL, XmlUtil.NamespaceManager);
                if (emailNode != null)
                {
                    s.email_display       = XmlUtil.AttributeValue(emailNode.Attributes, ZimbraService.A_EMAIL_DISPLAY);
                    s.email_address       = XmlUtil.AttributeValue(emailNode.Attributes, ZimbraService.A_EMAIL_ADDRESS);
                    s.email_personal_name = XmlUtil.AttributeValue(emailNode.Attributes, ZimbraService.A_EMAIL_PERSONAL_NAME);
                }

                XmlNode subjectNode = msgNode.SelectSingleNode(ZimbraService.NS_PREFIX + ":" + ZimbraService.E_SUBJECT, XmlUtil.NamespaceManager);
                if (subjectNode != null)
                {
                    s.subject = subjectNode.InnerText;
                }

                XmlNode fragmentNode = msgNode.SelectSingleNode(ZimbraService.NS_PREFIX + ":" + ZimbraService.E_FRAGMENT, XmlUtil.NamespaceManager);
                if (fragmentNode != null)
                {
                    s.fragment = fragmentNode.InnerText;
                }

                createdMessages[i] = s;
            }
        }
Esempio n. 13
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var busyUsers = new List <string>();
            //取得 Conflicts 的人員(會議室、車子...)
            var userNodes = responseNode.SelectNodes($"//{MailService.NS_PREFIX}:usr", XmlUtil.NamespaceManager);

            if (userNodes != null)
            {
                foreach (XmlNode userNode in userNodes)
                {
                    string email = XmlUtil.AttributeValue(userNode.Attributes, MailService.A_NAME);
                    busyUsers.Add(email);
                }
            }
            var res = new CheckRecurConflictsResponse(busyUsers);

            res.ResponseNode = responseNode;
            return(res);
        }
Esempio n. 14
0
        public override Response NewResponse(XmlNode responseNode)
        {
            XmlNode accountNode = responseNode.SelectSingleNode(AdminService.NS_PREFIX + ":" + AdminService.E_ACCOUNT, XmlUtil.NamespaceManager);

            String name = XmlUtil.AttributeValue(accountNode.Attributes, AdminService.A_NAME);
            String id   = XmlUtil.AttributeValue(accountNode.Attributes, AdminService.A_ID);

            Hashtable h = new Hashtable();

            for (int i = 0; i < accountNode.ChildNodes.Count; i++)
            {
                XmlNode child     = accountNode.ChildNodes[i];
                String  attrName  = XmlUtil.AttributeValue(child.Attributes, AdminService.A_ATTR_NAME);
                String  attrValue = child.InnerText;

                if (h.Contains(attrName))
                {
                    Object o = h[attrName];
                    if (o is String)
                    {
                        ArrayList al = new ArrayList();
                        al.Add((String)o);
                        al.Add(attrValue);
                        h.Remove(attrName);
                        h.Add(attrName, al);
                    }
                    else                     //its a string collection
                    {
                        ArrayList al = (ArrayList)o;
                        al.Add(attrValue);
                    }
                }
                else
                {
                    h.Add(attrName, attrValue);
                }
            }

            return(new GetAccountResponse(new Account(name, id, h)));
        }
Esempio n. 15
0
        public override Response NewResponse(XmlNode responseNode)
        {
            var calresList = new List <CalendarResource>();

            foreach (XmlNode calResource in responseNode.ChildNodes)
            {
                var calres = new CalendarResource {
                    id = XmlUtil.AttributeValue(calResource.Attributes, AccountService.A_ID)
                };
                foreach (XmlNode attrNode in calResource.ChildNodes)
                {
                    var attrName = XmlUtil.AttributeValue(attrNode.Attributes, AccountService.A_ATTRNAME);
                    if (!calres.AttributesList.ContainsKey(attrName))
                    {
                        calres.AttributesList.Add(attrName, attrNode.InnerText);
                    }
                }
                calresList.Add(calres);
            }
            var res = new SearchGalResponse(calresList);

            res.ResponseNode = responseNode;
            return(res);
        }