public static async Task <ReturnedSaveFuncInfo> SaveAsync(BuildingRelatedOptionsBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var obj = new WebBuildingRelatedOptions()
                {
                    Guid               = cls.Guid,
                    HardSerial         = cls.HardSerial,
                    BuildingOptionGuid = cls.BuildingOptionGuid,
                    BuildinGuid        = cls.BuildinGuid,
                    Modified           = cls.Modified,
                    ServerStatus       = cls.ServerStatus,
                    ServerDeliveryDate = cls.ServerDeliveryDate
                };
                await obj.SaveAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
예제 #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);
            }
        }