public async Task <ActionResult> Create([Bind(Include = "ContentID,Title,Description,Keywords,Author,PublishDate,Image,URL,CreatedDate,UpdatedDate")] ContentDetail contentDetail)
        {
            if (ModelState.IsValid)
            {
                db.ContentDetails.Add(contentDetail);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(contentDetail));
        }
Esempio n. 2
0
        public Tuple <DateTime, string, string, bool, float, float>[] GetContentVersionList(string sContentUniqueId)
        {
            JobDetail oJob = quartzScheduler.GetJobDetail(sContentUniqueId, ContentMonitorConstants.ContentMonitorGroupName);
            List <Tuple <DateTime, string, string, bool, float, float> > listVersion = new List <Tuple <DateTime, string, string, bool, float, float> >();

            if (oJob != null)
            {
                try
                {
                    string sContentDetailJson = (string)oJob.JobDataMap[ContentMonitorJobDataMapConstants.ContentDetail];
                    if (sContentDetailJson != null)
                    {
                        ContentDetail oContent = JsonConvert.DeserializeObject <ContentDetail>(sContentDetailJson);

                        foreach (VersionDetail oVer in oContent.Versions)
                        {
                            int nUnkownCount  = 0;
                            int nSeedingCount = 0;
                            int nSeedCount    = oVer.TorrentSeeds.Count;

                            foreach (TorrentSeedDetail oTSD in oVer.TorrentSeeds)
                            {
                                if (oTSD.StatusCode == TorrentStatus.Unknown)
                                {
                                    nUnkownCount++;
                                }
                                if (oTSD.StatusCode == TorrentStatus.Seeding)
                                {
                                    nSeedingCount++;
                                }
                            }
                            oVer.SeedDeploymentRatio = ((float)(nSeedCount - nUnkownCount) / (float)nSeedCount);
                            oVer.SeedingRatio        = ((float)nSeedingCount / (float)nSeedCount);
                            listVersion.Add(
                                new Tuple <DateTime, string, string, bool, float, float>(
                                    oVer.DateCreated,
                                    oVer.Name,
                                    oVer.Hash,
                                    oVer.DeployToTracker,
                                    (float)Math.Round(oVer.SeedDeploymentRatio, 3),
                                    (float)Math.Round(oVer.SeedingRatio, 3)));
                        }
                    }
                }
                catch (Exception oEx)
                {
                    throw new ApplicationException(string.Format(AppResource.ContentDetailReadFailed, oEx.Message), oEx);
                }
            }
            // Sort VersionDetails by DateCreated
            listVersion.Sort((x, y) => { return(x.Item1.CompareTo(y.Item1)); });
            return(listVersion.ToArray());
        }
        private void Bind()
        {
            //查询条件
            GetSearchItem();

            ContentDetail bll = new ContentDetail();

            rpData.DataSource = bll.GetList(pageIndex, pageSize, out totalCount, sqlWhere, parms == null ? null : parms.ToArray());
            rpData.DataBind();

            ltrMyData.Text = "<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalCount + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>";
        }
Esempio n. 4
0
        protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
        {
            Dictionary <string, string> attributes = GetAttributes(navigator);
            Type type = Utility.TypeFromName(attributes["typeName"]);

            if (type == typeof(ContentItem))
            {
                int         referencedItemID = int.Parse(navigator.Value);
                ContentItem referencedItem   = journal.Find(referencedItemID);
                if (referencedItem != null)
                {
                    collection.Add(ContentDetail.New(
                                       collection.EnclosingItem,
                                       attributes["name"],
                                       referencedItem));
                }
                else
                {
                    journal.Register(referencedItemID, (item) =>
                    {
                        collection.Add(ContentDetail.New(
                                           collection.EnclosingItem,
                                           attributes["name"],
                                           item));
                    });
                }
            }
            else if (type == typeof(Enum))
            {
                if (attributes.ContainsKey("meta"))
                {
                    collection.Add(ContentDetail.New(
                                       collection.EnclosingItem,
                                       attributes["name"],
                                       Parse(navigator.Value, Type.GetType(attributes["meta"]))));
                }
            }
            else if (type == typeof(IMultipleValue))
            {
                detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
            }
            else
            {
                object value = Parse(navigator.Value, type);
                if (value is string)
                {
                    value = detailReader.PrepareStringDetail(collection.EnclosingItem, collection.Name, value as string, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));
                }

                collection.Add(ContentDetail.New(collection.EnclosingItem, attributes["name"], value));
            }
        }
Esempio n. 5
0
        public void Constructor_Link()
        {
            var item = new Definitions.Definitions.SideshowItem {
                ID = 123
            };
            var detail = new ContentDetail(null, "Hello", item);

            Assert.That(detail, Is.InstanceOf <ContentDetail>());
            Assert.That(detail.LinkedItem, Is.EqualTo(item));
            Assert.That(detail.Value, Is.EqualTo(item));
            Assert.That(detail.ValueType, Is.EqualTo(typeof(ContentItem)));
            Assert.That(detail.ValueTypeKey, Is.EqualTo(ContentDetail.TypeKeys.LinkType));
        }
Esempio n. 6
0
        public JsonResult Detail(long id)
        {
            var content  = daoContent.getById(id);
            var category = daoCategory.getByID((long)content.CatagoryID);
            var data     = new ContentDetail();

            data.category = category;
            data.content  = content;
            return(Json(new {
                data = data,
                status = true
            }));
        }
Esempio n. 7
0
        public virtual void WriteDetail(ContentItem item, ContentDetail detail, XmlTextWriter writer)
        {
            using (ElementWriter detailElement = new ElementWriter("detail", writer))
            {
                detailElement.WriteAttribute("name", detail.Name);
                detailElement.WriteAttribute("typeName", SerializationUtility.GetTypeAndAssemblyName(detail.ValueType));

                if (detail.ValueType == typeof(object))
                {
                    string base64representation = SerializationUtility.ToBase64String(detail.Value);
                    detailElement.Write(base64representation);
                }
                else if (detail.ValueType == typeof(ContentItem))
                {
                    detailElement.Write(detail.LinkValue.HasValue ? detail.LinkValue.Value.ToString() : "0");
                }
                else if (detail.ValueType == typeof(string))
                {
                    string value = detail.StringValue;

                    if (!string.IsNullOrEmpty(value))
                    {
                        if (value.StartsWith(applicationPath, StringComparison.InvariantCultureIgnoreCase))
                        {
                            var pi = item.GetContentType().GetProperty(detail.Name);
                            if (pi != null)
                            {
                                var transformers = pi.GetCustomAttributes(typeof(IRelativityTransformer), false);
                                foreach (IRelativityTransformer transformer in transformers)
                                {
                                    if (transformer.RelativeWhen == RelativityMode.Always || transformer.RelativeWhen == RelativityMode.ImportingOrExporting)
                                    {
                                        value = transformer.Rebase(value, applicationPath, "~/");
                                    }
                                }
                            }
                        }

                        detailElement.WriteCData(value);
                    }
                }
                else if (detail.ValueType == typeof(DateTime))
                {
                    detailElement.Write(ElementWriter.ToUniversalString(detail.DateTimeValue));
                }
                else
                {
                    detailElement.Write(detail.Value.ToString());
                }
            }
        }
Esempio n. 8
0
        private void base_AfterCollapse(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            if (e.Node != null)
            {
                //Get Node Id
                string selectedNodeId = (string)e.Node.Tag;

                ContentDetail selectedCatNoteDetail = m_NotepadXDocument.GetNoteById(selectedNodeId);
                selectedCatNoteDetail.ExpandNodeByDefault = false;
            }
            else
            {
            };                          //don't know why this should happen but it did once
        }
 private void Bind()
 {
     if (!gId.Equals(Guid.Empty))
     {
         ContentDetail     bll   = new ContentDetail();
         ContentDetailInfo model = bll.GetModel(gId);
         if (model != null)
         {
             txtTitle.Value  = model.Title;
             txtParent.Value = model.ContentTypeId.ToString();
             hEditor1.Value  = model.ContentText;
         }
     }
 }
        private void Bind()
        {
            var bll   = new ContentDetail();
            var model = bll.GetModelByTypeCode(EnumData.MenuRoot.ProductAgreement.ToString());

            if (model != null)
            {
                ltrEditorContent.Text = model.ContentText;
            }

            string picUrl = PictureUrlHelper.GetUrl(model.FileDirectory, model.RandomFolder, model.FileExtension, EnumData.PictureType.OriginalPicture, EnumData.Platform.PC);

            agreementContainer.Style.Add("background-image", "url('" + picUrl + "')");
        }
Esempio n. 11
0
        public ResResultModel SaveContentDetail(ContentDetailFmModel model)
        {
            try
            {
                if (model == null)
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                if (string.IsNullOrWhiteSpace(model.AppCode) || string.IsNullOrWhiteSpace(model.Title))
                {
                    return(ResResult.Response(false, MC.Request_Params_InvalidError, null));
                }
                Guid Id = Guid.Empty;
                if (model.Id != null)
                {
                    Guid.TryParse(model.Id.ToString(), out Id);
                }
                Guid contentTypeId = Guid.Empty;
                if (model.ContentTypeId != null)
                {
                    Guid.TryParse(model.ContentTypeId.ToString(), out contentTypeId);
                }
                var userId    = WebCommon.GetUserId();
                var currTime  = DateTime.Now;
                var modelInfo = new ContentDetailInfo(model.AppCode, Id, userId, contentTypeId, model.Title, model.Keyword, model.Descr, model.ContentText, model.Openness, model.Sort, currTime, currTime);

                var bll    = new ContentDetail();
                int effect = -1;

                if (Id.Equals(Guid.Empty))
                {
                    modelInfo.Id = Guid.NewGuid();
                    effect       = bll.InsertByOutput(modelInfo);
                }
                else
                {
                    effect = bll.Update(modelInfo);
                }
                if (effect < 1)
                {
                    return(ResResult.Response(false, MC.M_Save_Error, ""));
                }

                return(ResResult.Response(true, "", modelInfo.Id));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Esempio n. 12
0
 private static void StoreObjectOnDetails(ContentItem item, string keyPrefix, object entity, DetailCollection collection)
 {
     foreach (var kvp in new RouteValueDictionary(entity))
     {
         if (ContentDetail.GetAssociatedPropertyName(kvp.Value) == "Value")
         {
             StoreObjectOnDetails(item, keyPrefix + "." + kvp.Key, kvp.Value, collection);
         }
         else
         {
             SetDetail(item, collection, keyPrefix + "." + kvp.Key, kvp.Value);
         }
     }
 }
        // GET: ContentDetails/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ContentDetail contentDetail = await db.ContentDetails.FindAsync(id);

            if (contentDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(contentDetail));
        }
Esempio n. 14
0
        public ContentDetail Create(ContentDetail contentDetail)
        {
            if (contentDetail.ContentID == Guid.Empty)
            {
                var content = _contentRepository.Create(new Content());
                contentDetail.ContentID = content.ID;
            }

            contentDetail = _contentDetailRepository.Create(contentDetail);

            UnitOfWork.SaveChanges();

            return(contentDetail);
        }
Esempio n. 15
0
        private void WriteMultiValue(ContentItem item, ContentDetail detail, string valueTypeKey, object value, XmlTextWriter writer)
        {
            if (value == null)
            {
                return;
            }

            using (ElementWriter multiElement = new ElementWriter("value", writer))
            {
                multiElement.WriteAttribute("key", valueTypeKey);

                WriteInnerContents(item, detail, valueTypeKey, multiElement);
            }
        }
Esempio n. 16
0
        private void Bind()
        {
            ShareSiteMapProvider ssmp = new ShareSiteMapProvider();
            var currNode = ssmp.FindSiteMapNode(HttpContext.Current);

            this.Page.Title = currNode.Title;

            var aId = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(Request.QueryString["aId"]))
            {
                Guid.TryParse(Request.QueryString["aId"], out aId);
            }
            if (!aId.Equals(Guid.Empty))
            {
                if (phUc.FindControl("UCRArticleDetail") == null)
                {
                    Control ctl = this.LoadControl("~/WebUserControls/UCRArticleDetail.ascx");
                    ctl.ID = "UCRArticleDetail";
                    phUc.Controls.Clear();
                    phUc.Controls.Add(ctl);
                }
            }
            else
            {
                BindUc(currNode.Title);
            }

            var bll   = new ContentDetail();
            var model = bll.GetModelByTitle(currNode.Title);

            if (model == null)
            {
                MessageBox.Messager(this.Page, MC.Submit_Data_NotExists, MC.AlertTitle_Ex_Error, "error");
                return;
            }

            StringBuilder sb = new StringBuilder();

            sb.Append(model.ContentText);

            string picUrl = PictureUrlHelper.GetUrl(model.FileDirectory, model.RandomFolder, model.FileExtension, EnumData.PictureType.OriginalPicture, EnumData.Platform.PC);
            int    width  = 0;
            int    height = 0;

            sb.AppendFormat(@"<div id=""myDataAppend"" style=""display:none;"">{{""banner"":""{0}"",""width"":""{1}"",""height"":""{2}""}}</div>", picUrl.Replace("/Files/", "/sw/Files/"), width, height);

            ltrMyData.Text = sb.ToString();
        }
Esempio n. 17
0
        private void Bind()
        {
            ShareSiteMapProvider ssmp = new ShareSiteMapProvider();
            var currNode = ssmp.FindSiteMapNode(HttpContext.Current);
            var bll      = new ContentDetail();
            var model    = bll.GetModelByTitle(currNode.Title);

            if (model == null)
            {
                MessageBox.Messager(this.Page, MC.Submit_Data_NotExists, MC.AlertTitle_Ex_Error, "error");
                return;
            }

            ltrMyData.Text = model.ContentText;
        }
Esempio n. 18
0
        private void base_AfterLabelEdit(object sender, System.Windows.Forms.NodeLabelEditEventArgs e)
        {
            //System.Diagnostics.Debug.WriteLine ("AfterLeabelEdit fired");
            if ((e.Node != null) && (e.Label != null))
            {
                //Get Node Id
                string selectedNodeId = (string)e.Node.Tag;

                ContentDetail selectedCatNoteDetail = m_NotepadXDocument.GetNoteById(selectedNodeId);
                selectedCatNoteDetail.Title = e.Label;
            }
            else
            {
            };                          //don't know why this should happen but it did once
        }
Esempio n. 19
0
        internal ContentDetail ReadMultipleValue(XPathNavigator navigator, ContentItem item, ReadingJournal journal, string name)
        {
            var multiDetail = ContentDetail.Multi(name);

            foreach (XPathNavigator valueElement in EnumerateChildren(navigator))
            {
                switch (valueElement.GetAttribute("key", ""))
                {
                case ContentDetail.TypeKeys.BoolType:
                    multiDetail.BoolValue = (bool)Parse(valueElement.Value, typeof(bool));
                    break;

                case ContentDetail.TypeKeys.DateTimeType:
                    multiDetail.DateTimeValue = (DateTime)Parse(valueElement.Value, typeof(DateTime));
                    break;

                case ContentDetail.TypeKeys.DoubleType:
                    multiDetail.DoubleValue = (double)Parse(valueElement.Value, typeof(double));
                    break;

                case ContentDetail.TypeKeys.IntType:
                    multiDetail.IntValue = (int)Parse(valueElement.Value, typeof(int));
                    break;

                case ContentDetail.TypeKeys.LinkType:
                    SetLinkedItem(valueElement.Value, journal, (referencedItem) => multiDetail.LinkedItem = referencedItem, valueElement.GetAttribute("versionKey", ""));
                    break;

                case ContentDetail.TypeKeys.MultiType:
                    journal.Error(new InvalidOperationException("Nested multi types not supported"));
                    break;

                case ContentDetail.TypeKeys.ObjectType:
                    multiDetail.ObjectValue = Parse(valueElement.Value, typeof(object));
                    break;

                case ContentDetail.TypeKeys.EnumType:     /* TODO: May need special treatment here as well (see other TODO). */
                case ContentDetail.TypeKeys.StringType:
                    Dictionary <string, string> attributes = GetAttributes(navigator);
                    multiDetail.StringValue = PrepareStringDetail(item, name, valueElement.Value, attributes.ContainsKey("encoded") && Convert.ToBoolean(attributes["encoded"]));
                    break;

                default:
                    throw new Exception("Failed to read MultipleValue");
                }
            }
            return(multiDetail);
        }
Esempio n. 20
0
        protected virtual void RemoveDetailReferences(ContentItem referenceToRemove, ContentItem item)
        {
            List <string> keys = new List <string>(item.Details.Keys);

            foreach (string key in keys)
            {
                ContentDetail detail = item.Details[key];
                if (detail.ValueType == typeof(ContentItem))
                {
                    if (detail.LinkedItem == referenceToRemove)
                    {
                        item.Details.Remove(key);
                    }
                }
            }
        }
        public async Task ShouldGetDocumentMetadata()
        {
            var contentId = await _fixture.GetRandomContentIdAsync(".jpg", 20);

            if (string.IsNullOrEmpty(contentId))
            {
                contentId = await _fixture.GetRandomContentIdAsync(".docx", 20);
            }

            Assert.False(string.IsNullOrEmpty(contentId));

            ContentDetail result = await _client.Contents.GetAsync(contentId);

            FileMetadata fileMetadata = result.GetFileMetadata();

            Assert.False(string.IsNullOrEmpty(fileMetadata.FileName));
        }
Esempio n. 22
0
 protected virtual void RemoveReferencesInCollections(ContentItem referenceToRemove, ContentItem item)
 {
     foreach (DetailCollection collection in item.DetailCollections.Values)
     {
         for (int i = collection.Details.Count - 1; i >= 0; --i)
         {
             ContentDetail detail = collection.Details[i];
             if (detail.ValueType == typeof(ContentItem))
             {
                 if (detail.LinkedItem == referenceToRemove)
                 {
                     collection.Remove(referenceToRemove);
                 }
             }
         }
     }
 }
Esempio n. 23
0
        // run checklist
        public void addPostListTask(List <TaskItemViewModel> taskItem, int checklistId)
        {
            foreach (var item in taskItem)
            {
                List <ContentDetail> contentDetails = new List <ContentDetail>();
                List <TaskMember>    taskMembers    = new List <TaskMember>();
                TaskItem             task           = new TaskItem();
                task.ChecklistId = checklistId;
                task.DueTime     = DateTime.Parse(item.DueTime);
                task.Name        = item.Name;
                task.Priority    = item.Priority;
                //  task.TaskStatus = item.TaskStatus;
                task.TaskStatus = "Running";
                context.TaskItem.Add(task);
                context.SaveChanges();
                var getTask = context.TaskItem.Where(t => t.Name.Equals(item.Name) && t.DueTime.Equals(task.DueTime) && t.TaskStatus.Equals("Running") && t.ChecklistId == checklistId).FirstOrDefault();
                int order   = 1;
                foreach (var content in item.ContentDetails)
                {
                    if (content.Id != 0)
                    {
                        ContentDetail detail = new ContentDetail();
                        detail.ImageSrc     = content.ImageSrc;
                        detail.Label        = content.Label;
                        detail.OrderContent = order;
                        detail.TaskItemId   = getTask.Id;
                        detail.Text         = content.Text;
                        detail.Type         = content.Type;
                        contentDetails.Add(detail);
                    }
                    order = order + 1;
                }
                foreach (var user in item.UserId)
                {
                    TaskMember member = new TaskMember();
                    member.UserId = user.Id;
                    member.TaskId = getTask.Id;
                    taskMembers.Add(member);
                }
                context.ContentDetail.AddRange(contentDetails);
                context.TaskMember.AddRange(taskMembers);
                context.SaveChanges();

                //context.Task
            }
        }
Esempio n. 24
0
        public void AddNewChildNoteForTreeNode(string noteId, string noteContent, string noteFormat)
        {
            //Get child notes
            ContentDetailCollection childsForSelectedNote = m_NotepadXDocument.GetChildNotes(noteId);
            ContentDetail           newNote = childsForSelectedNote.Add();

            newNote.Title   = DefaultNewNoteTitle;
            newNote.Content = noteContent;
            newNote.Format  = noteFormat;

            TreeNode newAddedNode = RefreshTreeFromCatNoteDocumentAndSelectNote(newNote.Id);

            if (newAddedNode != null)
            {
                newAddedNode.BeginEdit();
            }
        }
Esempio n. 25
0
        //add list task of template
        public void addListTaskItem(List <TaskItemViewModel> taskItem, int checklistId)
        {
            foreach (var item in taskItem)
            {
                List <ContentDetail> contentDetails = new List <ContentDetail>();
                List <TaskMember>    taskMembers    = new List <TaskMember>();
                TaskItem             task           = new TaskItem();
                task.ChecklistId = checklistId;
                task.DueTime     = DateTime.ParseExact(item.DueTime, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);
                task.Name        = item.Name;
                task.Priority    = item.Priority;
                //task.TaskStatus = item.TaskStatus;
                task.TaskStatus = "Template";
                context.TaskItem.Add(task);
                context.SaveChanges();
                var getTask = context.TaskItem.Where(t => t.Name.Equals(item.Name) && t.DueTime.Equals(task.DueTime) && t.TaskStatus.Equals("Template")).FirstOrDefault();
                var i       = 1;
                foreach (var content in item.ContentDetails)
                {
                    if (content.Id != 0)
                    {
                        ContentDetail detail = new ContentDetail();
                        detail.ImageSrc     = content.ImageSrc;
                        detail.Label        = content.Label;
                        detail.OrderContent = i;
                        detail.TaskItemId   = getTask.Id;
                        detail.Text         = content.Text;
                        detail.Type         = content.Type;
                        contentDetails.Add(detail);
                    }
                    i++;
                }
                foreach (var user in item.UserId)
                {
                    TaskMember member = new TaskMember();
                    member.UserId = user.Id;
                    member.TaskId = getTask.Id;
                    taskMembers.Add(member);
                }
                context.ContentDetail.AddRange(contentDetails);
                context.TaskMember.AddRange(taskMembers);
                context.SaveChanges();

                //context.Task
            }
        }
Esempio n. 26
0
        public static IMongoQuery CreateQuery(this IParameter parameter)
        {
            if (parameter is ParameterCollection)
            {
                var pc = parameter as ParameterCollection;
                switch (pc.Operator)
                {
                case Operator.And:
                    return(Query.And(pc.Select(p => p.CreateQuery())));

                case Operator.Or:
                    return(Query.Or(pc.Select(p => p.CreateQuery())));

                case Operator.None:
                default:
                    throw new NotSupportedException();
                }
            }
            else if (parameter is Parameter)
            {
                var p = (Parameter)parameter;

                if (p.IsDetail)
                {
                    var valueExpression = GetValueExpression(p.Comparison.HasFlag(Comparison.In)
                                                ? ContentDetail.GetAssociatedEnumerablePropertyName(p.Value as IEnumerable)
                                                : ContentDetail.GetAssociatedPropertyName(p.Value), p.Comparison, p.Value);
                    var detailExpression = (p.Name == null)
                                                ? valueExpression
                                                : Query.And(
                        Query.EQ("Name", p.Name),
                        valueExpression);

                    return(Query.Or(
                               Query.ElemMatch("Details", detailExpression),
                               Query.ElemMatch("DetailCollections.Details", detailExpression)));
                }

                p.Name = p.Name.TranslateProperty();

                return(GetValueExpression(p.Name, p.Comparison, p.Value));
            }
            throw new NotSupportedException();
        }
Esempio n. 27
0
        internal ContentDetail ReadMultipleValue(XPathNavigator navigator, ContentItem item, ReadingJournal journal, string name)
        {
            var multiDetail = ContentDetail.Multi(name);

            foreach (XPathNavigator valueElement in EnumerateChildren(navigator))
            {
                switch (valueElement.GetAttribute("key", ""))
                {
                case ContentDetail.TypeKeys.BoolType:
                    multiDetail.BoolValue = (bool)Parse(valueElement.Value, typeof(bool));
                    break;

                case ContentDetail.TypeKeys.DateTimeType:
                    multiDetail.DateTimeValue = (DateTime)Parse(valueElement.Value, typeof(DateTime));
                    break;

                case ContentDetail.TypeKeys.DoubleType:
                    multiDetail.DoubleValue = (double)Parse(valueElement.Value, typeof(double));
                    break;

                case ContentDetail.TypeKeys.IntType:
                    multiDetail.IntValue = (int)Parse(valueElement.Value, typeof(int));
                    break;

                case ContentDetail.TypeKeys.LinkType:
                    SetLinkedItem(valueElement.Value, journal, (referencedItem) => multiDetail.LinkedItem = referencedItem);
                    break;

                case ContentDetail.TypeKeys.MultiType:
                    journal.Error(new InvalidOperationException("Nested multi types not supported"));
                    break;

                case ContentDetail.TypeKeys.ObjectType:
                    multiDetail.ObjectValue = Parse(valueElement.Value, typeof(object));
                    break;

                case ContentDetail.TypeKeys.StringType:
                    multiDetail.StringValue = (string)PrepareStringDetail(item, name, valueElement.Value);
                    break;
                }
            }
            return(multiDetail);
        }
Esempio n. 28
0
        public ResResultModel GetContentDetailList(ListModel model)
        {
            try
            {
                if (model.PageIndex < 1)
                {
                    model.PageIndex = 1;
                }
                if (model.PageSize < 1)
                {
                    model.PageSize = 10;
                }
                int totalRecord = 0;
                var bll         = new ContentDetail();

                IList <ContentDetailInfo> list = null;

                StringBuilder sqlWhere = null;
                ParamsHelper  parms    = null;
                if (!string.IsNullOrWhiteSpace(model.Keyword))
                {
                    sqlWhere = new StringBuilder(1000);
                    parms    = new ParamsHelper();
                    sqlWhere.Append("and (p.Title+p.Keyword+p.Descr) like @Keyword ");
                    parms.Add(new SqlParameter("@Keyword", "%" + model.Keyword + "%"));
                }
                var contentTypeId = Guid.Empty;
                if (model.ParentId != null && Guid.TryParse(model.ParentId.ToString(), out contentTypeId))
                {
                    list = bll.GetListByContentType(model.PageIndex, model.PageSize, out totalRecord, contentTypeId, sqlWhere == null ? null : sqlWhere.ToString(), parms == null ? null : parms.ToArray());
                }
                else
                {
                    list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere == null ? null : sqlWhere.ToString(), parms == null ? null : parms.ToArray());
                }

                return(ResResult.Response(true, "", "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}"));
            }
            catch (Exception ex)
            {
                return(ResResult.Response(false, ex.Message, ""));
            }
        }
Esempio n. 29
0
        /// <summary>Finds links in a html string using regular expressions.</summary>
        /// <param name="html">The html to search for links.</param>
        /// <returns>A list of link (a) href attributes in the supplied html string.</returns>
        public virtual IList <ContentDetail> FindLinks(string html)
        {
            List <ContentDetail> links   = new List <ContentDetail>();
            MatchCollection      matches = linkExpression.Matches(html);

            foreach (Match m in matches)
            {
                var g = m.Groups["link"];
                if (g.Success)
                {
                    links.Add(ContentDetail.Multi(LinkDetailName, true, g.Index, null, null, g.Value, null, null));
                }
            }
            if (links.Count == 0 && !html.Contains(Environment.NewLine) && (html.StartsWith("/") || Regex.IsMatch(html, "^\\w+://", RegexOptions.Compiled | RegexOptions.IgnoreCase)))
            {
                links.Add(ContentDetail.Multi(LinkDetailName, false, 0, null, null, html, null, null));
            }
            return(links);
        }
Esempio n. 30
0
        protected virtual void ReadDetail(XPathNavigator navigator, DetailCollection collection, ReadingJournal journal)
        {
            Dictionary <string, string> attributes = GetAttributes(navigator);
            Type type = Utility.TypeFromName(attributes["typeName"]);

            if (type == typeof(ContentItem))
            {
                int         referencedItemID = int.Parse(navigator.Value);
                ContentItem referencedItem   = journal.Find(referencedItemID);
                if (referencedItem != null)
                {
                    collection.Add(ContentDetail.New(
                                       collection.EnclosingItem,
                                       attributes["name"],
                                       referencedItem));
                }
                else
                {
                    journal.ItemAdded += delegate(object sender, ItemEventArgs e)
                    {
                        if (e.AffectedItem.ID == referencedItemID)
                        {
                            collection.Add(ContentDetail.New(
                                               collection.EnclosingItem,
                                               attributes["name"],
                                               e.AffectedItem));
                        }
                    };
                }
            }
            else if (type == typeof(IMultipleValue))
            {
                detailReader.ReadMultipleValue(navigator, collection.EnclosingItem, journal, collection.Name).AddTo(collection);
            }
            else
            {
                collection.Add(ContentDetail.New(
                                   collection.EnclosingItem,
                                   attributes["name"],
                                   Parse(navigator.Value, type)));
            }
        }