Exemplo n.º 1
0
        /// <summary>
        /// 下载属性集合(商品)
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <returns></returns>
        public IList <PropByItemInfo> GetPropByItemPackaged(string Customer_Id, string User_Id, string Unit_Id)
        {
            LoggingSessionInfo     loggingSessionInfo = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            ItemPropService        itemPropService    = new ItemPropService();
            IList <PropByItemInfo> PropByItemInfoList = new List <PropByItemInfo>();

            PropByItemInfoList = itemPropService.GetPropByItemList(loggingSessionInfo);
            return(PropByItemInfoList);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取商品属性集合信息
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <param name="Item_Id">商品标识</param>
        /// <returns></returns>
        public IList <ItemPropInfo> GetItemPropInfoListPackaged(string Customer_Id, string User_Id, string Unit_Id, string Item_Id)
        {
            IList <ItemPropInfo> itemPropInfoList   = new List <ItemPropInfo>();
            IList <ItemInfo>     itemInfoList       = new List <ItemInfo>();
            LoggingSessionInfo   loggingSessionInfo = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            ItemPropService      itemPropService    = new ItemPropService();

            itemPropInfoList = itemPropService.GetItemPropListByItemId(loggingSessionInfo, Item_Id);
            return(itemPropInfoList);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 批量更新类目cid下所有属性值的is_parent字段,条件是必须保证cid下的所有属性及属性值已完全下载
        /// </summary>
        private void UpdatePropValueIsParent(List <string> cidlist, BackgroundWorker worker)
        {
            DataTable table = new DataTable();

            table.Columns.Add("cid", typeof(string));
            table.Columns.Add("is_parent", typeof(bool));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("name_alias", typeof(string));
            table.Columns.Add("pid", typeof(string));
            table.Columns.Add("prop_name", typeof(string));
            table.Columns.Add("vid", typeof(string));
            table.Columns.Add("status", typeof(string));
            table.Columns.Add("sort_order", typeof(Int32));

            List <Taobao.Entity.PropValue> pValueListNeedUpdate = new List <Taobao.Entity.PropValue>();

            /*每执行一次调用一次API,读取两次数据库
             * 这里不能用foreach,因为方法体里面有
             * cidlist.Remove(cid)语句,会造成无法
             * 枚举的异常
             * */
            for (int c = 0; c < cidlist.Count; c++)
            {
                string cid = cidlist[c];
                /*读取存在子属性的关键属性的pid*/
                List <string> keyPropsPidList = ItemPropService.GetKeyPropPid(cid);
                if (keyPropsPidList.Count == 0)
                {
                    return;
                }

                #region 循环获取keyPropsPidList的属性值,每执行一次调用一次API,读取一次数据库
                float n = keyPropsPidList.Count;
                //int temp = 0;//作用是避免进度值propgress没有改变时得重复报告
                for (int i = 0; i < n; i++)
                {
                    ////进度报告
                    //int propgress = (int)((float)(i + 1) / n * 100);
                    //if (propgress > temp)
                    //{
                    //    worker.ReportProgress(propgress, null);
                    //}
                    //temp = propgress;

                    string     pid = keyPropsPidList[i];
                    ItemCatRsp rsp = new ItemCatRsp();
                    try
                    {
                        rsp = TopService.ItemPropsGet(cid, pid, null);
                    }
                    catch (Exception ex)
                    {
                        worker.ReportProgress(int.Parse(cid), string.Format("异常信息{0}", ex.Message));
                        //加入错误列表
                        if (ciderrorlist == null)
                        {
                            ciderrorlist = new List <string>();
                        }
                        ciderrorlist.Add(cid);

                        //从需要更新列表中删除
                        cidlist.Remove(cid);
                        continue;
                    }
                    if (rsp.ItemProps == null || rsp.ItemProps.ItemProp == null)
                    {
                        /*说明下载失败*/
                        continue;
                    }

                    #region 加一条“自定义”记录至table里,读取了一次数据库
                    if (!ItemPropValueService.IsExistedPropValueName(cid, pid, "自定义"))
                    {
                        DataRow row = table.NewRow();
                        row["cid"]        = cid;
                        row["is_parent"]  = false;
                        row["name"]       = row["name_alias"] = "自定义";
                        row["pid"]        = pid;
                        row["vid"]        = 0;
                        row["status"]     = "normal";
                        row["sort_order"] = 1000;
                        if (rsp.ItemProps.ItemProp != null && rsp.ItemProps.ItemProp.Length > 0)
                        {
                            row["prop_name"] = rsp.ItemProps.ItemProp[0].Name ?? string.Empty;
                        }
                        else
                        {
                            row["prop_name"] = string.Empty;
                        }
                        table.Rows.Add(row);
                    }
                    #endregion

                    #region 将is_parent为TRUE的属性值加入pValueListNeedUpdate
                    foreach (Taobao.Entity.ItemProp prop in rsp.ItemProps.ItemProp)
                    {
                        Taobao.Entity.PropValues propvalues = prop.PropValues;
                        if (propvalues != null && propvalues.PropValue != null)
                        {
                            List <Alading.Taobao.Entity.PropValue> propValueWhereToList = propvalues.PropValue.Where(p => p.IsParent).ToList();
                            foreach (Taobao.Entity.PropValue pv in propValueWhereToList)
                            {
                                pv.Cid = cid;
                                pv.Pid = pid;
                            }
                            pValueListNeedUpdate.AddRange(propValueWhereToList);
                        }
                    } //foreach
                }     //for
                #endregion

                #endregion
            }
            //将自定义加入数据库
            if (table.Rows.Count > 0)
            {
                ItemPropValueService.AddItemPropValueSqlBulkCopy(table);
            }

            //更新is_parent
            if (pValueListNeedUpdate.Count > 0)
            {
                ItemPropValueService.UpdateItemPropValueDataParameters(pValueListNeedUpdate);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 批量下载类目cid下的所有属性,不能返回prop_values
        /// </summary>
        private void DownItemProp(List <string> cidlist, BackgroundWorker worker)
        {
            DataTable table = new DataTable();

            table.Columns.Add("cid", typeof(string));
            table.Columns.Add("child_template", typeof(string));
            table.Columns.Add("is_allow_alias", typeof(bool));
            table.Columns.Add("is_color_prop", typeof(bool));
            table.Columns.Add("is_enum_prop", typeof(bool));
            table.Columns.Add("is_input_prop", typeof(bool));
            table.Columns.Add("is_item_prop", typeof(bool));
            table.Columns.Add("is_key_prop", typeof(bool));
            table.Columns.Add("is_sale_prop", typeof(bool));
            table.Columns.Add("multi", typeof(bool));
            table.Columns.Add("must", typeof(bool));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("parent_pid", typeof(string));
            table.Columns.Add("parent_vid", typeof(string));
            table.Columns.Add("pid", typeof(string));
            table.Columns.Add("prop_name", typeof(string));
            table.Columns.Add("prop_values", typeof(string));
            table.Columns.Add("status", typeof(string));
            table.Columns.Add("sort_order", typeof(Int32));
            for (int c = 0; c < cidlist.Count; c++)
            {
                string cid = cidlist[c];
                if (ItemPropService.IsPropExistedCid(cid))
                {
                    continue;
                }
                ItemCatRsp rsp = new ItemCatRsp();
                try
                {
                    rsp = TopService.ItemPropsGet(cid);
                }
                catch (Exception ex)
                {
                    worker.ReportProgress(int.Parse(cid), string.Format("异常信息{0}", ex.Message));
                    //加入错误列表
                    if (ciderrorlist == null)
                    {
                        ciderrorlist = new List <string>();
                    }
                    ciderrorlist.Add(cid);

                    //从需要更新列表中删除
                    cidlist.Remove(cid);
                    continue;
                }
                if (rsp.ItemProps != null && rsp.ItemProps.ItemProp != null)
                {
                    ItemProp[] propArr = rsp.ItemProps.ItemProp;
                    for (int i = 0; i < propArr.Length; i++)
                    {
                        #region 数据赋值
                        DataRow row = table.NewRow();
                        row["cid"]            = cid;
                        row["child_template"] = propArr[i].ChildPropTemplate ?? string.Empty;
                        row["is_allow_alias"] = propArr[i].IsAllowAlias;
                        row["is_color_prop"]  = propArr[i].IsColorProp;
                        row["is_enum_prop"]   = propArr[i].IsEnumProp;
                        row["is_input_prop"]  = propArr[i].IsInputProp;
                        row["is_item_prop"]   = propArr[i].IsItemProp;
                        row["is_key_prop"]    = propArr[i].IsKeyProp;
                        row["is_sale_prop"]   = propArr[i].IsSaleProp;
                        row["multi"]          = propArr[i].IsMulti;
                        row["must"]           = propArr[i].IsMust;
                        row["name"]           = propArr[i].Name ?? string.Empty;
                        row["parent_pid"]     = propArr[i].ParentPid;
                        row["parent_vid"]     = propArr[i].ParentVid;
                        row["pid"]            = propArr[i].Pid;
                        row["prop_values"]    = JsonConvert.SerializeObject(propArr[i].PropValues) ?? string.Empty;
                        row["sort_order"]     = propArr[i].SortOrder;
                        row["status"]         = propArr[i].Status ?? string.Empty;
                        #endregion
                        table.Rows.Add(row);
                    }//for
                }
            }
            if (table.Rows.Count > 0)
            {
                ItemPropService.AddItemPropSqlBulkCopy(table);
            }
        }