protected void btnSave_Click(object sender, EventArgs e) { int classID = Globals.SafeInt(this.ddlType.SelectedValue, 0); if (classID <= 0) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddClass); } else { Maticsoft.Model.CMS.ContentClass model = this.bllContentClass.GetModel(classID); if (model != null) { if (!model.AllowAddContent) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddContent); return; } if ((2 == model.ClassModel) && this.bll.ExistsByClassID(classID)) { MessageBox.ShowFailTip(this, CMS.ContentErrorAddMoreContent); return; } } if (string.IsNullOrWhiteSpace(this.txtTitle.Text.Trim())) { MessageBox.ShowFailTip(this, CMS.TitleErrorAddContent); } else if (this.bll.ExistTitle(this.txtTitle.Text.Trim())) { MessageBox.ShowFailTip(this, CMS.ContentTooltipTitleExist); } else { Maticsoft.Model.CMS.Content content; content = new Maticsoft.Model.CMS.Content { Title = Globals.HtmlEncode(this.txtTitle.Text), SubTitle = Globals.HtmlEncode(this.txtTitle.Text), Summary = Globals.HtmlEncode(this.txtSummary.Text), CreatedUserID = base.CurrentUser.UserID, LastEditDate = new DateTime?(content.CreatedDate = DateTime.Now), LastEditUserID = new int?(base.CurrentUser.UserID), PvCount = 0, State = Globals.SafeInt(this.radlState.SelectedValue, 0), ClassID = classID, Description = this.txtContent.Text }; string oldValue = string.Format("/Upload/Temp/{0}/", DateTime.Now.ToString("yyyyMMdd")); string newValue = string.Format("/Upload/CMS/Article/{0}/", DateTime.Now.ToString("yyyyMM")); string.Format("/Upload/CMS/Files/{0}/", DateTime.Now.ToString("yyyyMM")); ArrayList fileNameList = new ArrayList(); if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value)) { string str3 = string.Format(this.HiddenField_ICOPath.Value, ""); fileNameList.Add(str3.Replace(oldValue, "")); content.ImageUrl = str3.Replace(oldValue, newValue); } content.TotalComment = 0; content.TotalSupport = 0; content.TotalFav = 0; content.TotalShare = 0; int num2 = this.bll.Add(content); if (0 < num2) { if (!string.IsNullOrWhiteSpace(this.HiddenField_ICOPath.Value)) { FileManage.MoveFile(base.Server.MapPath(oldValue), base.Server.MapPath(newValue), fileNameList); } string str4 = ""; str4 = this.chkSina.Checked ? "3" : ""; if (this.chkQQ.Checked) { str4 = str4 + (string.IsNullOrWhiteSpace(str4) ? "13" : ",13"); } UserBind bind = new UserBind(); string valueByCache = ConfigSystem.GetValueByCache("WeiBo_CMS_Url"); string url = "http://" + Globals.DomainFullName + string.Format(valueByCache, num2); bind.SendWeiBo(-1, str4, content.Title, url, content.ImageUrl); if (!string.IsNullOrWhiteSpace(this.ddlType.SelectedValue)) { MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK, "ListSimple.aspx?classid=" + this.ddlType.SelectedValue); } else { MessageBox.ShowSuccessTip(this, Site.TooltipSaveOK, "ListSimple.aspx?type=0"); } } } } }
private void SaveProductInfo() { if (string.IsNullOrWhiteSpace(this.Hidden_SelectValue.Value)) { MessageBox.ShowFailTip(this, "请选择产品分类!"); } else { string text = this.txtProductName.Text; int num = Globals.SafeInt(this.hfCurrentProductType.Value, -1); int num2 = Globals.SafeInt(this.hfCurrentProductBrand.Value, -1); int supplierId = base.SupplierId; int? nullable = new int?(Globals.SafeInt(this.ajaxRegion.SelectedValue, -1)); string str2 = this.txtUnit.Text; decimal? nullable2 = new decimal?(Globals.SafeDecimal(this.txtMarketPrice.Text, (decimal) -1M)); int num4 = Globals.SafeInt(this.txtDisplaySequence.Text, -1); string str3 = this.txtShortDescription.Text; string str4 = this.txtDescription.Text; string str5 = this.hfProductImages.Value; string str6 = this.hfCurrentAttributes.Value; string str7 = this.hfCurrentBaseProductSKUs.Value; string str8 = this.hfCurrentProductSKUs.Value; bool flag = false; string[] strArray = new string[0]; if (!string.IsNullOrWhiteSpace(str3)) { str3 = Globals.HtmlEncodeForSpaceWrap(str3); } if (!string.IsNullOrWhiteSpace(str5)) { strArray = str5.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); } if (string.IsNullOrWhiteSpace(str6)) { MessageBox.Show(this, "属性信息不存在,请检查已填数据是否正确!"); } else { List<Maticsoft.Model.Shop.Products.AttributeInfo> list = this.GetAttributeInfo4Json(JsonMapper.ToObject(str6)); if (string.IsNullOrWhiteSpace(str7)) { MessageBox.Show(this, "基础SKU信息不存在,请检查已填数据是否正确!"); } else { List<Maticsoft.Model.Shop.Products.SKUInfo> list2 = null; decimal? nullable3 = 0M; flag = !string.IsNullOrWhiteSpace(str8); if (flag) { list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str8)); if (this.salePriceList.Count > 0) { this.salePriceList.Sort(); nullable3 = new decimal?(Convert.ToDecimal(this.salePriceList[0])); } } else { list2 = this.GetSKUInfo4Json(JsonMapper.ToObject(str7)); nullable3 = new decimal?(Globals.SafeDecimal(this.txtSalePrice.Text, (decimal) -1M)); } Maticsoft.Model.Shop.Products.ProductInfo productInfo = new Maticsoft.Model.Shop.Products.ProductInfo(); string[] strArray2 = this.Hidden_SelectValue.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); productInfo.Product_Categories = strArray2; productInfo.ProductName = text; productInfo.CategoryId = 0; productInfo.TypeId = new int?(num); productInfo.BrandId = num2; if (supplierId > 0) { productInfo.SupplierId = supplierId; } else { productInfo.SupplierId = -1; } productInfo.RegionId = (nullable == -1) ? null : nullable; productInfo.Unit = str2; productInfo.MarketPrice = (nullable2 == -1M) ? 0 : nullable2; productInfo.LowestSalePrice = nullable3.Value; productInfo.DisplaySequence = num4; productInfo.ProductCode = this.txtProductSKU.Text; productInfo.AddedDate = DateTime.Now; productInfo.SaleStatus = -1; productInfo.ShortDescription = str3; productInfo.Description = str4; productInfo.Tags = ""; if (strArray.Length == 0) { productInfo.ImageUrl = productInfo.ThumbnailUrl1 = productInfo.ThumbnailUrl2 = "/Content/themes/base/Shop/images/none.png"; } string newValue = string.Format("/Upload/Shop/Images/Product/{0}/", DateTime.Now.ToString("yyyyMMdd")); string str10 = "/Upload/Shop/Images/ProductThumbs/" + DateTime.Now.ToString("yyyyMMdd") + "/"; ArrayList list3 = new ArrayList(); for (int i = 0; i < strArray.Length; i++) { if (i == 0) { string str11 = string.Format(strArray[i], ""); string str12 = strArray[i]; productInfo.ImageUrl = str11.Replace(this.tempFile, newValue); productInfo.ThumbnailUrl1 = str12.Replace(this.tempFile, str10); list3.Add(str11.Replace(this.tempFile, "")); list3.Add(str12.Replace(this.tempFile, "")); } else { string str13 = string.Format(strArray[i], ""); string str14 = strArray[i]; Maticsoft.Model.Shop.Products.ProductImage item = new Maticsoft.Model.Shop.Products.ProductImage { ImageUrl = str13.Replace(this.tempFile, newValue), ThumbnailUrl1 = str14.Replace(this.tempFile, str10) }; productInfo.ProductImages.Add(item); list3.Add(str13.Replace(this.tempFile, "")); list3.Add(str14.Replace(this.tempFile, "")); } Maticsoft.BLL.Shop.Products.ProductImage.MoveImage(strArray[i], newValue, str10); } productInfo.AttributeInfos = list; productInfo.HasSKU = flag; productInfo.SkuInfos = list2; productInfo.isRec = this.chbRec.Checked; productInfo.isNow = this.chbNew.Checked; productInfo.isHot = this.chbHot.Checked; productInfo.isLowPrice = this.chbLowPrice.Checked; if (!string.IsNullOrEmpty(this.Hidden_SelectPackage.Value)) { Maticsoft.BLL.Shop.Package.Package package = new Maticsoft.BLL.Shop.Package.Package(); List<int> list4 = new List<int>(); string[] strArray3 = this.Hidden_SelectPackage.Value.Split(new char[] { ',' }); int packageId = 0; foreach (string str15 in strArray3) { packageId = Globals.SafeInt(str15, 0); if (package.Exists(packageId)) { list4.Add(packageId); } } productInfo.PackageId = list4; } long productId = 0L; if (ProductManage.AddProduct(productInfo, out productId)) { if (this.skuImageList.Count > 0) { FileManage.MoveFile(base.Server.MapPath(this.tempFile), base.Server.MapPath(this.skuImageFile), this.skuImageList); } string str16 = ""; str16 = this.chkSina.Checked ? "3" : ""; if (this.chkQQ.Checked) { str16 = str16 + (string.IsNullOrWhiteSpace(str16) ? "13" : ",13"); } UserBind bind = new UserBind(); string url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Product/Detail/", productId }); bind.SendWeiBo(-1, str16, productInfo.ProductName, url, productInfo.ImageUrl); base.Response.Redirect(string.Format("InStock.aspx?SaleStatus=-1", new object[0])); } else { MessageBox.Show(this, "保存失败! 请重试."); } } } } }
public void AjaxPostWeibo(FormCollection Fm) { UserBind bind = new UserBind(); Maticsoft.BLL.SNS.Posts posts = new Maticsoft.BLL.SNS.Posts(); Maticsoft.BLL.SNS.GroupTopics topics = new Maticsoft.BLL.SNS.GroupTopics(); Maticsoft.BLL.SNS.GroupTopicReply reply = new Maticsoft.BLL.SNS.GroupTopicReply(); if ((base.currentUser.UserType != "AA") && !string.IsNullOrWhiteSpace(Fm["MediaIds"])) { string mediaIDs = Fm["MediaIds"]; string productName = Fm["ShareDes"]; string str3 = Fm["ImageUrl"]; string text1 = Fm["VideoRawUrl"]; string url = Fm["Url"]; string str5 = Fm["Type"]; int targetId = Globals.SafeInt(Fm["TargetID"], 0); int postID = Globals.SafeInt(Fm["PostID"], 0); int topicID = Globals.SafeInt(Fm["TopicID"], 0); int num4 = Globals.SafeInt(Fm["AlumbID"], 0); int replyID = Globals.SafeInt(Fm["ReplyId"], 0); if (num4 > 0) { url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Album/Details?AlbumID=", num4 }); } if (postID > 0) { Maticsoft.Model.SNS.Posts model = posts.GetModel(postID); if (model != null) { if (model.Type == 1) { str5 = "Photo"; targetId = model.TargetId; if (string.IsNullOrEmpty(productName)) { productName = "分享图片"; } } else if (model.Type == 2) { str5 = "Product"; targetId = model.TargetId; if (string.IsNullOrEmpty(productName)) { productName = model.ProductName; } } else if (model.Type == 0) { str5 = "Weibo"; productName = string.IsNullOrEmpty(model.Description) ? "分享图片" : model.Description; } str3 = model.ImageUrl.Replace("{0}", "T116x170_"); } } if (topicID > 0) { url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Group/TopicReply?id=", topicID }); Maticsoft.Model.SNS.GroupTopics topics2 = topics.GetModel(topicID); str3 = (topics2 != null) ? topics2.ImageUrl : ""; } if (replyID > 0) { url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Group/TopicReply?id=", topicID }); Maticsoft.Model.SNS.GroupTopicReply reply2 = reply.GetModel(replyID); str3 = (reply2 != null) ? reply2.PhotoUrl : ""; } if ((!string.IsNullOrEmpty(str3) && (str3.Split(new char[] { '|' }).Length > 2)) && (str5 != "Product")) { str3 = "http://" + Globals.DomainFullName + str3.Split(new char[] { '|' })[0]; } if (str5 == "Weibo") { url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/User/Posts/", base.currentUser.UserID }); } else if ((str5 == "Photo") || (str5 == "Product")) { url = string.Concat(new object[] { "http://", Globals.DomainFullName, "/Detail/", str5, "/", targetId }); } try { bind.SendWeiBo(base.currentUser.UserID, mediaIDs, productName, url, str3); } catch (Exception exception) { base.Response.Write(exception); } } }