public void FailedCopyCausesNonZeroReturnCode() { // given Mock<ICopier> copier = new Mock<ICopier>(MockBehavior.Strict); copier .Setup(r => r.Copy(It.Is<Computer>(c => c.Name == "mycomputer"), @"c:\temp\foo.bat", @"\bah\thing.bat")) .Throws<InvalidOperationException>(); // when Copy copy = new Copy(copier.Object); StringWriter output = new StringWriter(); ConsoleCommandDispatcher.DispatchCommand( copy, new[] { "-source", @"c:\temp\foo.bat", "-target", @"\bah\thing.bat", "-computername", "mycomputer", "-adminpassword", "foobah" }, output); int result = copy.Run(new string[] { }); Assert.That(result, Is.Not.EqualTo(0)); copier.VerifyAll(); }
public void ShouldDeleteDirectory() { var copier = new Mock<IFileSystemCopier>(); var toPath = "todir"; var toDir = new Copy(copier.Object) { ToPath = toPath}; toDir.TestClean(); copier.Verify(c => c.Delete(toPath), Times.Once()); }
public void TakingDependencyOnToPathShouldTakeDependencyOnCopyItself() { Task<string> fromPath = "fromPath"; Task<string> toPath = "toPath"; var copy = new Copy {FromPath = fromPath, ToPath = toPath}; Assert.That(copy.Dependencies.Select(d => d.Task), Has.Member(fromPath)); Assert.That(copy.Dependencies.Select(d => d.Task), Has.Member(toPath)); Assert.That(copy.ToPath.Dependencies.Select(d => d.Task), Has.Member(copy)); }
public override void Context() { RemoveAndCreateDirectory(destDir1); RemoveAndCreateDirectory(destDir2); var defaultPackageSource = new PackageSource(NuGetConstants.DefaultFeedUrl); var settings = Settings.LoadDefaultSettings(); IPackageSourceProvider sourceProvider = new PackageSourceProvider(settings, new[] { defaultPackageSource }); IPackageRepositoryFactory repositoryFactory = new CommandLineRepositoryFactory(); command = new Copy(repositoryFactory, sourceProvider); command.Console = new Console(); }
public void ShouldCopy() { var copier = new Mock<IFileSystemCopier>(); var fromPath = "fromdir"; var toPath = "todir"; var includes = new string[0]; var excludes = new string[0]; var toDir = new Copy(copier.Object) {ToPath = toPath, FromPath = fromPath, Includes = includes, Excludes = excludes}; var bounce = new Mock<IBounce>(); bounce.SetupGet(b => b.Log).Returns(new Mock<ILog>().Object); toDir.TestBuild(); copier.Verify(c => c.Copy(fromPath, toPath, excludes, includes, true), Times.Once()); }
/// <summary> /// create copy of given book searched by barcode and increase its quantity with 1 /// </summary> /// <param name="bookBarcode">the barcode of the book </param> /// <param name="serialNumber"></param> /// <param name="purchaseDate"></param> /// <param name="purchasePrice"></param> /// <returns>true if the copy is created successfully and false otherwise </returns> public bool CreateCopyOfBook(int bookBarcode, string purchaseDate, double purchasePrice, bool state) { Book book = GetBookByBarcode(bookBarcode); Random random = new Random(); int index = random.Next(1, 500); String serialNumber = index.ToString(); while(book.GetCopyBySerialNumber(serialNumber)!= null) { index = random.Next(1, 500); serialNumber = index.ToString(); } if(book != null ) { Copy copy = new Copy(serialNumber,purchaseDate,purchasePrice,state ); book.Copies.Add(copy); book.Quantity += 1; bookCollection.StoreBookCollectionToFile(books); return true; } return false; }
public HomeModule() { Get["/"] = _ => { Dictionary <object, object> model = new Dictionary <object, object>(); List <Checkout> allCheckouts = Checkout.GetAll(); foreach (Checkout checkout in allCheckouts) { Patron thisPatron = Patron.Find(checkout.GetPatronsId()); model.Add(checkout, thisPatron); } return(View["index.cshtml", model]); }; Get["/books"] = _ => { List <Book> allBooks = Book.GetAll(); return(View["books.cshtml", allBooks]); }; Get["/patrons"] = _ => { List <Patron> allPatrons = Patron.GetAll(); return(View["patrons.cshtml", allPatrons]); }; Get["/authors"] = _ => { List <Author> allAuthors = Author.GetAll(); return(View["authors.cshtml", allAuthors]); }; Post["/add_book"] = _ => { Book newBook = new Book(Request.Form["title"]); newBook.Save(); Author newAuthor = new Author(Request.Form["author-first"], Request.Form["author-last"]); newAuthor.Save(); newBook.AddAuthor(newAuthor); Copy newCopy = new Copy(newBook.GetId()); newCopy.Save(); newBook.AddCopy(Request.Form["num-copies"]); List <Book> allBooks = Book.GetAll(); return(View["books.cshtml", allBooks]); }; Post["/add_patron"] = _ => { Patron newPatron = new Patron(Request.Form["patron-first"], Request.Form["patron-last"]); newPatron.Save(); List <Patron> allPatrons = Patron.GetAll(); return(View["patrons.cshtml", allPatrons]); }; Get["/book/{id}"] = parameters => { Book newBook = Book.Find(parameters.id); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("book", newBook); model.Add("allAuthors", Author.GetAll()); return(View["book.cshtml", model]); }; Get["/author/{id}"] = parameters => { Author newAuthor = Author.Find(parameters.id); return(View["author.cshtml", newAuthor]); }; Get["/patron/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Patron newPatron = Patron.Find(parameters.id); model.Add("patron", newPatron); model.Add("allBooks", Book.GetAll()); return(View["patron.cshtml", model]); }; Post["/patron/delete/{id}"] = parameters => { Patron newPatron = Patron.Find(parameters.id); newPatron.DeletePatron(); List <Patron> allPatrons = Patron.GetAll(); return(View["patrons.cshtml", allPatrons]); }; Post["/patrons/delete"] = _ => { Patron.DeleteAll(); List <Patron> allPatrons = Patron.GetAll(); return(View["patrons.cshtml", allPatrons]); }; Post["/books/delete"] = _ => { Book.DeleteAll(); List <Book> allBooks = Book.GetAll(); return(View["books.cshtml", allBooks]); }; Post["/book/delete/{id}"] = parameters => { Book newBook = Book.Find(parameters.id); newBook.DeleteBook(); List <Book> allBooks = Book.GetAll(); return(View["books.cshtml", allBooks]); }; Post["/book/search_title"] = _ => { Book searchedBook = Book.SearchTitle(Request.Form["search-book-title"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("book", searchedBook); model.Add("allAuthors", Author.GetAll()); return(View["book.cshtml", model]); }; Post["/patron/search_name"] = _ => { Patron searchedPatron = Patron.SearchPatron(Request.Form["search-patron-name"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("patron", searchedPatron); model.Add("allBooks", Book.GetAll()); return(View["patron.cshtml", model]); }; Post["book/add_author/{id}"] = parameters => { Book searchedBook = Book.Find(parameters.id); searchedBook.AddAuthor(Author.Find(Request.Form["author-id"])); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("book", searchedBook); model.Add("allAuthors", Author.GetAll()); return(View["book.cshtml", model]); }; Patch["/book/update_title"] = _ => { Book newBook = Book.Find(Request.Form["book-id"]); newBook.UpdateTitle(Request.Form["new-title"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("book", newBook); model.Add("allAuthors", Author.GetAll()); return(View["book.cshtml", model]); }; Post["/book/add_copy"] = _ => { Book newBook = Book.Find(Request.Form["book-id"]); newBook.AddCopy(Request.Form["copy-amount"]); Dictionary <string, object> model = new Dictionary <string, object>(); model.Add("book", newBook); model.Add("allAuthors", Author.GetAll()); return(View["book.cshtml", model]); }; Post["/book/checkout/{id}"] = parameters => { Dictionary <string, object> model = new Dictionary <string, object>(); Patron foundPatron = Patron.Find(parameters.id); Book checkedoutBook = Book.Find(Request.Form["book-id"]); checkedoutBook.CheckoutBook(foundPatron.GetId()); model.Add("patron", foundPatron); model.Add("allBooks", Book.GetAll()); return(View["patron.cshtml", model]); }; Post["/add_author"] = _ => { Author newAuthor = new Author(Request.Form["author-first"], Request.Form["author-last"]); newAuthor.Save(); List <Author> allAuthors = Author.GetAll(); return(View["authors.cshtml", allAuthors]); }; Post["/authors/delete"] = _ => { Author.DeleteAll(); List <Author> allAuthors = Author.GetAll(); return(View["authors.cshtml", allAuthors]); }; Post["/delete/author/{id}"] = parameters => { Author foundAuthor = Author.Find(parameters.id); foundAuthor.DeleteAuthor(); List <Author> allAuthors = Author.GetAll(); return(View["authors.cshtml", allAuthors]); }; }
public ActionResult Create(Copy copy) { _db.Copies.Add(copy); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <IActionResult> OnPost(string jsonStr) { if (string.IsNullOrEmpty(jsonStr)) { return(Page()); } var data = Newtonsoft.Json.JsonConvert.DeserializeObject <AttendanceServiceDTO>(jsonStr); if (data == null) { return(Page()); } var report = _pinhuaContext.AttendanceReport.AsNoTracking().FirstOrDefault(r => r.Y == data.Y && r.M == data.M); if (report == null) { return(Page()); } var reportDetails = new List <AttendanceReportResults>(); foreach (var person in data.PersonList) { var detail = new AttendanceReportResults { ExcelServerRcid = report.ExcelServerRcid, ExcelServerRtid = report.ExcelServerRtid, Y = data.Y.Value, M = data.M.Value, 编号 = person.Id, 姓名 = person.Name, 是否全勤 = person.IsFullAttendance ? "是" : "否", 正班 = person.DaytimeHours, 加班 = person.OvertimeHours, 总工时 = person.TotalHours, 缺勤 = person.TimesOfAbsent, 迟到 = person.TimesOfLate, 早退 = person.TimesOfLeaveEarly, 请假 = person.TimesOfAskForLeave, 用餐 = person.TimesOfDinner, }; reportDetails.Add(detail); } reportDetails.ForEach(i => { var result = _pinhuaContext.AttendanceReportResults.FirstOrDefault(p => p.Y == i.Y && p.M == i.M && p.编号 == i.编号); if (result == null) { // 如果该条信息不存在,则添加 _pinhuaContext.AttendanceReportResults.Add(i); } else { // 如果该条信息存在,则修改 Copy.ShadowCopy(i, result); } }); await _pinhuaContext.AttendanceReportResults.Where(p => p.Y == data.Y && p.M == data.M).ForEachAsync(i => { var result = reportDetails.FirstOrDefault(p => p.编号 == i.编号); if (result == null) { // 如果该条信息多余,则删除 _pinhuaContext.AttendanceReportResults.Remove(i); } }); // 保存明细 var abc = new List <AttendanceReportDetails>(); foreach (var person in data.PersonList) { foreach (var detail in person.Results) { foreach (var range in detail.Details) { var o = new AttendanceReportDetails { 编号 = person.Id, 姓名 = person.Name, 日期 = detail.Date, 班段 = range.RangeId, 班段描述 = range.Range, 班 = range.Time1Fix, 班 = range.Time2Fix, 工时 = range.Hours, 考勤结果 = range.State, ExcelServerRcid = report.ExcelServerRcid, ExcelServerRtid = report.ExcelServerRtid, }; abc.Add(o); } } } var details = _pinhuaContext.AttendanceReportDetails.Where(d => d.ExcelServerRcid == report.ExcelServerRcid); _pinhuaContext.AttendanceReportDetails.RemoveRange(details); _pinhuaContext.AttendanceReportDetails.AddRange(abc); _pinhuaContext.SaveChanges(); return(RedirectToPage("Index")); }
public void isValidCommand() { foreach (string command in validCommands) { if (String.Compare(getCommand(), command, true) == 0) { valid = true; } } if (valid) { switch (getCommand().ToLower()) { case "mkdir": Mkdir m = new Mkdir(); m.mkdir(userArgs); //Console.WriteLine(m.getUsage()); break; case "dir": Console.WriteLine("Dir implemented"); Dir dir = new Dir(); dir.dir(userArgs); break; case "copy": Console.WriteLine("Copy implemented"); Copy c = new Copy(); c.copy(userArgs); break; case "del": Del del = new Del(); del.del(userArgs[0]); break; case "chdir": Chdir checkDirectory = new Chdir(); checkDirectory.chdir(userArgs); // Console.WriteLine(chdir); break; case "cls": Console.Clear(); break; case "cd": Cd changeDir = new Cd(); changeDir.cd(userArgs); break; case "find": Console.WriteLine("Find implemented"); break; case "ls": Console.WriteLine("LS implemented"); break; case "move": Move mov = new Move(); mov.move(userArgs); break; case "rmdir": Console.WriteLine("rmdir implemented"); break; case "rename": Rename r = new Rename(); r.rename(userArgs); break; case "replace": Console.WriteLine("replace implemented"); break; case "exit": Console.WriteLine("OS will now close. Goodbye"); System.Threading.Thread.Sleep(1000); Environment.Exit(0); break; case "help": Console.WriteLine("help"); break; default: Console.WriteLine("Nothing happened"); break; } } else { Console.WriteLine("invalid command."); } }
public bool HasChanges(bool withRemoval) => (withRemoval && Remove.Any()) || Update.Any() || New.Any() || Copy.Any() || ChangedCase.Any();
private static void ConvertPersonalGeodatabaseToFileGeodatabase() { // Initialize the Geoprocessor Geoprocessor geoprocessor = new Geoprocessor(); // Allow for the overwriting of file geodatabases, if they previously exist. geoprocessor.OverwriteOutput = true; // Set the workspace to a folder containing personal geodatabases. geoprocessor.SetEnvironmentValue("workspace", @"C:\data"); // Identify personal geodatabases. IGpEnumList workspaces = geoprocessor.ListWorkspaces("*", "Access"); string workspace = workspaces.Next(); while (workspace != "") { // Set workspace to current personal geodatabase geoprocessor.SetEnvironmentValue("workspace", workspace); // Create a file geodatabase with the same name as the personal geodatabase string gdbname = System.IO.Path.GetFileName(workspace).Replace(".mdb", ""); string dirname = System.IO.Path.GetDirectoryName(workspace); // Execute CreateFileGDB tool CreateFileGDB createFileGDBTool = new CreateFileGDB(dirname, gdbname + ".gdb"); geoprocessor.Execute(createFileGDBTool, null); // Initialize the Copy Tool Copy copyTool = new Copy(); // Identify feature classes and copy to file geodatabase IGpEnumList fcs = geoprocessor.ListFeatureClasses("", "", ""); string fc = fcs.Next(); while (fc != "") { Console.WriteLine("Copying " + fc + " to " + gdbname + ".gdb"); copyTool.in_data = fc; copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fc; geoprocessor.Execute(copyTool, null); fc = fcs.Next(); } // Identify feature datasets and copy to file geodatabase IGpEnumList fds = geoprocessor.ListDatasets("", ""); string fd = fds.Next(); while (fd != "") { Console.WriteLine("Copying " + fd + " to " + gdbname + ".gdb"); copyTool.in_data = fd; copyTool.data_type = "FeatureDataset"; copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + fd; try { geoprocessor.Execute(copyTool, null); } catch (Exception ex) { object sev = null; System.Windows.Forms.MessageBox.Show(ex.Message); } fd = fds.Next(); } // Identify tables and copy to file geodatabase IGpEnumList tbls = geoprocessor.ListTables("", ""); string tbl = tbls.Next(); while (tbl != "") { Console.WriteLine("Copying " + tbl + " to " + gdbname + ".gdb"); copyTool.in_data = tbl; copyTool.out_data = dirname + "\\" + gdbname + ".gdb" + "\\" + tbl; geoprocessor.Execute(copyTool, null); tbl = tbls.Next(); } workspace = workspaces.Next(); } }
public UploadResult UploadFile(Stream stream, string fileName) { FileUploader fileUploader = null; FileDestination fileDestination; switch (Info.DataType) { case EDataType.Image: fileDestination = Info.TaskSettings.ImageFileDestination; break; case EDataType.Text: fileDestination = Info.TaskSettings.TextFileDestination; break; default: case EDataType.File: fileDestination = Info.TaskSettings.FileDestination; break; } switch (fileDestination) { case FileDestination.Dropbox: fileUploader = new Dropbox(Program.UploadersConfig.DropboxOAuth2Info, Program.UploadersConfig.DropboxAccountInfo) { UploadPath = NameParser.Parse(NameParserType.URL, Dropbox.TidyUploadPath(Program.UploadersConfig.DropboxUploadPath)), AutoCreateShareableLink = Program.UploadersConfig.DropboxAutoCreateShareableLink, ShareURLType = Program.UploadersConfig.DropboxURLType }; break; case FileDestination.OneDrive: fileUploader = new OneDrive(Program.UploadersConfig.OneDriveOAuth2Info); break; case FileDestination.Copy: fileUploader = new Copy(Program.UploadersConfig.CopyOAuthInfo, Program.UploadersConfig.CopyAccountInfo) { UploadPath = NameParser.Parse(NameParserType.URL, Copy.TidyUploadPath(Program.UploadersConfig.CopyUploadPath)), URLType = Program.UploadersConfig.CopyURLType }; break; case FileDestination.GoogleDrive: fileUploader = new GoogleDrive(Program.UploadersConfig.GoogleDriveOAuth2Info) { IsPublic = Program.UploadersConfig.GoogleDriveIsPublic, FolderID = Program.UploadersConfig.GoogleDriveUseFolder ? Program.UploadersConfig.GoogleDriveFolderID : null }; break; case FileDestination.RapidShare: fileUploader = new RapidShare(Program.UploadersConfig.RapidShareUsername, Program.UploadersConfig.RapidSharePassword, Program.UploadersConfig.RapidShareFolderID); break; case FileDestination.SendSpace: fileUploader = new SendSpace(APIKeys.SendSpaceKey); switch (Program.UploadersConfig.SendSpaceAccountType) { case AccountType.Anonymous: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey); break; case AccountType.User: SendSpaceManager.PrepareUploadInfo(APIKeys.SendSpaceKey, Program.UploadersConfig.SendSpaceUsername, Program.UploadersConfig.SendSpacePassword); break; } break; case FileDestination.Minus: fileUploader = new Minus(Program.UploadersConfig.MinusConfig, Program.UploadersConfig.MinusOAuth2Info); break; case FileDestination.Box: fileUploader = new Box(Program.UploadersConfig.BoxOAuth2Info) { FolderID = Program.UploadersConfig.BoxSelectedFolder.id, Share = Program.UploadersConfig.BoxShare }; break; case FileDestination.Gfycat: fileUploader = new GfycatUploader(); break; case FileDestination.Ge_tt: fileUploader = new Ge_tt(APIKeys.Ge_ttKey) { AccessToken = Program.UploadersConfig.Ge_ttLogin.AccessToken }; break; case FileDestination.Localhostr: fileUploader = new Hostr(Program.UploadersConfig.LocalhostrEmail, Program.UploadersConfig.LocalhostrPassword) { DirectURL = Program.UploadersConfig.LocalhostrDirectURL }; break; case FileDestination.CustomFileUploader: if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomFileUploaderSelected)) { fileUploader = new CustomFileUploader(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomFileUploaderSelected]); } break; case FileDestination.FTP: int index; if (Info.TaskSettings.OverrideFTP) { index = Info.TaskSettings.FTPIndex.BetweenOrDefault(0, Program.UploadersConfig.FTPAccountList.Count - 1); } else { index = Program.UploadersConfig.GetFTPIndex(Info.DataType); } FTPAccount account = Program.UploadersConfig.FTPAccountList.ReturnIfValidIndex(index); if (account != null) { if (account.Protocol == FTPProtocol.FTP || account.Protocol == FTPProtocol.FTPS) { fileUploader = new FTP(account); } else if (account.Protocol == FTPProtocol.SFTP) { fileUploader = new SFTP(account); } } break; case FileDestination.SharedFolder: int idLocalhost = Program.UploadersConfig.GetLocalhostIndex(Info.DataType); if (Program.UploadersConfig.LocalhostAccountList.IsValidIndex(idLocalhost)) { fileUploader = new SharedFolderUploader(Program.UploadersConfig.LocalhostAccountList[idLocalhost]); } break; case FileDestination.Email: using (EmailForm emailForm = new EmailForm(Program.UploadersConfig.EmailRememberLastTo ? Program.UploadersConfig.EmailLastTo : string.Empty, Program.UploadersConfig.EmailDefaultSubject, Program.UploadersConfig.EmailDefaultBody)) { emailForm.Icon = ShareXResources.Icon; if (emailForm.ShowDialog() == DialogResult.OK) { if (Program.UploadersConfig.EmailRememberLastTo) { Program.UploadersConfig.EmailLastTo = emailForm.ToEmail; } fileUploader = new Email { SmtpServer = Program.UploadersConfig.EmailSmtpServer, SmtpPort = Program.UploadersConfig.EmailSmtpPort, FromEmail = Program.UploadersConfig.EmailFrom, Password = Program.UploadersConfig.EmailPassword, ToEmail = emailForm.ToEmail, Subject = emailForm.Subject, Body = emailForm.Body }; } else { StopRequested = true; } } break; case FileDestination.Jira: fileUploader = new Jira(Program.UploadersConfig.JiraHost, Program.UploadersConfig.JiraOAuthInfo, Program.UploadersConfig.JiraIssuePrefix); break; case FileDestination.Mega: fileUploader = new Mega(Program.UploadersConfig.MegaAuthInfos, Program.UploadersConfig.MegaParentNodeId); break; case FileDestination.AmazonS3: fileUploader = new AmazonS3(Program.UploadersConfig.AmazonS3Settings); break; case FileDestination.OwnCloud: fileUploader = new OwnCloud(Program.UploadersConfig.OwnCloudHost, Program.UploadersConfig.OwnCloudUsername, Program.UploadersConfig.OwnCloudPassword) { Path = Program.UploadersConfig.OwnCloudPath, CreateShare = Program.UploadersConfig.OwnCloudCreateShare, DirectLink = Program.UploadersConfig.OwnCloudDirectLink }; break; case FileDestination.Pushbullet: fileUploader = new Pushbullet(Program.UploadersConfig.PushbulletSettings); break; case FileDestination.MediaCrush: fileUploader = new MediaCrushUploader(); break; case FileDestination.MediaFire: fileUploader = new MediaFire(APIKeys.MediaFireAppId, APIKeys.MediaFireApiKey, Program.UploadersConfig.MediaFireUsername, Program.UploadersConfig.MediaFirePassword) { UploadPath = NameParser.Parse(NameParserType.URL, Program.UploadersConfig.MediaFirePath), UseLongLink = Program.UploadersConfig.MediaFireUseLongLink }; break; } if (fileUploader != null) { PrepareUploader(fileUploader); return(fileUploader.Upload(stream, fileName)); } return(null); }
public override object ToUFEEffect() { var eff = new Copy(); return(eff); }
public static bool Contains(this Copy container, Copy otherEnum) { return((container & otherEnum) != 0); }
static void Main(string[] args) { string dllFileName; if (!File.Exists(dllFileName = Path.Combine(Directory.GetCurrentDirectory(), "TestDLL.dll"))) { return; } uint lastError; int errorCode; bool result; IntPtr pDll = NativeMethods.LoadLibrary(dllFileName); if (pDll == IntPtr.Zero) { errorCode = Marshal.GetLastWin32Error(); lastError = NativeMethods.GetLastError(); return; } IntPtr pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "Add"); if (pAddressOfFunctionToCall == IntPtr.Zero) { errorCode = Marshal.GetLastWin32Error(); lastError = NativeMethods.GetLastError(); if (pDll != IntPtr.Zero) { result = NativeMethods.FreeLibrary(pDll); } return; } Add add = (Add)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(Add)); int resultOfAdd = add(1, 2); pAddressOfFunctionToCall = NativeMethods.GetProcAddress(pDll, "Copy"); if (pAddressOfFunctionToCall == IntPtr.Zero) { errorCode = Marshal.GetLastWin32Error(); lastError = NativeMethods.GetLastError(); if (pDll != IntPtr.Zero) { result = NativeMethods.FreeLibrary(pDll); } return; } byte[] from = { 65, 66, 67, 68, 69 }, to = new byte[5]; Copy copy = (Copy)Marshal.GetDelegateForFunctionPointer(pAddressOfFunctionToCall, typeof(Copy)); bool resultOfCopy = copy(from, to, 5L); if (pDll != IntPtr.Zero) { result = NativeMethods.FreeLibrary(pDll); } }
public async void PutItemAsync(Copy item) { HttpContent content = new StringContent(JsonConvert.SerializeObject(item), Encoding.UTF8, "application/json"); HttpResponseMessage message = await client.PutAsync(GetUri() + item.GetTableName() + "/" + item.ID, content); }
public Rw(string fileNameTXT, string fileLogName) { conf Config = new conf(); FileStream fs = new FileStream(fileNameTXT, FileMode.Open, FileAccess.ReadWrite); DataTable docNames = new DataTable(); docNames.Columns.Add("WZ", typeof(string)); String[] documents; string pdfName = fileNameTXT.Replace(".txt", ".pdf"); StreamReader sr = new StreamReader(fs); while (!sr.EndOfStream) { string text = sr.ReadLine().Replace(" ", ""); if ( text.Contains("rk") && text.Contains("us") && text.Contains("LP/") || text.Contains("Ar") && text.Contains("k") && text.Contains("s") ) { compilerDocName.Rw RwName = new ocr_wz.compilerDocName.Rw(); RwName.RWfirst(text); documents = RwName.resultRW.Split(';'); foreach (var document in documents) { if (document.Contains("LP_")) { RwName.LP(document); if (RwName.resultRW != null) { docNames.Rows.Add(RwName.resultRW); } } else if (document.Contains("RW_")) { RwName.RW(document); if (RwName.resultRW != null) { docNames.Rows.Add(RwName.resultRW); } } } } } if (docNames.Rows.Count == 0) { string docName = pdfName.Replace(Config.inPath + "\\!ocr\\po_ocr\\", ""); Copy CopyNewName = new Copy(pdfName, "0", docName, fileLogName); CopyNewName.CopyOther(); } else { var UniqueRows = docNames.AsEnumerable().Distinct(DataRowComparer.Default); DataTable uniqDocNames = UniqueRows.CopyToDataTable(); StreamWriter SW; SW = File.AppendText(fileLogName); SW.WriteLine("Tablica dokumentów:"); SW.Close(); int rw = 0; int lp = 0; foreach (DataRow row in uniqDocNames.Rows) { StreamWriter SW1; SW1 = File.AppendText(fileLogName); SW1.WriteLine(row.Field <string>(0)); SW1.Close(); if (row.Field <string>(0).Contains("LP_")) { lp++; yearDocs yearOut = new yearDocs(row.Field <string>(0)); yearOut.yearLP(); year = yearOut.year; } else if (row.Field <string>(0).Contains("RW_")) { rw++; } } if (rw == lp || rw > lp) { foreach (DataRow row in uniqDocNames.Rows) { if (row.Field <string>(0).Contains("RW_")) { Copy CopyNewName = new Copy(pdfName, year, row.Field <string>(0), fileLogName); CopyNewName.CopyRW(); } } } else { foreach (DataRow row in uniqDocNames.Rows) { if (row.Field <string>(0).Contains("LP_")) { Copy CopyNewName = new Copy(pdfName, year, row.Field <string>(0), fileLogName); CopyNewName.CopyRW(); } } } fs.Close(); } }
public void GeraMenu() { Console.WriteLine("WELCOME TO OMICRON"); string comando, contexto = ">", hdSelecionado = string.Empty; comando = String.Empty; while (!comando.Equals("exit")) { Console.Write(contexto); comando = Console.ReadLine(); string[] comand = comando.Split(' '); try { switch (comand[0]) { case "createhd": int buffer, linha, coluna; int.TryParse(comand[2], out linha); int.TryParse(comand[3], out coluna); buffer = linha * coluna; CreateHd.CriarHd(comand[1], buffer, true); break; case "cls": Console.Clear(); break; case "selecthd": var existe = SelectHd.SelecionaHd(comand[1]); if (existe) { hdSelecionado = comand[1]; contexto = hdSelecionado + ">"; } else { Console.WriteLine("HD não reconhecido"); } break; case "dirhd": DirHd.ListaHd(); break; case "help": var com = ""; if (comand.Length > 1) { com = comand[1]; } Help.Ajuda(com); break; case "formathd": FormatHd.FormatarHd(comand[1]); break; case "statushd": StatusHd.Status(comand[1]); break; case "typehd": TypeHd.ImprimeTudo(comand[1]); break; case "create": if (!String.IsNullOrEmpty(hdSelecionado)) { Create.CriaArquivo(contexto.Replace(">", ""), comand[1], comand[2]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "del": if (!String.IsNullOrEmpty(hdSelecionado)) { Del.Deleta(contexto.Replace(">", ""), comand[1]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "rmdir": if (!String.IsNullOrEmpty(hdSelecionado)) { Rmdir.RemoveDiretorio(contexto.Replace(">", ""), comand[1]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "type": if (!String.IsNullOrEmpty(hdSelecionado)) { TypeArq.MostrarTudo(contexto.Replace(">", ""), comand[1]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "renamedir": if (!String.IsNullOrEmpty(hdSelecionado)) { RenameDir.RenomeiaDir(contexto.Replace(">", ""), comand[1], comand[2]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "rename": if (!String.IsNullOrEmpty(hdSelecionado)) { RenameArq.RenomeiaArquivo(contexto.Replace(">", ""), comand[1], comand[2]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "mkdir": if (!String.IsNullOrEmpty(hdSelecionado)) { Mkdir.CriaDiretorio(contexto.Replace(">", ""), comand[1]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "dir": if (!String.IsNullOrEmpty(hdSelecionado)) { Dir.MostraDiretorios(contexto.Replace(">", "")); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "copyfrom": if (!String.IsNullOrEmpty(hdSelecionado)) { CopyFrom.PegaImagem(comand[1], comand[2], contexto.Replace(">", "")); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "copyto": if (!String.IsNullOrEmpty(hdSelecionado)) { CopyTo.EnviaImagem(comand[1], comand[2], contexto.Replace(">", "")); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "copy": if (!String.IsNullOrEmpty(hdSelecionado)) { Copy.Copia(contexto.Replace(">", ""), comand[1], comand[2]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "move": if (!String.IsNullOrEmpty(hdSelecionado)) { Move.Movimenta(contexto.Replace(">", ""), comand[1], comand[2]); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "tree": if (!String.IsNullOrEmpty(hdSelecionado)) { Tree.Arvore(hdSelecionado, contexto.Replace(">", "")); } else { Console.WriteLine("Por favor, selecione um hd"); } break; case "removehd": RemoveHd.RemoverHd(comand[1]); break; case "cd": if (comand[1].Equals("..") && string.Concat(hdSelecionado + ">").Equals(contexto)) { hdSelecionado = string.Empty; contexto = ">"; } else if (!String.IsNullOrEmpty(hdSelecionado)) { contexto = SeparaDir(contexto, comand); } else { Console.WriteLine("Por favor, selecione um hd"); } break; default: break; } } catch (Exception e) { Console.WriteLine("...."); } } }
public bool EditCopy(Copy copyToEdit) { RefreshRepositories(); return(rc.EditCopy(copyToEdit)); }
public override void CopyMethod <T>(T source, T target, ReferenceHandling referenceHandling) { Copy.FieldValues(source, target, referenceHandling); }
public void CopyFieldValues() { Copy.FieldValues(this.source, this.target); }
//button select or delete on grid view protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Select") { //must add inside or else exception index=-1(default) occurs int index = Int32.Parse(e.CommandArgument.ToString()); if (copyExist == false) { GridViewRow gvRow = GridView1.Rows[index]; txtTitle.Text = gvRow.Cells[3].Text; //title //default blank in gridview = txtAuthor.Text = gvRow.Cells[4].Text.Trim().Equals(" ") ? "" : gvRow.Cells[4].Text; //author txtPublisher.Text = gvRow.Cells[5].Text.Trim().Equals(" ") ? "" : gvRow.Cells[5].Text; //publisher bo = new Book(); bo.BookNumber = Int32.Parse(gvRow.Cells[2].Text.ToString()); //book number } else { GridViewRow gridViewRow = GridView2.Rows[index]; txtTypecopy.Text = gridViewRow.Cells[5].Text.ToString(); // type txtPrice.Text = gridViewRow.Cells[6].Text.Equals(" ") ? "" : gridViewRow.Cells[6].Text; // price co = new Copy(); co.CopyNumber = Int32.Parse(gridViewRow.Cells[2].Text.ToString()); } } //delete if (e.CommandName == "Del") { int index = Int32.Parse(e.CommandArgument.ToString()); if (copyExist == false) { GridViewRow gvRow = GridView1.Rows[index]; int bookNum = Int32.Parse(gvRow.Cells[2].Text.ToString()); if (BookDAO.Delete(bookNum)) { reload(); } else { return; } } else { GridViewRow gridViewRow = GridView2.Rows[index]; int copyNum = Int32.Parse(gridViewRow.Cells[2].Text.ToString()); if (CopyDAO.Delete(copyNum)) { reload(); } else { return; } } } }
public static void PrintCopy(StreamWriter writer, Copy c) { writer.WriteLine("{0} {1}: {2} loaned to {3}, {4}.", c.OnLoan.DueDate.ToShortDateString(), c.Book.Shelf, c.Id, c.OnLoan.Client.LastName, System.Globalization.StringInfo.GetNextTextElement(c.OnLoan.Client.FirstName)); }
//button save protected void Button5_Click(object sender, EventArgs e) { //edit if (checkEditBook == true) { //book if (copyExist == false) { if (txtTitle.Text.Trim().Length == 0) { lbErrorTitleAdd.Text = "Please input title"; lbErrorTitleAdd.Visible = true; return; } bo.Title = txtTitle.Text; bo.Authors = txtAuthor.Text; bo.Publisher = txtPublisher.Text; if (!BookDAO.Update(bo)) { return; } btSaveBook.Enabled = false; btCancelBook.Enabled = false; } else { //copy if (txtTypecopy.Text.Trim().Length == 0) { lbErrorCopies.Text = "Please iput type A/F"; lbErrorCopies.Visible = true; return; } co.Type = char.Parse(txtTypecopy.Text.ToUpper()); if (co.Type != 'A' && co.Type != 'F') { lbErrorCopies.Text = "Please iput type A/F"; lbErrorCopies.Visible = true; return; } co.Price = double.Parse(txtPrice.Text); co.BookNumber = int.Parse(GridView2.SelectedRow.Cells[3].Text); co.CopyNumber = int.Parse(GridView2.SelectedRow.Cells[2].Text); if (!CopyDAO.Update(co)) { return; } btSaveCopies.Enabled = false; btCancelCopies.Enabled = false; txtTypecopy.ReadOnly = true; txtPrice.ReadOnly = true; } } //add if (checkAddBook == true) { if (copyExist == false) { if (txtTitle.Text.Trim().Length == 0) { lbErrorTitleAdd.Text = "Please input title"; lbErrorTitleAdd.Visible = true; return; } bo = new Book(); bo.BookNumber = BookDAO.GetBookNumberMax() + 1; bo.Title = txtTitle.Text; bo.Authors = txtAuthor.Text; bo.Publisher = txtPublisher.Text; if (!BookDAO.Insert(bo)) { return; } foreach (TextBox tb in GetTextBoxes()) { tb.ReadOnly = true; } btSaveBook.Enabled = false; btCancelBook.Enabled = false; } else { if (txtTypecopy.Text.Trim().Length == 0) { lbErrorCopies.Text = "Please iput type A/F"; lbErrorCopies.Visible = true; return; } String type = txtTypecopy.Text.Trim().ToUpper(); if (!type.Equals("A") && !type.Equals("F")) { lbErrorCopies.Text = "Please iput type A/F"; lbErrorCopies.Visible = true; return; } co = new Copy(); co.CopyNumber = CopyDAO.GetCopyNumberMax() + 1; co.BookNumber = Int32.Parse(txtBookNumberCopies.Text); co.SequenceNumber = CopyDAO.GetSequenceNumberMax(co.BookNumber) + 1; co.Type = char.Parse(type); if (co.Type != 'A' && co.Type != 'F') { co.Price = double.Parse(txtPrice.Text.Trim().Length == 0 ? "0" : txtPrice.Text.Trim()); } if (!CopyDAO.Insert(co)) { return; } } btSaveCopies.Enabled = false; // save btCancelCopies.Enabled = false; // cancel } foreach (TextBox tb in GetTextBoxes()) { if (!checkEditBook) { tb.Text = ""; } tb.ReadOnly = true; } checkAddBook = false; checkEditBook = false; reload(); }
public RedirectToRouteResult CopyTemplate(Copy model) { return(this.RedirectToAction(c => c.Details(model.CopyId))); }
public override void ExportExtensions(ITextureSerializer textureSerializer) { // avatar var animator = Copy.GetComponent <Animator>(); if (animator != null) { var humanoid = Copy.GetComponent <VRMHumanoidDescription>(); UniHumanoid.AvatarDescription description = null; var nodes = Copy.transform.Traverse().Skip(1).ToList(); { var isCreated = false; if (humanoid != null) { description = humanoid.GetDescription(out isCreated); } if (description != null) { // use description VRM.humanoid.Apply(description, nodes); } if (isCreated) { GameObject.DestroyImmediate(description); } } { // set humanoid bone mapping var avatar = animator.avatar; foreach (HumanBodyBones key in Enum.GetValues(typeof(HumanBodyBones))) { if (key == HumanBodyBones.LastBone) { break; } var transform = animator.GetBoneTransform(key); if (transform != null) { VRM.humanoid.SetNodeIndex(key, nodes.IndexOf(transform)); } } } } // morph var master = Copy.GetComponent <VRMBlendShapeProxy>(); if (master != null) { var avatar = master.BlendShapeAvatar; if (avatar != null) { foreach (var x in avatar.Clips) { VRM.blendShapeMaster.Add(x, this); } } } // secondary VRMSpringUtility.ExportSecondary(Copy.transform, Nodes, x => VRM.secondaryAnimation.colliderGroups.Add(x), x => VRM.secondaryAnimation.boneGroups.Add(x) ); #pragma warning disable 0618 // meta(obsolete) { var meta = Copy.GetComponent <VRMMetaInformation>(); if (meta != null) { VRM.meta.author = meta.Author; VRM.meta.contactInformation = meta.ContactInformation; VRM.meta.title = meta.Title; if (meta.Thumbnail != null) { VRM.meta.texture = TextureExporter.RegisterExportingAsSRgb(meta.Thumbnail, needsAlpha: true); } VRM.meta.licenseType = meta.LicenseType; VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; VRM.meta.reference = meta.Reference; } } #pragma warning restore 0618 // meta { var _meta = Copy.GetComponent <VRMMeta>(); if (_meta != null && _meta.Meta != null) { var meta = _meta.Meta; // info VRM.meta.version = meta.Version; VRM.meta.author = meta.Author; VRM.meta.contactInformation = meta.ContactInformation; VRM.meta.reference = meta.Reference; VRM.meta.title = meta.Title; if (meta.Thumbnail != null) { VRM.meta.texture = TextureExporter.RegisterExportingAsSRgb(meta.Thumbnail, needsAlpha: true); } // ussage permission VRM.meta.allowedUser = meta.AllowedUser; VRM.meta.violentUssage = meta.ViolentUssage; VRM.meta.sexualUssage = meta.SexualUssage; VRM.meta.commercialUssage = meta.CommercialUssage; VRM.meta.otherPermissionUrl = meta.OtherPermissionUrl; // distribution license VRM.meta.licenseType = meta.LicenseType; if (meta.LicenseType == LicenseType.Other) { VRM.meta.otherLicenseUrl = meta.OtherLicenseUrl; } } } // firstPerson var firstPerson = Copy.GetComponent <VRMFirstPerson>(); if (firstPerson != null) { if (firstPerson.FirstPersonBone != null) { VRM.firstPerson.firstPersonBone = Nodes.IndexOf(firstPerson.FirstPersonBone); VRM.firstPerson.firstPersonBoneOffset = firstPerson.FirstPersonOffset; VRM.firstPerson.meshAnnotations = firstPerson.Renderers.Select(x => new glTF_VRM_MeshAnnotation { mesh = Meshes.IndexOf(x.SharedMesh), firstPersonFlag = x.FirstPersonFlag.ToString(), }).ToList(); } // lookAt { var lookAtHead = Copy.GetComponent <VRMLookAtHead>(); if (lookAtHead != null) { var boneApplyer = Copy.GetComponent <VRMLookAtBoneApplyer>(); var blendShapeApplyer = Copy.GetComponent <VRMLookAtBlendShapeApplyer>(); if (boneApplyer != null) { VRM.firstPerson.lookAtType = LookAtType.Bone; VRM.firstPerson.lookAtHorizontalInner.Apply(boneApplyer.HorizontalInner); VRM.firstPerson.lookAtHorizontalOuter.Apply(boneApplyer.HorizontalOuter); VRM.firstPerson.lookAtVerticalDown.Apply(boneApplyer.VerticalDown); VRM.firstPerson.lookAtVerticalUp.Apply(boneApplyer.VerticalUp); } else if (blendShapeApplyer != null) { VRM.firstPerson.lookAtType = LookAtType.BlendShape; VRM.firstPerson.lookAtHorizontalOuter.Apply(blendShapeApplyer.Horizontal); VRM.firstPerson.lookAtVerticalDown.Apply(blendShapeApplyer.VerticalDown); VRM.firstPerson.lookAtVerticalUp.Apply(blendShapeApplyer.VerticalUp); } } } } // materials foreach (var m in Materials) { VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureExporter)); } // Serialize VRM var f = new JsonFormatter(); VRMSerializer.Serialize(f, VRM); var bytes = f.GetStoreBytes(); glTFExtensionExport.GetOrCreate(ref _gltf.extensions).Add("VRM", bytes); }
private ICollection <IInstruction> ParseInstructions(byte[] source, byte[] target) { List <IInstruction> instructions = new List <IInstruction>(); int offset = 0; bool increment = true; for (int i = 0; i < source.Length;) { increment = true; if (i + offset > target.Length) { break; } byte one = source[i]; byte two = target[i + offset]; if (one == two) { var copy = new Copy() { Index = i, Length = 1 }; for (int j = i + 1; j < source.Length; j++) { one = source[j]; two = target[j + offset]; if (one == two) { copy.Length++; } else { break; } } i = copy.Index + copy.Length; instructions.Add(copy); increment = false; } else { //Todo: run goes here var add = new Add(); add.Index = i; using (MemoryStream stream = new MemoryStream()) { for (int j = i + offset; j < target.Length; j++) { two = target[j]; if (one != two) { stream.WriteByte(two); } else { increment = false; break; } } add.Data = stream.ToArray(); } offset = Convert.ToInt32(add.Data.Length); instructions.Add(add); } if (increment) { i++; } } return(instructions); }
public Person(string jconValue) : base(null) { Copy.InitT(this, jconValue); }
public ActionResult Edit(Copy copy) { _db.Entry(copy).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public virtual void Export(MeshExportSettings meshExportSettings) { var bytesBuffer = new ArrayByteBuffer(new byte[50 * 1024 * 1024]); var bufferIndex = glTF.AddBuffer(bytesBuffer); GameObject tmpParent = null; if (Copy.transform.childCount == 0) { tmpParent = new GameObject("tmpParent"); Copy.transform.SetParent(tmpParent.transform, true); Copy = tmpParent; } try { Nodes = Copy.transform.Traverse() .Skip(1) // exclude root object for the symmetry with the importer .ToList(); #region Materials and Textures Materials = Nodes.SelectMany(x => x.GetSharedMaterials()).Where(x => x != null).Distinct().ToList(); var unityTextures = Materials.SelectMany(x => TextureIO.GetTextures(x)).Where(x => x.Texture != null).Distinct().ToList(); TextureManager = new TextureExportManager(unityTextures.Select(x => x.Texture)); var materialExporter = CreateMaterialExporter(); glTF.materials = Materials.Select(x => materialExporter.ExportMaterial(x, TextureManager)).ToList(); for (int i = 0; i < unityTextures.Count; ++i) { var unityTexture = unityTextures[i]; TextureIO.ExportTexture(glTF, bufferIndex, TextureManager.GetExportTexture(i), unityTexture.TextureType); } #endregion #region Meshes var unityMeshes = MeshWithRenderer.FromNodes(Nodes).ToList(); MeshBlendShapeIndexMap = new Dictionary <Mesh, Dictionary <int, int> >(); foreach (var(mesh, gltfMesh, blendShapeIndexMap) in MeshExporter.ExportMeshes( glTF, bufferIndex, unityMeshes, Materials, meshExportSettings)) { glTF.meshes.Add(gltfMesh); if (!MeshBlendShapeIndexMap.ContainsKey(mesh)) { // 同じmeshが複数回現れた MeshBlendShapeIndexMap.Add(mesh, blendShapeIndexMap); } } Meshes = unityMeshes.Select(x => x.Mesh).ToList(); #endregion #region Nodes and Skins var unitySkins = unityMeshes .Where(x => x.UniqueBones != null) .ToList(); glTF.nodes = Nodes.Select(x => ExportNode(x, Nodes, unityMeshes.Select(y => y.Renderer).ToList(), unitySkins.Select(y => y.Renderer as SkinnedMeshRenderer).ToList())).ToList(); glTF.scenes = new List <gltfScene> { new gltfScene { nodes = Copy.transform.GetChildren().Select(x => Nodes.IndexOf(x)).ToArray(), } }; foreach (var x in unitySkins) { var matrices = x.GetBindPoses().Select(y => y.ReverseZ()).ToArray(); var accessor = glTF.ExtendBufferAndGetAccessorIndex(bufferIndex, matrices, glBufferTarget.NONE); var renderer = x.Renderer as SkinnedMeshRenderer; var skin = new glTFSkin { inverseBindMatrices = accessor, joints = x.UniqueBones.Select(y => Nodes.IndexOf(y)).ToArray(), skeleton = Nodes.IndexOf(renderer.rootBone), }; var skinIndex = glTF.skins.Count; glTF.skins.Add(skin); foreach (var z in Nodes.Where(y => y.Has(x.Renderer))) { var nodeIndex = Nodes.IndexOf(z); var node = glTF.nodes[nodeIndex]; node.skin = skinIndex; } } #endregion #if UNITY_EDITOR #region Animations var clips = new List <AnimationClip>(); var animator = Copy.GetComponent <Animator>(); var animation = Copy.GetComponent <Animation>(); if (animator != null) { clips = AnimationExporter.GetAnimationClips(animator); } else if (animation != null) { clips = AnimationExporter.GetAnimationClips(animation); } if (clips.Any()) { foreach (AnimationClip clip in clips) { var animationWithCurve = AnimationExporter.Export(clip, Copy.transform, Nodes); foreach (var kv in animationWithCurve.SamplerMap) { var sampler = animationWithCurve.Animation.samplers[kv.Key]; var inputAccessorIndex = glTF.ExtendBufferAndGetAccessorIndex(bufferIndex, kv.Value.Input); sampler.input = inputAccessorIndex; var outputAccessorIndex = glTF.ExtendBufferAndGetAccessorIndex(bufferIndex, kv.Value.Output); sampler.output = outputAccessorIndex; // modify accessors var outputAccessor = glTF.accessors[outputAccessorIndex]; var channel = animationWithCurve.Animation.channels.First(x => x.sampler == kv.Key); switch (glTFAnimationTarget.GetElementCount(channel.target.path)) { case 1: outputAccessor.type = "SCALAR"; //outputAccessor.count = ; break; case 3: outputAccessor.type = "VEC3"; outputAccessor.count /= 3; break; case 4: outputAccessor.type = "VEC4"; outputAccessor.count /= 4; break; default: throw new NotImplementedException(); } } animationWithCurve.Animation.name = clip.name; glTF.animations.Add(animationWithCurve.Animation); } } #endregion #endif } finally { if (tmpParent != null) { tmpParent.transform.GetChild(0).SetParent(null); if (Application.isPlaying) { GameObject.Destroy(tmpParent); } else { GameObject.DestroyImmediate(tmpParent); } } } }
public override void Export() { base.Export(); var gltf = GLTF; var exporter = this; // var go = Copy; //exporter.Prepare(go); //exporter.Export(); gltf.extensions.VCAST_vci_material_unity = new glTF_VCAST_vci_material_unity { materials = exporter.Materials .Select(m => glTF_VCI_Material.CreateFromMaterial(m, exporter.TextureManager.Textures)) .ToList() }; if (Copy == null) { return; } // vci interaction var vciObject = Copy.GetComponent <VCIObject>(); if (vciObject != null) { // script if (vciObject.Scripts.Any()) { gltf.extensions.VCAST_vci_embedded_script = new glTF_VCAST_vci_embedded_script { scripts = vciObject.Scripts.Select(x => { int viewIndex = -1; #if UNITY_EDITOR if (!string.IsNullOrEmpty(x.filePath)) { if (File.Exists(x.filePath)) { using (var resader = new StreamReader(x.filePath)) { string scriptStr = resader.ReadToEnd(); viewIndex = gltf.ExtendBufferAndGetViewIndex <byte>(0, Utf8String.Encoding.GetBytes(scriptStr)); } } else { Debug.LogError("script file not found. スクリプトファイルが見つかりませんでした: " + x.filePath); throw new FileNotFoundException(x.filePath); } } else #endif { viewIndex = gltf.ExtendBufferAndGetViewIndex <byte>(0, Utf8String.Encoding.GetBytes(x.source)); } return(new glTF_VCAST_vci_embedded_script_source { name = x.name, mimeType = x.mimeType, targetEngine = x.targetEngine, source = viewIndex, }); }) .ToList() } } ; var springBones = Copy.GetComponents <VCISpringBone>(); if (springBones.Length > 0) { var sbg = new glTF_VCAST_vci_spring_bone(); sbg.springBones = new List <glTF_VCAST_vci_SpringBone>(); gltf.extensions.VCAST_vci_spring_bone = sbg; foreach (var sb in springBones) { sbg.springBones.Add(new glTF_VCAST_vci_SpringBone() { center = Nodes.IndexOf(sb.m_center), dragForce = sb.m_dragForce, gravityDir = sb.m_gravityDir, gravityPower = sb.m_gravityPower, stiffiness = sb.m_stiffnessForce, hitRadius = sb.m_hitRadius, colliderIds = sb.m_colliderObjects .Where(x => x != null) .Select(x => Nodes.IndexOf(x)) .ToArray(), bones = sb.RootBones.Where(x => x != null).Select(x => Nodes.IndexOf(x.transform)).ToArray() }); } } // meta var meta = vciObject.Meta; gltf.extensions.VCAST_vci_meta = new glTF_VCAST_vci_meta { exporterVCIVersion = VCIVersion.VCI_VERSION, specVersion = VCISpecVersion.Version, title = meta.title, version = meta.version, author = meta.author, contactInformation = meta.contactInformation, reference = meta.reference, description = meta.description, modelDataLicenseType = meta.modelDataLicenseType, modelDataOtherLicenseUrl = meta.modelDataOtherLicenseUrl, scriptLicenseType = meta.scriptLicenseType, scriptOtherLicenseUrl = meta.scriptOtherLicenseUrl, scriptWriteProtected = meta.scriptWriteProtected, scriptEnableDebugging = meta.scriptEnableDebugging, scriptFormat = meta.scriptFormat }; if (meta.thumbnail != null) { gltf.extensions.VCAST_vci_meta.thumbnail = TextureExporter.ExportTexture( gltf, gltf.buffers.Count - 1, meta.thumbnail, glTFTextureTypes.Unknown); } } // collider & rigidbody & joint & item & playerSpawnPoint for (var i = 0; i < exporter.Nodes.Count; i++) { var node = exporter.Nodes[i]; var gltfNode = gltf.nodes[i]; // 各ノードに複数のコライダーがあり得る var colliders = node.GetComponents <Collider>(); if (colliders.Any()) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_collider = new glTF_VCAST_vci_colliders(); gltfNode.extensions.VCAST_vci_collider.colliders = new List <glTF_VCAST_vci_Collider>(); foreach (var collider in colliders) { var gltfCollider = glTF_VCAST_vci_Collider.GetglTfColliderFromUnityCollider(collider); if (gltfCollider == null) { Debug.LogWarningFormat("collider is not supported: {0}", collider.GetType().Name); continue; } gltfNode.extensions.VCAST_vci_collider.colliders.Add(gltfCollider); } } var rigidbodies = node.GetComponents <Rigidbody>(); if (rigidbodies.Any()) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_rigidbody = new glTF_VCAST_vci_rigidbody(); gltfNode.extensions.VCAST_vci_rigidbody.rigidbodies = new List <glTF_VCAST_vci_Rigidbody>(); foreach (var rigidbody in rigidbodies) { gltfNode.extensions.VCAST_vci_rigidbody.rigidbodies.Add( glTF_VCAST_vci_Rigidbody.GetglTfRigidbodyFromUnityRigidbody(rigidbody)); } } var joints = node.GetComponents <Joint>(); if (joints.Any()) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_joints = new glTF_VCAST_vci_joints(); gltfNode.extensions.VCAST_vci_joints.joints = new List <glTF_VCAST_vci_joint>(); foreach (var joint in joints) { gltfNode.extensions.VCAST_vci_joints.joints.Add( glTF_VCAST_vci_joint.GetglTFJointFromUnityJoint(joint, exporter.Nodes)); } } var item = node.GetComponent <VCISubItem>(); if (item != null) { var warning = item.ExportWarning; if (!string.IsNullOrEmpty(warning)) { throw new System.Exception(warning); } if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_item = new glTF_VCAST_vci_item { grabbable = item.Grabbable, scalable = item.Scalable, uniformScaling = item.UniformScaling, groupId = item.GroupId, }; } // Attachable var vciAttachable = node.GetComponent <VCIAttachable>(); if (vciAttachable != null && vciAttachable.AttachableHumanBodyBones != null && vciAttachable.AttachableHumanBodyBones.Any()) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_attachable = new glTF_VCAST_vci_attachable { attachableHumanBodyBones = vciAttachable.AttachableHumanBodyBones.Select(x => x.ToString()).ToList(), attachableDistance = vciAttachable.AttachableDistance, scalable = vciAttachable.Scalable, offset = vciAttachable.Offset }; } // Text var tmp = node.GetComponent <TextMeshPro>(); var rt = node.GetComponent <RectTransform>(); if (tmp != null && rt != null) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_rectTransform = new glTF_VCAST_vci_rectTransform() { rectTransform = glTF_VCAST_vci_RectTransform.CreateFromRectTransform(rt) }; gltfNode.extensions.VCAST_vci_text = new glTF_VCAST_vci_text { text = glTF_VCAST_vci_Text.Create(tmp) }; } // PlayerSpawnPoint var psp = node.GetComponent <VCIPlayerSpawnPoint>(); if (psp != null) { if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } gltfNode.extensions.VCAST_vci_player_spawn_point = new glTF_VCAST_vci_player_spawn_point { playerSpawnPoint = glTF_VCAST_vci_PlayerSpawnPoint.Create(psp) }; var pspR = node.GetComponent <VCIPlayerSpawnPointRestriction>(); if (pspR != null) { gltfNode.extensions.VCAST_vci_player_spawn_point_restriction = new glTF_VCAST_vci_player_spawn_point_restriction { playerSpawnPointRestriction = glTF_VCAST_vci_PlayerSpawnPointRestriction.Create(pspR) }; } } } // Audio var clips = exporter.Copy.GetComponentsInChildren <AudioSource>() .Select(x => x.clip) .Where(x => x != null) .ToArray(); if (clips.Any()) { var audios = clips.Select(x => FromAudioClip(gltf, x)).Where(x => x != null).ToList(); gltf.extensions.VCAST_vci_audios = new glTF_VCAST_vci_audios { audios = audios }; } #if UNITY_EDITOR // Animation // None RootAnimation var animators = exporter.Copy.GetComponentsInChildren <Animator>().Where(x => exporter.Copy != x.gameObject); var animations = exporter.Copy.GetComponentsInChildren <Animation>().Where(x => exporter.Copy != x.gameObject); // NodeIndex to AnimationClips Dictionary <int, AnimationClip[]> animationNodeList = new Dictionary <int, AnimationClip[]>(); foreach (var animator in animators) { var animationClips = AnimationExporter.GetAnimationClips(animator); var nodeIndex = exporter.Nodes.FindIndex(0, exporter.Nodes.Count, x => x == animator.transform); if (animationClips.Any() && nodeIndex != -1) { animationNodeList.Add(nodeIndex, animationClips.ToArray()); } } foreach (var animation in animations) { var animationClips = AnimationExporter.GetAnimationClips(animation); var nodeIndex = exporter.Nodes.FindIndex(0, exporter.Nodes.Count, x => x == animation.transform); if (animationClips.Any() && nodeIndex != -1) { animationNodeList.Add(nodeIndex, animationClips.ToArray()); } } int bufferIndex = 0; foreach (var animationNode in animationNodeList) { List <int> clipIndices = new List <int>(); // write animationClips foreach (var clip in animationNode.Value) { var animationWithCurve = AnimationExporter.Export(clip, Nodes[animationNode.Key], Nodes); AnimationExporter.WriteAnimationWithSampleCurves(gltf, animationWithCurve, clip.name, bufferIndex); clipIndices.Add(gltf.animations.IndexOf(animationWithCurve.Animation)); } // write node if (clipIndices.Any()) { var node = gltf.nodes[animationNode.Key]; if (node.extensions == null) { node.extensions = new glTFNode_extensions(); } node.extensions.VCAST_vci_animation = new glTF_VCAST_vci_animation() { animationReferences = new List <glTF_VCAST_vci_animationReference>() }; foreach (var index in clipIndices) { node.extensions.VCAST_vci_animation.animationReferences.Add(new glTF_VCAST_vci_animationReference() { animation = index }); } } } #endif // Effekseer var effekseerEmitters = exporter.Copy.GetComponentsInChildren <Effekseer.EffekseerEmitter>() .Where(x => x.effectAsset != null) .ToArray(); if (effekseerEmitters.Any()) { gltf.extensions.Effekseer = new glTF_Effekseer() { effects = new List <glTF_Effekseer_effect>() }; foreach (var emitter in effekseerEmitters) { var index = exporter.Nodes.FindIndex(x => x == emitter.transform); if (index < 0) { continue; } var effectIndex = AddEffekseerEffect(gltf, emitter); var gltfNode = gltf.nodes[index]; if (gltfNode.extensions == null) { gltfNode.extensions = new glTFNode_extensions(); } if (gltfNode.extensions.Effekseer_emitters == null) { gltfNode.extensions.Effekseer_emitters = new glTF_Effekseer_emitters() { emitters = new List <glTF_Effekseer_emitter>() }; } gltfNode.extensions.Effekseer_emitters.emitters.Add(new glTF_Effekseer_emitter() { effectIndex = effectIndex, isLoop = emitter.isLooping, isPlayOnStart = emitter.playOnStart }); } } // LocationBounds var locationBounds = exporter.Copy.GetComponent <VCILocationBounds>(); if (locationBounds != null) { gltf.extensions.VCAST_vci_location_bounds = new glTF_VCAST_vci_location_bounds { LocationBounds = glTF_VCAST_vci_LocationBounds.Create(locationBounds) }; } }
protected void ButCancel_Click(object sender, EventArgs e) { // Get the record from viewstate and goes to copy list copy = (Copy)ViewState["copy"]; Response.Redirect("~/Book/Copies.aspx?bookId=" + copy.BookId); }
/// <summary> /// Copies /// </summary> /// <param name="inputPaths">The input paths.</param> /// <param name="outPutPath">The out put path.</param> /// <returns></returns> public IGeoProcessorResult Copy(string inputPaths, string outPutPath) { try { Copy pCopy = new Copy(inputPaths, outPutPath); Geoprocessor GP = new Geoprocessor(); GP.OverwriteOutput = true; GP.TemporaryMapLayers = false; IGeoProcessorResult result = GP.Execute(pCopy, null) as IGeoProcessorResult; //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.Status.ToString()); //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.GetMessages(0)); return result; } catch (Exception exp) { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return null; } }
private void buttonAdd_Click(object sender, EventArgs e) { // First, we need to create the book, as the author list demands an id of the book if (textBoxName.Text.Length > 0 && textBoxISBN.Text.Length > 0 && textBoxGenre.Text.Length > 0 && textBoxName.Text.Length < 63 && textBoxISBN.Text.Length < 15 && textBoxGenre.Text.Length < 31) { var bookToAdd = new Book(); bookToAdd.Name = textBoxName.Text; bookToAdd.ISBN = textBoxISBN.Text; bookToAdd.Genre = textBoxGenre.Text; bookToAdd.DateOfAdd = DateTime.Now; //Jak z tymi kopiami robimy context.Books.InsertOnSubmit(bookToAdd); context.SubmitChanges(); //As we have just created the book, we check the id of it var bookId = from Book in context.Books where (Book.Name == textBoxName.Text) && (Book.ISBN == textBoxISBN.Text) && (Book.Genre == textBoxGenre.Text) select Book.Id; int quantity = int.Parse(textBoxCopies.Text); for (int i = 0; i < quantity; i++) { Copy copyToAdd = new Copy(); copyToAdd.BookId = bookId.FirstOrDefault(); copyToAdd.Status = "Dostępna"; context.Copies.InsertOnSubmit(copyToAdd); context.SubmitChanges(); } List <int> authors = new List <int>(); //checking if the Athor is already in DB foreach (var element in listOfAuthors) { var author = from auth in context.Authors where (auth.Firstname == element.Firstname) && (auth.Lastname == element.Lastname) select auth.Id; var authorFirst = author.FirstOrDefault(); if (authorFirst != 0) { var authorList = new AuthorList(); authorList.AuthorId = authorFirst; authorList.BookId = bookId.FirstOrDefault(); context.AuthorLists.InsertOnSubmit(authorList); context.SubmitChanges(); } else { var id = (from auth in context.Authors select auth.Id).Max(); var authorToAdd = new Author(); authorToAdd.Firstname = element.Firstname; authorToAdd.Lastname = element.Lastname; context.Authors.InsertOnSubmit(authorToAdd); context.SubmitChanges(); var addedAuthor = (from authrs in context.Authors where authrs.Lastname == element.Lastname select authrs.Id).FirstOrDefault(); var authorList = new AuthorList() { AuthorId = addedAuthor, BookId = bookId.FirstOrDefault() }; context.AuthorLists.InsertOnSubmit(authorList); context.SubmitChanges(); } } } else { MessageBox.Show("Zły format danych", "Błąd!"); } this.Close(); }
public ActionResult Details(int id) { Copy c = _db.Copies.Include(x => x.Book).FirstOrDefault(x => x.Id == id); return(View(c)); }
public void BorrowCopy(Copy copy) { copy.Borrowed = true; EditCopy(copy); }
private void appendFeatureClasses(string workspace,string outname) { m_GP.SetEnvironmentValue("workspace", workspace); IGpEnumList fcs = m_GP.ListFeatureClasses("", "", ""); string fc_from = fcs.Next(); string fc_to = fcs.Next(); Append appendTool = new Append(); while (fc_to != "") { appendTool.inputs = fc_from; appendTool.target = fc_to; m_GP.Execute(appendTool, null); fc_from = fc_to; fc_to = fcs.Next(); } Copy copytool = new Copy(); copytool.in_data = fc_from; copytool.out_data = m_Dirpath + outname; m_GP.Execute(copytool, null); }
public Copy(Copy source) { }