コード例 #1
0
        static private bool Init(string db, string user)
        {
            if (Context == null)
            {
                IModelsRepository modelsRepository = new ModelsRepository();
                Context = modelsRepository.GetModelContext(db);
                if (Context != null)
                {
                    Licence.InitLicence(Context.Kernel, null);
                    SetUser(Context, user);
                }
                else
                {
                    return(false);
                }
            }


            /*
             *
             * if (CreateTransFile == null)
             * {
             *  CreateTransFile = new CreateTransFile();
             *  CreateTransFile.Init(Context);
             * }
             */
            return(true);
        }
コード例 #2
0
        static private bool Init(string db, string user)
        {
            if (Context == null)
            {
                IModelsRepository modelsRepository = new ModelsRepository();
                Context = modelsRepository.GetModelContext(db);
                if (Context != null)
                {
                    Licence.InitLicence(Context.Kernel, null);
                    SetUser(Context, user);
                }
                else
                {
                    return(false);
                }
            }

            if (ClipperApi == null)
            {
                ClipperApi = new ClipperApi();
                ClipperApi.InitAlmaCam(Context);
            }

            return(true);
        }
コード例 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //creation du model repository
            IModelsRepository modelsRepository = new ModelsRepository();

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

            ;

            this.Text = DbName + "-P." + Clipper_Dll.Clipper_Param.getClipperDllVersion() + "-CAM." + Clipper_Dll.Clipper_Param.getAlmaCAMCompatibleVerion();
        }
コード例 #4
0
        /// <summary>
        /// form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Form1_Load(object sender, EventArgs e)
        {
            //creation du model repository
            IModelsRepository modelsRepository = new ModelsRepository();

            _Context = modelsRepository.GetModelContext(DbName);  //nom de la base;
            int    i = _Context.ModelsRepository.ModelList.Count();
            string infosPasserelle;

            infosPasserelle      = DbName + "-P." + AF_Clipper_Dll.Clipper_Param.GetClipperDllVersion() + "-CAM." + AF_Clipper_Dll.Clipper_Param.GetAlmaCAMCompatibleVerion();
            this.Text            = this.Name;
            this.InfosLabel.Text = infosPasserelle;
            this.Text            = "Passerelle Clipper V8 validée pour : " + infosPasserelle;
        }
コード例 #5
0
ファイル: ClipperApi.cs プロジェクト: vbimard/CLIPPER_SP5
        public bool Init(string databaseName, string user)
        {
            ModelsRepository modelsRepository = new ModelsRepository();

            _Context = modelsRepository.GetModelContext(databaseName);

            if (_Context != null)
            {
                Licence.InitLicence(_Context.Kernel, null);
                _UserOk = SetUser(_Context, user);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        static private bool Init(string db, string user)
        {
            if (Context == null)
            {
                IModelsRepository modelsRepository = new ModelsRepository();
                Context = modelsRepository.GetModelContext(db);
                if (Context != null)
                {
                    Licence.InitLicence(Context.Kernel, null);
                    SetUser(Context, user);
                }
                else
                {
                    //recuperation de la derniere base ouverte
                    MessageBox.Show("la base demandée par Clipper n'est pas detectée - > nom de la base demandée :" + db + ", merci de revoir le nom de la base configurée dans les profiles clipper .  " + "\r\n", db);
                    return(false);
                }
            }



            return(true);
        }
コード例 #7
0
ファイル: ClipperApi.cs プロジェクト: vbimard/CLIPPER_SP6
        /// <summary>
        /// connexion a la base almacam
        /// </summary>
        /// <param name="databaseName">nom de la base</param>
        /// <param name="user">utilisateur</param>
        /// <returns></returns>
        public bool ConnectAlmaCamDatabase(string databaseName, string user)
        {
            ModelsRepository modelsRepository = new ModelsRepository();

            _Context = modelsRepository.GetModelContext(databaseName);


            if (_Context != null)
            {
                Licence.InitLicence(_Context.Kernel, null);
                if (SetUser(_Context, user))
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("User Inconnu"); return(false);
                }                                                                                                    //_UserOk = SetUser(_Context, user);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
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;
                    }
                }
            }
        }
コード例 #9
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 = AF_JOHN_DEERE.Alma_RegitryInfos.GetLastDataBase();

            AF_JOHN_DEERE.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();
                JohnDeere_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


                        break;

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


                        break;

                    case "OF":

                        clipper_modelsRepository = new ModelsRepository();
                        //import of


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

                        string of_dataModelstring = JohnDeere_Param.GetModelCA();


                        using (JohnDeere_OF CahierAffaire = new JohnDeere_OF())
                        {
                            CahierAffaire.Import(_clipper_Context, csvImportPath, of_dataModelstring);
                        }



                        break;
                    }
                }
            }
        }
コード例 #10
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);
                }
            }
        }