public void TestAssertShortUri() { IPageStore pageStore; ulong resourceId, resourceIndexRoot; var shortenedUri = "p0:" + Guid.Empty; using (pageStore = TestUtils.CreateEmptyPageStore("TestAssertShortUri.data")) { var resourceIndex = new ResourceIndex(0, pageStore, null); resourceId = resourceIndex.AssertResourceInIndex(0, shortenedUri); Assert.AreEqual(resourceId, resourceIndex.GetResourceId(shortenedUri, false, null, null, true)); var resource = resourceIndex.GetResource(resourceId, true); Assert.IsNotNull(resource); Assert.AreEqual(shortenedUri, resource.Value); Assert.IsFalse(resource.IsLiteral); resourceIndexRoot = resourceIndex.RootId; resourceIndex.Save(0, null); pageStore.Commit(0ul, null); } using (pageStore = TestUtils.OpenPageStore("TestAssertShortUri.data", false)) { var resourceIndex = new ResourceIndex(pageStore, null, resourceIndexRoot); Assert.AreEqual(resourceId, resourceIndex.GetResourceId(shortenedUri, false, null, null, true)); var resource = resourceIndex.GetResource(resourceId, true); Assert.IsNotNull(resource); Assert.AreEqual(shortenedUri, resource.Value); Assert.IsFalse(resource.IsLiteral); } }
public bool UpdateVideoStatus(string serialnumber, int status) { bool _ret = false; string sql = @"update Resources set status=@status where itemserialnumber=@sn"; int i = 0; SqlParameter[] ps = new SqlParameter[2]; ps[i++] = new SqlParameter("@status", status); ps[i++] = new SqlParameter("@sn", serialnumber); try { SqlHelper.ExecuteNonQuery(CommonInfo.ConQJVRMS, CommandType.Text, sql, ps); _ret = true; } catch { } //同时更新索引 string[] SNs = new string[] { serialnumber }; ResourceIndex.updateIndex(SNs); return(_ret); }
public void TestAssertLongLiteral() { var longStringValue = "Long string value " + new string('!', 100); var pageStore = TestUtils.CreateEmptyPageStore("TestAssertLongLiteral.data"); var resourceStore = TestUtils.CreateEmptyPageStore("TestAssertLongLiteral.resources"); var resourceTable = new ResourceTable(resourceStore); var resourceIndex = new ResourceIndex(0, pageStore, resourceTable); var resourceId = resourceIndex.AssertResourceInIndex(0, longStringValue, true, "http://example.org/datatypes/string", "en-us"); // Should now be able to find the resource id Assert.AreEqual(resourceId, resourceIndex.GetResourceId(longStringValue, true, "http://example.org/datatypes/string", "en-us", true)); // data type URI and language code should have been inserted as resources Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("http://example.org/datatypes/string", false, null, null, true)); Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("en-us", true, null, null, true)); var resource = resourceIndex.GetResource(resourceId, true); Assert.IsNotNull(resource); Assert.IsTrue(resource.IsLiteral); Assert.AreEqual(longStringValue, resource.Value); var dtResource = resourceIndex.GetResource(resource.DataTypeId, true); Assert.IsNotNull(dtResource); Assert.IsFalse(dtResource.IsLiteral); Assert.AreEqual("http://example.org/datatypes/string", dtResource.Value); var lcResource = resourceIndex.GetResource(resource.LanguageCodeId, true); Assert.IsNotNull(lcResource); Assert.IsTrue(lcResource.IsLiteral); Assert.AreEqual("en-us", lcResource.Value); // Persist the index var resourceIndexRoot = resourceIndex.RootId; resourceIndex.Save(0, null); pageStore.Commit(0ul, null); pageStore.Close(); resourceTable.Commit(0ul, null); resourceTable.Dispose(); // Test we can still find the resource after reopening the store using (pageStore = TestUtils.OpenPageStore("TestAssertLongLiteral.data", false)) { using (var rt = new ResourceTable(TestUtils.OpenPageStore("TestAssertLongLiteral.resources", false))) { resourceIndex = new ResourceIndex(pageStore, rt, resourceIndexRoot); // Should still be able to find the resource id Assert.AreEqual(resourceId, resourceIndex.GetResourceId(longStringValue, true, "http://example.org/datatypes/string", "en-us", true)); Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("http://example.org/datatypes/string", false, null, null, true)); Assert.AreNotEqual(StoreConstants.NullUlong, resourceIndex.GetResourceId("en-us", true, null, null, true)); } } }
public static void Run() { var index = new ResourceIndex(); var factory = new PSArmDslFactory(); foreach (ResourceSchema schema in index.GetResourceSchemas()) { factory.CreateResourceDslDefinition(schema.Properties, schema.DiscriminatedSubtypes); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); ResourceIndex Index = (ResourceIndex)target; if (GUILayout.Button("Bake ResourceIndex")) { Index.Bake(); } }
protected void btnSetCata_Click(object sender, EventArgs e) { ArrayList selNodes = new ArrayList(); TreeNode parentNode = cataTree.RootNode; //获取checked的节点List selNodes = this.cataTree.ArrCheckbox(selNodes, parentNode); //QJVRMS.Business.ImageStorageClass imageClass = new QJVRMS.Business.ImageStorageClass(); Resource objResource = new Resource(); ArrayList catalogIds = new ArrayList(selNodes.Count); foreach (TreeNode node in selNodes) { // chNode = (TreeNode)(nodeList[i]); catalogIds.Add(new Guid(node.Value)); //imageClass.CreateRelationshipImageAndCatalog(img.ItemId, new Guid(chNode.Value)); } try { objResource.CreateRelationshipResourceAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid))); //imageClass.CreateRelationshipImageAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid))); ShowMessage("设置分类成功"); //更新索引 //根据itemId获得SN ResourceEntity model = objResource.GetResourceInfoByItemId(Request["itemid"].ToString()); if (model != null) { string[] SNs = new string[] { model.ItemSerialNum }; ResourceIndex.updateIndex(SNs); } } catch { ShowMessage("设置分类失败"); } }
/// <summary> /// Called when loading the finishing bake level, separated from previous method for clarity /// </summary> /// <param name="scene">Scene opened</param> /// <param name="mode">Mode in which the scene was opened</param> void OnFinishBakeLevelOpened(Scene scene, OpenSceneMode mode) { //No matter if we succeed or fail now, we don't need to react to scene changes until next bake UnityEditor.SceneManagement.EditorSceneManager.sceneOpened -= OnFinishBakeLevelOpened; GameObject Caller = GameObject.Find(BakeContext.CallerName); ResourceIndex Index = Caller != null?Caller.GetComponentInChildren <ResourceIndex>() : null; if (Index) { Index.OnCommitBake(IndexMap); Debug.Log("Baking complete"); } else { Debug.LogError("Baking failed, could not locate baking context caller when reloading scene."); } //Finished, we clear the loading bar EditorUtility.ClearProgressBar(); }
public void ProcessRequest(HttpContext context) { HttpRequest Request = context.Request; HttpResponse Response = context.Response; Response.ContentType = "text/plain"; StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); sb.Append("["); string key = Request.QueryString["q"]; if (!string.IsNullOrEmpty(key)) { string[] ret = ResourceIndex.GetRelatedKeywords(key); int icount = ret.Length; for (int i = 0; i < icount; i++) { sb.Append("'"); sb.Append(ret[i]); sb.Append("'"); sb1.Append(ret[i]); if (i < icount - 1) { sb.Append(","); sb1.Append("\r\n"); } } } sb.Append("]"); Response.Write(sb1.ToString()); Response.End(); //返回一个关键字数组 ['','',''] }
protected void btnUpload_ServerClick(object sender, EventArgs e) { //是否有版权的资源 int hasCopyRight = 0; try { hasCopyRight = Convert.ToInt32(this.rblCopyright.SelectedValue); } catch (Exception ex) { } #region 验证日期部分 //if (this.shotDate1.Text.Trim() == string.Empty) //{ // this.ShowMessage(this, "请选择时间"); // return; //} //else //{ // if (Convert.ToDateTime(this.shotDate1.Text) > DateTime.Now) // { // this.ShowMessage(this, "拍摄时间应比现在早"); // return; // } //} //验证日期 DateTime sDate = new DateTime(); DateTime eDate = new DateTime(); if (this.startDate.Text != "") { //有效开始日期就不做验证了,只要结束日期比现在晚就可以了。 sDate = Convert.ToDateTime(this.startDate.Text); //if (sDate <= DateTime.Now) //{ // this.ShowMessage(this, "有效开始日期应比现在日期晚"); // return; //} } else { sDate = Convert.ToDateTime("1900-01-01"); } if (this.endDate.Text != "") { eDate = Convert.ToDateTime(this.endDate.Text); if (sDate == Convert.ToDateTime("1900-01-01") && eDate < DateTime.Now) { this.ShowMessage(this, "有效结束日期应至少比现在日期晚"); return; } else if (eDate < sDate) { this.ShowMessage(this, "有效结束日期应比有效开始日期晚"); return; } } else { eDate = Convert.ToDateTime("1900-01-01"); } #endregion #region 验证是否选择目录节点 ////根节点 //TreeNode parentNode = catalogTree.RootNode; ////获取checked的节点List //ArrayList nodeList = new ArrayList(); //this.catalogTree.ArrCheckbox(nodeList, parentNode); //ArrayList catalogIds = new ArrayList(nodeList.Count); //foreach (TreeNode node in nodeList) //{ // catalogIds.Add(new Guid(node.Value)); //} //if (catalogIds.Count == 0) //{ // this.ShowMessage(this, "没有选择分类,上传失败!"); // return; //} string catIds = this.hidCatIds.Value.Trim().Trim(new char[] { ',' }); string[] arrCatIds = catIds.Split(",".ToCharArray()); if (arrCatIds.Length == 0) { this.ShowMessage(this, "没有选择分类,上传失败!"); return; } ArrayList catalogIds = new ArrayList(arrCatIds.Length); foreach (string _s in arrCatIds) { catalogIds.Add(new Guid(_s)); } #endregion string fileName = ""; //原始文件名 if (!string.IsNullOrEmpty(Request["selectedFile"])) { fileName = Request["selectedFile"].ToString().ToLower(); } else { return; } string uploadFileName = ""; //上传以后重新分配的文件名 prefix+yymmdd+00001.extention if (!string.IsNullOrEmpty(Request["uploadFileName"])) { uploadFileName = Request["uploadFileName"].ToString(); } else { return; } string[] arrFiles = uploadFileName.Split(','); foreach (string singleFiles in arrFiles) { if (!singleFiles.Contains(":")) { continue; } string[] _arr = singleFiles.Split(':'); string strClientFileName = _arr[1]; string strServerFileName = _arr[0]; fileName = strClientFileName; uploadFileName = strServerFileName; /** start **/ Resource objResource = new Resource(); ResourceEntity model = new ResourceEntity(); //管理员上传直接审核通过 if (IsSuperAdmin) { model.Status = (int)ResourceEntity.ResourceStatus.IsPass; } else { model.Status = (int)ResourceEntity.ResourceStatus.NewUpload; } //改成所有人上传的都可以直接通过 , 到时直接注释下面一句话就可以 model.Status = (int)ResourceEntity.ResourceStatus.IsPass; model.Status = 0; if (this.txt_Caption.Value.Trim().Length > 0) { model.Caption = this.txt_Caption.Value; } else { model.Caption = Path.GetFileNameWithoutExtension(strClientFileName); } model.Description = this.description.Value; model.EndDate = eDate; model.FileName = fileName; model.FolderName = CurrentUser.UserLoginName; if (uploadFileName.ToLower().IndexOf(".cr2") != -1 || uploadFileName.ToLower().IndexOf(".nef") != -1 || uploadFileName.ToLower().IndexOf(".psd") != -1) { model.ServerFileName = uploadFileName.Replace("cr2", "jpg").Replace("nef", "jpg").Replace("psd", "jpg"); } else { model.ServerFileName = uploadFileName; } model.GroupId = CurrentUser.UserGroupId; model.ItemId = Guid.NewGuid(); model.ItemSerialNum = Path.GetFileNameWithoutExtension(uploadFileName); //model.Keyword = this.keyWord.Value; model.Keyword = this.txtKeyWords.Text.Trim().Trim(",".ToCharArray()); //model.shotDate = Convert.ToDateTime(this.shotDate1.Text); model.StartDate = sDate; model.uploadDate = DateTime.Now; model.userId = CurrentUser.UserId; model.updateDate = DateTime.Now; model.Author = this.txt_Author.Value.Trim(); //取得文件的扩展名,不包括.号 string fileExtName = string.Empty; fileExtName = Path.GetExtension(fileName); if (fileExtName.IndexOf(".") > -1) { fileExtName = fileExtName.Substring(1); } model.ResourceType = ResourceTypeFactory.getResourceType(fileExtName).ResourceType; model.FileSize = Resource.GetResourceFileSize(uploadFileName, model.FolderName, fileExtName, ""); model.HasCopyright = hasCopyRight; model.shotDate = DateTime.Now; DateTime shotDateTime = Resource.GetResourceShotDateTime(uploadFileName, model.FolderName, model.ResourceType, ""); if (shotDateTime != DateTime.MinValue) { model.shotDate = shotDateTime; } objResource.Add(model); objResource.CreateRelationshipResourceAndCatalog(model.ItemId, (Guid[])catalogIds.ToArray(typeof(Guid))); //同时更新索引 string[] SNs = new string[] { model.ItemSerialNum }; ResourceIndex.updateIndex(SNs); } /** end **/ #region 注释部分 //VideoStorageClass vsc = new VideoStorageClass(); //VideoStorage v = new VideoStorage(); //v.Caption = this.txt_Caption.Value; //v.Description = this.description.Value; //v.EndDate = eDate; //v.FileName = fileName; //v.FolderName = CurrentUser.UserLoginName; //v.ServerFileName = uploadFileName; //v.GroupId = CurrentUser.UserGroupId; //v.ItemId = Guid.NewGuid(); //v.ItemSerialNum = Path.GetFileNameWithoutExtension(uploadFileName); //v.Keyword = this.keyWord.Value; //v.shotDate = Convert.ToDateTime(this.shotDate.Value); //v.StartDate = sDate; //v.uploadDate = DateTime.Now; //v.userId = CurrentUser.UserId; //v.updateDate = DateTime.Now; ////存储数据库记录 //// img.ItemSerialNum = ImageStorageClass.AddImageStorage(img); //if (!vsc.Add(v)) //{ // this.ShowMessage(this, "上传失败"); // return; //} //vsc.CreateRelationshipVideoAndCatalog(v.ItemId, (Guid[])catalogIds.ToArray(typeof(Guid))); #endregion //this.shotDate1.Text = ""; this.keyWord.Value = ""; this.description.Value = ""; this.txt_Caption.Value = ""; this.startDate.Text = ""; this.endDate.Text = ""; initCalendar(); //this.ShowMessage(this, "上传成功"); //Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>myUploadSuccess2()</script>"); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>myUploadSuccess2()</script>"); }
/// <summary> /// Adds the <see cref="TextImageSpacing"/> to the image. /// </summary> /// <param name="p_imgImage">The image to pad.</param> /// <returns>The given image with the padding added to the appropriate side, based on /// <see cref="TextImageRelation"/>.</returns> private Bitmap PadImage(int index) { Image p_imgImage = null; ResourceIndex ri = (ResourceIndex)index; string ri_name = ri.ToString(); p_imgImage = m_imgImages[ri_name]; Int32 intWidth = 0; Int32 intHeight = 0; Int32 intXOffset = 0; Int32 intYOffset = 0; switch (TextImageRelation) { case TextImageRelation.ImageAboveText: intWidth = p_imgImage.Width; intHeight = p_imgImage.Height + TextImageSpacing; intXOffset = 0; intYOffset = 0; break; case TextImageRelation.ImageBeforeText: intWidth = p_imgImage.Width + TextImageSpacing; intHeight = p_imgImage.Height; intXOffset = 0; intYOffset = 0; break; case TextImageRelation.Overlay: intWidth = p_imgImage.Width; intHeight = p_imgImage.Height; intXOffset = 0; intYOffset = 0; break; case TextImageRelation.TextAboveImage: intWidth = p_imgImage.Width; intHeight = p_imgImage.Height + TextImageSpacing; intXOffset = 0; intYOffset = TextImageSpacing; break; case TextImageRelation.TextBeforeImage: intWidth = p_imgImage.Width + TextImageSpacing; intHeight = p_imgImage.Height; intXOffset = TextImageSpacing; intYOffset = 0; break; } Bitmap bmpPadded = new Bitmap(intWidth, intHeight, p_imgImage.PixelFormat); try { using (Graphics g = Graphics.FromImage(bmpPadded)) g.DrawImageUnscaled(p_imgImage, intXOffset, intYOffset); } catch (Exception ex) { Console.Error.WriteLine("PadImage::[index:{0}] [name:{1}]", index, ri_name); Trace.TraceInformation(String.Format("PadImage::[index:{0}] [name:{1}]", index, ri_name)); Console.Error.WriteLine("PadImage::[PixelFormat:{0}]", p_imgImage.PixelFormat); Trace.TraceInformation(String.Format("PadImage::[PixelFormat:{0}]", p_imgImage.PixelFormat)); Console.Error.WriteLine("PadImage::{0}", ex.Message); Console.Error.WriteLine(ex.ToString()); Trace.TraceInformation(ex.ToString()); } return(bmpPadded); }
public ValidationResult AddRemindBook(string resourceId, ResourceFromSite site, User user) { if (site == null || user == null || resourceId == null) { return(new ValidationResult("服务器错误,请刷新后重试")); } using (var scope = new System.Transactions.TransactionScope()) { var userRoleContext = WebRepoFactory.CreateRepo <UserResourceIndex>(Repo.dbContext); try { var data = MemoryCacheProvider.Cache.Get(resourceId + site.ToString()) as SearchBook; var modelcontext = WebRepoFactory.CreateRepo <ResourceIndex>(userRoleContext.dbContext); var resource = modelcontext.GetAll().FirstOrDefault(r => r.ResourceId == resourceId && r.ResourceFromsite == site); if (resource == null) { resource = new ResourceIndex() { Name = data.BookName, ResourceFromsite = site, ResourceId = resourceId, ResourceType = ResourceType.小说, SubscribeNum = 1, Url = data.BookUrl, CreatedBy = user.UserName, CreatedOn = DateTime.Now, ModifiedBy = user.UserName, ModifiedOn = DateTime.Now, }; Repo.Insert(new Book() { AuthorName = " " + data.AuthorName, ImgUrl = data.ImgUrl, ResourceIndex = resource, Description = data.Description.Trim(), LastChapter = data.LastChapter, LastChapterUrl = data.LastChapterUrl }); userRoleContext.Insert(new UserResourceIndex() { ResourceIndex = resource, UserId = user.Id }); } else { if (userRoleContext.GetAll().Any(r => r.ResourceIndexId == resource.Id && r.UserId == user.Id)) { return(new ValidationResult("用户已经订阅个信息")); } resource.SubscribeNum += 1; userRoleContext.Insert(new UserResourceIndex() { ResourceIndex = resource, UserId = user.Id }); } userRoleContext.Save(); scope.Complete(); } catch (Exception e) { LogHelper.error(e.Message); return(new ValidationResult(e.Message)); } } return(null); }
protected void btnSetCata_Click(object sender, EventArgs e) { //Response.Write(this.hfItemId.Value); //return; string ids = Request.QueryString["ids"]; if (string.IsNullOrEmpty(ids)) { return; } //ids = ids.TrimEnd(";".ToCharArray()); //string[] arrIds = ids.Split(";".ToCharArray()); string items = ids.Trim().Trim(";".ToCharArray()); if (string.IsNullOrEmpty(items)) { ShowMessage("设置分类失败"); return; } ArrayList selNodes = new ArrayList(); TreeNode parentNode = cataTree.RootNode; //获取checked的节点List selNodes = this.cataTree.ArrCheckbox(selNodes, parentNode); //QJVRMS.Business.ImageStorageClass imageClass = new QJVRMS.Business.ImageStorageClass(); Resource objResource = new Resource(); ArrayList catalogIds = new ArrayList(selNodes.Count); foreach (TreeNode node in selNodes) { // chNode = (TreeNode)(nodeList[i]); catalogIds.Add(new Guid(node.Value)); //imageClass.CreateRelationshipImageAndCatalog(img.ItemId, new Guid(chNode.Value)); } try { string[] _itemarr = items.Split(";".ToCharArray()); foreach (string itemId in _itemarr) { //objResource.CreateRelationshipResourceAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid))); objResource.CreateRelationshipResourceAndCatalog(new Guid(itemId), (Guid[])catalogIds.ToArray(typeof(Guid))); //更新索引 //根据itemId获得SN ResourceEntity model = objResource.GetResourceInfoByItemId(itemId); if (model != null) { string[] SNs = new string[] { model.ItemSerialNum }; ResourceIndex.updateIndex(SNs); } } //imageClass.CreateRelationshipImageAndCatalog(new Guid(Request["itemid"]), (Guid[])catalogIds.ToArray(typeof(Guid))); ShowMessage("设置分类成功"); } catch { ShowMessage("设置分类失败"); } }