Пример #1
0
 public void Reset()
 {
     if (currentMap != null)
     {
         Destroy(currentMap.deadMap.gameObject);
         Destroy(currentMap.livingMap.gameObject);
     }
     currentMap = null;
 }
Пример #2
0
 public static void Map(this Type type, Dictionary <string, string> maps)
 {
     lock (MapPairs)
     {
         if (!MapPairs.TryGetValue(type, out MapPair value))
         {
             value = new MapPair(type);
             MapPairs.Add(type, value);
         }
         value.InitialCurrent(maps);
     }
 }
Пример #3
0
    private MapPair SpawnMapPair(string mapName, Vector3 origin, Vector2 sizeLerp)
    {
        var mapEntry = mapNames.GetEntry(mapName);
        var map      = SpawnTilemap(mapEntry.tiled, Vector3.zero);
        var mapSize  = MapSize(map);

        origin += new Vector3(sizeLerp.x * mapSize.x, sizeLerp.y * mapSize.y);
        isDead  = IsSpirit(mapName);
        var mapPair = new MapPair(NormalizeName(mapName));

        isDead = IsSpirit(mapName);

        if (isDead)
        {
            var otherEntry = mapNames.GetEntry(NormalizeName(mapName));

            mapPair.deadMap   = map;
            mapPair.livingMap = SpawnTilemap(otherEntry.tiled, UnusedOffset);
        }
        else
        {
            var otherEntry = mapNames.GetEntry(SpiritName(mapName));

            mapPair.deadMap   = SpawnTilemap(otherEntry.tiled, UnusedOffset);
            mapPair.livingMap = map;
        }

        SetActiveMap(map);
        currentMap = mapPair;

        var min = LerpMap(map, Vector2.zero);
        var max = LerpMap(map, Vector2.one);

        worldBounds.min = Vector3.Min(min, max);
        worldBounds.max = Vector3.Max(min, max);

        if (followCamera != null)
        {
            followCamera.bounds = worldBounds;
        }

        return(mapPair);
    }
Пример #4
0
        void ExecuteOdoo(Autodesk.Connectivity.WebServices.Item item, VDF.Vault.Currency.Connections.Connection connection, bool okToProcess)
        {
            string processFileName = AppSettings.Get("VaultExportFilePath").ToString() + "Process.txt";

            using (StreamWriter writer = new StreamWriter(processFileName))
            {
                if (okToProcess == false)
                {
                    writer.WriteLine("false");
                }
                else
                {
                    writer.WriteLine("true");
                }
            }

            //string filename = (string)AppSettings.Get("ExportFile");
            string filename1 = @"C:\Users\lorne\Desktop\Vault Export\odoo1.csv";
            string filename2 = @"C:\Users\lorne\Desktop\Vault Export\odoo2.csv";

            PackageService packageSvc = connection.WebServiceManager.PackageService;

            // export to CSV file
            PkgItemsAndBOM pkgBom = packageSvc.GetLatestPackageDataByItemIds(new long[] { item.Id }, BOMTyp.Latest);

            // Create a mapping between Item properties and columns in the CSV file
            MapPair parentPair = new MapPair();

            parentPair.ToName   = "product";
            parentPair.FromName = "BOMStructure-41FF056B-8EEF-47E2-8F9E-490BC0C52C71";

            MapPair numberPair = new MapPair();

            numberPair.ToName   = "name";
            numberPair.FromName = "Number";

            MapPair titlePair = new MapPair();

            titlePair.ToName   = "Title (Item,CO)";
            titlePair.FromName = "Title(Item,CO)";

            MapPair descriptionPair = new MapPair();

            descriptionPair.ToName   = "description";
            descriptionPair.FromName = "Description(Item,CO)";

            MapPair categoryNamePair = new MapPair();

            categoryNamePair.ToName   = "CategoryName";
            categoryNamePair.FromName = "CategoryName";

            MapPair thicknessPair = new MapPair();

            thicknessPair.ToName   = "Thickness";
            thicknessPair.FromName = "7c5169ad-9081-4aa7-b1a3-4670edae0b8c";

            MapPair materialPair = new MapPair();

            materialPair.ToName   = "Material";
            materialPair.FromName = "Material";

            MapPair operationsPair = new MapPair();

            operationsPair.ToName   = "Operations";
            operationsPair.FromName = "794d5b7d-49b5-49ba-938a-7e341a7ff8e4";

            MapPair quantityPair = new MapPair();

            quantityPair.ToName   = "bom_line_ids/product_qty";
            quantityPair.FromName = "Quantity-41FF056B-8EEF-47E2-8F9E-490BC0C52C71";

            MapPair structCodePair = new MapPair();

            structCodePair.ToName   = "Structural Code";
            structCodePair.FromName = "e3811c7a-a3ee-4f67-b34e-cbc892640616";

            MapPair plantIDPair = new MapPair();

            plantIDPair.ToName   = "Plant ID";
            plantIDPair.FromName = "eff195ae-da71-4929-b3df-2d6fd1e25f53";

            MapPair isStockPair = new MapPair();

            isStockPair.ToName   = "Is Stock";
            isStockPair.FromName = "f78c17cd-86d1-4728-96b5-8001fb58b67f";

            MapPair requiresPDFPair = new MapPair();

            requiresPDFPair.ToName   = "Requires PDF";
            requiresPDFPair.FromName = "6df4ae8b-fbd9-4e62-b801-a46097d4f9c5";

            MapPair commentPair = new MapPair();

            commentPair.ToName   = "Comment";
            commentPair.FromName = "Comment";

            MapPair modDatePair = new MapPair();

            modDatePair.ToName   = "Date Modified";
            modDatePair.FromName = "ModDate";

            MapPair statePair = new MapPair();

            statePair.ToName   = "State";
            statePair.FromName = "State";

            MapPair stockNamePair = new MapPair();

            stockNamePair.ToName   = "Stock Name";
            stockNamePair.FromName = "a42ca550-c503-4835-99dd-8c4d4ff6dbaf";

            MapPair keywordsPair = new MapPair();

            keywordsPair.ToName   = "Keywords";
            keywordsPair.FromName = "Keywords";

            MapPair notesPair = new MapPair();

            notesPair.ToName   = "Notes";
            notesPair.FromName = "0d012a5c-cc28-443c-b44e-735372eee117";

            FileNameAndURL fileNameAndUrl = packageSvc.ExportToPackage(pkgBom, FileFormat.TDL_PARENT,
                                                                       new MapPair[] { numberPair, descriptionPair });

            // write parts to file1
            long currentByte = 0;
            long partSize    = connection.PartSizeInBytes;

            using (FileStream fs = new FileStream(filename1, FileMode.Create))
            {
                while (currentByte < fileNameAndUrl.FileSize)
                {
                    long   lastByte = currentByte + partSize < fileNameAndUrl.FileSize ? currentByte + partSize : fileNameAndUrl.FileSize;
                    byte[] contents = packageSvc.DownloadPackagePart(fileNameAndUrl.Name, currentByte, lastByte);
                    fs.Write(contents, 0, (int)(lastByte - currentByte));
                    currentByte += partSize;
                }
            }

            // write bom to file2

            MapPair bomNumberPair = new MapPair();

            bomNumberPair.ToName   = "bom_line_ids/product_id";
            bomNumberPair.FromName = "Number";

            fileNameAndUrl = packageSvc.ExportToPackage(pkgBom, FileFormat.TDL_PARENT,
                                                        new MapPair[] { parentPair, bomNumberPair, quantityPair });

            currentByte = 0;
            partSize    = connection.PartSizeInBytes;
            using (FileStream fs = new FileStream(filename2, FileMode.Create))
            {
                while (currentByte < fileNameAndUrl.FileSize)
                {
                    long   lastByte = currentByte + partSize < fileNameAndUrl.FileSize ? currentByte + partSize : fileNameAndUrl.FileSize;
                    byte[] contents = packageSvc.DownloadPackagePart(fileNameAndUrl.Name, currentByte, lastByte);
                    fs.Write(contents, 0, (int)(lastByte - currentByte));
                    currentByte += partSize;
                }
            }
        }
Пример #5
0
        private void Import()
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "CSV Files|*.csv";
            DialogResult result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string filename = dialog.FileName;

            PackageService packageSvc = m_connection.WebServiceManager.PackageService;

            // Create a mapping between the CVS columns and the item properties.
            // NOTE: It is assumed the we are importing a file created by the
            // export command in this sample.  Otherwise we can't assume the
            // columns being used.
            Map info = new Map();

            //map the first column to level
            MapPair levelPair = new MapPair();

            levelPair.FromName = "Level";
            levelPair.ToName   = "BOMIndicator-41FF056B-8EEF-47E2-8F9E-490BC0C52C71";

            //map the second column to number
            MapPair numberPair = new MapPair();

            numberPair.FromName = "Number";
            numberPair.ToName   = "Number";

            //map the third column to type
            MapPair typePair = new MapPair();

            typePair.FromName = "Type";
            typePair.ToName   = "ItemClass";

            info.PairArray = new MapPair[] { levelPair, numberPair, typePair };

            FileNameAndURL fileNameandURL = null;

            using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                long   partSize = m_connection.PartSizeInBytes;
                byte[] contents = new byte[partSize];
                int    bytesRead;
                while ((bytesRead = fs.Read(contents, 0, (int)partSize)) > 0)
                {
                    string existingPackageName = null;
                    if (fileNameandURL != null)
                    {
                        existingPackageName = fileNameandURL.Name;
                    }
                    fileNameandURL = packageSvc.UploadPackagePart(existingPackageName, ".csv", bytesRead == partSize ? contents : contents.Take(bytesRead).ToArray());
                }
            }

            PkgItemsAndBOM createResult = packageSvc.ImportFromPackage(FileFormat.CSV_LEVEL, info, fileNameandURL.Name);

            foreach (PkgItem item in createResult.PkgItemArray)
            {
                // to keep things simple, this sample only handles cases where we are
                // importing new items.  It does not handle complex cases like when an item needs updating.
                if (item.Resolution != null && item.Resolution.ResolutionMethod != ResolutionMethod.Create)
                {
                    MessageBox.Show("There are conflicts in the import.  This function can only be used for creating new Items.");
                    return;
                }
            }

            packageSvc.CommitImportedData(createResult);

            MessageBox.Show("Import completed");
            RefreshItemList();
        }
Пример #6
0
        private void Export()
        {
            if (m_selectedItem == null)
            {
                MessageBox.Show("You must select an Item first");
                return;
            }

            SaveFileDialog dialog = new SaveFileDialog();

            dialog.Filter = "CSV Files|*.csv";
            DialogResult result = dialog.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            string filename = dialog.FileName;

            PackageService packageSvc = m_connection.WebServiceManager.PackageService;

            // export to CSV file
            PkgItemsAndBOM pkgBom = packageSvc.GetLatestPackageDataByItemIds(new long[] { m_selectedItem.Id }, BOMTyp.Latest);

            // Create a mapping between Item properties and columns in the CSV file
            MapPair levelPair = new MapPair();

            levelPair.ToName   = "Level";
            levelPair.FromName = "BOMIndicator-41FF056B-8EEF-47E2-8F9E-490BC0C52C71";

            MapPair numberPair = new MapPair();

            numberPair.ToName   = "Number";
            numberPair.FromName = "Number";

            MapPair typePair = new MapPair();

            typePair.ToName   = "Type";
            typePair.FromName = "ItemClass";

            // NOTE: not everything is being exported in this example.  So if this file is imported,
            // omitted data, such as lifecycle state, may not be the same.

            FileNameAndURL fileNameAndUrl = packageSvc.ExportToPackage(pkgBom, FileFormat.CSV_LEVEL,
                                                                       new MapPair[] { levelPair, numberPair, typePair });

            long currentByte = 0;
            long partSize    = m_connection.PartSizeInBytes;

            using (FileStream fs = new FileStream(filename, FileMode.Create))
            {
                while (currentByte < fileNameAndUrl.FileSize)
                {
                    long   lastByte = currentByte + partSize < fileNameAndUrl.FileSize ? currentByte + partSize : fileNameAndUrl.FileSize;
                    byte[] contents = packageSvc.DownloadPackagePart(fileNameAndUrl.Name, currentByte, lastByte);
                    fs.Write(contents, 0, (int)(lastByte - currentByte));
                    currentByte += partSize;
                }
            }

            MessageBox.Show("Export completed");
        }