예제 #1
0
        static void Main(string[] args)
        {
            TypeQueryField<DateTime> q = new TypeQueryField<DateTime>("date");
            CAMLExpression<object> exp = q.LessEqual(DateTime.Now);
            exp &= q.MoreEqual(DateTime.Now.AddDays(-1));

            string rs=CAMLBuilder.Where(exp);
        }
예제 #2
0
        private void TRReportDataBind(DateTime dateFrom, DateTime dateTo)
        {
            SPList travelRequestList = SPContext.Current.Web.Lists[WorkflowListName.TravelRequestWorkflow2];
            TypeQueryField<DateTime> queryField = new TypeQueryField<DateTime>("Created");

            //SPUtility.FormatDate(SPContext.Current.Web, dateFrom, SPDateFormat.DateOnly)
            CAMLExpression<object> exp = queryField.MoreEqual(dateFrom);

            exp &= queryField.LessEqual(dateTo);

            SPQuery query = new SPQuery();
            query.Query = CAMLBuilder.Where(exp);

            SPListItemCollection items = travelRequestList.GetItems(query);

            if (items.Count > 0)
            {
                SPGridView1.DataSource = GetDataSource(items);
            }
            else
            {
                SPGridView1.DataSource = null;
            }
            SPGridView1.DataBind();
        }
예제 #3
0
파일: WF.cs 프로젝트: porter1130/MyTest
        public override bool FindLockedWorkflow()
        {
            bool hasLockedWF = false;

            Dictionary<int, string> taskLockDict = new Dictionary<int, string>(), exceptionLockDict = new Dictionary<int, string>();

            TypeQueryField<DateTime> queryField = new TypeQueryField<DateTime>("Created");

            CAMLExpression<object> exp = queryField.MoreEqual(DateTime.Now.AddDays(Constants.WF_Lastest_Days));

            SPListItemCollection items = ListQuery.Select()
                                                .From(context.CurrList)
                                                .Where(exp).GetItems();
            SPWorkflowManager wfManager = context.Currweb.Site.WorkflowManager;
            #region find Locked workflow list item
            foreach (SPListItem item in items)
            {
                foreach (SPWorkflow workflow in wfManager.GetItemActiveWorkflows(item))
                {
                    if (item.ParentList.WorkflowAssociations[workflow.AssociationId].Name.Equals(context.WfName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (workflow.IsLocked
                            || IsErrorOccured(item[context.CurrList.WorkflowAssociations[workflow.AssociationId].Name].AsString()))
                        {
                            RegisterLock(item, exceptionLockDict);
                            AddExceptionList(GetWFKey(item.ID, item.ParentList.Title), workflow.Tasks);
                            continue;
                        }

                        foreach (SPWorkflowTask task in workflow.Tasks)
                        {
                            if (task[SPBuiltInFieldId.WorkflowVersion].AsString() != "1")
                            {
                                RegisterLock(item, taskLockDict);
                                AddExceptionList(GetWFKey(item.ID, item.ParentList.Title), workflow.Tasks);
                                break;
                            }
                        }
                    }
                }

            }
            #endregion

            #region generate email notisfication
            context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P);
            context.HtmlWriter.Write("Scanning List {0}", context.CurrList.Title);
            context.HtmlWriter.WriteBreak();
            if (taskLockDict != null
                && taskLockDict.Count > 0)
            {
                context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P);
                context.HtmlWriter.Write("There are {0} task locked item.", taskLockDict.Count);
                context.HtmlWriter.WriteBreak();
                foreach (KeyValuePair<int, string> kvp in taskLockDict)
                {
                    context.HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, kvp.Value);
                    context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.A);
                    context.HtmlWriter.Write(" {0} ", kvp.Key);
                    context.HtmlWriter.RenderEndTag();
                }
                context.HtmlWriter.RenderEndTag();
                hasLockedWF = true;
            }
            else
            {
                context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P);
                context.HtmlWriter.Write("There are not task locked items.");
                context.HtmlWriter.WriteBreak();
            }

            if (exceptionLockDict != null
                && exceptionLockDict.Count > 0)
            {
                context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P);
                context.HtmlWriter.Write("There are {0} exception locked item.", exceptionLockDict.Count);
                context.HtmlWriter.WriteBreak();
                foreach (KeyValuePair<int, string> kvp in exceptionLockDict)
                {
                    context.HtmlWriter.AddAttribute(HtmlTextWriterAttribute.Href, kvp.Value);
                    context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.A);
                    context.HtmlWriter.Write(" {0} ", kvp.Key);
                    context.HtmlWriter.RenderEndTag();
                }
                context.HtmlWriter.RenderEndTag();
                hasLockedWF = true;
            }
            else
            {
                context.HtmlWriter.RenderBeginTag(HtmlTextWriterTag.P);
                context.HtmlWriter.Write("There are not exception locked items.");
                context.HtmlWriter.WriteBreak();
            }
            context.HtmlWriter.RenderEndTag();
            #endregion

            return hasLockedWF;
        }