Esempio n. 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            //import of
            //chargement de sparamètres
            // bool SansDt=false;

            Clipper_Param.GetlistParam(_Context);
            string csvImportPath = Clipper_Param.GetPath("IMPORT_CDA");
            //recuperation du nom de fichier
            string csvFileName     = Path.GetFileNameWithoutExtension(csvImportPath);
            string csvDirectory    = Path.GetDirectoryName(csvImportPath);
            string csvImportSandDt = csvDirectory + "\\" + csvFileName + "_SANSDT.csv";

            /*
             * if (csvImportSandDt.Contains("SANSDT")| csvImportSandDt.Contains("SANS_DT"))
             * {
             *  SansDt = true;
             * }
             */

            string dataModelstring = Clipper_Param.GetModelCA();


            using (Clipper_OF CahierAffaire = new Clipper_OF())
            {
                CahierAffaire.Import(_Context, csvImportPath, dataModelstring, false);
                CahierAffaire.Import(_Context, csvImportSandDt, dataModelstring, true);
                //}
            }
        }
Esempio n. 2
0
        private void AfterSendToWorkshop_Click(object sender, EventArgs e)
        {
            //IEntity TO_CUT_nesting;

            AF_Clipper_Dll.Clipper_DoOnAction_AfterSendToWorkshop doonaction = new Clipper_DoOnAction_AfterSendToWorkshop();
            string stage = "_TO_CUT_NESTING";

            //creation du fichier de sortie
            //recupere les path
            Clipper_Param.GetlistParam(_Context);
            IEntitySelector nestingselector = null;

            nestingselector = new EntitySelector();

            //entity type pointe sur la list d'objet du model
            nestingselector.Init(_Context, _Context.Kernel.GetEntityType(stage));
            nestingselector.MultiSelect = true;


            if (nestingselector.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                foreach (IEntity nesting in nestingselector.SelectedEntity)
                {
                    doonaction.execute(nesting);
                }
            }


            // doonaction.execute(_Context, TO_CUT_nesting);
        }
Esempio n. 3
0
        private void button7_Click(object sender, EventArgs e)
        {
            Clipper_Param.GetlistParam(_Context);

            string           csvImportPath = Clipper_Param.GetPath("IMPORT_CDA");
            ProcessStartInfo start         = new ProcessStartInfo();
            ProcessStartInfo start_ca      = new ProcessStartInfo();

            start_ca.Arguments = "OF " + csvImportPath;
            //start.FileName = @"C:\AlmaCAM\Bin\Clipper_Import.exe";
            start_ca.FileName = Clipper_Param.Get_application1();
            //start.WindowStyle = ProcessWindowStyle.Normal;
            start_ca.CreateNoWindow  = false;
            start_ca.UseShellExecute = true;
            string  exename = Clipper_Param.Get_application1();
            Process p       = Process.Start(exename, "OF " + csvImportPath);
        }
Esempio n. 4
0
        private void button6_Click(object sender, EventArgs e)
        {
            ///for test
            ///
            ///
            ///Pour la passerelle « ALMACAM », je vous fournirai un executable pour l’import automatique du stock et du cahier d’affaire en suivant la meme logique.
            ///Chemin de l’executable paramétable et paramétré par defaut dans
            ///

            Clipper_Param.GetlistParam(_Context);
            string           csvImportPath = Clipper_Param.GetPath("IMPORT_DM");
            ProcessStartInfo start_dm      = new ProcessStartInfo();

            start_dm.Arguments = "stock " + csvImportPath;
            //start.FileName =  @"C:\AlmaCAM\Bin\AlmaCamUser1.exe";
            start_dm.FileName = Clipper_Param.Get_application1();
            //start.WindowStyle = ProcessWindowStyle.Normal;
            start_dm.CreateNoWindow  = true;
            start_dm.UseShellExecute = true;
            System.Diagnostics.Process.Start(start_dm);
        }
Esempio n. 5
0
        private void AfterClose_Click(object sender, EventArgs e)
        {
            AF_Clipper_Dll.Clipper_DoOnAction_After_Cutting_end doonaction = new Clipper_DoOnAction_After_Cutting_end();

            //string stage = "_CLOSED_NESTING";
            string stage = "_CUT_SHEET";

            //creation du fichier de sortie
            //recupere les path
            Clipper_Param.GetlistParam(_Context);
            IEntitySelector Entityselector = null;

            Entityselector = new EntitySelector();

            //entity type pointe sur la list d'objet du model
            Entityselector.Init(_Context, _Context.Kernel.GetEntityType(stage));
            Entityselector.MultiSelect = true;

            if (Entityselector.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                doonaction.execute(Entityselector.SelectedEntity);
            }
        }
Esempio n. 6
0
        //initialisation des listes
        /// <summary>
        /// aucun log dans ce programme, seulement des messages informels
        /// Si pas de fichier detecté   , alors on annule l'import
        /// Si pas de type detecté      , alors on annule l'import
        /// </summary>
        /// <param name="args">arg  0 : type d'import, arg 1 chemin vers le fichier d'import
        /// il n'y a pas d'obligation a envoyer le chemin car ce dernier peut etre fourni par l'application almacam
        /// </param>
        static void Main(string[] args)
        {
            IContext _clipper_Context = null;

            string TypeImport = "";
            //string fulpathname = "";
            string DbName = Alma_RegitryInfos.GetLastDataBase();

            Alma_Log.Create_Log();



            using (EventLog eventLog = new EventLog("Application"))
            {
                ModelsRepository clipper_modelsRepository = new ModelsRepository();
                string           csvImportPath            = null;
                _clipper_Context = clipper_modelsRepository.GetModelContext(DbName);  //nom de la base;
                int i = _clipper_Context.ModelsRepository.ModelList.Count();
                Clipper_Param.GetlistParam(_clipper_Context);
                if (args.Length == 0)
                {
                    /* dans ce cas on recupere les arguments de la base directement*/
                    /* on force l'import of*/
                    TypeImport = "OF";
                    /**/
                }
                else  //sinon on recupere le paramètre du type d'import
                {
                    TypeImport = args[0].ToUpper().ToString();
                }


                {
                    switch (TypeImport)
                    {
                    //fullpath name
                    case "STOCK":
                        //import stock
                        csvImportPath = null;
                        //
                        if (args.Length == 0 || args.Length == 1)
                        {
                            csvImportPath = Clipper_Param.GetPath("IMPORT_DM");
                        }
                        else
                        {
                            csvImportPath = args[1];
                        }

                        Alma_Log.Write_Log(" chemin du fichier d'import" + csvImportPath);

                        string dataModelstring = Clipper_Param.GetModelDM();
                        using (Clipper_Stock Stock = new Clipper_Stock())
                        {
                            //Stock.Import(_clipper_Context, csvImportPath, dataModelstring);
                            Stock.Import(_clipper_Context);    //, csvImportPath);
                        }
                        clipper_modelsRepository = null;

                        break;

                    case "STOCK_PURGE":
                        //puge de tous les elements du stock


                        IEntityList stocks = _clipper_Context.EntityManager.GetEntityList("_STOCK");
                        stocks.Fill(false);

                        foreach (IEntity stock in stocks)
                        {
                            stock.Delete();
                        }


                        IEntityList formats = _clipper_Context.EntityManager.GetEntityList("_SHEET");
                        formats.Fill(false);

                        foreach (IEntity format in formats)
                        {
                            format.Delete();
                        }
                        clipper_modelsRepository = null;
                        break;

                    case "OF":

                        clipper_modelsRepository = new ModelsRepository();
                        //import of


                        if (args.Length == 0 || args.Length == 1)
                        {
                            csvImportPath = Clipper_Param.GetPath("IMPORT_CDA");
                        }
                        else
                        {
                            csvImportPath = args[1].ToUpper().ToString();
                        }

                        string of_dataModelstring = Clipper_Param.GetModelCA();

                        //chargement des paramètres
                        bool SansDt = false;

                        //MessageBox.Show(csvImportPath);

                        if (csvImportPath.Contains("SANSDT") | csvImportPath.Contains("SANS_DT"))
                        {
                            SansDt = true;
                        }


                        using (Clipper_OF CahierAffaire = new Clipper_OF())
                        {
                            CahierAffaire.Import(_clipper_Context, csvImportPath, of_dataModelstring, SansDt);
                            //CahierAffaire.Import(_clipper_Context, csvImportSandDt, of_dataModelstring, true);
                        }



                        break;
                    }
                }
            }
        }
Esempio n. 7
0
        //initialisation des listes
        // [DllImport("user32.dll")]
        // static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        // [DllImport("Kernel32")]
        // private static extern IntPtr GetConsoleWindow();

        // const int SW_HIDE=0;
        // const int SW_SHOW=5;

        static void Main(string[] args)
        {
            string   DbName;
            IContext _clipper_Context = null;


            Console.WriteLine("hello");
            Console.WriteLine(args[1].ToString());
            Console.WriteLine(args[0].ToString());
            Console.ReadLine();

            //EventLog.WriteEntry("Clipper_import", "arguments " + args[0] + " ; " + args[1], EventLogEntryType.Information, 255);
            // RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"HKEY_CURRENT_USER\Software\Alma\Wpm");
            // DbName = (string)registryKey.GetValue("LastModelDatabaseName");
            DbName = "AlmaCAM_Test";
            ModelsRepository clipper_modelsRepository = new ModelsRepository();

            clipper_modelsRepository = null;


            _clipper_Context = clipper_modelsRepository.GetModelContext(DbName);      //nom de la base;
            int i = _clipper_Context.ModelsRepository.ModelList.Count();

            Clipper_Param.GetlistParam(_clipper_Context);



            //string DbName = "AlmaCAM_Clipper_5";
            //creation du model repository


            //IntPtr hwnd;
            // hwnd=GetConsoleWindow();
            //ShowWindow(hwnd,SW_HIDE);
            //ShowWindow(hwnd,SW_SHOW);

            using (EventLog eventLog = new EventLog("Application"))
            {
                eventLog.Source = "Clipper_import";
                //EventLog.WriteEntry("Clipper_import", "Found " + (string)registryKey.GetValue("LastModelDatabaseName"), EventLogEntryType.Information, 255);
                EventLog.WriteEntry("Clipper_import", "Found " + DbName, EventLogEntryType.Information, 255);
                if (args.Length != 0)
                {
                    string fulpathname = args[1];
                    switch (args[0].ToUpper())
                    {
                    //fullpath name
                    case "STOCK":
                        //import stock
                        string csvImportPath   = Clipper_Param.GetPath("IMPORT_DM");
                        string dataModelstring = Clipper_Param.GetModelDM();


                        using (Clipper_Stock Stock = new Clipper_Stock())
                        {
                            Stock.Import(_clipper_Context, csvImportPath, dataModelstring);
                        }
                        clipper_modelsRepository = null;

                        EventLog.WriteEntry("Clipper_import", "Import du stock terminé", EventLogEntryType.Information, 255);
                        break;

                    case "STOCK_PURGE":
                        //puge de tous les elements du stock
                        // clipper_modelsRepository =  new ModelsRepository();
                        //_clipper_Context = clipper_modelsRepository.GetModelContext(DbName);  //nom de la base;
                        //int i = _clipper_Context.ModelsRepository.ModelList.Count();

                        IEntityList stocks = _clipper_Context.EntityManager.GetEntityList("_STOCK");
                        stocks.Fill(false);

                        foreach (IEntity stock in stocks)
                        {
                            stock.Delete();
                        }


                        IEntityList formats = _clipper_Context.EntityManager.GetEntityList("_SHEET");
                        formats.Fill(false);

                        foreach (IEntity format in formats)
                        {
                            format.Delete();
                        }
                        clipper_modelsRepository = null;
                        break;

                    case "OF":
                        //import stock
                        clipper_modelsRepository = new ModelsRepository();
                        //import of
                        //chargement de sparamètres
                        //Clipper_Param.GetlistParam(_clipper_Context);
                        string csvImport_of_Path  = Clipper_Param.GetPath("IMPORT_CDA");
                        string of_dataModelstring = Clipper_Param.GetModelCA();

                        using (Clipper_OF CahierAffaire = new Clipper_OF())
                        {
                            CahierAffaire.Import(_clipper_Context, csvImport_of_Path, of_dataModelstring, false);
                        }



                        //
                        //csv
                        string csvfile = System.IO.Path.GetFileNameWithoutExtension(csvImport_of_Path);
                        dataModelstring = Clipper_Param.GetModelCA();
                        string csvImportPath_sans_dt = csvImport_of_Path.Substring(0, (csvImport_of_Path.Length - (csvfile.Length + 4))) + csvfile + "_SANSDT.csv";
                        using (Clipper_OF CahierAffaire_sans_Dt = new Clipper_OF())
                        {
                            CahierAffaire_sans_Dt.Import(_clipper_Context, csvImportPath_sans_dt, dataModelstring, true);
                        }

                        EventLog.WriteEntry("Clipper_import", "Import du ca terminé" + csvImportPath_sans_dt, EventLogEntryType.Information, 255);
                        clipper_modelsRepository = null;
                        break;
                    }
                }
                else
                {
                    EventLog.WriteEntry("Clipper_import", "impossible de trouver les arguments demandés <type import> <nomfichier>", EventLogEntryType.Warning, 255);
                }
            }
        }