示例#1
0
        public clsMessage(clsJSON json)
        {
            string[] strFrom = new string[]
            {
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
            };

            #region данные класса

            foreach (string[] line in json.data)
            {
                if (line[0].ToLower().CompareTo("url") == 0)
                {
                    this.url = line[1];
                }
                if (line[0].ToLower().CompareTo("url_api") == 0)
                {
                    this.url_api = line[1];
                }
                if (line[0].ToLower().CompareTo("subject") == 0)
                {
                    this.subject = line[1];
                }
                if (line[0].ToLower().CompareTo("has_attach") == 0)
                {
                    int _i = 0;
                    if (int.TryParse(line[1], out _i))
                    {
                        this.attachCount = _i;
                    }
                }
                if (line[0].ToLower().CompareTo("last_post_time") == 0)
                {
                    this.last_post_time = DateTime.Parse(line[1]); //clsTimeConvert.dtFrom8061(line[1]);
                }
                if (line[0].ToLower().CompareTo("post_time") == 0)
                {
                    this.post_time = DateTime.Parse(line[1]);//clsTimeConvert.dtFrom8061(line[1]);
                }
                if (line[0].ToLower().CompareTo("unread_count") == 0)
                {
                    int _i = 0;
                    if (int.TryParse(line[1], out _i))
                    {
                        this.unread_count = _i;
                    }
                }
                if (line[0].ToLower().CompareTo("is_unread") == 0)
                {
                    string cs = "true";

                    if (line[1].Equals(cs))
                    {
                        is_unread = true;
                    }
                    else
                    {
                        is_unread = false;
                    }
                }
            }

            #endregion

            #region от кого

            if (json.bloks != null)
            {
                clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0);

                if (block != null)
                {
                    foreach (string[] line in block.data)
                    {
                        if (line[0].ToLower().CompareTo("profile_id") == 0)
                        {
                            strFrom[0] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("login") == 0)
                        {
                            strFrom[1] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("url") == 0)
                        {
                            strFrom[2] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("avatar") == 0)
                        {
                            strFrom[3] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("fname") == 0)
                        {
                            strFrom[4] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("sname") == 0)
                        {
                            strFrom[5] = line[1];
                        }
                    }
                }
            }

            this.from = new clsFrom(strFrom);

            #endregion
        }
        public clsMessDialog(clsJSON json)
        {
            string[] strFrom = new string[]
            {
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
            };
            string[] strTo = new string[]
            {
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
            };

            have_attach     = false;
            url_Attachments = new List <string>();

            #region обработка данных класса

            foreach (string[] line in json.data)
            {
                if (line[0].ToLower().CompareTo("message_html") == 0)
                {
                    this.message_html = line[1];
                }
                if (line[0].ToLower().CompareTo("message_text") == 0)
                {
                    this.message_text = line[1];
                }

                if (line[0].ToLower().CompareTo("post_time") == 0)
                {
                    this.post_time = DateTime.Parse(line[1]);//clsTimeConvert.dtFrom8061(line[1]);
                }
                if (line[0].ToLower().CompareTo("attachments") == 0)
                {
                    have_attach = true;
                }

                if (line[0].ToLower().CompareTo("url") == 0)
                {
                    if (have_attach)
                    {
                        string turl = line[1];
                        string s    = "//content.freelancehunt.com/message/";
                        if (turl.Remove(s.Length) == s)
                        {
                            turl = "https:" + turl;
                            url_Attachments.Add(turl);
                        }
                    }
                    else
                    {
                        this.url = line[1];
                    }
                }
            }
            #endregion

            #region приложения

            /*
             * if (json.block.attachments != null)
             * {
             *  clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("attachments") == 0);
             *
             *  if (block != null)
             *  {
             *      this.url_Attachments = new List<string>();
             *      foreach (string[] param in block.data)
             *      {
             *          if (param[0].ToLower().CompareTo("url") == 0) { this.url_Attachments.Add("https:" + param[1]); }
             *      }
             *  }
             * }
             */
            #endregion

            #region от кого

            if (json.bloks != null)
            {
                clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0);

                if (block != null)
                {
                    foreach (string[] line in block.data)
                    {
                        if (line[0].ToLower().CompareTo("profile_id") == 0)
                        {
                            strFrom[0] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("login") == 0)
                        {
                            strFrom[1] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("url") == 0)
                        {
                            strFrom[2] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("avatar") == 0)
                        {
                            strFrom[3] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("fname") == 0)
                        {
                            strFrom[4] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("sname") == 0)
                        {
                            strFrom[5] = line[1];
                        }
                    }
                }
            }

            this.from = new clsFrom(strFrom);

            #endregion

            #region кому

            if (json.bloks != null)
            {
                clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("to") == 0);

                if (block != null)
                {
                    foreach (string[] line in block.data)
                    {
                        if (line[0].ToLower().CompareTo("profile_id") == 0)
                        {
                            strTo[0] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("login") == 0)
                        {
                            strTo[1] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("url") == 0)
                        {
                            strTo[2] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("avatar") == 0)
                        {
                            strTo[3] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("fname") == 0)
                        {
                            strFrom[4] = line[1];
                        }
                        if (line[0].ToLower().CompareTo("sname") == 0)
                        {
                            strFrom[5] = line[1];
                        }
                    }
                }
            }

            this.to = new clsFrom(strTo);

            #endregion
        }
示例#3
0
        public clsFeed(clsJSON json)
        {
            string[] strFrom = new string[]
            {
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
                string.Empty,
            };

            #region обработка данных для этого класса

            foreach (string[] line in json.data)
            {
                if (line[0].ToLower().CompareTo("time") == 0)
                {
                    this.date = clsTimeConvert.dtFrom8061(line[1]);
                }
                if (line[0].ToLower().CompareTo("message") == 0)
                {
                    this.message = line[1];
                    mesDivider(this.message);
                }

                if (line[0].ToLower().CompareTo("is_new") == 0)
                {
                    this.is_new = line[1].ToLower().CompareTo("true") == 0;
                }
                if (line[0].ToLower().CompareTo("time_millis") == 0)
                {
                    if (!line[1].Contains("message"))
                    {
                        Int64 date = 0;
                        if (Int64.TryParse(line[1], out date))
                        {
                            time_millis = date;
                        }
                    }
                    else
                    {
                        Int64 date = 0;
                        if (Int64.TryParse(line[1].Split('m')[0], out date))
                        {
                            time_millis = date;
                        }

                        String ms = line[1].Split(':')[1];
                        if (String.IsNullOrEmpty(this.message))
                        {
                            this.message = ms;
                            mesDivider(this.message);
                        }
                    }
                }
            }

            #endregion

            #region от кого

            clsJSON_block block = json.bloks.FirstOrDefault(b => b.name.ToLower().CompareTo("from") == 0);

            if (block != null)
            {
                foreach (string[] line in block.data)
                {
                    if (line[0].ToLower().CompareTo("profile_id") == 0)
                    {
                        strFrom[0] = line[1];
                    }
                    if (line[0].ToLower().CompareTo("login") == 0)
                    {
                        strFrom[1] = line[1];
                    }
                    if (line[0].ToLower().CompareTo("url") == 0)
                    {
                        strFrom[2] = line[1];
                    }
                    if (line[0].ToLower().CompareTo("avatar") == 0)
                    {
                        strFrom[3] = line[1];
                    }
                    if (line[0].ToLower().CompareTo("fname") == 0)
                    {
                        strFrom[4] = line[1];
                    }
                    if (line[0].ToLower().CompareTo("sname") == 0)
                    {
                        strFrom[5] = line[1];
                    }
                }
            }

            this.from = new clsFrom(strFrom);

            #endregion
        }