public static CreateProject AddAspNetStart(this CreateProject project, bool full)
        {
            string appStartUpTemplate = Resources.AspNet.Startup
                .Replace("[{namespace}]", $"{project.Parameter.ProjectName}");

            appStartUpTemplate = appStartUpTemplate
                    .Replace("[{factoryUsing}]", !full ? string.Empty : $"using {project.Parameter.SolutionParam.SolutionName}.Business.Factory;")
                    .Replace("[{factoryInit}]", !full ? string.Empty : "Register.Do(appSettings.UnitTest);")
                    .Replace("[{name}]", GetSafeName(project.Parameter.SolutionParam.SolutionName));

            string appProgramTemplate = Resources.AspNet.Program
                .Replace("[{namespace}]", $"{project.Parameter.ProjectName}");

            string appControllerTemplate = Resources.AspNet.HomeController
                .Replace("[{namespace}]", $"{project.Parameter.ProjectName}.Controllers");

            CreateFile appStartUp = new CreateFile(new CreateFileParam(project.Parameter, "Code", "Startup.cs") { Template = appStartUpTemplate });
            project.Add(appStartUp);

            CreateFile appProgram = new CreateFile(new CreateFileParam(project.Parameter, "Code", "Program.cs") { Template = appProgramTemplate });
            project.Add(appProgram);

            CreateFile appController = new CreateFile(new CreateFileParam(project.Parameter, "Controllers", "HomeController.cs") { Template = appControllerTemplate });
            project.Add(appController);

            return project;
        }
Beispiel #2
0
 private void CreateFileModel()
 {
     model = new CreateFile()
     {
         Body = new Body()
         {
             Row = new List <string>()
             {
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
             }
         },
         Header = new Header()
         {
             Date     = DateTime.Now,
             FirmName = "Good Programmer Marcin Buczak"
         }
     };
 }
Beispiel #3
0
    public void Create(IOutput output, string?path = null, bool overwrite = false)
    {
        if (output is not IFileGroup fileGroup)
        {
            throw new NotSupportedException($"{nameof(CreateFileGroup)} only supports {SupportedType.FullName} output types.");
        }

        if (string.IsNullOrWhiteSpace(output.Name) && !string.IsNullOrWhiteSpace(path))
        {
            fileGroup.SetPath(path);
        }
        else if (!Path.IsPathRooted(output.Name))
        {
            if (!string.IsNullOrWhiteSpace(path))
            {
                fileGroup.SetPath(Path.Combine(path, output.Name));
            }
            else
            {
                fileGroup.SetPath(output.Name);
            }
        }
        foreach (var file in fileGroup.Files)
        {
            var fileOutput = new CreateFile(_fileWriter);
            fileOutput.Create(file, path, overwrite);
        }
    }
        public CardHandler(ICard cardOwner)
        {
            this.card       = cardOwner as IISO7816Card;
            context         = new CardContext();
            context.CurFile = card.MasterFile;

            commandMap[0x0044] = new ActivateFile();
            commandMap[0x00e2] = new AppendRecord();
            commandMap[0x9024] = new ChangeKeyData();
            commandMap[0x0024] = new ChangeReferenceData();
            commandMap[0x00e0] = new CreateFile();
            commandMap[0x0004] = new DeactivateFile();
            commandMap[0x0082] = new ExternalAuthenticate();
            commandMap[0x0046] = new GenerateKeyPair();
            commandMap[0x0084] = new GetChallenge();
            commandMap[0x8086] = new GiveRandom();
            commandMap[0x0022] = new ManageSecurityEnvironment();
            commandMap[0x002a] = new PerformSecurityOperation();
            commandMap[0x00da] = new PutData();
            commandMap[0x00b0] = new ReadBinary();
            commandMap[0x00b2] = new ReadRecord();
            commandMap[0x002c] = new ResetRetryCounter();
            commandMap[0x00a4] = new Select();
            commandMap[0x00d6] = new UpdateBinary();
            commandMap[0x00dc] = new UpdateRecord();
            commandMap[0x0020] = new Verify();


            foreach (var v in commandMap.Values)
            {
                v.Card    = card;
                v.Handler = this;
            }
        }
Beispiel #5
0
    public void CreateFile_SupportedType_IsFIle()
    {
        var writer = Substitute.For <IFileWriter>();
        var sut    = new CreateFile(writer);

        sut.SupportedType.Should().Be <IFile>();
    }
Beispiel #6
0
        private R2Package CreateFileWithSizeMB(double fileSizeMB)
        {
            //var nme  = $"sampleFile.{fileSizeMB}MB";
            //var tmp1 = Path.Combine(Path.GetTempPath(), nme);
            //var tmp2 = Path.Combine(Path.GetTempPath(), "Test_Package_2.pkg");
            //var size = (int)(fileSizeMB * 1024 * 1024);

            //if (!File.Exists(tmp1))
            //{
            //    var sb = new StringBuilder();

            //    while (sb.Length < size)
            //        sb.AppendLine(_fke.Text);

            //    File.WriteAllText(tmp1, sb.ToString());
            //}

            //File.Copy(tmp1, tmp2, true);

            var tmp = CreateFile.WithSizeMB(fileSizeMB, "Test_Package_2.pkg");
            var pkg = LocalR2Package.From(tmp);

            pkg.nid = 2;
            return(pkg);
        }
 public WorkspaceEditDocumentChange(CreateFile createFile)
 {
     TextDocumentEdit = null;
     CreateFile       = createFile;
     RenameFile       = null;
     DeleteFile       = null;
 }
Beispiel #8
0
    public void Create(IOutput output, string?path = null, bool overwrite = false)
    {
        if (output is not ISolution solution)
        {
            throw new NotSupportedException($"{nameof(CreateSolution)} only supports {SupportedType.FullName} output types.");
        }

        path ??= string.Empty;
        if (solution.Directory != null && !Path.IsPathRooted(solution.Directory))
        {
            solution.Directory = Path.Combine(path, solution.Directory);
        }

        if (!string.IsNullOrWhiteSpace(solution.Directory))
        {
            var s = new DirectoryInfo(solution.Directory);
            if (!s.Exists)
            {
                s.Create();
            }
        }

        foreach (var file in solution.Files)
        {
            var fileOutput = new CreateFile(_fileWriter);
            fileOutput.Create(file, path);
        }

        foreach (var project in solution.Projects)
        {
            var projectOutput = new CreateProject(_fileWriter);
            projectOutput.Create(project, path);
        }
    }
Beispiel #9
0
        public static void AddCatList(string cat)
        {
            string category = cat;

            CategoryList.AddCat(category);

            CreateFile.CreateCategoryFile();
        }
Beispiel #10
0
        public void FileClosed()
        {
            var tmp = CreateFile.WithText("abcdef");
            var sha = tmp.SHA1ForFile();

            File.Delete(tmp);
            sha.Should().Be("1f8ac10f-23c5b5bc-1167bda8-4b833e5c-057a77d2");
        }
 public InstitutionsController(UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager, RatingContext db, IHostEnvironment environment, CreateFile createFile)
 {
     _userManager = userManager;
     _roleManager = roleManager;
     _db          = db;
     _environment = environment;
     _createFile  = createFile;
 }
Beispiel #12
0
 public IActionResult Index(string printData)
 {
     ViewData["TextToShow"] = string.IsNullOrEmpty(printData)?  "dummy text to show": printData;
     CreateFile.Word("./test.docx", ViewData["TextToShow"].ToString());
     CreateFile.Xlsx("./test.xlsx", ViewData["TextToShow"].ToString());
     CreateFile.Pdf("./test.pdf", ViewData["TextToShow"].ToString());
     CreateFile.HTMLToWord("./test.docx", @"<!DOCTYPE html ><html xmlns='http://www.w3.org/1999/xhtml'><head><meta charset='UTF-8' /><title></title><meta name='Generator' content='PowerTools for Open XML' /></head><body><div><div align='right'><table dir='ltr' class='pt-000000'><tr class='pt-000001'><td class='pt-000002'><p dir='ltr' class='pt-NoSpacing'><span xml:space='preserve' class='pt-000003'> </span></p></td><td class='pt-000004'><p dir='ltr' class='pt-Normal'><span xml:space='preserve' class='pt-000003'> </span></p></td><td class='pt-000005'><div align='left'><table dir='ltr' class='pt-000006'><tr class='pt-000007'><td class='pt-000008'><p dir='ltr' class='pt-NoSpacing'><span xml:space='preserve' class='pt-000003'> </span></p></td></tr><tr class='pt-000009'><td class='pt-000010'><p dir='ltr' class='pt-Title'><span class='pt-DefaultParagraphFont'>Business Trip Checklist</span></p></td></tr><tr class='pt-000011'><td class='pt-000012'><p dir='ltr' class='pt-NoSpacing'><span xml:space='preserve' class='pt-000003'> </span></p></td></tr></table></div><p dir='ltr' class='pt-Normal'><span xml:space='preserve' class='pt-000003'> </span></p></td></tr></table></div><div class='pt-000013'><h1 dir='ltr' class='pt-000014'><span class='pt-000015'>1.</span><span class='pt-DefaultParagraphFont-000016'>While You Are Away: Preparing the Office</span></h1></div><div align='left'><table dir='ltr' class='pt-000006'><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☒</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Organize any necessary meetings to take place on your trip; book appointments and meeting rooms.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>If traveling internationally, obtain any necessary paperwork and vaccinations.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Familiarize yourself with local business customs common at destination.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Confirm appointments, schedules, reservations, etc.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Tie up any loose ends at the office (finish up projects; set up out-of-office replies; notify or remind coworkers about your departure).</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Print out hard copies of presentations, agendas, and important documents.</span></p></td></tr></table></div><div class='pt-000013'><h1 dir='ltr' class='pt-000021'><span class='pt-000015'>2.</span><span class='pt-DefaultParagraphFont-000016'>While You Are Away: Preparing the Home</span></h1></div><div align='left'><table dir='ltr' class='pt-000006'><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Arrange for child, pet, and plant care; communicate needs and schedules.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Pause routine deliveries.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Make your home seem lived-in while away by putting lights and a radio on timers.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Turn down thermostat.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Leave house and car keys, and your complete itinerary, with a trusted friend.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Lock windows, garages, and doors.</span></p></td></tr></table></div><div class='pt-000013'><h1 dir='ltr' class='pt-000021'><span class='pt-000015'>3.</span><span class='pt-DefaultParagraphFont-000016'>Packing for the Trip</span></h1></div><div align='left'><table dir='ltr' class='pt-000006'><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Make a list of the specific items of clothing you’ll need to pack for your trip to suit the various functions you’ll attend.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Try to pack everything you need in a carry-on bag, to avoid the possibility of lost luggage.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>If you check your bag, pack a second set of business clothes and toiletries in a carry-on bag, in case of lost luggage.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Print several copies of this checklist, and save a copy on your computer’s hard drive to refer to when planning your next trip. Storing the checklist on your computer is the easiest way to make updates to it when necessary.</span></p></td></tr></table></div><div class='pt-000013'><h1 dir='ltr' class='pt-000021'><span class='pt-000015'>4.</span><span class='pt-DefaultParagraphFont-000016'>What to Leave for Family and Caregivers at Home</span></h1></div><div align='left'><table dir='ltr' class='pt-000006'><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Leave your contact information—including the names, addresses, and phone numbers of the hotels where you are staying—with a family member, so they can reach you while you’re away.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Phone numbers (all contact numbers for you; doctor/vet; pharmacy; mechanic; school/daycare; helpful friends/neighbors; alarm company).</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Cash for groceries and emergencies.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Consent for medical treatment forms and insurance cards.</span></p></td></tr><tr><td class='pt-000017'><p dir='ltr' class='pt-Checkbox'><span class='pt-DefaultParagraphFont-000018'>☐</span></p></td><td class='pt-000019'><p dir='ltr' class='pt-List'><span class='pt-DefaultParagraphFont-000020'>Your travel itinerary.</span></p></td></tr></table></div><p dir='ltr' class='pt-Normal'><span xml:space='preserve' class='pt-000003'> </span></p></div></body></html>");
     return(View());
 }
        public static CreateProject AddCSharpFactoryDo(this CreateProject project)
        {
            string template = Resources.CSharp.FactoryRegister
                .Replace("[{namespace}]", project.Parameter.ProjectName);

            CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "Register.cs") { Template = template });
            project.Add(file);
            return project;
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            using (BaseClass baseClass = new BaseClass())
            {
                CreateFile createFile = new CreateFile();

                createFile.Exec();
            }
        }
Beispiel #15
0
        private void CopyFile(CreateFile file)
        {
            var filePath = NormalizeAndEvaluate(file.FilePath);

            DeleteFile(filePath);
            var directory = Path.GetDirectoryName(filePath);

            _filesystem.CreateDirectory(directory);
            _filesystem.WriteAllBytes(filePath, file.Content);
        }
Beispiel #16
0
        /// <summary>
        /// Handles plugin initialization.
        /// Fired when the server is started and the plugin is being loaded.
        /// You may register hooks, perform loading procedures etc here.
        /// </summary>
        public override void Initialize()
        {   // Create a Folder
            // Create a file

            List <string> data = new List <string>();

            data.Add("default");
            data.Add("255,255,255");
            data.Add("tshock.canchat");
            data.Add("tshock.account.login");

            if (!Directory.Exists(GroupDirectory))
            {
                Directory.CreateDirectory(GroupDirectory);
                Console.WriteLine("Directory Created");
                if (!File.Exists(file))
                {
                    CreateFile.DoCreateFile(file, data);
                    Console.WriteLine("File Created");
                }
            }

            // Read contents of a file and create groups based on them.
            foreach (string dir in Directory.GetFiles(GroupDirectory))
            {
                Console.WriteLine(dir);
                string thing = Path.GetFullPath(dir);
                Console.WriteLine(thing);
                GroupObject bleh = new GroupObject(thing);
                //if the group doesn't exist, and the parent does, execute.
                Console.WriteLine("Adding Group: " + bleh.Name + " with parent: " + bleh.parent);
                string parent = Path.GetFullPath(bleh.parent);

                if (!TShock.Groups.GroupExists(bleh.Name))
                {
                    // check if parent group exists
                    if (TShock.Groups.GroupExists(bleh.parent.ToString()))
                    {
                        AddGroupFromFile(bleh);
                    }
                    // if parent doesn't exists, but file for it does
                    else if (File.Exists(parent.ToString()))
                    {
                        GroupObject Parent = new GroupObject(parent);
                        AddGroupFromFile(Parent);
                        AddGroupFromFile(bleh);
                    }
                    // TO DO: Make this recursive
                    else
                    {
                        Console.WriteLine(bleh.Name + "has failed to load because it's parent Group " + parent + ", parent's doesn't exist.  Also, creator of this plugin needs to learn how to handle this scenario.");
                    }
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// 检查事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheck_Click(object sender, EventArgs e)
        {
            //检查文件路径
            if (cbJGFHX.Checked)
            {
                CheckPath checkPath = new CheckPath();
                checkPath.CheckPathMsg(tbBrowse.Text, this);
            }
            //成果文件配置
            if (cbJGFHX.Checked)
            {
                CheckFile checkFile = new CheckFile();
                checkFile.CheckFileMsg(checkFile.ReturnFiles(tbBrowse.Text, this), tbBrowse.Text, this);
            }
            if (cbJCZB.Checked)
            {
                CheckFile    checkFile = new CheckFile();
                CheckZhiBiao zhibiao   = new CheckZhiBiao();
                //zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this);
                Thread thread = new Thread(delegate() { zhibiao.CheckZhiBiaoMsg(ComMsg.infoList, tbBrowse.Text, this); });
                thread.Start();
            }
            if (cbJCZB.Checked)
            {
                CheckGuiZe guize = new CheckGuiZe();
                guize.CheckSempleGuiZe(tbBrowse.Text, this);
            }
            /********************此区域预留用于检查其它项目,代码参考CheckPathMsg**************************/

            /********************************************************************************************/
            //将错误信息写入首页的DataGridView
            WriteFile writeFile = new WriteFile();

            this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入列表文件";
            writeFile.WriteDataGridView(ComMsg.ResultShow, this.dgCheckResult);

            //生成文档
            CreateFile createFile = new CreateFile();

            createFile.CreateDoc(tbBrowse.Text, cmbType.Text); //创建word文档
            createFile.CreateXls(tbBrowse.Text, cmbType.Text); //创建Excel文档

            //写入文档
            this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Excel文件";
            writeFile.WriteXls(ComMsg.xlsPath);      //向Excel文档中写入检查结果
            this.rtbLog.Text += "\n " + DateTime.Now.ToLongTimeString() + "写入Word文件";
            createFile.WrithDocFile(ComMsg.docPath); //向doc文档中写入检查结果


            //清空相关的文档
            ComMsg.docPath    = string.Empty;
            ComMsg.xlsPath    = string.Empty;
            ComMsg.infoList   = new List <FileInfo>();
            ComMsg.ResultShow = new List <ResultEntity>();
        }
Beispiel #18
0
        public void FileInUse()
        {
            var tmp = CreateFile.WithText("abcdef");
            //var loc = new FileStream(tmp, FileMode.Open, FileAccess.Read, FileShare.None);
            var loc = new FileStream(tmp, FileMode.Open, FileAccess.ReadWrite);
            var sha = tmp.SHA1ForFile();

            loc.Dispose();
            File.Delete(tmp);
            sha.Should().Be("1f8ac10f-23c5b5bc-1167bda8-4b833e5c-057a77d2");
        }
        public static CreateProject AddAspNetSettings(this CreateProject project)
        {
            var safeName = GetSafeName(project.Parameter.SolutionParam.SolutionName);

            var template = Resources.AspNet.AppSettings
                .Replace("[{name}]", safeName);

            CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "appsettings.json") { Template = template });
            project.Add(file);
            return project;
        }
Beispiel #20
0
    public void CreateFile_Create_ThrowsWithSnippet()
    {
        var writer = Substitute.For <IFileWriter>();
        var output = Substitute.For <ISnippet>();

        var sut = new CreateFile(writer);

        var act = () => sut.Create(output);

        act.Should().Throw <NotSupportedException>();
    }
Beispiel #21
0
    public void CreateFile_Create_WritesFIle()
    {
        var writer = Substitute.For <IFileWriter>();
        var output = Substitute.For <IFile>();

        var sut = new CreateFile(writer);

        sut.Create(output);

        writer.ReceivedCalls().Should().HaveCount(1);
    }
Beispiel #22
0
    public void CreateFile_Create_UpdatesEmptyPath()
    {
        var writer = Substitute.For <IFileWriter>();
        var output = Substitute.For <IFile>();

        var sut = new CreateFile(writer);

        sut.Create(output, "path");

        writer.ReceivedCalls().Should().HaveCount(1);
        output.Path.Should().Be("path");
    }
Beispiel #23
0
        public static async void CheckIfUserPressesEnterAsync(string textBoxText, CreateFile CreateFileForm, KeyPressEventArgs e, CreateFileBindingModel bindingModel)
        {
            //uses string textBoxText to get user input for a name of a file
            //uses CreateFile Form, KeyPressEventArgs to check if user has done everything properly on that form.
            //uses CreateFileBindingModel to set its properties.

            if (e.KeyChar == (char)Keys.Enter)
            {
                //checks if user has pressed Enter in CreateFile Form
                await Task.Run(() => CheckIfTextBoxIsEmpty(textBoxText, CreateFileForm, bindingModel));
            }
        }
Beispiel #24
0
        private void CreateFilePrivate(string destinationFilePath, byte[] content)
        {
            var file = new CreateFile
            {
                FilePath = destinationFilePath,
                Content  = content
            };

            _files.ExecuteBatchAsync(new FileBatch {
                FilesToCreate = { file }
            }).Wait();
        }
        // Deletes a specific category
        public static void DeleteCat(string cat)
        {
            for (int i = 0; i < CatList.Count; i++)
            {
                if (CatList.ElementAt(i).Equals(cat))
                {
                    CatList.RemoveAt(i);

                    CreateFile.CreateCategoryFile();
                }
            }
        }
 public void Execute(ServiceObject service)
 {
     CreateFile.SetConfig(service);
     CreateFile.FileIService(service.Functions);
     CreateFile.FileService(service.Functions, service.OriginServiceName);
     CreateFile.FileServiceSVC();
     CreateFile.FileProj(service.OriginServiceName, service.ObjectTypes);
     CreateFile.WebConfig();
     CreateFile.Package();
     CreateFile.Solution();
     CreateFile.CreateProxyClassFromStream(service);
 }
        private void CheckIfCancelIsPressed(CreateFileBindingModel createFileBindingModel)
        {
            //Uses CreateFileBindingModel to set its properties

            if (createFileBindingModel.IsPressed == false)
            {
                //Checks the user input in CreateFile form if the users hasn't pressed Cancel
                CheckUserPressedButton(createFileBindingModel);
            }

            CreateFileForm.Dispose();
            CreateFileForm = new CreateFile();
        }
        public async Task UpdatesColdTarget()
        {
            var svrFile = CreateFile.WithRandomText();
            var locFile = svrFile.MakeTempCopy(".locFile1");
            var server  = FcServer.StartWith(svrFile, 1, out VersionKeeperSettings cfg);
            var client  = await FcClient.StartWith(locFile, cfg);

            FileChange.Trigger(svrFile);
            await Task.Delay(1000 * 2);

            locFile.MustMatchHashOf(svrFile);

            await TmpDir.Cleanup(server, svrFile, client, locFile);
        }
Beispiel #29
0
    public void CreateFile_Create_RootedPathDoesntUpdate()
    {
        var writer = Substitute.For <IFileWriter>();
        var output = Substitute.For <IFile>();

        output.Path = "c:\\test";

        var sut = new CreateFile(writer);

        sut.Create(output, "path");

        writer.ReceivedCalls().Should().HaveCount(1);
        output.Path.Should().Be("c:\\test");
    }
Beispiel #30
0
        private static void CheckIfTextBoxIsEmpty(string textBoxText, CreateFile CreateFileForm, CreateFileBindingModel bindingModel)
        {
            //uses string textBoxText to get user input for a name of a file
            //uses CreateFile Form, KeyPressEventArgs to check if user has done everything properly on that form.
            //uses CreateFileBindingModel to set its properties.

            if (textBoxText != "")
            {
                SetCreateFileBindingModelName(textBoxText, bindingModel);
                CreateFileForm.Close();
            }
            else
            {
                ShowMessage();
            }
        }
 private void CreateFile_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (TBadres.Text != "")
         {
             pathForCreate = TBadres.Text;
             CreateFile cf = new CreateFile();
             cf.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Критическая ошибка.");
     }
 }
        public void UploadFile()
        {
            var storageAccount = CloudStorageAccount.Parse(configuration.GetConnectionString("storage"));
            var blobClient     = storageAccount.CreateCloudBlobClient();
            var container      = blobClient.GetContainerReference("uploadedfiles");

            container.CreateIfNotExists();

            var blockBlob = container.GetBlockBlobReference("myblob");

            // Create or overwrite the "myblob" blob with contents from a local file.
            using (var stream = CreateFile.Get())
            {
                blockBlob.UploadFromStream(stream);
            }
        }
Beispiel #33
0
        private void CreateFirstPopulation(int sizeOfPopulation, int employeesNumber, Subjects subjects)
        {
            var profitList = new List <double>();
            var sorted     = _factory.EmployeesList.OrderBy(o => o.Abilities).ToList();

            for (int i = 0; i < sizeOfPopulation; i++)
            {
                Population.Add(CreateBee(employeesNumber));
            }
            Population = Population.OrderBy(o => o.Profit).ToList();
            _iterationResults.Add(Population[Population.Count - 1].Profit);
            for (int i = 0; i < _numberOfIterations; i++)
            {
                NeigbourhoodSearch(Population);
            }
            CreateFile.CreateResultFile(_iterationResults);
        }
        public HttpResponseMessage ValidatePost([FromBody] FileUploadValidationModel model)
        {
            var command = new CreateFile(User)
            {
                FileData = new CreateFile.FileDataWrapper
                {
                    FileName = model.Name,
                    Content = model.Length.HasValue ? new byte[model.Length.Value] : new byte[0],
                },
            };
            var validationResult = _createValidator.Validate(command);

            var forProperties = new List<Func<ValidationFailure, bool>>
            {
                x => x.PropertyName == command.PropertyName(y => y.FileData.FileName),
            };
            if (model.Length.HasValue)
                forProperties.Add(x => x.PropertyName == command.PropertyName(y => y.FileData.Content));
            foreach (var forProperty in forProperties)
                if (validationResult.Errors.Any(forProperty))
                    return Request.CreateResponse(HttpStatusCode.BadRequest,
                        validationResult.Errors.First(forProperty).ErrorMessage, "text/plain");

            return Request.CreateResponse(HttpStatusCode.OK);
        }
        public static CreateProject AddAspNetProjectJson(this CreateProject project, bool full)
        {
            var references = new List<string>();

            if (full)
            {
                references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Contract");
                references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Entity");
                references.Add($"{project.Parameter.SolutionParam.SolutionName}.Business.Factory");
            }

            var template = CommandExtencionsCommon.MergeProjectJson(Resources.AspNet.ProjecJson, references);

            CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "project.json") { Template = template });
            project.Add(file);
            return project;
        }
        public static CreateProject AddAngularGulp(this CreateProject project, bool full)
        {
            string template = Resources.Angular2.GulpFileSimple;

            if (full)
            {
                template = Resources.Angular2.GulpFile
                    .Replace("[{entity}]", $"{project.Parameter.SolutionParam.SolutionName}.Business.Entity")
                    .Replace("[{resource}]", $"{project.Parameter.SolutionParam.SolutionName}.Business.Resource")
                    .Replace("[{codegenerator}]", $"{project.Parameter.SolutionParam.SolutionName}.CodeGenerator");
            }

            CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "gulpfile.js") { Template = template });
            project.Add(file);
            return project;
        }
 public static CreateProject AddCSharpProjectJson(this CreateProject project, ProjectJson type)
 {
     CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "project.json") { Template = GetProjectJson(project, type) });
     project.Add(file);
     return project;
 }
 public static CreateProject AddFile(this CreateProject project, string path, string name, string template)
 {
     CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, path, name) { Template = template });
     project.Add(file);
     return project;
 }
Beispiel #39
0
 //Insert 1 file object
 public void Post(CreateFile request)
 {
     Db.ExecuteSql("INSERT INTO file (title, date, path, description, type, locationid, analysisid) VALUES ('" + request.title + "', '" + request.date + "', '" + request.path + "', '" + request.description + "', '" + request.type + "', '" + request.locationid + "', '" + request.analysisid + "')");
 }
Beispiel #40
0
        private void insertRecord(CreateAnalysis cAna, CreateLocation cLoc, CreateFile cFile)
        {
            AnalysisService analysis = new AnalysisService();
            CreateAnalysisResult anaResult = analysis.Post(cAna);
            int analysisID = anaResult.Analysis.ID;
            cFile.analysisid = analysisID;

            LocationsService location = new LocationsService();
            CreateLocationResult locResult = location.Post(cLoc);
            int locationID = locResult.Location.ID;
            cFile.locationid = locationID;

            FileService file = new FileService();
            file.Post(cFile);
        }
 public static CreateProject AddAspNetWebConfig(this CreateProject project)
 {
     CreateFile file = new CreateFile(new CreateFileParam(project.Parameter, ".", "web.config") { Template = Resources.AspNet.WebConfig });
     project.Add(file);
     return project;
 }
        public HttpResponseMessage Post(int agreementId, [FromBody] AgreementFileApiModel model)
        {
            model.AgreementId = agreementId;
            var command = new CreateFile(User)
            {
                FileData = model.FileMedium == null ? null : new CreateFile.FileDataWrapper
                {
                    FileName = model.FileMedium.FileName,
                    MimeType = model.FileMedium.ContentType,
                    Content = model.FileMedium.Content,
                },
            };
            Mapper.Map(model, command);

            try
            {
                _createHandler.Handle(command);
            }
            catch (ValidationException ex)
            {
                Func<ValidationFailure, bool> forName = x => x.PropertyName == command.PropertyName(y => y.FileData.FileName);
                Func<ValidationFailure, bool> forContent = x => x.PropertyName == command.PropertyName(y => y.FileData.Content);
                if (ex.Errors.Any(forName))
                    return Request.CreateResponse(HttpStatusCode.UnsupportedMediaType,
                        ex.Errors.First(forName).ErrorMessage, "text/plain");
                if (ex.Errors.Any(forContent))
                    return Request.CreateResponse(HttpStatusCode.RequestEntityTooLarge,
                        ex.Errors.First(forContent).ErrorMessage, "text/plain");
            }

            var url = Url.Link(null, new
            {
                controller = "AgreementFiles",
                action = "Get",
                agreementId,
                fileId = command.CreatedFileId,
            });
            Debug.Assert(url != null);
            var successPayload = new
            {
                message = string.Format("File '{0}' was successfully attached.", model.CustomName),
                location = url, // TODO: when IE8 dies, no need to do this (it is a workaround for kendo + IE only)
            };
            var successJson = JsonConvert.SerializeObject(successPayload);
            var response = Request.CreateResponse(HttpStatusCode.Created, successJson, "text/plain");
            response.Headers.Location = new Uri(url);
            return response;
        }
Beispiel #43
0
 private void insertIntoDatabase()
 {
     abuseper = 0;
     //Face
     if (angry > smile && angry > sad && angry > neutral && angry > noDetect)
     {
         abuseper = abuseper + 25;
     }
     //Motion
     if ((((leftfist + rightfist + leftpalm + rightpalm) / totalFrame) * 100) > 20)
     {
         abuseper = abuseper + 25;
     }
     //Sound
     if (soundresult == true)
     {
         abuseper = abuseper + 25;
     }
     //Heat
     if (feverresult >= 50)
     {
         abuseper = abuseper + 25;
     }
     CreateAnalysis cAna = new CreateAnalysis(abuseper, totalFrame, smile, angry, sad, neutral, leftfist, rightfist, leftpalm, rightpalm, soundresult, soundpath, feverresult);
     CreateLocation cLoc = new CreateLocation(address, x, y);
     CreateFile cFile = new CreateFile(title, date, path, desc, type);
     insertRecord(cAna, cLoc, cFile);
 }