示例#1
0
        public ActionResult GetCatalog([FromRoute] decimal cd, [FromRoute] string language)
        {
            M_CATALOG catalog = _context.M_CATALOGS.FirstOrDefault(x => x.CATALOG_CD == cd);

            if (catalog == null)
            {
                return(Ok(new Result
                {
                    Status = 404,
                    Message = "Data not exists.",
                    Data = null
                }));
            }

            CatalogEntity entity = new CatalogEntity();

            entity.cd = catalog.CATALOG_CD;

            if (string.IsNullOrEmpty(language) || language.Equals(Constant.LANGUAGE_VN))
            {
                entity.name = catalog.CATALOG_NAME;
            }
            else
            {
                entity.name = catalog.CATALOG_NAME_EN;
            }

            return(Ok(new Result
            {
                Status = 200,
                Message = string.Empty,
                Data = entity
            }));
        }
示例#2
0
        protected void LinkButtonAddCatalog_Click(object sender, EventArgs e)
        {
            if (this.TextBoxCatalogName.Text.Length == 0)
            {
                this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_CatalogNameNull;
                return;
            }
            CatalogService service = new CatalogService();
            CatalogEntity  catalog = service.GetCatalogByName(this.TextBoxCatalogName.Text);

            if (catalog != null)
            {
                this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_CatalogNameExist;
                this.LabelCatalogName.Text     = "";
                return;
            }
            else
            {
                CatalogEntity new_catalog = new CatalogEntity(this.TextBoxCatalogName.Text);
                string        res         = service.SaveCatalog(new_catalog);
                if (res != null)
                {
                    Response.Redirect(PageInfo.PathCatalogAuthorizePage + new_catalog.CatalogName);
                    return;
                }
                else
                {
                    this.LabelPageMessageInfo.Text = PageInfo.MessageInfo_AddCatalogError;
                    return;
                }
            }
        }
示例#3
0
        public CatalogEntity get(string name)
        {
            CatalogEntity catalog = session.QueryOver <CatalogEntity>().Where(c => c.CatalogName == name).SingleOrDefault();

            //session.Close();
            return(catalog);
        }
示例#4
0
        public string save(CatalogEntity catalog)
        {
            ITransaction tx         = session.BeginTransaction();
            string       generateId = session.Save(catalog) as string;

            tx.Commit();
            //session.Close();
            return(generateId);
        }
示例#5
0
        public void AuthorizeCatalogToClients(CatalogEntity catalog, string[] usernames)
        {
            IList <ClientEntity> clients = clientDao.GetClientsByUsernames(usernames);

            foreach (var client in clients)
            {
                client.Catalogs.Add(catalog);
            }
            clientDao.UpdateClients(clients);
        }
示例#6
0
        /// <summary>
        /// 注册catalog
        /// </summary>
        private static void RegisterCatalog()
        {
            var catalog = new CatalogEntity();

            var serviceGovern = new CatalogGovern();
            var result        = serviceGovern.RegisterCatalog(catalog).GetAwaiter().GetResult();

            Console.WriteLine(result.backJson);
            Console.WriteLine(result.result);
        }
示例#7
0
        public void DeleteCatalogByName(string catalog_name)
        {
            ITransaction  tx      = session.BeginTransaction();
            CatalogEntity catalog = this.get(catalog_name);

            if (catalog != null)
            {
                session.Delete(catalog);
            }
            tx.Commit();
        }
示例#8
0
        private void initCatalog()
        {
            string[]        catalogNames = { "调研文章", "审批", "申请" };
            CatalogEntity[] catalogs     = new CatalogEntity[3];
            for (int index = 0; index < catalogNames.Length; index++)
            {
                catalogs[index] = new CatalogEntity(catalogNames[index]);
            }
            CatalogDao dao = new CatalogDao();

            dao.save(catalogs);
        }
示例#9
0
        public void DeleteClientsForCatalog(CatalogEntity catalog, string[] usernames)
        {
            IList <ClientEntity> clients = clientDao.GetClientsByUsernames(usernames);

            foreach (var client in clients)
            {
                if (client.Catalogs.Contains(catalog))
                {
                    client.Catalogs.Remove(catalog);
                }
            }
            clientDao.UpdateClients(clients);
        }
示例#10
0
        /// <summary>
        /// 得到图片
        /// </summary>
        /// <returns></returns>
        public virtual string CatalogFullFileName(CatalogEntity catalog)
        {
            if (catalog.Commodities == null || catalog.Commodities.Count == 0)
            {
                return("");
            }
            var commodity = catalog.Commodities.First();

            if (string.IsNullOrEmpty(commodity.FileName))
            {
                return("");
            }
            return(commodity.GetFullFileName(commodity.FileName, "i"));
        }
示例#11
0
        public void TestCasCadeCatalog()
        {
            CatalogEntity catalog = new CatalogEntity("test cata for cascade");
            CatalogDao    dao     = new CatalogDao();

            dao.save(catalog);

            ArticleEntity article = new ArticleEntity();

            article.Author  = new ClientDao().getClientByUsername("admin");
            article.Catalog = new CatalogDao().get(catalog.CatalogName);
            article.Title   = "test title";
            article.Content = "test content";

            ArticleDao articleDao = new ArticleDao();

            articleDao.save(article);
        }
        public async Task <CatalogEntity> SaveToTableAsync(CatalogItem item)
        {
            CatalogEntity catalogEntity = new CatalogEntity(item.Name, item.Id)
            {
                ImageUrl          = item.ImageUrl,
                ReorderLevel      = item.ReorderLevel,
                Quantity          = item.Quantity,
                Price             = item.Price,
                ManufacturingDate = item.ManufacturingDate
            };

            tableClient = tableAccount.CreateCloudTableClient();
            var catalogTable = tableClient.GetTableReference("catalog");
            await catalogTable.CreateIfNotExistsAsync();

            TableOperation operation   = TableOperation.InsertOrMerge(catalogEntity);
            var            tableResult = await catalogTable.ExecuteAsync(operation);

            return(tableResult.Result as CatalogEntity);
        }
        public async Task <CatalogEntity> SaveToTableAsync(CatalogItem item)
        // CALL THIS METHOD AFTER ADDING DATA TO MONGO PRIMARY DATABASE
        {
            CatalogEntity catalogEntity = new CatalogEntity(item.Name, item.Id)
            {
                ImageUrl          = item.ImageUrl,
                ReorderLevel      = item.ReorderLevel,
                Quantity          = item.Quantity,
                ManufacturingDate = item.ManufacturingDate
            };

            //tableClient = storageAccount.CreateCloudTableClient();
            tableClient = tableStorageAccount.CreateCloudTableClient();
            var catalogTable = tableClient.GetTableReference("catalog");
            await catalogTable.CreateIfNotExistsAsync();

            TableOperation operation = TableOperation.InsertOrMerge(catalogEntity);
            var            result    = await catalogTable.ExecuteAsync(operation);

            return(result.Result as CatalogEntity);
        }
示例#14
0
        /// <summary>
        /// 得到图片
        /// </summary>
        /// <returns></returns>
        public virtual string CatalogFullFileName(CatalogEntity catalog)
        {
            if (!string.IsNullOrEmpty(catalog.FileName))
            {
                return(catalog.FullFileName);
            }
            if (catalog.Commodities == null || catalog.Commodities.Count == 0)
            {
                return(SharedHelperExtension.GetNoPicture());
            }
            var commodity = catalog.Commodities.First();

            if (string.IsNullOrEmpty(commodity.FileName))
            {
                return(SharedHelperExtension.GetNoPicture());
            }
            if (!string.IsNullOrEmpty(commodity.Password))
            {
                return(string.Format("{0}/Images/lock.png", Configuration.ConfigurationManager.GetSetting <string>("CloudSiteMobileUrl")));
            }
            return(commodity.GetFullFileName(commodity.FileName, "i"));
        }
示例#15
0
        public virtual ActionResult Remove(string[] id)
        {
            var result = new Dictionary <string, object>();
            var rev    = false;

            if (id != null)
            {
                var infos = new List <CatalogEntity>();
                foreach (var i in id)
                {
                    var info = new CatalogEntity
                    {
                        Id       = i.Convert <long>(),
                        SaveType = SaveType.Remove
                    };
                    infos.Add(info);
                }
                rev = this.SaveEntities(infos);
            }
            result.Add("Status", rev);
            return(this.Jsonp(result));
        }
示例#16
0
        public ActionResult GetCatalogList(string language)
        {
            var query = from d in _context.M_CATALOGS
                        where d.DELETE_FLG == Constant.USING_FLG &&
                        d.SHOW_FLG == (int)ShowFlg.Show
                        orderby d.DISP_ORDER ascending
                        select d;

            List <M_CATALOG>     emps = query.ToList();
            List <CatalogEntity> list = new List <CatalogEntity>();

            foreach (M_CATALOG catalog in emps)
            {
                CatalogEntity entity = new CatalogEntity();

                entity.cd = catalog.CATALOG_CD;

                if (string.IsNullOrEmpty(language) || language.Equals(Constant.LANGUAGE_VN))
                {
                    entity.name = catalog.CATALOG_NAME;
                }
                else
                {
                    entity.name = catalog.CATALOG_NAME_EN;
                }

                entity.dispOrder = catalog.DISP_ORDER;

                list.Add(entity);
            }

            return(Ok(new Result
            {
                Status = 200,
                Message = string.Empty,
                Data = list
            }));
        }
示例#17
0
        /// <summary>
        /// 创建实体
        /// </summary>
        /// <param name="saveType"></param>
        /// <returns></returns>
        public virtual CatalogEntity CreateEntity(SaveType saveType)
        {
            var entity = new CatalogEntity
            {
                Name     = Name,
                Sequence = Sequence == null?1: Sequence.Value,
                SaveType = saveType
            };

            if (!string.IsNullOrEmpty(FileName) && FileName != " " && FileName != "")
            {
                entity.FileByte = Ioc.Resolve <IFileApplicationService>().Grab(FileName.Substring(FileName.IndexOf("/Files")));
                entity.FileName = string.Format("Files/Images/SiteCatalog/copy{0}", Path.GetExtension(FileName));
            }
            if (FileName == " " || FileName == "")
            {
                entity.FileName = "";
            }
            if (saveType == SaveType.Modify)
            {
                entity.Id = Id.Convert <long>();
                if (Name != null)
                {
                    entity.SetProperty(it => it.Name);
                }
                if (FileName != null)
                {
                    entity.SetProperty(it => it.FileName);
                }
                if (Sequence != null)
                {
                    entity.SetProperty(it => it.Sequence);
                }
            }
            return(entity);
        }
示例#18
0
        public ActionResult GetCommonList(string language)
        {
            CommonEntity    commonEntity = new CommonEntity();
            List <M_DEFINE> emps         = _context.M_DEFINES.ToList();

            List <DefineEntity> list = new List <DefineEntity>();

            foreach (M_DEFINE denfine in emps)
            {
                DefineEntity entity = new DefineEntity();

                entity.controlName = denfine.CONTROL_NAME;
                entity.dataType    = denfine.DATA_TYPE;
                entity.value       = denfine.VALUE;
                entity.memo        = denfine.MEMO;
                list.Add(entity);
            }

            commonEntity.commonList = list;

            var query2 = from d in _context.M_UNITS
                         where d.DELETE_FLG == 0 &&
                         d.SHOW_FLG == (int)ShowFlg.Show
                         orderby d.DISP_ORDER ascending
                         select d;

            List <M_UNIT>     empsUnit = query2.ToList();
            List <UnitEntity> unitList = new List <UnitEntity>();

            foreach (M_UNIT unit in empsUnit)
            {
                UnitEntity unitEntity = new UnitEntity();

                unitEntity.cd = unit.UNIT_CD;

                if (string.IsNullOrEmpty(language) || language.Equals(Constant.LANGUAGE_VN))
                {
                    unitEntity.name = unit.UNIT_NAME;
                }
                else
                {
                    unitEntity.name = unit.UNIT_NAME_EN;
                }

                unitEntity.dispOrder = unit.DISP_ORDER;

                unitList.Add(unitEntity);
            }

            commonEntity.unitList = unitList;

            var query3 = from d in _context.M_CATALOGS
                         where d.DELETE_FLG == Constant.USING_FLG &&
                         d.SHOW_FLG == (int)ShowFlg.Show
                         orderby d.DISP_ORDER ascending
                         select d;

            List <M_CATALOG>     empsCatalog = query3.ToList();
            List <CatalogEntity> catalogList = new List <CatalogEntity>();

            foreach (M_CATALOG catalog in empsCatalog)
            {
                CatalogEntity entity = new CatalogEntity();

                entity.cd = catalog.CATALOG_CD;

                if (string.IsNullOrEmpty(language) || language.Equals(Constant.LANGUAGE_VN))
                {
                    entity.name = catalog.CATALOG_NAME;
                }
                else
                {
                    entity.name = catalog.CATALOG_NAME_EN;
                }

                entity.dispOrder = catalog.DISP_ORDER;

                catalogList.Add(entity);
            }

            commonEntity.catalogList = catalogList;

            return(Ok(new Result
            {
                Status = 200,
                Message = string.Empty,
                Data = commonEntity
            }));
        }
示例#19
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="entity">更新</param>
 /// <returns></returns>
 public int Update(CatalogEntity entity)
 {
     return(baseRepository.Update(entity));
 }
示例#20
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="entity">新增实体</param>
 /// <returns></returns>
 public int Insert(CatalogEntity entity)
 {
     return(baseRepository.Insert(entity));
 }
示例#21
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="entity">删除实体</param>
 /// <returns></returns>
 public int Delete(CatalogEntity entity)
 {
     return(baseRepository.Delete(entity));
 }
示例#22
0
        /// <summary>
        /// 创建商品
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        protected virtual void CreateCommodity(DirectoryInfo directory, CatalogEntity category)
        {
            if (directory == null || !directory.Exists)
            {
                return;
            }
            var files = directory.GetFiles()
                        .Where(it => it.Name.ToLower().EndsWith(".jpg") || it.Name.ToLower().EndsWith(".png") || it.Name.ToLower().EndsWith(".gif"))
                        .OrderBy(it => it.Name.Replace(Path.GetExtension(it.Name), "").Convert <int>()).ToArray();
            var dataInfos = GetCommodities(category.Id);

            for (int j = 0; j < files.Length; j++)
            {
                var index = files[j].Name.IndexOf(".");
                if (index <= -1)
                {
                    continue;
                }
                var names      = files[j].Name.Substring(0, index).Split('|');
                var commodity  = dataInfos.FirstOrDefault(it => it.Name == names[0]);
                var selectText = comboBox1.SelectedItem.Convert <string>();
                if (commodity == null && selectText == "目录图片")
                {
                    continue;
                }
                var fileName = string.Format("Files/Images/{0}/copy{1}", selectText == "目录图片"? "SiteAlbum": "SiteCommodity", Path.GetExtension(files[j].Name));
                if (commodity == null)
                {
                    commodity = new CommodityEntity
                    {
                        Catalog       = category,
                        Name          = names[0],
                        Description   = names.Length > 1 ? names[1] : "",
                        Cost          = 0,
                        Price         = 0,
                        IsShowPrice   = false,
                        Status        = CommodityStatusType.Normal,
                        VenderAddress = "",
                        VenderMobile  = "",
                        VenderName    = "",
                        VenderLinkman = "",
                        Password      = "",
                        Site          = new SiteEntity {
                            Id = SiteId
                        },
                        Sequence      = CommoditySequence,
                        FileName      = "",
                        AlbumFileName = "",
                        IsCreateAlbum = true,
                        SaveType      = SaveType.Add
                    };
                    if (selectText == "目录图片")
                    {
                        commodity.AlbumFileName = fileName;
                    }
                    else
                    {
                        commodity.FileName = fileName;
                    }
                }
                else
                {
                    if (selectText == "目录图片")
                    {
                        commodity.AlbumFileName = fileName;
                        commodity.SetProperty(it => it.AlbumFileName);
                    }
                    else
                    {
                        commodity.FileName = fileName;
                        commodity.SetProperty(it => it.FileName);
                    }
                    commodity.SaveType = SaveType.Modify;
                }
                var bt = ImageHelper.Create(files[j].FullName, 800, 800, Color.White, 0);
                ImageHelper.Save(files[j].FullName, bt);
                if (selectText == "目录图片")
                {
                    commodity.AlbumFileByte = GetFileByte(files[j].FullName);
                }
                else
                {
                    commodity.FileByte = GetFileByte(files[j].FullName);
                }
                CommoditySequence = CommoditySequence + 5000 > 100000000 ? 100000000 + 1 : CommoditySequence + 5000;
                var rev = Ioc.Resolve <IApplicationService, CommodityEntity>().Save(commodity);
                if (rev)
                {
                    files[j].Delete();
                }
                else
                {
                    dataGridView1.Rows.Add(new object[] { directory.FullName, commodity.Errors?.FirstOrDefault()?.Message });
                }
            }
        }
示例#23
0
 public string SaveCatalog(CatalogEntity catalog)
 {
     return(dao.save(catalog));
 }