Exemplo n.º 1
0
 /// <summary>
 /// Method that removes the selected activity from the ActivityList, called by the equivalent command.
 /// </summary>
 private void RemoveActivity()
 {
     if (ActivityList.Count > 0 && ActivityList.Contains(SelectedActivity))
     {
         ActivityList.Remove(SelectedActivity);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Method that edit the selected activity from the ActivityList, called by the equivalent command.
        /// </summary>
        private async void EditActivity()
        {
            if (SelectedActivity != null && ActivityList.Contains(SelectedActivity))
            {
                int Index = ActivityList.IndexOf(SelectedActivity);
                _inserted = false;
                await AddActivity(Index);

                if (_inserted)
                {
                    ActivityList.Remove(SelectedActivity);
                }
            }
        }
Exemplo n.º 3
0
        public CodeWriterFilterService(ICodeWriterFilterService defaultService)
        {
            Console.WriteLine("Initializing CodeWriterFilterService.");

            ActivityList     = ServiceHelper.ActivityLogicalNames();
            DefaultService   = defaultService;
            EntityBlackList  = new List <string>();
            EntityWhiteList  = new List <string>();
            FieldBlackList   = new List <string>();
            OptionList       = new List <string>();
            OptionSetList    = new List <string>();
            RelationshipList = new List <string>();

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.EntityBlackList))
            {
                string[] entities = Properties.Settings.Default.EntityBlackList.Split(",".ToCharArray());
                if (entities.Length > 0)
                {
                    EntityBlackList = entities.ToList();
                }
            }

            if (!Properties.Settings.Default.GenerateAllEntities)
            {
                XElement xmlDocument     = XElement.Load(Properties.Settings.Default.EntityWhiteListFilename);
                XElement entitiesElement = xmlDocument.Element("entities");

                if (entitiesElement == null)
                {
                    throw new InvalidProgramException("Entities XML file is missing the 'entities' element.");
                }

                if (entitiesElement.Elements("entity").ToList().Count == 0)
                {
                    throw new InvalidProgramException("Entities XML file does not contain any entities.");
                }

                bool entityWhiteListContainsActivity = false;

                foreach (XElement entityElement in entitiesElement.Elements("entity"))
                {
                    string entityName = Regex.Replace(entityElement.Value, @"[^a-zA-Z0-9_]", string.Empty).ToLowerInvariant();
                    if (!string.IsNullOrWhiteSpace(entityName))
                    {
                        EntityWhiteList.Add(entityName);
                    }
                    if (ActivityList.Contains(entityName))
                    {
                        entityWhiteListContainsActivity = true;
                    }
                }

                if (entityWhiteListContainsActivity)
                {
                    if (!EntityWhiteList.Contains(ServiceHelper.ActivityPartyLogicalName))
                    {
                        EntityWhiteList.Add(ServiceHelper.ActivityPartyLogicalName);
                    }
                    if (!EntityWhiteList.Contains(ServiceHelper.ActivityPointerLogicalName))
                    {
                        EntityWhiteList.Add(ServiceHelper.ActivityPointerLogicalName);
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(Properties.Settings.Default.GlobalFieldBlackList))
            {
                string[] fields = Properties.Settings.Default.GlobalFieldBlackList.Split(",".ToCharArray());
                if (fields.Length > 0)
                {
                    FieldBlackList = fields.ToList();
                }
            }

            // Debugging: Uncomment the below lines of code - run the generate batch file, set the break points and
            // attach the debugger on CrmSvcUtil.exe process. Then press enter to start your debugging.
            //Console.WriteLine("CodeWriterFilterService attach debugger and press enter.");
            //Console.ReadLine();

            Console.WriteLine("CodeWriterFilterService initialized successfully.");
        }