Beispiel #1
0
        public async Task SaveAsync()
        {
            try
            {
                var res = await Extentions.PostToApi <MoeinBussines, WebMoein>(this, Url);

                if (res.ResponseStatus != ResponseStatus.Success)
                {
                    var temp = new TempBussines()
                    {
                        ObjectGuid = Guid,
                        Type       = EnTemp.Moein
                    };
                    await temp.SaveAsync();

                    return;
                }
                var bu = res.Data;
                if (bu == null)
                {
                    return;
                }
                await TempBussines.UpdateEntityAsync(EnTemp.Moein, bu.Guid, ServerStatus.Delivered, DateTime.Now);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #2
0
        public async Task SaveAsync(string p)
        {
            try
            {
                var res = await Extentions.PostToApi <BuildingBussines, WebBuilding>(this, Url);

                if (res.ResponseStatus != ResponseStatus.Success)
                {
                    var temp = new TempBussines()
                    {
                        ObjectGuid = Guid,
                        Type       = EnTemp.Building
                    };
                    await temp.SaveAsync();

                    return;
                }

                var bu = res.Data;
                if (bu == null)
                {
                    return;
                }

                await TempBussines.UpdateEntityAsync(EnTemp.Building, bu.Guid, ServerStatus.Delivered, DateTime.Now);

                await WebBuildingRelatedOptions.SaveAsync(OptionList);

                if (string.IsNullOrEmpty(Image))
                {
                    return;
                }

                var file = await FileInfoBussines.GetAsync(Image);

                if (file != null)
                {
                    if (file.FileName == Image)
                    {
                        return;
                    }
                }

                var img = Path.Combine(p, "Images");
                if (!Directory.Exists(img))
                {
                    return;
                }
                if (!Image.EndsWith(".jpg") && !Image.EndsWith(".png"))
                {
                    return;
                }
                var path      = Path.Combine(img, Image);
                var imageByte = File.ReadAllBytes(path);
                await UploadBitmapAsync(imageByte, Image);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }