コード例 #1
0
        public List <SourceObject> UnAssociatedSources(SourceObjectType type)
        {
            using (var context = new ApplicationDbContext()) {
                switch (type)
                {
                case SourceObjectType.Campaign:
                    var campaignsQ = from vc in context.ApplicationVideoSourceCampaigns
                                     join c in context.SourceCampaigns on vc.CampaignId equals c.Id
                                     select c;
                    return(context.SourceCampaigns.Except(campaignsQ)
                           .Select(SourceCampaignObject).ToList());

                case SourceObjectType.AdSet:

                    var adsetsQ = from vc in context.ApplicationPersonaVersionSourceAdSets
                                  join c in context.SourceAdSets on vc.AdSetId equals c.Id
                                  select c;
                    return(context.SourceAdSets.Except(adsetsQ)
                           .Select(SourceAdSetObject).ToList());

                case SourceObjectType.Video:
                    var sourceVideosQ = from avsv in context.ApplicationVideoSourceVideos
                                        join sv in context.SourceVideos on avsv.SourceVideoId equals sv.Id
                                        select sv;
                    return(context.SourceVideos.Except(sourceVideosQ)
                           .Select(SourceVideoObject).ToList());

                default:
                    throw new Exception("Unsupported Source Type");
                }
            }
        }
コード例 #2
0
        private void Parent_OnObjectSelectEvent(object sender, ObjectSelectEventArgs e)
        {
            Cursor cursor = Cursor.Current;

            try
            {
                Cursor.Current = Cursors.WaitCursor;

                object selectedObject = e.SelectedObject;
                if (selectedObject != null)
                {
                    if (Visible)
                    {
                        if (SourceObjectType.Equals(selectedObject.GetType()))
                        {
                            SourceObject = selectedObject;
                            ProcessView();
                        }
                    }
                }
            }
            finally
            {
                Cursor.Current = cursor;
            }
        }
コード例 #3
0
        private void ListView_FormatCell(object sender, FormatCellEventArgs e)
        {
            object item = e.Model;

            if (item != null)
            {
                PropertyInfo p = item.GetType().GetProperty("IsArchived");
                if (p != null && p.PropertyType == typeof(bool) && (bool)(p.GetValue(item)) == true)
                {
                    e.SubItem.ForeColor = Color.Gray;
                }
                else
                {
                    if (e.Column.AspectName == null)
                    {
                        return;
                    }
                    Type         pType       = AttrHelper.GetPropertyType(SourceObjectType, e.Column.AspectName);
                    PropertyInfo propInfo    = SourceObjectType.GetProperty(e.Column.AspectName);
                    JExpired     expiredProp = AttrHelper.GetAttribute <JExpired>(propInfo);
                    if (expiredProp != null)
                    {
                        object propValue = null;
                        if (expiredProp.ExpiredProperty != null)
                        {
                            PropertyInfo propInfo1 = SourceObjectType.GetProperty(expiredProp.ExpiredProperty);
                            if (propInfo1 != null)
                            {
                                propValue = AttrHelper.GetPropertyValue(e.Model, propInfo1);
                            }
                        }
                        else
                        {
                            propValue = AttrHelper.GetPropertyValue(e.Model, propInfo);
                        }
                        if (propValue != null)
                        {
                            ModelHelper.ExpiredToColor(propValue.ToString(), e.SubItem.ForeColor);
                        }
                    }
                    else
                    {
                        JDictProp dictProp = AttrHelper.GetAttribute <JDictProp>(propInfo);
                        if (dictProp != null &&
                            (dictProp.DictPropertyStyle == DisplyPropertyStyle.ColoredTextOnly || dictProp.DictPropertyStyle == DisplyPropertyStyle.ColoredTextAndImage))
                        {
                            object propValue = AttrHelper.GetPropertyValue(e.Model, propInfo);
                            if (propValue != null)
                            {
                                JDictItem ditem = Dm.Instance.GetDictText(dictProp.Id, propValue.ToString());
                                if (ditem != null && ditem.TextColor != null && ditem.TextColor != Color.Black)
                                {
                                    e.SubItem.ForeColor = ditem.TextColor;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        public static SourceObject GenerateSourceObject(string id, SourceObjectType type, string source)
        {
            string name;

            switch (type)
            {
            case SourceObjectType.Campaign:
                name = "Campaign Title " + id;
                break;

            case SourceObjectType.AdSet:
                name = "AdSet Title " + id;
                break;

            case SourceObjectType.Video:
                name = "Video Title " + id;
                break;

            default:
                throw new Exception("no source");
            }
            return(new SourceObject {
                SourceId = id,
                Type = type,
                SourceName = source,
                Title = name,
                Links = new List <SourceLink>()
                {
                    new SourceLink {
                        Type = SourceLinkType.Content,
                        Link = "https://fee.org",
                    }
                },
            });
        }
コード例 #5
0
        public bool SaveChanges()
        {
            JValidationResult result = Dm.Instance.ValidateObject(tempSourceObject);

            if (!result.isError)
            {
                Dm.CopyObjectProperties(tempSourceObject, sourceObject, CopyRestrictLevel.AllPropertiesNewLists);
                if (AttrHelper.IsAttributeDefinedForType <JEntity>(SourceObjectType, true))
                {
                    Dm.Instance.SaveObject(sourceObject);
                    if (ViewMode == ViewMode.New && CloningObject != null)
                    {
                        MethodInfo cloneDependenciesMethod = SourceObjectType.GetMethod("CloneDependencies");
                        if (cloneDependenciesMethod != null)
                        {
                            DialogResult res = MessageBox.Show("Clone dependencies?", FrwConstants.WARNING, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                            if (res == DialogResult.Yes)
                            {
                                object cdResult = cloneDependenciesMethod.Invoke(null, new object[] { CloningObject, sourceObject });//Pass null as the first argument (no need for an instance)
                            }
                        }
                    }
                }
                SetModified(false);
                ChildObjectUpdateEventArgs ev = new ChildObjectUpdateEventArgs();
                ev.UpdatedObject = sourceObject;
                OnPropertyObjectUpdate(ev);
                if (ViewMode == ViewMode.New)
                {
                    ViewMode = ViewMode.Edit;
                }
                return(true);
            }
            else
            {
                AppManager.ShowValidationErrorMessage(result);
                return(false);
            }
        }
コード例 #6
0
        static List <SourceObject> StaticUnAssociatedSources(SourceObjectType type)
        {
            var associated = Videos.SelectMany(x => x.Sources != null ? x.Sources.SelectMany(y => y.SourceObjects) : new List <SourceObject>());

            return(SourceObjects.Where(x => x.Type == type && !associated.Contains(x)).ToList());
        }
コード例 #7
0
 public List <SourceObject> UnAssociatedSources(SourceObjectType type)
 {
     return(StaticUnAssociatedSources(type));
 }
コード例 #8
0
 public List <SourceObject> GetUnassociatedSources(SourceObjectType type)
 {
     return(Backend.UnAssociatedSources(type));
 }