示例#1
0
        private void buttonCafmConnectCreate_Click(object sender, EventArgs e)
        {
            linkLabel1.Text              = string.Empty;
            textBoxCafmConnectFile.Text  = "Please wait, this takes a while, sometimes several minutes.";
            textBoxCafmConnectFile.Text += Environment.NewLine + "We work hard to optimize the code, to make this happen faster...";
            textBoxCafmConnectFile.Text += Environment.NewLine + "When the file is created, please open it with the CAFM-Conenct Editor.";
            textBoxCafmConnectFile.Refresh();
            int maxVariants = Convert.ToInt16(textBox2.Text);

            string fileName = Path.GetTempPath() + maxVariants.ToString() + ".ifczip";

            CafmConnect.Workspace ws = new Workspace();
            string key = ws.CreateCcFile("Author", "Organization", "System", "Authorization");

            string    siteGuid = ws.AddNewSite(key, "CGN", "SiteDescription", "SiteStreet", "50667", "Cologne", "DE");
            Stopwatch sw       = new Stopwatch();

            sw.Start();

            for (int i = 1; i <= maxVariants; i++)
            {
                CafmConnect.Manufacturer.CcManufacturerProduct product = new CcManufacturerProduct("461");
                product.Description = "Aufzug " + i.ToString();
                product.Name        = "Variante " + i.ToString();
                product.Attributes.Add(new CcManufacturerProductDetail("Anzahl Haltestellen", "Anzahl Haltestellen", "10"));
                product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft in Personen", "Tragkraft in Personen", "5"));
                product.Attributes.Add(new CcManufacturerProductDetail("Tragkraft", "Tragkraft", (i * 2).ToString()));

                if (siteGuid != null)
                {
                    ws.AddNewProduct(key, siteGuid, "461", product, product.Description);
                }

                labelCounter.Text = i.ToString();
                labelCounter.Refresh();

                labelStopwatch.Text = (sw.ElapsedMilliseconds / i).ToString();
                labelStopwatch.Refresh();
            }

            ws.SaveCcFileAs(key, fileName, true, true);
            sw.Stop();

            linkLabel1.Text             = fileName;
            textBoxCafmConnectFile.Text = ws.GetModelOfCcFile(fileName);
        }