Пример #1
0
        private async Task <string> UpdateProductSpecMesh(AssetFileModel file, ProductSpecModel spec, StreamWriter loger)
        {
            StaticMeshModel mesh = cache.Parsed.GetById(file.ObjId) as StaticMeshModel;

            if (mesh == null)
            {
                return("mesh obj not found " + file.ObjId);
            }

            spec.name          = file.Name;
            spec.iconAssetId   = file.iconfid;
            spec.ComponentsObj = new List <FProductComponentModel>();
            FProductStaticMeshComponent meshcomp = new FProductStaticMeshComponent();

            meshcomp.StaticMesh = mesh;
            meshcomp.Id         = mesh.id;
            meshcomp.Name       = mesh.name;
            meshcomp.Icon       = file.iconurl;
            spec.ComponentsObj.Add(meshcomp);
            spec.staticMeshIds = "{\"Items\":[{\"StaticMeshId\":\"" + mesh.id + "\",\"MaterialIds\":[]}]}";
            spec.PropObjToStr();

            var res = await api.PutAsync <ProductSpecModel>("/productspec", spec);

            return(res.IsSuccess ? "ok" : "failed " + res.StatusCode);
        }
Пример #2
0
        private async Task <string> CreateProductForMesh(AssetFileModel file, StreamWriter loger)
        {
            StaticMeshModel mesh = cache.Parsed.GetById(file.ObjId) as StaticMeshModel;

            if (mesh == null)
            {
                return("mesh obj not found " + file.ObjId);
            }

            ProductSpecModel spec = new ProductSpecModel();

            spec.name          = file.Name;
            spec.iconAssetId   = file.iconfid;
            spec.IconUrl       = file.iconurl;
            spec.ComponentsObj = new List <FProductComponentModel>();
            FProductStaticMeshComponent meshcomp = new FProductStaticMeshComponent();

            meshcomp.StaticMesh = mesh;
            meshcomp.Id         = mesh.id;
            meshcomp.Name       = mesh.name;
            meshcomp.Icon       = file.iconurl;
            spec.ComponentsObj.Add(meshcomp);
            spec.staticMeshIds = "{\"Items\":[{\"StaticMeshId\":\"" + mesh.id + "\",\"MaterialIds\":[]}]}";
            spec.PropObjToStr();

            ProductModel product = new ProductModel();

            product.name        = file.Name;
            product.iconAssetId = file.iconfid;
            product.IconUrl     = file.iconurl;
            var prodres = await api.PostAsync <ProductModel>("/products", product);

            string productId = "";
            string specId    = "";

            if (prodres.IsSuccess && prodres.Content != null && prodres.Content.specifications?.Count > 0)
            {
                productId = prodres.Content.id;
                specId    = prodres.Content.specifications[0]?.id;
                spec.id   = specId;
                var specres = await api.PutAsync("/productspec", spec);//现在的api版本,put 不需要id

                if (specres.IsSuccess)
                {
                    loger.WriteLine($"{DateTime.Now}, CREATE, {file.Package}, {file.Type}, {file.ObjId}, productid {prodres.Content.id} SpecId {specId} update ok");
                }
                else
                {
                    loger.WriteLine($"{DateTime.Now}, CREATE, {file.Package}, {file.Type}, {file.ObjId}, productid {prodres.Content.id} SpecId {specId} update failed. {specres.StatusCode} {specres.Content}");
                }
            }
            else
            {
                loger.WriteLine($"{DateTime.Now}, CREATE, {file.Package}, {file.Type}, {file.ObjId}, create product failed. {prodres.StatusCode} {prodres.Content}");
            }
            string ids = $"product id {productId} specid {specId}";

            return(prodres.IsSuccess ? "ok " + ids : "failed " + prodres.StatusCode);
        }