Beispiel #1
0
        /// <summary>
        /// Gens the source.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="totalCount">The total count.</param>
        /// <returns></returns>
        private DataTable genSource(string text, out int totalCount)
        {
            DataTable dt = new DataTable();

            dt.Locale = CultureInfo.InvariantCulture;
            dt.Columns.Add(new DataColumn("PrimaryKeyId", typeof(int)));
            dt.Columns.Add(new DataColumn(TitleFieldName, typeof(string)));
            MetaClass mc = MetaDataWrapper.ResolveMetaClassByNameOrCardName(ClassName);

            FilterElementCollection fec = new FilterElementCollection();

            fec.Add(new FilterElement(mc.TitleFieldName, FilterElementType.Contains, text));
            if (!String.IsNullOrEmpty(CardFilter))
            {
                string[] mas = CardFilter.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                if (mas.Length > 0)
                {
                    OrBlockFilterElement fe = new OrBlockFilterElement();
                    foreach (string sCard in mas)
                    {
                        fe.ChildElements.Add(FilterElement.EqualElement("Card", sCard.Trim()));
                    }
                    fec.Add(fe);
                }
            }

            MetaObject[] list = MetaObject.List(mc,
                                                fec,
                                                new SortingElementCollection(SortingElement.Ascending(mc.TitleFieldName)));
            int count = 0;

            foreach (MetaObject bo in list)
            {
                DataRow row = dt.NewRow();
                row["PrimaryKeyId"] = bo.PrimaryKeyId;
                row[TitleFieldName] = bo.Properties[mc.TitleFieldName].Value.ToString();
                dt.Rows.Add(row);
                count++;
                if (count > 10)
                {
                    break;
                }
            }
            totalCount = list.Length;

            return(dt);
        }
Beispiel #2
0
        /// <summary>
        /// Customs the method.
        /// </summary>
        /// <param name="context">The context.</param>
        protected virtual void SetDefaultAddress(BusinessContext context)
        {
            // Load Address
            MetaObject newDefaultAddress = MetaObjectActivator.CreateInstance(AddressEntity.GetAssignedMetaClassName(),
                                                                              context.GetTargetPrimaryKeyId().Value);


            if (newDefaultAddress["ContactId"] != null)
            {
                // Find default addresses
                MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
                                                                  FilterElement.EqualElement("ContactId", newDefaultAddress["ContactId"]),
                                                                  FilterElement.EqualElement("IsDefaultContactElement", true));

                // Reset default addresses
                foreach (MetaObject defaultAddress in defaultAddressList)
                {
                    defaultAddress["IsDefaultContactElement"] = false;
                    defaultAddress.Save();
                }

                // Set default address
                newDefaultAddress["IsDefaultContactElement"] = true;
                newDefaultAddress.Save();
            }
            else if (newDefaultAddress["OrganizationId"] != null)
            {
                // Find default addresses
                MetaObject[] defaultAddressList = MetaObject.List(DataContext.Current.GetMetaClass(AddressEntity.GetAssignedMetaClassName()),
                                                                  FilterElement.EqualElement("OrganizationId", newDefaultAddress["OrganizationId"]),
                                                                  FilterElement.EqualElement("IsDefaultOrganizationElement", true));

                // Reset default addresses
                foreach (MetaObject defaultAddress in defaultAddressList)
                {
                    defaultAddress["IsDefaultOrganizationElement"] = false;
                    defaultAddress.Save();
                }

                // Set default address
                newDefaultAddress["IsDefaultOrganizationElement"] = true;
                newDefaultAddress.Save();
            }

            context.SetResponse(new Response());
        }
Beispiel #3
0
 public static Report[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting)
 {
     return(MetaObject.List <Report>(Report.GetAssignedMetaClass(), filters, sorting));
 }
Beispiel #4
0
 public static ListInfo[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <ListInfo>(ListInfo.GetAssignedMetaClass(), sorting));
 }
Beispiel #5
0
 public static ListInfo[] List()
 {
     return(MetaObject.List <ListInfo>(ListInfo.GetAssignedMetaClass()));
 }
Beispiel #6
0
 public static CalendarEvent[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <CalendarEvent>(CalendarEvent.GetAssignedMetaClass(), sorting));
 }
Beispiel #7
0
 public static CalendarEvent[] List()
 {
     return(MetaObject.List <CalendarEvent>(CalendarEvent.GetAssignedMetaClass()));
 }
Beispiel #8
0
 public static CalendarFolder[] List()
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass()));
 }
Beispiel #9
0
 public static Folder[] List()
 {
     return(MetaObject.List <Folder>(Folder.GetAssignedMetaClass()));
 }
 public static TimeTrackingBlock[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting)
 {
     return(MetaObject.List <TimeTrackingBlock>(TimeTrackingBlock.GetAssignedMetaClass(), filters, sorting));
 }
 public static CalendarEventRecurrence[] List()
 {
     return(MetaObject.List <CalendarEventRecurrence>(CalendarEventRecurrence.GetAssignedMetaClass()));
 }
Beispiel #12
0
 public static Principal[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting)
 {
     return(MetaObject.List <Principal>(Principal.GetAssignedMetaClass(), filters, sorting));
 }
Beispiel #13
0
 public static Principal[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <Principal>(Principal.GetAssignedMetaClass(), sorting));
 }
Beispiel #14
0
 public static Principal[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <Principal>(Principal.GetAssignedMetaClass(), filters));
 }
Beispiel #15
0
 public static Principal[] List()
 {
     return(MetaObject.List <Principal>(Principal.GetAssignedMetaClass()));
 }
Beispiel #16
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(string));
            dt.Columns.Add("Name", typeof(string));

            string sSearch = tbSearchString.Text.Trim();

            FilterElementCollection fec = new FilterElementCollection();

            if (!String.IsNullOrEmpty(Request["filterName"]) && !String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe   = FilterElement.EqualElement(Request["filterName"], Request["filterValue"]);
                FilterElement fe1  = FilterElement.IsNullElement(Request["filterName"]);
                FilterElement feOr = new OrBlockFilterElement();
                feOr.ChildElements.Add(fe);
                feOr.ChildElements.Add(fe1);
                fec.Add(feOr);
            }
            else if (!String.IsNullOrEmpty(Request["filterName"]) && String.IsNullOrEmpty(Request["filterValue"]))
            {
                FilterElement fe = FilterElement.IsNullElement(Request["filterName"]);
                fec.Add(fe);
            }

            MetaObject[] list = MetaObject.List(mc, fec.ToArray());

            foreach (MetaObject obj in list)
            {
                DataRow row = dt.NewRow();
                row["Id"] = obj.PrimaryKeyId.ToString();
                if (obj.Properties[mc.TitleFieldName].Value != null)
                {
                    row["Name"] = CHelper.GetResFileString(obj.Properties[mc.TitleFieldName].Value.ToString());
                }
                dt.Rows.Add(row);
            }

            if (ViewState["SelectItem_Sort"] == null)
            {
                ViewState["SelectItem_Sort"] = "Name";
            }
            if (ViewState["SelectItem_CurrentPage"] == null)
            {
                ViewState["SelectItem_CurrentPage"] = 0;
            }
            if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize)
            {
                grdMain.AllowPaging = false;
            }
            else
            {
                grdMain.AllowPaging = true;
            }
            DataView dv = dt.DefaultView;

            if (sSearch != String.Empty)
            {
                dv.RowFilter = String.Format(CultureInfo.InvariantCulture, "Name LIKE '%{0}%'", sSearch);
            }
            dv.Sort = ViewState["SelectItem_Sort"].ToString();
            if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging)
            {
                grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"];
            }
            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (DataGridItem dgi in grdMain.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibRelate");
                if (ib != null)
                {
                    string sId     = dgi.Cells[0].Text;
                    string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId));
                    ib.Attributes.Add("onclick", sAction);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(int));
            dt.Columns.Add("Name", typeof(string));

            string sSearch = tbSearchString.Text.Trim();

            MetaObject[] list;
            if (sSearch == String.Empty)
            {
                list = MetaObject.List(mc);
            }
            else
            {
                FilterElement filter = new FilterElement(mc.TitleFieldName, FilterElementType.Like, "%" + sSearch + "%");
                list = MetaObject.List(mc, filter);
            }

            foreach (MetaObject obj in list)
            {
                DataRow row = dt.NewRow();
                row["Id"]   = obj.PrimaryKeyId;
                row["Name"] = obj.Properties[mc.TitleFieldName].Value.ToString();
                dt.Rows.Add(row);
            }

            if (ViewState["SelectItem_Sort"] == null)
            {
                ViewState["SelectItem_Sort"] = "Name";
            }
            if (ViewState["SelectItem_CurrentPage"] == null)
            {
                ViewState["SelectItem_CurrentPage"] = 0;
            }
            if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize)
            {
                grdMain.AllowPaging = false;
            }
            else
            {
                grdMain.AllowPaging = true;
            }
            DataView dv = dt.DefaultView;

            dv.Sort = ViewState["SelectItem_Sort"].ToString();
            if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging)
            {
                grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"];
            }
            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (DataGridItem dgi in grdMain.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibRelate");
                if (ib != null)
                {
                    string sId     = dgi.Cells[0].Text;
                    string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId));
                    ib.Attributes.Add("onclick", sAction);
                }
            }
        }
Beispiel #18
0
 public static Folder[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <Folder>(Folder.GetAssignedMetaClass(), filters));
 }
Beispiel #19
0
 public static CalendarFolder[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting)
 {
     return(MetaObject.List <CalendarFolder>(CalendarFolder.GetAssignedMetaClass(), filters, sorting));
 }
Beispiel #20
0
 public static Folder[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <Folder>(Folder.GetAssignedMetaClass(), sorting));
 }
Beispiel #21
0
 public static CalendarEvent[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <CalendarEvent>(CalendarEvent.GetAssignedMetaClass(), filters));
 }
 public static TimeTrackingBlockType[] List()
 {
     return(MetaObject.List <TimeTrackingBlockType>(TimeTrackingBlockType.GetAssignedMetaClass()));
 }
Beispiel #23
0
 public static CalendarEvent[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count)
 {
     return(MetaObject.List <CalendarEvent>(CalendarEvent.GetAssignedMetaClass(), filters, sorting, start, count));
 }
 public static TimeTrackingBlockType[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <TimeTrackingBlockType>(TimeTrackingBlockType.GetAssignedMetaClass(), filters));
 }
Beispiel #25
0
 public static ListInfo[] List(params Mediachase.Ibn.Data.FilterElement[] filters)
 {
     return(MetaObject.List <ListInfo>(ListInfo.GetAssignedMetaClass(), filters));
 }
 public static TimeTrackingBlockType[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <TimeTrackingBlockType>(TimeTrackingBlockType.GetAssignedMetaClass(), sorting));
 }
Beispiel #27
0
 public static ListInfo[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count)
 {
     return(MetaObject.List <ListInfo>(ListInfo.GetAssignedMetaClass(), filters, sorting, start, count));
 }
 public static TimeTrackingBlockType[] List(Mediachase.Ibn.Data.FilterElementCollection filters, Mediachase.Ibn.Data.SortingElementCollection sorting, int start, int count)
 {
     return(MetaObject.List <TimeTrackingBlockType>(TimeTrackingBlockType.GetAssignedMetaClass(), filters, sorting, start, count));
 }
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("Id", typeof(PrimaryKeyId));
            dt.Columns.Add("Name", typeof(string));

            string sSearch = tbSearchString.Text.Trim();

            MetaClass mc = MetaDataWrapper.GetMetaClassByName(ddClasses.SelectedValue);

            if (mc == null)
            {
                return;
            }

            MetaObject[] list = MetaObject.List(mc);

            foreach (MetaObject obj in list)
            {
                DataRow row = dt.NewRow();
                row["Id"]   = obj.PrimaryKeyId.Value;
                row["Name"] = CHelper.GetResFileString(obj.Properties[mc.TitleFieldName].Value.ToString());
                dt.Rows.Add(row);
            }

            if (ViewState["SelectItem_Sort"] == null)
            {
                ViewState["SelectItem_Sort"] = "Name";
            }
            if (ViewState["SelectItem_CurrentPage"] == null)
            {
                ViewState["SelectItem_CurrentPage"] = 0;
            }
            if (dt.Rows != null && dt.Rows.Count < grdMain.PageSize)
            {
                grdMain.AllowPaging = false;
            }
            else
            {
                grdMain.AllowPaging = true;
            }
            DataView dv = dt.DefaultView;

            if (sSearch != String.Empty)
            {
                dv.RowFilter = String.Format(CultureInfo.InvariantCulture, "Name LIKE '%{0}%'", sSearch);
            }
            dv.Sort = ViewState["SelectItem_Sort"].ToString();
            if (ViewState["SelectItem_CurrentPage"] != null && grdMain.AllowPaging)
            {
                grdMain.CurrentPageIndex = (int)ViewState["SelectItem_CurrentPage"];
            }
            grdMain.DataSource = dv;
            grdMain.DataBind();

            foreach (DataGridItem dgi in grdMain.Items)
            {
                ImageButton ib = (ImageButton)dgi.FindControl("ibRelate");
                if (ib != null)
                {
                    string sId     = ddClasses.SelectedValue + "_" + dgi.Cells[0].Text;
                    string sAction = CHelper.GetCloseRefreshString(RefreshButton.Replace("xxx", sId));
                    ib.Attributes.Add("onclick", sAction);
                }
            }
        }
Beispiel #30
0
 public static Report[] List(params Mediachase.Ibn.Data.SortingElement[] sorting)
 {
     return(MetaObject.List <Report>(Report.GetAssignedMetaClass(), sorting));
 }