public ServiceTemporaryWindow(string stencilPath, Dictionary<string, Project> projects, string lastFolder)
    {
      this.lastFolder = lastFolder;

      InitializeComponent();

      addProjectButton.Focus();

      this.Text = "SysCAD.Service (" + Assembly.Load("SysCAD.Service").GetName().Version + ") -- SVN Revision: " + SysCAD.SVNVersion.SVNVersion.version;

      Config config = new Config();
      if (!ServiceConnectCheck(config)) // If service not already there.
      {
        System.Runtime.Remoting.Channels.BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
        serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;

        BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();

        Hashtable ipcProps = new Hashtable();
        ipcProps["portName"] = "SysCAD.Service";
        ipcProps["exclusiveAddressUse"] = false;
        //ipcProps["typeFilterLevel"] = TypeFilterLevel.Full;
        IpcChannel ipcChannel = new IpcChannel(ipcProps, clientProv, serverProv);
        ChannelServices.RegisterChannel(ipcChannel, false);

        logView.LogFile = System.IO.Path.GetTempPath() + "test.log";

        Config.AddProjectHandler addProjectHandler = new Config.AddProjectHandler(AddProject);
        Config.AddProjectAnywayHandler addProjectAnywayHandler = new Config.AddProjectAnywayHandler(AddProjectAnyway);
        configData = new ConfigData();
        configData.Setup(stencilPath, addProjectHandler, addProjectAnywayHandler);

        RemotingServices.Marshal(configData, "Global");

        Dictionary<string, Project> tempProjects = projects;
        
        foreach (Project project in tempProjects.Values)
        {
          AddProject(project);
        }

        this.projects = projects;
      }
    }
Beispiel #2
0
        public void Setup(string stencilPath, Config.AddProjectHandler addProject, Config.AddProjectAnywayHandler addProjectAnyway)
        {
            this.addProject       = addProject;
            this.addProjectAnyway = addProjectAnyway;

            {
                //int iStencil = 0;
                //LogNote("Srvr : 0 : ModelStencils:");
                String[] files = Directory.GetFiles(stencilPath, "*.modelstencil");
                for (int i = 0; i < files.GetLength(0); i++)
                {
                    String fullpath = files[i];

                    //try
                    //{
                    ModelStencil modelStencil = ModelStencil.Deserialize(fullpath);

                    if (ConfirmModelStencil(modelStencil))
                    {
                        TrimAnchorPoints(modelStencil);
                        ModelStencils.Add(modelStencil.Tag, modelStencil);
                    }

                    //Console.WriteLine("  {0}] {1}", iStencil++, Path.GetFileNameWithoutExtension(fullpath));
                    //LogNote("Srvr : 0 : " + iStencil++ + " : " + System.IO.Path.GetFileNameWithoutExtension(fullpath));
                    //}
                    //catch (Exception)
                    //{
                    //  int asdf = 0;
                    //  //Message("Error '" + e.Message + "' loading ModelStencil: " + fullpath, MessageType.Error);
                    //}
                }

                Console.WriteLine("\n");
            }

            {
                //int iStencil = 0;
                //LogNote("Srvr : 0 : GraphicStencils:");
                String[] files = Directory.GetFiles(stencilPath, "*.graphicstencil");
                for (int i = 0; i < files.GetLength(0); i++)
                {
                    String fullpath = files[i];

                    //try
                    //{
                    GraphicStencil graphicStencil = GraphicStencil.Deserialize(fullpath);

                    foreach (String tag in graphicStencil.Tags)
                    {
                        GraphicStencils.Add(tag, graphicStencil);
                    }
                    //}
                    //catch
                    //{
                    //  int adsf = 0;
                    //  //logNote("Config : Error loading GraphicStencil " + fullpath);
                    //}
                }
            }
        }