Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            Action action = () =>
            {
                if (ServerType.Equals(ServerType.IIS))
                {
                    Server.IIsFireUrl = this.FireUrlText.Text;
                }
                if (ServerType.Equals(ServerType.DOCKER))
                {
                    Server.DockerFireUrl = this.FireUrlText.Text;
                }
                if (ServerType.Equals(ServerType.WINSERVICE))
                {
                    Server.WindowsServiceFireUrl = this.FireUrlText.Text;
                }

                progress_iis_build.Dispose();
                progress_iis_package.Dispose();
                progress_iis_upload.Dispose();
                progress_iis_deploy.Dispose();
                base.Dispose(disposing);
            };

            if (this.InvokeRequired)
            {
                this.BeginInvoke(action, null);
            }
            else
            {
                action();
            }
        }
Exemplo n.º 2
0
        public bool CheckFireUrl()
        {
            //当是需要人选的 但是没有被选 那就不去check
            if (!this.CheckBox.Checked)
            {
                return(true);
            }

            var url = this.FireUrlText.Text.ToLower();

            if (!string.IsNullOrEmpty(url) && !url.StartsWith("http"))
            {
                return(false);
            }

            if (ServerType.Equals(ServerType.IIS))
            {
                Server.IIsFireUrl = this.FireUrlText.Text;
            }
            if (ServerType.Equals(ServerType.DOCKER))
            {
                Server.DockerFireUrl = this.FireUrlText.Text;
            }
            if (ServerType.Equals(ServerType.LINUXSERVICE))
            {
                Server.LinuxServiceFireUrl = this.FireUrlText.Text;
            }
            if (ServerType.Equals(ServerType.WINSERVICE))
            {
                Server.WindowsServiceFireUrl = this.FireUrlText.Text;
            }

            return(true);
        }
        public List <Queries> LoadRecord(ServerType serveurType)
        {
            List <Queries> lstQueries = new List <Queries>();

            foreach (IDbConnection connectDB in ImplementConnection.Instance.Conns)
            {
                if (connectDB.State != ConnectionState.Open)
                {
                    connectDB.Open();
                }
            }

            IDbCommand cmd = null;

            //Indice 1 Pour connexion MySQL et 0 pour SQLServer
            if (serveurType.Equals(ServerType.SQLServer))
            {
                cmd = ImplementConnection.Instance.Conns[0].CreateCommand();
            }
            else
            {
                cmd = ImplementConnection.Instance.Conns[1].CreateCommand();
            }

            cmd.CommandText = "select id,requete from tmp_query";
            IDataReader rd = cmd.ExecuteReader();

            while (rd.Read())
            {
                Queries req = new Queries();
                req.Id      = Convert.ToInt32(rd["id"]);
                req.Requete = Convert.ToString(rd["requete"]);
                lstQueries.Add(req);
            }

            rd.Dispose();
            cmd.Dispose();

            return(lstQueries);
        }
Exemplo n.º 4
0
        public bool CheckFireUrl()
        {
            var url = this.FireUrlText.Text.ToLower();

            if (!string.IsNullOrEmpty(url) && !url.StartsWith("http"))
            {
                return(false);
            }

            if (ServerType.Equals(ServerType.IIS))
            {
                Server.IIsFireUrl = this.FireUrlText.Text;
            }
            if (ServerType.Equals(ServerType.DOCKER))
            {
                Server.DockerFireUrl = this.FireUrlText.Text;
            }
            if (ServerType.Equals(ServerType.WINSERVICE))
            {
                Server.WindowsServiceFireUrl = this.FireUrlText.Text;
            }

            return(true);
        }
        public int CoutRecord(ServerType serveurType)
        {
            int countQueries = 0;

            foreach (IDbConnection connectDB in ImplementConnection.Instance.Conns)
            {
                if (connectDB.State != ConnectionState.Open)
                {
                    connectDB.Open();
                }
            }

            IDbCommand cmd = null;

            //Indice 1 Pour connexion MySQL et 0 pour SQLServer
            if (serveurType.Equals(ServerType.SQLServer))
            {
                cmd = ImplementConnection.Instance.Conns[0].CreateCommand();
            }
            else
            {
                cmd = ImplementConnection.Instance.Conns[1].CreateCommand();
            }

            cmd.CommandText = "select count(id) as nbrRec from tmp_query";
            IDataReader rd = cmd.ExecuteReader();

            if (rd.Read())
            {
                countQueries = Convert.ToInt32(rd["nbrRec"]);
            }

            rd.Dispose();
            cmd.Dispose();
            return(countQueries);
        }
Exemplo n.º 6
0
        public ProgressBox(System.Drawing.Point location, BaseServer server, ServerType serverType, Action <ServerType, BaseServer> LoadHistoryAction)
        {
            this.ServerType = serverType;
            this.Server     = server;
            this.Location   = location;
            var Progressheight = 36;
            var buttonHeight   = Progressheight + 31;

            this.Size    = new System.Drawing.Size(546, 130);
            this.TabStop = false;
            this.SuspendLayout();

            this.label29              = new System.Windows.Forms.Label();
            this.progress_iis_build   = new CircularProgressBar.CircularProgressBar();
            this.progress_iis_package = new CircularProgressBar.CircularProgressBar();
            this.progress_iis_upload  = new CircularProgressBar.CircularProgressBar();
            this.progress_iis_deploy  = new CircularProgressBar.CircularProgressBar();
            this.b_build_end          = new System.Windows.Forms.Button();
            this.b_package_end        = new System.Windows.Forms.Button();
            this.b_upload_end         = new System.Windows.Forms.Button();
            this.FireUrlText          = new System.Windows.Forms.TextBox();
            HostoryButton             = new AltoButton();
            //
            // label29
            //
            this.label29.AutoSize = true;
            this.label29.Location = new System.Drawing.Point(42, Progressheight - 15);
            this.label29.Size     = new System.Drawing.Size(107, 12);
            this.label29.Text     = "Fire Url:";

            //
            // txt_iis_website_url
            //
            this.FireUrlText.Location = new System.Drawing.Point(120, Progressheight - 20);
            this.FireUrlText.Size     = new System.Drawing.Size(322, 21);

            if (serverType.Equals(ServerType.IIS))
            {
                this.FireUrlText.Text = server.IIsFireUrl;
            }
            if (serverType.Equals(ServerType.DOCKER))
            {
                this.FireUrlText.Text = server.DockerFireUrl;
            }
            if (serverType.Equals(ServerType.WINSERVICE))
            {
                this.FireUrlText.Text = server.WindowsServiceFireUrl;
            }
            //
            // progress_iis_build
            //
            this.progress_iis_build.Anchor            = System.Windows.Forms.AnchorStyles.None;
            this.progress_iis_build.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
            this.progress_iis_build.AnimationSpeed    = 500;
            this.progress_iis_build.BackColor         = System.Drawing.Color.Transparent;
            this.progress_iis_build.Font                  = new System.Drawing.Font("Arial", 13F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
            this.progress_iis_build.ForeColor             = System.Drawing.Color.Red;
            this.progress_iis_build.InnerColor            = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.progress_iis_build.InnerMargin           = 0;
            this.progress_iis_build.InnerWidth            = -1;
            this.progress_iis_build.Location              = new System.Drawing.Point(42, Progressheight);
            this.progress_iis_build.MarqueeAnimationSpeed = 2000;
            this.progress_iis_build.OuterColor            = System.Drawing.Color.Gray;
            this.progress_iis_build.OuterMargin           = -25;
            this.progress_iis_build.OuterWidth            = 22;
            this.progress_iis_build.ProgressColor         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_build.ProgressWidth         = 15;
            this.progress_iis_build.SecondaryFont         = new System.Drawing.Font("Microsoft Sans Serif", 10F);
            this.progress_iis_build.Size                  = new System.Drawing.Size(84, 77);
            this.progress_iis_build.StartAngle            = 270;
            this.progress_iis_build.SubscriptColor        = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_build.SubscriptMargin       = new System.Windows.Forms.Padding(0);
            this.progress_iis_build.SubscriptText         = "";
            this.progress_iis_build.SuperscriptColor      = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_build.SuperscriptMargin     = new System.Windows.Forms.Padding(-23, 0, 0, 0);
            this.progress_iis_build.SuperscriptText       = "Wait";
            this.progress_iis_build.TabIndex              = 9;
            this.progress_iis_build.Text                  = "Build";
            this.progress_iis_build.TextMargin            = new System.Windows.Forms.Padding(10, 8, 0, 0);
            this.progress_iis_build.Style                 = System.Windows.Forms.ProgressBarStyle.Marquee;
            this.progress_iis_build.Value                 = 0;
            //
            // progress_iis_package
            //
            this.progress_iis_package.Anchor            = System.Windows.Forms.AnchorStyles.None;
            this.progress_iis_package.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
            this.progress_iis_package.AnimationSpeed    = 500;
            this.progress_iis_package.BackColor         = System.Drawing.Color.Transparent;
            this.progress_iis_package.Font                  = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
            this.progress_iis_package.ForeColor             = System.Drawing.Color.Red;
            this.progress_iis_package.InnerColor            = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.progress_iis_package.InnerMargin           = 0;
            this.progress_iis_package.InnerWidth            = -1;
            this.progress_iis_package.Location              = new System.Drawing.Point(162, Progressheight);
            this.progress_iis_package.MarqueeAnimationSpeed = 2000;
            this.progress_iis_package.OuterColor            = System.Drawing.Color.Gray;
            this.progress_iis_package.OuterMargin           = -25;
            this.progress_iis_package.OuterWidth            = 22;
            this.progress_iis_package.ProgressColor         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_package.ProgressWidth         = 15;
            this.progress_iis_package.SecondaryFont         = new System.Drawing.Font("Microsoft Sans Serif", 10F);
            this.progress_iis_package.Size                  = new System.Drawing.Size(84, 77);
            this.progress_iis_package.StartAngle            = 270;
            this.progress_iis_package.SubscriptColor        = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_package.SubscriptMargin       = new System.Windows.Forms.Padding(0);
            this.progress_iis_package.SubscriptText         = "";
            this.progress_iis_package.SuperscriptColor      = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_package.SuperscriptMargin     = new System.Windows.Forms.Padding(-26, 0, 0, 0);
            this.progress_iis_package.SuperscriptText       = "0%";
            this.progress_iis_package.TabIndex              = 10;
            this.progress_iis_package.Text                  = "Package";
            this.progress_iis_package.TextMargin            = new System.Windows.Forms.Padding(10, 8, 0, 0);
            this.progress_iis_package.Style                 = System.Windows.Forms.ProgressBarStyle.Marquee;
            this.progress_iis_package.Value                 = 0;
            //
            // progress_iis_upload
            //
            this.progress_iis_upload.Anchor            = System.Windows.Forms.AnchorStyles.None;
            this.progress_iis_upload.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
            this.progress_iis_upload.AnimationSpeed    = 500;
            this.progress_iis_upload.BackColor         = System.Drawing.Color.Transparent;
            this.progress_iis_upload.Font                  = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
            this.progress_iis_upload.ForeColor             = System.Drawing.Color.Red;
            this.progress_iis_upload.InnerColor            = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.progress_iis_upload.InnerMargin           = 0;
            this.progress_iis_upload.InnerWidth            = -1;
            this.progress_iis_upload.Location              = new System.Drawing.Point(282, Progressheight);
            this.progress_iis_upload.MarqueeAnimationSpeed = 2000;
            this.progress_iis_upload.OuterColor            = System.Drawing.Color.Gray;
            this.progress_iis_upload.OuterMargin           = -25;
            this.progress_iis_upload.OuterWidth            = 22;
            this.progress_iis_upload.ProgressColor         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_upload.ProgressWidth         = 15;
            this.progress_iis_upload.SecondaryFont         = new System.Drawing.Font("Microsoft Sans Serif", 10F);
            this.progress_iis_upload.Size                  = new System.Drawing.Size(84, 77);
            this.progress_iis_upload.StartAngle            = 270;
            this.progress_iis_upload.SubscriptColor        = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_upload.SubscriptMargin       = new System.Windows.Forms.Padding(0);
            this.progress_iis_upload.SubscriptText         = "";
            this.progress_iis_upload.SuperscriptColor      = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_upload.SuperscriptMargin     = new System.Windows.Forms.Padding(-26, 0, 0, 0);
            this.progress_iis_upload.SuperscriptText       = "0%";
            this.progress_iis_upload.TabIndex              = 11;
            this.progress_iis_upload.Text                  = "Upload";
            this.progress_iis_upload.TextMargin            = new System.Windows.Forms.Padding(10, 8, 0, 0);
            this.progress_iis_upload.Style                 = System.Windows.Forms.ProgressBarStyle.Marquee;
            this.progress_iis_upload.Value                 = 0;
            //
            // progress_iis_deploy
            //
            this.progress_iis_deploy.Anchor            = System.Windows.Forms.AnchorStyles.None;
            this.progress_iis_deploy.AnimationFunction = WinFormAnimation.KnownAnimationFunctions.Liner;
            this.progress_iis_deploy.AnimationSpeed    = 500;
            this.progress_iis_deploy.BackColor         = System.Drawing.Color.Transparent;
            this.progress_iis_deploy.Font                  = new System.Drawing.Font("Arial", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(178)));
            this.progress_iis_deploy.ForeColor             = System.Drawing.Color.Red;
            this.progress_iis_deploy.InnerColor            = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.progress_iis_deploy.InnerMargin           = 0;
            this.progress_iis_deploy.InnerWidth            = -1;
            this.progress_iis_deploy.Location              = new System.Drawing.Point(402, Progressheight);
            this.progress_iis_deploy.MarqueeAnimationSpeed = 2000;
            this.progress_iis_deploy.OuterColor            = System.Drawing.Color.Gray;
            this.progress_iis_deploy.OuterMargin           = -25;
            this.progress_iis_deploy.OuterWidth            = 22;
            this.progress_iis_deploy.ProgressColor         = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_deploy.ProgressWidth         = 15;
            this.progress_iis_deploy.SecondaryFont         = new System.Drawing.Font("Microsoft Sans Serif", 10F);
            this.progress_iis_deploy.Size                  = new System.Drawing.Size(92, 77);
            this.progress_iis_deploy.StartAngle            = 270;
            this.progress_iis_deploy.SubscriptColor        = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_deploy.SubscriptMargin       = new System.Windows.Forms.Padding(0);
            this.progress_iis_deploy.SubscriptText         = "";
            this.progress_iis_deploy.SuperscriptColor      = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(99)))), ((int)(((byte)(180)))));
            this.progress_iis_deploy.SuperscriptMargin     = new System.Windows.Forms.Padding(-28, 0, 0, 0);
            this.progress_iis_deploy.SuperscriptText       = "Wait";
            this.progress_iis_deploy.TabIndex              = 12;
            this.progress_iis_deploy.Text                  = "Deploy";
            this.progress_iis_deploy.TextMargin            = new System.Windows.Forms.Padding(12, 8, 0, 0);
            this.progress_iis_deploy.Style                 = System.Windows.Forms.ProgressBarStyle.Marquee;
            this.progress_iis_deploy.Value                 = 0;
            //
            // b_build_end
            //
            this.b_build_end.Location  = new System.Drawing.Point(113, buttonHeight);
            this.b_build_end.BackColor = System.Drawing.Color.LightGray;
            this.b_build_end.Size      = new System.Drawing.Size(76, 19);
            this.b_build_end.TabIndex  = 17;
            this.b_build_end.UseVisualStyleBackColor = true;

            //
            // b_package_end
            //
            this.b_package_end.Location  = new System.Drawing.Point(234, buttonHeight);
            this.b_package_end.BackColor = System.Drawing.Color.LightGray;
            this.b_package_end.Size      = new System.Drawing.Size(76, 19);
            this.b_package_end.TabIndex  = 18;
            this.b_package_end.UseVisualStyleBackColor = true;
            //
            // b_upload_end
            //
            this.b_upload_end.Location  = new System.Drawing.Point(358, buttonHeight);
            this.b_upload_end.BackColor = System.Drawing.Color.LightGray;
            this.b_upload_end.Size      = new System.Drawing.Size(76, 19);
            this.b_upload_end.TabIndex  = 19;
            this.b_upload_end.UseVisualStyleBackColor = true;

            this.HostoryButton.Location     = new System.Drawing.Point(this.FireUrlText.Location.X + this.FireUrlText.Width + 20, Progressheight - 20);
            this.HostoryButton.Size         = new System.Drawing.Size(60, 20);
            this.HostoryButton.Text         = "Histroy";
            this.HostoryButton.Active1      = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(168)))), ((int)(((byte)(183)))));
            this.HostoryButton.Active2      = System.Drawing.Color.FromArgb(((int)(((byte)(36)))), ((int)(((byte)(164)))), ((int)(((byte)(183)))));
            this.HostoryButton.BackColor    = System.Drawing.Color.Transparent;
            this.HostoryButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.HostoryButton.ForeColor    = System.Drawing.Color.Black;
            this.HostoryButton.Inactive1    = System.Drawing.Color.LightGray;
            this.HostoryButton.Inactive2    = System.Drawing.Color.LightGray;
            this.HostoryButton.Name         = "b_windows_service_rollback";
            this.HostoryButton.Radius       = 10;
            this.HostoryButton.Stroke       = false;
            this.HostoryButton.StrokeColor  = System.Drawing.Color.Gray;
            this.HostoryButton.Transparency = false;
            this.HostoryButton.Click       += (sender, args) => { LoadHistoryAction(this.ServerType, this.Server); };

            //
            // groupBox_iis_progress
            //
            this.Controls.Add(this.label29);
            this.Controls.Add(this.FireUrlText);
            this.Controls.Add(this.HostoryButton);
            this.Controls.Add(this.progress_iis_build);
            this.Controls.Add(this.b_build_end);

            this.Controls.Add(this.progress_iis_package);
            this.Controls.Add(this.b_package_end);

            this.Controls.Add(this.progress_iis_upload);
            this.Controls.Add(this.b_upload_end);

            this.Controls.Add(this.progress_iis_deploy);

            this.b_build_end.SendToBack();
            this.b_package_end.SendToBack();
            this.b_upload_end.SendToBack();
        }
 public bool IsNextFormInstructionEvent() => ServerType.Equals(NextFormInstructionEventType);
 public bool IsValidationEvent() => ServerType.Equals(ValidationEventType);
        public int Execute(string strQuery, ServerType serveurType)
        {
            int            nbRecord    = 0;
            IDbTransaction transaction = null;

            System.IO.FileInfo fileInfo = null;

            try
            {
                if (ImplementConnection.Instance.Conn.State != ConnectionState.Open)
                {
                    ImplementConnection.Instance.Conn.Open();
                }

                string strPath = ImplementUtilities.Instance.LoadParameters(directoryMaster, DirectoryUtilConn, FilePathFile);
                transaction = ImplementConnection.Instance.Conn.BeginTransaction(IsolationLevel.Serializable);

                //On set le fichier
                fileInfo = new System.IO.FileInfo(strPath);

                //Changement attribut du fichier pour etre en lecture seul - Eviter d'ajouter contenu pendant execution query
                fileInfo.IsReadOnly = true;

                //connexion MySQL pour inserer les requetes venant de SQLServer est enregistrees dans le fichier
                nbRecord = DoExecuteQueryFile(strQuery, nbRecord, transaction);

                //On rend le fichier accessible en lecture-ecriture
                fileInfo.IsReadOnly = false;

                //Vider le fichier de son contenu
                switch (fileInfo.Attributes)
                {
                case System.IO.FileAttributes.Normal:
                    System.IO.File.WriteAllText(strPath, string.Empty);
                    break;

                case System.IO.FileAttributes.Hidden:
                    fileInfo.Attributes = System.IO.FileAttributes.Normal;
                    System.IO.File.WriteAllText(strPath, string.Empty);
                    break;

                default:
                    fileInfo.Attributes = System.IO.FileAttributes.Normal;
                    System.IO.File.WriteAllText(strPath, string.Empty);
                    break;
                }

                fileInfo.Attributes = System.IO.FileAttributes.Hidden;
                //On rend le fichier inaccessible en lecture-ecriture
                fileInfo.IsReadOnly = true;

                switch (serveurType)
                {
                case ServerType.SQLServer:
                {
                    //Enregistrement dans le fichier Log
                    if (nbRecord > 0)
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Enregistrement comptes MySQL => SQL Server avec succès", DirectoryUtilLog, FileLog);
                    }
                    break;
                }

                case ServerType.MySQL:
                {
                    //Enregistrement dans le fichier Log
                    if (nbRecord > 0)
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Enregistrement comptes SQL Server => MySQL avec succès", DirectoryUtilLog, FileLog);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                fileInfo.Attributes = System.IO.FileAttributes.Hidden;
                //On rend le fichier inaccessible en lecture-ecriture
                fileInfo.IsReadOnly = true;

                if (transaction != null)
                {
                    transaction.Rollback();

                    //Enregistrement dans le fichier Log
                    if (serveurType.Equals(ServerType.SQLServer))
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Echec de l'insertion des comptes étudiant-SQL Server : " + ex.Message, DirectoryUtilLog, FileLog);
                    }
                    else
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Echec de l'insertion des comptes étudiant-MySQL : " + ex.Message, DirectoryUtilLog, FileLog);
                    }
                }
            }
            return(nbRecord);
        }
Exemplo n.º 10
0
        public void Execute(List <Queries> lstQueries, ServerType serveurType)
        {
            IDbTransaction transaction = null, transaction1 = null;

            try
            {
                foreach (IDbConnection connectDB in ImplementConnection.Instance.Conns)
                {
                    if (connectDB.State != ConnectionState.Open)
                    {
                        connectDB.Open();
                    }
                }

                switch (serveurType)
                {
                case ServerType.SQLServer:
                {
                    //Indice 1 Pour connexion MySQL et 0 pour SQLServer
                    transaction  = ImplementConnection.Instance.Conns[1].BeginTransaction(IsolationLevel.Serializable);
                    transaction1 = ImplementConnection.Instance.Conns[0].BeginTransaction(IsolationLevel.Serializable);
                    break;
                }

                case ServerType.MySQL:
                {
                    transaction  = ImplementConnection.Instance.Conns[0].BeginTransaction(IsolationLevel.Serializable);
                    transaction1 = ImplementConnection.Instance.Conns[1].BeginTransaction(IsolationLevel.Serializable);
                    break;
                }
                }

                //Insertion des records
                foreach (Queries req in lstQueries)
                {
                    IDbCommand cmd = null;
                    //Execution des requetes dans la bloucle
                    if (serveurType.Equals(ServerType.SQLServer))
                    {
                        cmd = ImplementConnection.Instance.Conns[1].CreateCommand();
                    }
                    else
                    {
                        cmd = ImplementConnection.Instance.Conns[0].CreateCommand();
                    }

                    cmd.CommandText = req.Requete;
                    cmd.Transaction = transaction;

                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                }

                //Suppression des tous les records inseres
                foreach (Queries req in lstQueries)
                {
                    IDbCommand cmd = null;
                    //Execution des requetes dans la bloucle
                    if (serveurType.Equals(ServerType.SQLServer))
                    {
                        cmd = ImplementConnection.Instance.Conns[0].CreateCommand();
                    }
                    else
                    {
                        cmd = ImplementConnection.Instance.Conns[1].CreateCommand();
                    }

                    cmd.CommandText = "delete from tmp_query where id=@id";
                    IDbDataParameter param = cmd.CreateParameter();
                    param.ParameterName = "@id";
                    param.Value         = req.Id;
                    cmd.Parameters.Add(param);

                    cmd.Transaction = transaction1;

                    cmd.ExecuteNonQuery();
                    cmd.Dispose();
                }

                transaction.Commit();
                transaction1.Commit();
                transaction.Dispose();
                transaction1.Dispose();

                //Enregistrement dans le fichier Log
                if (serveurType.Equals(ServerType.SQLServer))
                {
                    ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Enregistrement comptes SQL Server => MySQL avec succès", DirectoryUtilLog, FileLog);
                }
                else
                {
                    ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Enregistrement comptes MySQL => SQL Server avec succès", DirectoryUtilLog, FileLog);
                }
            }
            catch (Exception ex)
            {
                if (transaction != null || transaction1 != null)
                {
                    transaction.Rollback();
                    transaction1.Rollback();

                    //Enregistrement dans le fichier Log
                    if (serveurType.Equals(ServerType.SQLServer))
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Echec de l'insertion des comptes étudiant-SQL Server : " + ex.Message, DirectoryUtilLog, FileLog);
                    }
                    else
                    {
                        ImplementLog.Instance.PutLogMessage(directoryMaster, DateTime.Now + " : Echec de l'insertion des comptes étudiant-MySQL : " + ex.Message, DirectoryUtilLog, FileLog);
                    }
                }
            }
            finally
            {
                foreach (IDbConnection connectDB in ImplementConnection.Instance.Conns)
                {
                    if (connectDB.State != ConnectionState.Closed)
                    {
                        connectDB.Close();
                    }
                }
            }
        }
Exemplo n.º 11
0
        //This is to finally execute a query that will return a data frame that will be loaded in a grid.
        private bool ExecuteQuery(string query, string dframename)
        {
            //Get table using custom query
            DataFrame alltablesDF = null;
            //Get list of Tables in a database.
            string command = null;// "GetDataframe(" + ConnectionString + ", databasename ='" + SelectedDatabase + "', '" + query + "','" + dframename + "')";

            if (ServerType.Equals("MS-ACCESS"))
            {
                command = "GetDataframe(" + ConnectionString + ", query= '" + query + "', datasetname='" + dframename + "')";
            }
            else
            {
                command = "GetDataframe(" + ConnectionString + ", databasename ='" + SelectedDatabase + "', query= '" + query + "', datasetname='" + dframename + "')";
            }
            //object alltables = service.ImportTableListFromSQL(command);


            UAReturn uaret = service.ImportTableListFromSQL(command);

            OutputHelper.AnalyticsData.Result = uaret;//putting DOM

            //A table is always returned with single bool value that shows whether Dataset
            //creation in R memory was success or not
            bool[] visibleRows;
            int    datanumber     = 1;                             // there is just one table that we are intrested in. Its first table in  /Root/UATableList
            bool   isDatasetReady = false;
            int    backup         = OutputHelper.FlexGridMaxCells; //backup current value

            OutputHelper.FlexGridMaxCells = 1000;                  //change to required value
            string[,] datasetReady        = OutputHelper.GetDataMatrix(datanumber, out visibleRows);
            OutputHelper.FlexGridMaxCells = backup;                //restore original value back again;
            if (datasetReady != null)
            {
                isDatasetReady = datasetReady[0, 0].ToLower().Equals("true") ? true : false;
            }
            //// Now fetching errors if any
            string[,] ew = OutputHelper.GetBSkyErrorsWarning(0, "normal");//0 for automatically finding the tablenumber
            if (ew != null)
            {
                StringBuilder errmsg = new StringBuilder();
                int           rcount = ew.GetLength(0);
                int           ccount = ew.GetLength(1);
                for (int r = 0; r < rcount; r++)
                {
                    for (int c = 0; c < ccount; c++)
                    {
                        errmsg.Append(ew[r, c] + "\n");
                    }
                }

                MessageBox.Show(errmsg.ToString(), "Errors/Warnings:", MessageBoxButton.OK, MessageBoxImage.Error);
                HideProgressbar();
            }

            if (!isDatasetReady) // if dataset was not created in R memory due to wrong query or other reasons.
            {
                return(false);
            }


            DataSource ds        = service.OpenDataframe(dframename, "");
            bool       isSuccess = false;
            string     errormsg  = string.Empty;

            if (ds != null && ds.Message != null && ds.Message.Length > 0) //message that is related to error
            {
                errormsg = "\n" + ds.Message;
                ds       = null;          //making it null so that we do execute further
            }
            if (ds != null)               //03Dec2012
            {
                bool isDatasetNew = true; // service.isDatasetNew(dframename + "");
                logService.WriteToLogLevel("Start Loading Dataframe: " + ds.Name, LogLevelEnum.Info);
                if (isDatasetNew)
                {
                    controller.Load_Dataframe(ds);
                }
                else
                {
                    controller.RefreshBothGrids(ds); //23Jul2015 .RefreshGrids(ds);//.RefreshDataSet(ds);
                }
                ds.Changed = true;                   // keep track of change made, so that it can prompt for saving while closing dataset tab.
                logService.WriteToLogLevel("Finished Loading Dataframe: " + ds.Name, LogLevelEnum.Info);
                //recentfiles.AddXMLItem(dframename);//adding to XML file for recent docs
                isSuccess = true;
            }
            else
            {
                HideProgressbar();
                MessageBox.Show("Unable to open SQL dataframe'" + dframename + "'..." +
                                "\nReasons could be one or more of the following:" +
                                "\n1. Not a data frame object." +
                                "\n2. File format not supported (or corrupt file or duplicate column names)." +
                                "\n3. Dataframe does not have row(s) or column(s)." +
                                "\n4. R.Net server from the old session still running (use task manager to kill it)." +
                                "\n5. Some issue on R side (like: required library not loaded, incorrect syntax)." +
                                "\n6. Incorrect values provided while connecting to the SQL server.",
                                "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                //SendToOutputWindow("Error Opening Dataset.(probably not a data frame)", dframename + errormsg);
            }

            HideProgressbar();
            return(true);
        }