private void Create(CreationType creationType)
 {
     if (IsFormValid(creationType))
     {
         ExecuteMethod(CreateCode, creationType);
     }
 }
Esempio n. 2
0
        public DeadlineActivity(string name,
                                string description,
                                Color color,
                                CreationType creationType,
                                IEnumerable <Label> labels,
                                Category category,
                                string userId,
                                DateTime start,
                                DateTime end,
                                List <Milestone> milestones,
                                bool baseActivity)
            : base(name,
                   description,
                   color,
                   creationType,
                   labels,
                   category,
                   userId,
                   ActivityType.DeadlineActivity,
                   baseActivity)
        {
            if (start >= end)
            {
                throw new ArgumentException("Start, End");
            }

            this.Start      = start;
            this.End        = end;
            this.Milestones = milestones ?? new List <Milestone>();
        }
Esempio n. 3
0
        private static bool IsValidPath(CreationType creationType, CreationType creationTypeToCheck, TextBox textPath, CheckBox chk, string name)
        {
            if (creationType != creationTypeToCheck && creationType != CreationType.All)
            {
                return(true);
            }
            var isValid           = true;
            var containsExtension = !string.IsNullOrWhiteSpace(Path.GetExtension(textPath.Text));

            // Validate Path
            if (chk.Checked)
            {
                if (containsExtension)
                {
                    MessageBox.Show(name + @" path must be a directory!", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    isValid = false;
                }
            }
            else
            {
                if (!containsExtension)
                {
                    MessageBox.Show(name + @" path must be a file!", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    isValid = false;
                }
            }
            return(isValid);
        }
Esempio n. 4
0
        private string GetOutputFilePath(Config config, CreationType creationType)
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var filePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), Config.GetSettingValue(creationType, Config.UserArgumentNames.Out));

            if (creationType == CreationType.Actions && config.ExtensionConfig.CreateOneFilePerAction)
            {
                filePath = Path.Combine(filePath, "Actions.cs");
            }
            else if (creationType == CreationType.Entities && config.ExtensionConfig.CreateOneFilePerEntity)
            {
                var entities = config.ServiceContextName;

                if (string.IsNullOrWhiteSpace(entities))
                {
                    entities = "Entities";
                }

                filePath = Path.Combine(filePath, entities + ".cs");
            }
            else if (creationType == CreationType.OptionSets && config.ExtensionConfig.CreateOneFilePerOptionSet)
            {
                filePath = Path.Combine(filePath, "OptionSets.cs");
            }

            return(filePath);
        }
Esempio n. 5
0
        public void CreatePerson(DataManager datamanager, Random random, CreationType creationType)
        {
            personID = datamanager.getRandomID(random);

            //choose gender randomly
            if (random.Next(1, 3) == 1)
            {
                personGender = Gender.Male;
            }
            else
            {
                personGender = Gender.Female;
            }

            //get person first name
            getFirstName(datamanager, random);
            //get person last name
            getLastName(datamanager, random);
            //get person's age
            getAge(creationType, random);
            //get personality
            //getPersonality(creationType, random);
            //add random traits
            AddRandomTrait(random, creationType, 4);
            //add random skills
            AddRandomSkill(random, creationType, 2);
            //get Stat Attributes
            GetAttributeStats(random, datamanager);
            //get Health Stats
            GetHealthStats(random, datamanager);
            //get appearance
            createPersonConstruct(datamanager, random);
        }
Esempio n. 6
0
        //Returns a list of valid directions for creation
        private List <Direction> GetDirectionsPossible(int size, CreationType creationType)
        {
            List <Direction> directions = new List <Direction>();
            Direction        direction  = Direction.North;
            int x = currentx;
            int y = currenty;

            bool result = false;

            for (int i = 0; i < 4; i++)
            {
                result    = false;
                direction = (Direction)i;

                if (creationType == CreationType.Corridor)
                {
                    currentx = x;
                    currenty = y;
                    GoToRoomsEdge(direction);
                    result = IsClearForCorridor(direction, size);
                }
                else
                {
                    result = IsClearForRoom(direction, size);
                }

                if (result)
                {
                    directions.Add(direction);
                }
            }
            return(directions);
        }
Esempio n. 7
0
        public UnfixedActivity(
            string name,
            string description,
            Color color,
            CreationType creationType,
            IEnumerable <Label> labels,
            Category category,
            string userId,
            int priority,
            TimeSpan timeSpan,
            bool baseActivity) : base(name,
                                      description,
                                      color,
                                      creationType,
                                      labels,
                                      category,
                                      userId,
                                      ActivityType.UnfixedActivity,
                                      baseActivity)
        {
            if (priority < 0)
            {
                throw new ArgumentOutOfRangeException("priority");
            }

            Priority = priority;
            TimeSpan = timeSpan;
            Repeat   = null;
            Start    = null;
        }
Esempio n. 8
0
 private void Create(CreationType creationType)
 {
     if (IsFormValid(creationType))
     {
         ExecuteMethod(CreateCode, creationType);
     }
 }
Esempio n. 9
0
        private void LogConfigSettings(CreationType creationType)
        {
            var properties = Settings.ExtensionConfig.GetType().GetProperties().ToDictionary(
                k => k.Name,
                v => v.GetValue(Settings.ExtensionConfig)?.ToString() ?? string.Empty);

            foreach (var kvp in properties.ToList())
            {
                if (kvp.Key.ToLower().EndsWith("list"))
                {
                    properties.Add(kvp.Key + "Count", string.IsNullOrWhiteSpace(kvp.Value)
                        ? "0"
                        : kvp.Value.Split('|').Length.ToString());
                }
            }

            properties["AudibleCompletionNotification"] = Settings.AudibleCompletionNotification.ToString();
            properties["CrmSvcUtilRelativePath"]        = Settings.CrmSvcUtilRelativePath;
            properties["IncludeCommandLine"]            = Settings.IncludeCommandLine.ToString();
            properties["MaskPassword"]    = Settings.MaskPassword.ToString();
            properties["SupportsActions"] = Settings.SupportsActions.ToString();
            properties["UseCrmOnline"]    = Settings.UseCrmOnline.ToString();
            properties["Version"]         = Settings.Version;
            properties["CreationType"]    = creationType.ToString();

            if (Telemetry.Enabled)
            {
                TxtOutput.AppendText($"Tracking {creationType} Generation Event." + Environment.NewLine);
                Telemetry.TrackEvent("ConfigSettings", properties);
            }
            else
            {
                TxtOutput.AppendText("Tracking not enabled!  Please consider allowing the Xrm Tool Box to send anonymous statistics via the Configuration --> Settings -- Data Collect.  This allows reporting for which features are used and what features can be deprecated." + Environment.NewLine);
            }
        }
Esempio n. 10
0
    void CreateBits(CreationType ct, int density)
    {
        Transform container = new GameObject(gameObject.name + " container").transform;

        int bits = density;//qty;

        foreach (StickJoint limb in limbs)
        {
            bool terminating = limb.linked == null;

            for (int i = 0; i < bits; i++)
            {
                float point = (float)i / (float)bits;

                StickJoint linked = limb.linked;
                if (linked == null)
                {
                    linked = limb;
                }
                Floater fl = ct.MakeBit(limb, linked, point);//new Floater(limb, limb.linked ?? limb, newFloater.transform, point);
                limb.floaters.Add(fl);
                fl.floater.transform.SetParent(container);
                fl.floater.gameObject.layer = 2;

                if (terminating)
                {
                    i = bits;
                }
            }
        }
    }
Esempio n. 11
0
    public void Init(CreationType ct, int density)
    {
        // behavior = new Floating();

        FindLimbs();
        CreateBits(ct, density);
    }
Esempio n. 12
0
        private void SetExcludedLanuage(LanguageType language, CreationType creation, bool isExcluded)
        {
            var code = (int)language + (int)creation;

            if (isExcluded)
            {
                var temp = ExcludedCodes;
                if (!temp.Contains(code))
                {
                    temp.Add(code);
                    ExcludedCodes = temp;
                }
            }
            else
            {
                var temp = ExcludedCodes;
                if (temp.Contains(code))
                {
                    temp.Remove(code);;
                    ExcludedCodes = temp;
                }
            }

            NotifyPropertyChanged($"Excluded{language.ToString()}{creation.ToString()}");
            NotifyPropertyChanged($"Excluded{language.ToString()}");
        }
        private static bool IsValidPath(CreationType creationType, CreationType creationTypeToCheck, string path, bool pathIsDirectory, string name)
        {
            if (creationType != creationTypeToCheck && creationType != CreationType.All)
            {
                return(true);
            }
            var isValid           = true;
            var containsExtension = !string.IsNullOrWhiteSpace(Path.GetExtension(path));

            // Validate Path
            if (pathIsDirectory)
            {
                if (containsExtension)
                {
                    MessageBox.Show(name + @" path must be a directory!  Did you forget to add a \\?", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    isValid = false;
                }
            }
            else
            {
                if (!containsExtension)
                {
                    MessageBox.Show(name + @" path must be a file!", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    isValid = false;
                }
            }
            return(isValid);
        }
Esempio n. 14
0
        private void GenerateAndOpenReport(CreationType createType)
        {
            var data   = SampleDataBuilder.Build();
            var result = this._createReportCommand.Execute(data, createType);

            TryWriteAndOpen(result, createType.ToString());
        }
Esempio n. 15
0
        public void HasDbContext_Regularly_ShouldReturnTrue(CreationType creationType)
        {
            var accessor = this.Create(creationType);

            var result = accessor.HasDbContext;

            Assert.True(result);
        }
Esempio n. 16
0
 /// <summary>
 /// Creates a <see cref="FixedDbContextAccessor{TDbContext}"/>, its <see cref="Microsoft.EntityFrameworkCore.DbContext"/> accessible through the <see cref="DbContext"/> property.
 /// </summary>
 private FixedDbContextAccessor <TestDbContext> Create(CreationType creationType)
 {
     return(creationType switch
     {
         CreationType.Instance => FixedDbContextAccessor.Create(dbContext: this.CreateAndRememberDbContext()),
         CreationType.Factory => FixedDbContextAccessor.Create(this.CreateAndRememberDbContext),
         _ => throw new NotImplementedException(),
     });
Esempio n. 17
0
        private Argument GetUserArgument(CreationType creationType, string setting)
        {
            var argument = UserArguments.FirstOrDefault(s =>
                                                        string.Equals(s.Name, setting, StringComparison.InvariantCultureIgnoreCase) &&
                                                        s.SettingType == creationType);

            return(argument ?? new Argument(creationType, setting, string.Empty));
        }
Esempio n. 18
0
        private void HandleResult(string filePath, DateTime date, CreationType creationType, string consoleOutput)
        {
            var speaker = new SpeechSynthesizer();

            try
            {
                //if (creationType == CreationType.Actions && Config.ExtensionConfig.CreateOneFilePerAction)
                //{
                //    var tempPath = filePath;
                //    filePath = "Actions.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("Actions.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else if (creationType == CreationType.OptionSets && Config.ExtensionConfig.CreateOneFilePerOptionSet)
                //{
                //    var tempPath = filePath;
                //    filePath = "OptionSet.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("OptionSet.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else
                if (date != File.GetLastWriteTimeUtc(filePath) || consoleOutput.Contains(filePath + " was unchanged."))
                {
                    lock (_speakToken)
                    {
                        speaker.Speak(creationType + " Completed Successfully");
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                UpdateStatus("Error", ex.ToString());
                lock (_speakToken)
                {
                    speaker.Speak(creationType + " Errored");
                }
            }

            //int result;
            lock (_speakToken)
            {
                UpdateStatus("Error", "Output file was not updated or not found!  " + filePath);
                speaker.Speak(creationType + " Errored");
            }
        }
Esempio n. 19
0
        public void CurrentDbContext_Regularly_ShouldReturnExpectedResult(CreationType creationType)
        {
            var accessor = this.Create(creationType);

            var result = accessor.CurrentDbContext;

            Assert.NotNull(result);
            Assert.Equal(this.DbContext, result);
        }
Esempio n. 20
0
        private bool IsFormValid(CreationType creationType)
        {
            var isValid =
                IsValidPath(creationType, CreationType.Entities, TxtEntityPath, ChkCreateOneEntityFile, "Entities") &&
                IsValidPath(creationType, CreationType.Entities, TxtOptionSetPath, ChkCreateOneOptionSetFile, "OptionSets") &&
                IsValidPath(creationType, CreationType.Entities, TxtActionPath, ChkCreateOneActionFile, "Actions");

            return(isValid);
        }
Esempio n. 21
0
        public CreateFileWindow(CreationType type)
        {
            InitializeComponent();
            if (type == CreationType.File)
                this.Title = "Create File";
            else
                this.Title = "Create Folder";

            tbname.Focus();
        }
 public JsonModularHousehold([NotNull] string name, [CanBeNull] string description, StrGuid guid, CreationType creationType, [CanBeNull] JsonReference deviceSelection, EnergyIntensityType energyIntensityType, JsonReference vacation)
 {
     Name                = name;
     Description         = description;
     Guid                = guid;
     CreationType        = creationType;
     DeviceSelection     = deviceSelection;
     EnergyIntensityType = energyIntensityType;
     Vacation            = vacation;
 }
 public Vacation([NotNull] string name, [CanBeNull] int?pID, [NotNull] string connectionString, int minimumAge, int maximumAge,
                 CreationType creationType, StrGuid guid) : base(name, TableName, connectionString, guid)
 {
     _creationType   = creationType;
     _minimumAge     = minimumAge;
     _maximumAge     = maximumAge;
     ID              = pID;
     TypeDescription = "Vacation";
     AreNumbersOkInNameForIntegrityCheck = true;
     _vacationTimes = new ObservableCollection <VacationTime>();
 }
Esempio n. 24
0
 void getAge(CreationType creationType, Random rando)
 {
     if (creationType == CreationType.Created)
     {
         personAge = rando.Next(14, 60);
     }
     else if (creationType == CreationType.Birthed)
     {
         personAge = 0;
     }
 }
Esempio n. 25
0
        private bool IsFormValid(CreationType creationType)
        {
            SettingsMap.PushChanges();
            var isValid =
                IsValidPath(creationType, CreationType.Entities, SettingsMap.EntityOutPath, SettingsMap.CreateOneFilePerEntity, "Entities") &&
                IsValidPath(creationType, CreationType.Entities, SettingsMap.OptionSetOutPath, SettingsMap.CreateOneFilePerOptionSet, "OptionSets") &&
                IsValidPath(creationType, CreationType.Entities, SettingsMap.ActionOutPath, SettingsMap.CreateOneFilePerAction, "Actions") &&
                IsNamespaceDifferentThanContext();

            return(isValid);
        }
Esempio n. 26
0
        public virtual IPlayer CreatePlayer(CreationType creation = CreationType.Player, FigureFormsType shape = FigureFormsType.Zero)
        {
            switch (creation)
            {
            case CreationType.Player:
                return(new Player());

            default:
                throw new WrongCreationException();
            }
        }
Esempio n. 27
0
        public string GetSettingValue(CreationType creationType, string setting)
        {
            var value = CommandLineArguments.FirstOrDefault(s => string.Equals(s.Name, setting, StringComparison.InvariantCultureIgnoreCase) &&
                                                            (s.SettingType == creationType || s.SettingType == CreationType.All));

            if (value == null)
            {
                throw new KeyNotFoundException("Unable to find setting for " + creationType + " " + setting);
            }

            return(value.Value);
        }
Esempio n. 28
0
        private void HandleResult(string filePath, DateTime date, CreationType creationType, string consoleOutput, bool speakResult)
        {
            try
            {
                if (consoleOutput.Contains("Unable to Login to Dynamics CRM"))
                {
                    UpdateStatus("Unable to login.  Attempting to login using interactive mode.");
                    _useInteractiveMode = true;
                    Create(creationType);
                    return;
                }
                //if (creationType == CreationType.Actions && Config.ExtensionConfig.CreateOneFilePerAction)
                //{
                //    var tempPath = filePath;
                //    filePath = "Actions.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("Actions.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else if (creationType == CreationType.OptionSets && Config.ExtensionConfig.CreateOneFilePerOptionSet)
                //{
                //    var tempPath = filePath;
                //    filePath = "OptionSet.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("OptionSet.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else
                if (date != File.GetLastWriteTimeUtc(filePath) || consoleOutput.Contains(filePath + " was unchanged."))
                {
                    Speak(creationType + " Completed Successfully", speakResult);
                    return;
                }
            }
            catch (Exception ex)
            {
                UpdateStatus("Error", ex.ToString());
                Speak(creationType + " Errored", speakResult);
            }

            UpdateStatus("Error", "Output file was not updated or not found!  " + filePath);
        }
Esempio n. 29
0
        public virtual IFigure CreateFigure(CreationType creation = CreationType.Figure,
                                            FigureFormsType shape = FigureFormsType.Zero,
                                            MaterialType material = MaterialType.Wood)
        {
            switch (creation)
            {
            case CreationType.Figure:
                return(new Figures(1, 1, 0, 0, shape, material));

            default:
                throw new WrongCreationException();
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Resolves the specified key.
        /// </summary>
        /// <typeparam name="TKey">The type of the key.</typeparam>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="key">The key.</param>
        /// <param name="creationType">Type of the creation.</param>
        private TValue Get <TKey, TValue>(TKey key, CreationType creationType) where TValue : ILinkable <TKey>
        {
            if (!this.IsCached <TValue>())
            {
                this.Cache <TKey, TValue>();
            }

            Linker <TKey, TValue> linker = this.GetLinker <TKey, TValue>();

            linker.CreationType = creationType;

            return(linker.Resolve(key));
        }
Esempio n. 31
0
        public virtual IField CreateField(CreationType creation)
        {
            switch (creation)
            {
            case CreationType.Playground:
                return(new PlayGround(GlobalConstant.StandarPlaygroundtWidth + 2, GlobalConstant.StandartPlaygroundHeight + 2));

            case CreationType.SpecialField:
                return(new SpecialField(GlobalConstant.SpecialFieldWidth, GlobalConstant.SpecialFieldHeight));

            default:
                throw new WrongCreationException();
            }
        }
Esempio n. 32
0
        public virtual IBlock CreateBlock(CreationType creation, FigureFormsType shape = FigureFormsType.Zero)
        {
            switch (creation)
            {
            case CreationType.WallBlock:
                return(new WallBlock(1, 1, 0, 0, shape));

            case CreationType.End:
                return(new End());

            default:
                throw new WrongCreationException();
            }
        }
Esempio n. 33
0
        protected Solution(CreationType creationType)
        {
            switch (creationType)
            {
                case CreationType.Random:
                    for (int i = 0; i < MaxNumberOfFactors; ++i)
                    {
                        _weights.Add(Randomizer.GetNextWeight());
                    }
                    break;
                case CreationType.LoadFromDb:
                    LoadFromDb();
                    break;

            }
        }
        private void HandleResult(string filePath, DateTime date, CreationType creationType, string consoleOutput)
        {
            var speaker = new SpeechSynthesizer();
            try
            {
                //if (creationType == CreationType.Actions && Config.ExtensionConfig.CreateOneFilePerAction)
                //{
                //    var tempPath = filePath;
                //    filePath = "Actions.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("Actions.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else if (creationType == CreationType.OptionSets && Config.ExtensionConfig.CreateOneFilePerOptionSet)
                //{
                //    var tempPath = filePath;
                //    filePath = "OptionSet.cs";
                //    if (!File.Exists(tempPath))
                //    {
                //        lock (_speakToken)
                //        {
                //            speaker.Speak("OptionSet.cs Completed Successfully");
                //        }
                //        return;
                //    }
                //}
                //else 
                if (date != File.GetLastWriteTimeUtc(filePath) || consoleOutput.Contains(filePath + " was unchanged."))
                {
                    lock (_speakToken)
                    {
                        speaker.Speak(creationType + " Completed Successfully");
                    }
                    return;
                }
            }
            catch(Exception ex)
            {
                UpdateStatus("Error", ex.ToString());
                lock (_speakToken)
                {
                    speaker.Speak(creationType + " Errored");
                }
            }

            //int result;
            lock (_speakToken)
            {
                UpdateStatus("Error", "Output file was not updated or not found!  "  + filePath);
                speaker.Speak(creationType + " Errored");
            }
        }
        private string GetConfigArguments(Config config, CreationType type)
        {
            var sb = new StringBuilder();
            sb.AppendFormat("/url:\"{0}\" ", config.Url);

            foreach (var argument in config.CommandLineArguments.Where(a => a.SettingType == CreationType.All || a.SettingType == type))
            {
                var value = argument.Value;
                if (argument.Name == "out")
                {
                    value = GetOutputFilePath(config, type);
                }
                if (argument.Value == null)
                {
                    sb.AppendFormat("/{0} ", argument.Name);
                }
                else
                {
                    sb.AppendFormat("/{0}:\"{1}\" ", argument.Name, value);
                }
            }

            if (!String.IsNullOrWhiteSpace(config.Password))
            {
                sb.AppendFormat("/username:\"{0}\" ", config.UserName);
                sb.AppendFormat("/password:\"{0}\" ", config.Password);

                // Add Login Info
                if (!config.UseCrmOnline && !String.IsNullOrWhiteSpace(config.Domain))
                {
                    sb.AppendFormat("/domain:\"{0}\" ", config.Domain);
                }
            }

            return sb.ToString();
        }
        public void CreateCode(CreationType creationType)
        {
            EnableForm(false);

            WorkAsync("Shelling out to Command Line...",
                (w, e) => // Work To Do Asynchronously
                {
                    HydrateSettingsFromUI();

                    //SetGenerateEnumSettings(Settings);

                    var generator = new Logic(Settings);
                    Logic.LogHandler onLog = m => w.ReportProgress(0, m);
                    generator.OnLog += onLog;
                    try
                    {
                        switch (creationType)
                        {
                            case CreationType.Actions:
                                w.ReportProgress(0, "Executing for Actions");
                                generator.CreateActions();
                                break;
                            case CreationType.All:
                                w.ReportProgress(0, "Executing for All");
                                generator.ExecuteAll();
                                break;
                            case CreationType.Entities:
                                w.ReportProgress(0, "Executing for Entities");
                                generator.CreateEntities();
                                break;
                            case CreationType.OptionSets:
                                w.ReportProgress(0, "Executing for OptionSets");
                                generator.CreateOptionSets();
                                break;
                            default:
                                throw new ArgumentOutOfRangeException(nameof(creationType));
                        }
                        w.ReportProgress(99, "Creation Complete!");
                    }
                    catch (InvalidOperationException ex)
                    {
                        w.ReportProgress(int.MinValue, ex.Message);
                    }
                    catch (Exception ex)
                    {
                        w.ReportProgress(int.MinValue, ex.ToString());
                    }
                    finally
                    {
                        generator.OnLog -= onLog;
                    }
                },
                e => // Creation has finished.  Cleanup
                {
                    var result = e.Result as Logic.LogMessageInfo;
                    if (result != null)
                    {
                        TxtOutput.AppendText(result.Detail + Environment.NewLine);
                    }
                    EnableForm(true);
                    Settings.Save();
                },
                e => // Logic wants to display an update
                {
                    string summary;
                    var result = e.UserState as Logic.LogMessageInfo;
                    if (result == null)
                    {
                        summary = e.UserState.ToString();
                    }
                    else
                    {
                        TxtOutput.AppendText(result.Detail + Environment.NewLine);
                        summary = result.Summary;
                    }
                    // Status Update
                    if (e.ProgressPercentage == int.MinValue)
                    {
                        TxtOutput.AppendText(e.UserState + Environment.NewLine);
                    }
                    else
                    {
                        SetWorkingMessage(summary);
                    }
                });
        }
Esempio n. 37
0
 public Argument(CreationType settingType, CrmSrvUtilService service, string value) :this(settingType, service.ToString().ToLower(), value)
 { }
Esempio n. 38
0
        /// <summary>
        /// Converts a GraphMapData instance, with data from an import operation,
        /// to a Graph (GraphComponents)
        /// </summary>
        /// <param name="graph">The mapping data to be imported into the Graph</param>
        /// <param name="graphComponents">The Graph that data is being imported into</param>
        /// <param name="creationType">The specified CreationType</param>
        public static void ImportGraph(this GraphMapData graph, GraphComponents graphComponents, CreationType creationType)
        {
            // Ensure that valid mapping data was provided
            if (graph == null)
            {
                throw new ArgumentNullException("graph", "No mapping data was provided");
            }

            graphComponents.NodeType = NodeTypes.Text;
            foreach (NodeMapData objNode in graph.GetNodes())
            {
                if (objNode is IconNodeMapData)
                {
                    graphComponents.NodeType = NodeTypes.Icon;
                    break;
                }
            }

            // TODO edgedefault?

            // Loop over the node mapping objects
            foreach (NodeMapData objNode in graph.GetNodes())
            {
                AddNode(graphComponents, creationType, objNode);
            }

            // Edges
            foreach (EdgeMapData objEdge in graph.GetEdges())
            {
                AddEdge(graphComponents, creationType, objEdge);
            }
        }
Esempio n. 39
0
 private static void WriteToFile(string workingDirectory, int count, IEnumerable<string> lines, CreationType creationType)
 {
   var prefix = CreationData.Prefixes[creationType];
   var fileType = CreationData.FileTypes[creationType];
   var fileName = $"{prefix}_{count}.{fileType}";
   var path = Path.Combine(workingDirectory, fileName);
   File.WriteAllLines(path, lines);
 }
Esempio n. 40
0
        private void SetUserArgument(CreationType creationType, string setting, string value)
        {
            var argument = GetUserArgument(creationType, setting);

            if (argument == null)
            {
                if (value != null)
                {
                    UserArguments.Add(new Argument {Name = setting, SettingType = creationType, Value = value});
                }
            }
            else if (value == null)
            {
                UserArguments.Remove(argument);
            }
            else
            {
                argument.Value = value;
            }
        }
Esempio n. 41
0
        private string GetConfigArguments(Config config, CreationType type)
        {
            var sb = new StringBuilder();
            if (!config.UseConnectionString)
            {
                sb.AppendFormat("/url:\"{0}\" ", config.Url);
            }

            foreach (var argument in config.CommandLineArguments.Where(a => a.SettingType == CreationType.All || a.SettingType == type))
            {
                var value = argument.Value;
                if (argument.Name == "out")
                {
                    value = GetOutputFilePath(config, type);
                }
                if (argument.Value == null)
                {
                    sb.AppendFormat("/{0} ", argument.Name);
                }
                else
                {
                    sb.AppendFormat("/{0}:\"{1}\" ", argument.Name, value);
                }
            }

            if (!string.IsNullOrWhiteSpace(config.Password))
            {
                if (Config.UseConnectionString)
                {
                    // Fix for https://github.com/daryllabar/DLaB.Xrm.XrmToolBoxTools/issues/14 - Problem with CRM 2016 on premises with ADFS
                    // CrmSvcUtil.exe /out:entitie.cs / connectionstring:"Url=https://serverName.domain.com:444/orgName;Domain=myDomain;UserName=username;Password=*****"
                    // And this command doesn't work :
                    // CrmSvcUtil.exe /out:entitie.cs /url:"https://serverName.domain.com:444/orgName" / domain:"myDomain" / username:"******" / password:"******"

                    var domain = string.Empty;
                    if (!string.IsNullOrWhiteSpace(config.Domain))
                    {
                        domain = "Domain=" +config.Domain + ";";
                    }
                    var password = config.Password.Replace("\"", "^\"").Replace("&", "^&");  // Handle Double Quotes and &s???
                    var builder = new System.Data.Common.DbConnectionStringBuilder
                    {
                        {"A", $"Url={config.Url};{domain}UserName={config.UserName};Password={password}"}
                    };
                    
                    sb.AppendFormat("/connectionstring:{0} ", builder.ConnectionString.Substring(2)); // Replace "A=" with "/connectionstring:"
                }
                else
                {
                    sb.AppendFormat("/username:\"{0}\" ", config.UserName);
                    sb.AppendFormat("/password:\"{0}\" ", config.Password);

                    // Add Login Info
                    if (!config.UseCrmOnline && !string.IsNullOrWhiteSpace(config.Domain))
                    {
                        sb.AppendFormat("/domain:\"{0}\" ", config.Domain);
                    }
                }
            }

            return sb.ToString();
        }
Esempio n. 42
0
        private void SetUserArgument(CreationType creationType, string setting, string value)
        {
            var argument = UserArguments.FirstOrDefault(s =>
                string.Equals(s.Name, setting, StringComparison.InvariantCultureIgnoreCase)
                && s.SettingType == creationType);

            if (argument == null)
            {
                UserArguments.Add(new Argument {Name = setting, SettingType = creationType, Value = value});
            }
            else
            {
                argument.Value = value;
            }
        }
Esempio n. 43
0
        private string GetUserArgument(CreationType creationType, string setting)
        {
            var argument = UserArguments.FirstOrDefault(s =>
                string.Equals(s.Name, setting, StringComparison.InvariantCultureIgnoreCase)
                && s.SettingType == creationType);

            return argument == null ? string.Empty : argument.Value;
        }
Esempio n. 44
0
        public string GetSettingValue(CreationType creationType, string setting)
        {
            var value = CommandLineArguments.FirstOrDefault(s => string.Equals(s.Name, setting, StringComparison.InvariantCultureIgnoreCase)
                                                                 && (s.SettingType == creationType || s.SettingType == CreationType.All));

            if (value == null)
            {
                throw new KeyNotFoundException("Unable to find setting for " + creationType + " " + setting);
            }

            return value.Value;
        }
 private static bool IsValidPath(CreationType creationType, CreationType creationTypeToCheck, TextBox textPath, CheckBox chk, string name)
 {
     if (creationType != creationTypeToCheck && creationType != CreationType.All)
     {
         return true;
     }
     var isValid = true;
     var containsExtension = !string.IsNullOrWhiteSpace(Path.GetExtension(textPath.Text));
     // Validate Path
     if (chk.Checked)
     {
         if (containsExtension)
         {
             MessageBox.Show(name + @" path must be a directory!", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
             isValid = false;
         }
     }
     else
     {
         if (!containsExtension)
         {
             MessageBox.Show(name + @" path must be a file!", @"Invalid " + name + @" Path", MessageBoxButtons.OK, MessageBoxIcon.Error);
             isValid = false;
         }
     }
     return isValid;
 }
        private void Create(CreationType creationType)
        {
            var filePath = GetOutputFilePath(Config, creationType);
            // Check for file to be editable if not using TFS and creating only one file
            if (!Config.ExtensionConfig.UseTfsToCheckoutFiles 
                && ((creationType == CreationType.Actions && !Config.ExtensionConfig.CreateOneFilePerAction) || 
                    (creationType == CreationType.Entities && !Config.ExtensionConfig.CreateOneFilePerEntity) ||
                    (creationType == CreationType.OptionSets && !Config.ExtensionConfig.CreateOneFilePerOptionSet))
                && !AbleToMakeFileAccessible(filePath))
            {
                return;
            }

            var date = File.GetLastWriteTimeUtc(filePath);
            var p = new Process
            {
                StartInfo =
                {
                    FileName = Config.CrmSvcUtilPath,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true,
                    UseShellExecute = false,
                    Arguments = GetConfigArguments(Config, creationType),
                },
            };

            if (!File.Exists(p.StartInfo.FileName))
            {
                throw new FileNotFoundException("Unable to locate CrmSvcUtil at path '" + p.StartInfo.FileName +"'.  Update the CrmSvcUtilRelativePath in the DLaB.EarlyBoundGeneratorPlugin.Settings.xml file and try again.");
            }

            var args = GetSafeArgs(Config, p);
            if (Config.IncludeCommandLine)
            {
                switch (creationType)
                {
                    case CreationType.Actions:
                        Config.ExtensionConfig.ActionCommandLineText = "\"" + p.StartInfo.FileName + "\" " + args;
                        break;
                    case CreationType.All:
                        break;
                    case CreationType.Entities:
                        Config.ExtensionConfig.EntityCommandLineText = "\"" + p.StartInfo.FileName + "\" " + args;
                        break;
                    case CreationType.OptionSets:
                        Config.ExtensionConfig.OptionSetCommandLineText = "\"" + p.StartInfo.FileName + "\" " + args;
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("creationType");
                }
            }
            UpdateCrmSvcUtilConfig(Config);
            UpdateStatus("Shelling out to CrmSrvUtil for creating " + creationType, "Executing \"" + p.StartInfo.FileName + "\" " + args);
            p.Start();
            var consoleOutput = new StringBuilder();
            while (!p.StandardOutput.EndOfStream)
            {
                var line = p.StandardOutput.ReadLine();
                UpdateStatus(line);
                consoleOutput.AppendLine(line);
            }

            HandleResult(filePath, date, creationType, consoleOutput.ToString());
        }
Esempio n. 47
0
 public void SetExtensionArgument(CreationType creationType, CrmSrvUtilService service, string value)
 {
     SetExtensionArgument(creationType, service.ToString().ToLower(), value);
 }
 public Argument(CreationType settingType, string name, string value)
 {
     SettingType = settingType;
     Name = name;
     Value = value;
 }
Esempio n. 49
0
 public Argument GetExtensionArgument(CreationType creationType, CrmSrvUtilService service)
 {
     return GetExtensionArgument(creationType, service.ToString().ToLower());
 }
Esempio n. 50
0
 public void SetUnits()
 {
     for (int i = 0; i < transform.childCount; i++)
         Destroy(transform.GetChild(i).gameObject);
     creationType = CreationType.Units;
     Start();
 }
Esempio n. 51
0
        /// <summary>
        /// Adds the specificed edge
        /// </summary>
        /// <param name="graphComponents">The Graph that data is being imported into</param>
        /// <param name="creationType">The specified CreationType</param>
        /// <param name="objEdge">Edge to be added</param>
        public static void AddEdge(GraphComponents graphComponents, CreationType creationType, EdgeMapData objEdge)
        {
            INode uiSourceNode = graphComponents.Data.GetNode(objEdge.Source);
            if (uiSourceNode == null && creationType == CreationType.Imported)
            {
                throw new Exception("Missing Source Node");
            }
            else if (uiSourceNode == null)// && creationType == CreationType.Live
            {
                uiSourceNode = new GhostNode(objEdge.Source);
            }

            INode uiTargetNode = graphComponents.Data.GetNode(objEdge.Target);
            if (uiTargetNode == null && creationType == CreationType.Imported)
            {
                throw new Exception("Missing Target Node");
            }
            else if (uiTargetNode == null)// && creationType == CreationType.Live
            {
                uiTargetNode = new GhostNode(objEdge.Target);
            }

            if (string.IsNullOrEmpty(objEdge.Label) && objEdge.Attributes.Count == 0)
            {
                Berico.SnagL.Model.Edge uiEdge = new Berico.SnagL.Model.Edge(uiSourceNode, uiTargetNode);
                uiEdge.SourceMechanism = creationType;

                // Properties
                uiEdge.Type = objEdge.Type;

                // the EdgeViewModel must be created after uiEdge has had a Type specified
                IEdgeViewModel uiEdgeVM = EdgeViewModelBase.GetEdgeViewModel(uiEdge, graphComponents.Scope);
                graphComponents.AddEdgeViewModel(uiEdgeVM);
            }
            else
            {
                DataEdge uiEdge = new DataEdge(uiSourceNode, uiTargetNode);
                uiEdge.SourceMechanism = creationType;

                // Properties
                uiEdge.Type = objEdge.Type;
                uiEdge.DisplayValue = objEdge.Label;

                // the EdgeViewModel must be created after uiEdge has had a Type specified
                IEdgeViewModel uiEdgeVM = EdgeViewModelBase.GetEdgeViewModel(uiEdge, graphComponents.Scope);
                graphComponents.AddEdgeViewModel(uiEdgeVM);

                uiEdgeVM.Thickness = objEdge.Thickness;
                uiEdgeVM.Color = new SolidColorBrush(objEdge.Color);
                uiEdgeVM.EdgeLine.Text = objEdge.Label;
                uiEdgeVM.EdgeLine.LabelTextUnderline = objEdge.IsLabelTextUnderlined;
                uiEdgeVM.EdgeLine.LabelBackgroundColor = new SolidColorBrush(objEdge.LabelBackgroundColor);
                uiEdgeVM.EdgeLine.LabelForegroundColor = new SolidColorBrush(objEdge.LabelForegroundColor);
                uiEdgeVM.EdgeLine.LabelFontStyle = objEdge.LabelFontStyle;
                uiEdgeVM.EdgeLine.LabelFontWeight = objEdge.LabelFontWeight;
                if (objEdge.LabelFont != null)
                {
                    uiEdgeVM.EdgeLine.LabelFont = objEdge.LabelFont;
                }

                // Attributes
                foreach (KeyValuePair<string, AttributeMapData> objEdgeAttrKVP in objEdge.Attributes)
                {
                    Attributes.Attribute uiEdgeAttribute = new Attributes.Attribute(objEdgeAttrKVP.Value.Name);
                    AttributeValue uiEdgeAttributeValue = new AttributeValue(objEdgeAttrKVP.Value.Value);

                    uiEdge.Attributes.Add(uiEdgeAttribute.Name, uiEdgeAttributeValue);
                    //GlobalAttributeCollection.GetInstance(graphComponents.Scope).Add(uiEdgeAttribute, uiEdgeAttributeValue);

                    uiEdgeAttribute.SemanticType = objEdgeAttrKVP.Value.SemanticType;
                    uiEdgeAttribute.PreferredSimilarityMeasure = objEdgeAttrKVP.Value.SimilarityMeasure;
                    uiEdgeAttribute.Visible = !objEdgeAttrKVP.Value.IsHidden;
                }
            }
        }
Esempio n. 52
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataLoadedEventArgs"/> class
 /// </summary>
 /// <param name="scope">The scope of the loaded data</param>
 /// <param name="sourceMechanism">Indicates the source mechanism for the data that was loaded</param>
 public DataLoadedEventArgs(string scope, CreationType sourceMechanism)
 {
     Scope = scope;
     SourceMechanism = sourceMechanism;
 }
Esempio n. 53
0
        /// <summary>
        /// Adds the specificed node
        /// </summary>
        /// <param name="graphComponents">The Graph that data is being imported into</param>
        /// <param name="creationType">The specified CreationType</param>
        /// <param name="objNode">Node to be added</param>
        public static void AddNode(GraphComponents graphComponents, CreationType creationType, NodeMapData objNode)
        {
            // Create new node
            Node uiNode = new Node(objNode.Id);
            uiNode.SourceMechanism = creationType;

            // TODO as NodeMapData types expands, this needs to be adjusted
            NodeTypes uiNodeType = NodeTypes.Simple;
            if (objNode is IconNodeMapData)
            {
                uiNodeType = NodeTypes.Icon;
            }
            else if (objNode is TextNodeMapData)
            {
                uiNodeType = NodeTypes.Text;
            }

            NodeViewModelBase uiNodeVM = NodeViewModelBase.GetNodeViewModel(uiNodeType, uiNode, graphComponents.Scope);

            // Properties
            if (uiNodeType == NodeTypes.Icon)
            {
                IconNodeMapData objIconNode = (IconNodeMapData)objNode;
                if (objIconNode.ImageSource != null)
                {
                    ((IconNodeViewModel)uiNodeVM).ImageSource = objIconNode.ImageSource.ToString();
                }
            }

            uiNodeVM.Description = objNode.Description;
            uiNodeVM.DisplayValue = objNode.Label;
            uiNodeVM.Width = objNode.Dimension.Width;
            uiNodeVM.Height = objNode.Dimension.Height;
            uiNodeVM.Position = objNode.Position;
            uiNodeVM.IsHidden = objNode.IsHidden;

            SolidColorBrush uiBackgroundColorBrush = new SolidColorBrush(objNode.BackgroundColor);
            uiNodeVM.BackgroundColor = uiBackgroundColorBrush;

            SolidColorBrush uiSelectionColorBrush = new SolidColorBrush(objNode.SelectionColor);
            uiNodeVM.SelectionColor = uiSelectionColorBrush;

            if (uiNodeVM.Height == 0)
            {
                uiNodeVM.Height = 45;
            }

            if (uiNodeVM.Width == 0)
            {
                uiNodeVM.Width = 45;
            }

            // Add the node to the graph
            graphComponents.AddNodeViewModel(uiNodeVM);

            // Attributes
            foreach (KeyValuePair<string, AttributeMapData> objNodeAttrKVP in objNode.Attributes)
            {
                Attributes.Attribute uiNodeAttribute = new Attributes.Attribute(objNodeAttrKVP.Value.Name);
                AttributeValue uiNodeAttributeValue = new AttributeValue(objNodeAttrKVP.Value.Value);

                uiNode.Attributes.Add(uiNodeAttribute.Name, uiNodeAttributeValue);
                GlobalAttributeCollection.GetInstance(graphComponents.Scope).Add(uiNodeAttribute, uiNodeAttributeValue);

                uiNodeAttribute.SemanticType = objNodeAttrKVP.Value.SemanticType;
                uiNodeAttribute.PreferredSimilarityMeasure = objNodeAttrKVP.Value.SimilarityMeasure;
                uiNodeAttribute.Visible = !objNodeAttrKVP.Value.IsHidden;
            }
        }
Esempio n. 54
0
 public Argument GetExtensionArgument(CreationType creationType, string setting)
 {
     return ExtensionArguments.FirstOrDefault(a => a.SettingType == creationType && 
                                                   string.Equals(a.Name, setting, StringComparison.InvariantCultureIgnoreCase)) ?? 
         new Argument(creationType, setting, string.Empty);
 }
Esempio n. 55
0
        private string GetOutputFilePath(EarlyBoundGeneratorConfig earlyBoundGeneratorConfig, CreationType creationType)
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var filePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), EarlyBoundGeneratorConfig.GetSettingValue(creationType, EarlyBoundGeneratorConfig.UserArgumentNames.Out));

            if (creationType == CreationType.Actions && earlyBoundGeneratorConfig.ExtensionConfig.CreateOneFilePerAction)
            {
                filePath = Path.Combine(filePath, "Actions.cs");
            }
            else if (creationType == CreationType.Entities && earlyBoundGeneratorConfig.ExtensionConfig.CreateOneFilePerEntity)
            {
                var entities = earlyBoundGeneratorConfig.ServiceContextName;

                if (string.IsNullOrWhiteSpace(entities))
                {
                    entities = "Entities";
                }

                filePath = Path.Combine(filePath, entities + ".cs");
            }
            else if (creationType == CreationType.OptionSets && earlyBoundGeneratorConfig.ExtensionConfig.CreateOneFilePerOptionSet)
            {
                filePath = Path.Combine(filePath, "OptionSets.cs");
            }

            return filePath;
        }
Esempio n. 56
0
 internal void CreateObject(CreationType t, string name)
 {
     if (t == CreationType.File)
         File.Create(Path.Combine(OpenedDirectory, name));
     else
         Directory.CreateDirectory(Path.Combine(OpenedDirectory, name));
 }
Esempio n. 57
0
 private async void CreateCombinationsAsync(string workingDirectory, CreationType creationType)
 {
   var creationCount = CreationData.CreationCounts[creationType];
   ProgressBar.Minimum = 0;
   ProgressBar.Maximum = creationCount;
   ProgressBar.Value = 0;
   var counts = Enumerable.Range(0, creationCount);
   await Task.Run(() => Parallel.ForEach(counts, c => CreateCombinationFile(c, workingDirectory, creationType)));
 }
        private string GetOutputFilePath(Config config, CreationType creationType)
        {
            // ReSharper disable once AssignNullToNotNullAttribute
            var filePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), Config.GetSettingValue(creationType, Config.UserArgumentNames.Out));

            if (creationType == CreationType.Actions && config.ExtensionConfig.CreateOneFilePerAction)
            {
                return Path.Combine(filePath, "Actions.cs");
            }
            else if (creationType == CreationType.Entities && config.ExtensionConfig.CreateOneFilePerEntity)
            {
                return Path.Combine(filePath, config.ServiceContextName + ".cs");
            }
            else if (creationType == CreationType.OptionSets && config.ExtensionConfig.CreateOneFilePerOptionSet)
            {
                return Path.Combine(filePath, "OptionSets.cs");
            }
            else
            {
                return filePath;
            }
        }
        private bool IsFormValid(CreationType creationType)
        {
            var isValid =
                IsValidPath(creationType, CreationType.Entities, TxtEntityPath, ChkCreateOneEntityFile, "Entities") &&
                IsValidPath(creationType, CreationType.Entities, TxtOptionSetPath, ChkCreateOneOptionSetFile, "OptionSets") &&
                IsValidPath(creationType, CreationType.Entities, TxtActionPath, ChkCreateOneActionFile, "Actions");

            return isValid;
        }
Esempio n. 60
0
 private void CreateCombinationFile(int count, string workingDirectory, CreationType creationType)
 {
   var lines = CreatorFuncs[creationType].Invoke(count);
   WriteToFile(workingDirectory, count, lines, creationType);
   IncrementProgressBar();
 }