Пример #1
0
        private void UploadButtonOnClick(Button obj)
        {
            var req = JesusWebRequest.Post(ServerUrl.Url + "Model", _formData);

            req.Send();
            //var resp = req.GetResponse();
        }
Пример #2
0
        private void SubmitTags()
        {
            var tags = _tagsWrapper.Children.OfType <TagField>().Where(p => p.Tag != null).ToArray();

            var newTags     = tags.Where(p => p.Tag != null && p.Tag.Id == 0).Select(p => new { p.Tag.Name, p.Tag.ChineseName });
            var changedTags = (
                from tagElm in tags
                let tag = tagElm.Tag
                          let dbTags = (
                    from dbTag in _materialTagsDb
                    where dbTag.Id == tag.Id &&
                    (
                        dbTag.Name != tag.Name || dbTag.ChineseName != tag.ChineseName
                    )
                    select dbTag
                    )
                                       where tagElm.Tag != null &&
                                       tag.Id > 0 &&
                                       tagElm.Delete == false &&
                                       dbTags.Any()
                                       select tag
                );
            var deletedTags = tags.Where(p => p.Tag != null && p.Delete).Select(p => p.Tag.Id);

            if (newTags.Any() == false && changedTags.Any() == false && deletedTags.Any() == false)
            {
                return;
            }

            var user = Login.GetGlobal();

            var req = JesusWebRequest.Post(TagsUrl, new {
                NewTags     = newTags,
                ChangedTags = changedTags,
                DeletedTags = deletedTags,
                UserName    = user.Username,
                Password    = Crc32.Checksum(user.Password)
            });

            req.SendWait();
            var resp = req.GetResponse <TagsResponse>();

            if (resp.Error)
            {
                Debug.LogError("Error in webserver response");
            }


            var ids = resp.NewIds.GetEnumerator();

            foreach (var tag in tags.Where(p => p.Tag != null && p.Tag.Id == 0))
            {
                ids.MoveNext();
                if (ids.Current != null)
                {
                    tag.Tag.Id = (int)ids.Current;
                }
            }

            _tagsWrapper.Children.RemoveAll(p => ((TagField)p).Delete);
            _materialTagsDb = tags.Select(p => p.Tag).Select(p => new MaterialTag {
                Id = p.Id, Name = p.Name, ChineseName = p.ChineseName
            }).ToList();
        }