Пример #1
0
        private void AddUser(string userName, string accessType)
        {
            int accessTypeID = 0;
            if (accessType.Equals("user"))
                accessTypeID = 1;
            else if (accessType.Equals("admin"))
                accessTypeID = 2;
            else if (accessType.Equals("superadmin"))
                accessTypeID = 3;

            try
            {
                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                service.Add_User(userName, accessTypeID);
                service.Close();

                var result = KryptonMessageBox.Show("User added !", "User added",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
            }

            catch
            {
                var result = KryptonMessageBox.Show("Fail to create user", "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                DataGridView.Rows.Remove(DataGridView.Rows[DataGridView.Rows.Count - 1]);
            }

            _RowAdded = false;
        }
Пример #2
0
        /**********************************************\
         * Load users:                                *
         *   - Connect to the database and get users. *
         *   - Update DatagridView                    *
        \**********************************************/
        public void LoadUsers()
        {
            AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
            DataSet dataSet = service.Get_Users();
            DataGridView.DataSource = dataSet.Tables[0];
            service.Close();

            DataGridView.Columns[0].HeaderText = "User Name";
            DataGridView.Columns[1].HeaderText = "Access Type";
        }
Пример #3
0
        /*******************************************************\
         * Authenticate user (simple mode):                    *
         *   - Try to get access_type regarding login/password *
         *        |-> If ok, update access type & return true  *
         *        |-> if not, return false                     *
        \*******************************************************/
        public Boolean Authenticate()
        {
            try
            {
                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();

                if (LoginTextBox.Text.Equals("") || PasswordTextBox.Text.Equals("") || LoginTextBox.Text.Contains(" ") || PasswordTextBox.Text.Contains(" "))
                {
                    var result = KryptonMessageBox.Show("Incorrect Login / Password", "Error",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Stop);
                }

                else
                {
                    string access_type = null;

                    access_type = service.Authenticate(LoginTextBox.Text, PasswordTextBox.Text);
                    if (!access_type.Equals(""))
                    {
                        _AccessType = access_type;
                        service.Close();
                        return true;
                    }

                    else
                    {
                        var result = KryptonMessageBox.Show("Incorrect Login / Password", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                        service.Close();
                        return false;
                    }
                }
            }

            catch
            {
                var result = KryptonMessageBox.Show("No connection found, please ensure that your connection is functionning.", "Connection Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                return false;
            }

            return false;
        }
Пример #4
0
        /**********************************************\
         * Get All chronicles for a specific config : *
         *    - Query on DB & bind to Datagrid View   *
        \**********************************************/
        public void GetChroniclesFromSpecificConfig(string name)
        {
            try
            {
                // Query on DB & bind to Datagrid View
                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                DataSet dataSet = service.Get_histo_modif_per_config(name);

                BindingSource bs = new BindingSource();
                bs.DataSource = dataSet.Tables[0];
                DataGridView.DataSource = bs;

                service.Close();
            }

            catch (Exception ex) { KryptonMessageBox.Show(ex.ToString()); }
        }
Пример #5
0
        /*****************************************************************************\
         * Authenticate user (hardware lock mode):                                   *
         *   - 1st verify if login/password is correct                               *
         *   - If correct, then try to insert new user (with PUC and access_type_id) *
         *         |-> If user already exists, update access type                    *
         *   - If not, return false.                                                 *
        \*****************************************************************************/
        public Boolean AuthenticateAndRemember()
        {
            try
            {
                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();

                if (LoginTextBox.Text.Equals("") || PasswordTextBox.Text.Equals("") || LoginTextBox.Text.Contains(" ") || PasswordTextBox.Text.Contains(" "))
                {
                    var result = KryptonMessageBox.Show("Incorrect Login / Password", "Error",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Stop);
                }

                else
                {
                    string access_type = null;

                    int accessTypeId = service.Get_password_id(LoginTextBox.Text, PasswordTextBox.Text);

                    if (accessTypeId != 666)
                    {
                        Boolean inserted = false;

                        string computer = System.Environment.MachineName;
                        inserted = service.Insert_user(computer, accessTypeId);

                        if (!inserted)
                            service.Update_access_type_id(computer, accessTypeId);

                        access_type = service.Authenticate(LoginTextBox.Text, PasswordTextBox.Text);
                        if (!access_type.Equals(""))
                        {
                            _AccessType = access_type;
                            service.Close();
                            return true;
                        }
                    }

                    else
                    {
                        var result = KryptonMessageBox.Show("Incorrect Login / Password", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                        service.Close();
                        return false;
                    }
                }
            }

            catch
            {
                var result = KryptonMessageBox.Show("No connection found, please ensure that your connection is functionning.", "Connection Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Stop);
                return false;
            }

            return false;
        }
Пример #6
0
        /******************************************************\
         * Check if PUC exists in DB (case of hardware lock): *
         * Check also if connection available                 *
        \******************************************************/
        public void CheckSavedPUC(string PUC)
        {
            try
            {
                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                _AccessType = service.Get_access_type(PUC);
                if (_AccessType.Equals(""))
                    _AccessType = "user";
                service.Close();
                _NetworkAvailable = true;
            }

            catch
            {
                _NetworkAvailable = false;
                _AccessType = "user";
            }
        }
Пример #7
0
        /********************************************************************\
         * Run the config (method called when a thread starts)              *
         *   - Measure the whole process time.                              *
         *   - Perform Preprocess.                                          *
         *   - Treat each input file :                                      *
         *       - Convert the current treated file into a list of strings. *
         *       - Perform Process.                                         *
         *       - Write Datamod.                                           *
         *       - Perform Controls.                                        *
         *       - Perform Header Consistency.                              *
         *       - Write logs.                                              *
         *       - Create Logs Datagrid View.                               *
         *       - Update stats                                             *
        \********************************************************************/
        internal void Run(int id)
        {
            float counter = 0;
            Stopwatch launchStopwatch = new Stopwatch();
            _ID = id;

            launchStopwatch.Start();

            UpdateProgressBar(counter);

            _Logs = _Logs + System.DateTime.Now + "\n" + _Config.Get_Name();

            // Perform Preprocess
            if (_PreProcess)
            {
                UpdateRichTextBox("title", "PRE-PROCESS");

                foreach (Process process in _Config.Get_ProcessList().OrderBy(x => x.Get_OrderId()))
                    if (process.Get_OrderId() < 0)
                    {
                        try
                        {
                            PreProcess(process.Get_Datatable());
                            counter++;
                            UpdateProgressBar(counter);
                        }
                        catch
                        {
                            counter++;
                            UpdateProgressBar(counter);
                            UpdateRichTextBox("fail", "FAIL");
                        }
                    }
            }

            // Treat each input file
            if (_InputFiles.Count > 0)
            {
                int numberOfInputFiles = _InputFiles.Count;
                foreach (String processedFile in _InputFiles)
                {
                    int nbLinesBefore = 0; // Number of lines before reformating.
                    int nbLinesAfter = 0;  // Number of lines after reformating.

                    Stopwatch launchStopwatch3 = new Stopwatch();
                    launchStopwatch3.Start();

                    string originalProcessedFile = processedFile.Replace("_1.txt", ".txt");
                    _FileCounter++;
                    _CurrentFile = processedFile;

                    _DatamodPath = Path.GetDirectoryName(processedFile) + "\\" + Path.GetFileNameWithoutExtension(processedFile) + "_new" + Path.GetExtension(processedFile);

                    // Convert the current treated file into a list of strings.
                    _TabData = FileToLS(processedFile);
                    nbLinesBefore = _TabData.Count;

                    // Perform process.
                    if (_Process)
                    {
                        UpdateRichTextBox("title", "PROCESS" + " (file n° " + _FileCounter + "/" + numberOfInputFiles + ") ");
                        foreach (Process process in _Config.Get_ProcessList().OrderBy(x => x.Get_OrderId()))
                            if (process.Get_OrderId() > 0 && process.Get_OrderId() < 100)
                            {
                                Process(process.Get_Datatable());
                                counter = counter + (float)((float)1 / (float)numberOfInputFiles);
                                UpdateProgressBar(counter);
                            }
                    }

                    // Write Datamod.
                    if (!String.IsNullOrEmpty(_Config.Get_CountryCode()))
                    {
                        nbLinesAfter = WriteDatamod();
                    }
                    else _DatamodPath = processedFile;

                    // Perform Controls.
                    if (_Control)
                    {
                        UpdateRichTextBox("title", "CONTROL" + " (file n° " + _FileCounter + "/" + numberOfInputFiles + ") ");
                        foreach (Process process in _Config.Get_ProcessList().OrderBy(x => x.Get_OrderId()))
                            if (process.Get_OrderId() > 100)
                            {
                                Control(process.Get_Datatable());
                                counter = counter + (float)((float)1 / (float)numberOfInputFiles);
                                UpdateProgressBar(counter);
                            }
                    }

                    // Perform Header Consistency.
                    if (_HeaderConsistency)
                        HeaderConsistency();

                    // Write logs.
                    WriteLogs();

                    /////////////////////////////////////////////////////////
                    // Create LogsGrid, analyze it and add it to the control.

                    Stopwatch launchStopwatch2 = new Stopwatch();
                    launchStopwatch2.Start();

                    UpdateRichTextBox("title", "*** ANALYZE LOGS ***");
                    AddLogsGridView(_DatamodPath, originalProcessedFile);
                    counter = counter + (float)((float)1 / (float)numberOfInputFiles);
                    UpdateRichTextBox("complete", "      |-->Complete!");
                    UpdateProgressBar(counter);

                    launchStopwatch2.Stop();
                    TimeSpan ts2 = launchStopwatch2.Elapsed;
                    string elapsedTime2 = String.Format("{0:00}:{1:00}", ts2.Minutes, ts2.Seconds);
                    UpdateRichTextBox("time", elapsedTime2);

                    // Update statistics
                    launchStopwatch3.Stop();
                    AnalyticsWebService.AnalyticsSoapClient query = new AnalyticsWebService.AnalyticsSoapClient();
                    query.Insert(System.Environment.UserName, _Config.Get_ConfigType(), _Config.Get_Name(), processedFile, _DatamodPath, (int)launchStopwatch3.ElapsedMilliseconds / 1000);
                    query.Close();

                    // Suppress input file if xml
                    if (processedFile.Contains(".xml"))
                        File.Delete(processedFile);

                    // Display number of lines before & after reformating
                    UpdateRichTextBox("lineCounter", "");
                    if (nbLinesBefore > 0)
                        UpdateRichTextBox("lineCounter", "Number of line before reformating : " + nbLinesBefore);
                    if (nbLinesAfter > 0)
                        UpdateRichTextBox("lineCounter", "Number of line after reformating : " + nbLinesAfter);
                }
            }

            else
            {
                UpdateRichTextBox("superfail", "GLOBAL PROCESS FAILED, sorry");
                counter = _NumberOfProcesses;
                UpdateProgressBarPut100Percent();
            }

            // Display elapsed time
            launchStopwatch.Stop();
            TimeSpan ts = launchStopwatch.Elapsed;
            //string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
            string elapsedTime = String.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds);

            UpdateProgressBarPut100Percent();
            DisplayConfigProcessTime(elapsedTime);
        }
Пример #8
0
        /**************************************************************\
         * Get specific chronicle of modif selected in DataGridView : *
         *    - Query on DB & bind to RTBs + status bar               *
        \**************************************************************/
        private void DataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            BeforeRichTextBox.Clear();
            AfterRichTextBox.Clear();

            if (e.RowIndex != -1)
            {
                try
                {
                    string pathAtModif = null;
                    int linesDeleted = 0;
                    int linesAdded = 0;
                    string before = null;
                    string after = null;
                    Boolean trigger = false;
                    Boolean appended = false;

                    // Query on DB
                    AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                    DataSet dataSet = service.Get_histo_modif_per_config_specific(int.Parse(DataGridView.Rows[e.RowIndex].Cells[0].Value.ToString()));
                    service.Close();

                    // Get data
                    pathAtModif = dataSet.Tables[0].Rows[0]["path_at_modif"].ToString();
                    linesDeleted = int.Parse(dataSet.Tables[0].Rows[0]["lines_deleted"].ToString());
                    linesAdded = int.Parse(dataSet.Tables[0].Rows[0]["lines_added"].ToString());
                    before = dataSet.Tables[0].Rows[0]["config_before"].ToString();
                    after = dataSet.Tables[0].Rows[0]["config_after"].ToString();
                    string[] configBefore = before.Split(new string[] { "\n" }, StringSplitOptions.None);
                    string[] configAfter = after.Split(new string[] { "\n" }, StringSplitOptions.None);

                    // Bind data to status bar.
                    if (pathAtModif.Contains("POLE INFORMATIQUE"))
                        PathAtModifLabel.Text = "Path at modif : MIMAS\\ ... " + pathAtModif.Split(new string[] { "POLE INFORMATIQUE" }, StringSplitOptions.None)[1];
                    else
                        PathAtModifLabel.Text = "Path at modif : " + pathAtModif;

                    LinesDeletedLabel.Text = "Lines deleted : " + linesDeleted;
                    LinesAddedLabel.Text = "Lines added : " + linesAdded;

                    // Bind data to RTBs

                    IEnumerable<String> onlyInOldConfig = configBefore.Except(configAfter);
                    IEnumerable<String> onlyInNewConfig = configAfter.Except(configBefore);

                    // BEFORE
                    for (int i = 0; i < configBefore.Length; i++)
                    {
                        foreach (string str in onlyInOldConfig)
                        {
                            if (configBefore[i].Contains("<Function"))
                                if (configBefore[i + 1] != null && configBefore[i + 1].Equals(str))
                                {
                                    trigger = true;
                                }

                            if (configBefore[i].Equals(str) && !appended)
                            {
                                BeforeRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                BeforeRichTextBox.SelectionBackColor = Color.IndianRed;
                                BeforeRichTextBox.AppendText(configBefore[i] + "\n");
                                appended = true;
                            }
                        }

                        if (!appended)
                        {
                            if (trigger)
                            {
                                BeforeRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                BeforeRichTextBox.SelectionBackColor = Color.IndianRed;
                                BeforeRichTextBox.AppendText(configBefore[i] + "\n");
                                if (configBefore[i].Contains("</Function>"))
                                    trigger = false;
                            }

                            else
                            {
                                BeforeRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                BeforeRichTextBox.AppendText(configBefore[i] + "\n");
                            }
                        }
                        appended = false;
                    }

                    // AFTER
                    for (int i = 0; i < configAfter.Length; i++)
                    {
                        foreach (string str in onlyInNewConfig)
                        {
                            if (configAfter[i].Contains("<Function"))
                                if (configAfter[i + 1] != null && configAfter[i + 1].Equals(str))
                                {
                                    trigger = true;
                                }

                            if (configAfter[i].Equals(str) && !appended)
                            {
                                AfterRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                AfterRichTextBox.SelectionBackColor = Color.LightGreen;
                                AfterRichTextBox.AppendText(configAfter[i] + "\n");
                                appended = true;

                            }
                        }

                        if (!appended)
                        {
                            if (trigger)
                            {
                                AfterRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                AfterRichTextBox.SelectionBackColor = Color.LightGreen;
                                AfterRichTextBox.AppendText(configAfter[i] + "\n");
                                linesAdded++;
                                if (configAfter[i].Contains("</Function>"))
                                    trigger = false;
                            }
                            else
                            {
                                AfterRichTextBox.SelectionFont = new System.Drawing.Font("Calibri", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                                AfterRichTextBox.AppendText(configAfter[i] + "\n");
                            }
                        }

                        appended = false;
                    }

                    BeforeRichTextBox.SelectionStart = 0;
                    BeforeRichTextBox.ScrollToCaret();

                    AfterRichTextBox.SelectionStart = 0;
                    AfterRichTextBox.ScrollToCaret();
                }

                catch (Exception ex) { KryptonMessageBox.Show(ex.ToString()); }
            }
        }
Пример #9
0
        /***************************************\
         * Get Path of configs from WebService *
        \***************************************/
        private String InitializePath()
        {
            AnalyticsWebService.AnalyticsSoapClient request; // Webservice instance.
            string path = null;

            request = new AnalyticsWebService.AnalyticsSoapClient();

            try
            {
                request.Open();
                path = request.Get_Path("ADMV2");
                request.Close();
            }

            catch
            {
                var result = KryptonMessageBox.Show("Path introuvable, veuillez le définir manuellement", "Path introuvable",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Exclamation);

                if (result == DialogResult.OK)
                {
                    FolderBrowserDialog openFolderDialog = new FolderBrowserDialog();
                    openFolderDialog.RootFolder = Environment.SpecialFolder.Desktop;

                    DialogResult result2 = openFolderDialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        path = openFolderDialog.SelectedPath;
                    }
                }
            }
            return path;
        }
Пример #10
0
        private void Drop(TreeView treeView, DragEventArgs e)
        {
            FileBrowser fileBrowser = ((FileBrowser)(((KryptonGroupBox)(((Panel)treeView.Parent).Parent)).Parent));

            TreeNode newNode;

            if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false))
            {
                Point pt = treeView.PointToClient(new Point(e.X, e.Y));
                TreeNode destinationNode = treeView.GetNodeAt(pt);
                newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
                _PreviousNodeName = newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0];

                _SourcePath = newNode.FullPath;

                if (destinationNode.ImageIndex == 2)
                {
                    if (destinationNode.Parent.FullPath == newNode.Parent.FullPath)
                        _TargetPath = _SourcePath;
                    else if (File.Exists(destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml"))
                        _TargetPath = destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + "-COPY.xml";
                    else _TargetPath = destinationNode.Parent.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml";
                }

                else
                {
                    if (File.Exists(destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml"))
                        _TargetPath = destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + "-COPY.xml";
                    else _TargetPath = destinationNode.FullPath + "\\" + newNode.Text.Split(new string[] { "." }, StringSplitOptions.None)[0] + ".xml";
                }

                if (_TargetPath != _SourcePath)
                {
                    try
                    {
                        if (treeView.SelectedNode.ImageIndex == 2)
                        {
                            File.Move(_SourcePath, _TargetPath);

                            // Check if config in db exists, else add config
                            try
                            {
                                AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                                int idConfig = session.Get_histo_id_config(_SourcePath);
                                if (idConfig == 0)
                                    session.Add_histo_config(_PreviousNodeName.Replace(".xml", ""), _SourcePath);
                                session.Close();
                            }
                            catch { }

                            // Update Config path in database
                            try
                            {
                                AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                                service.Update_histo_config_path(_SourcePath, _TargetPath);
                                service.Close();
                            }
                            catch { }
                        }
                        else if (treeView.SelectedNode.ImageIndex == 1)
                            Directory.Move(_SourcePath, _TargetPath.Replace(".xml", ""));
                    }
                    catch (Exception ex) { Console.WriteLine(ex); }
                }
            }

            fileBrowser.EditToolStripMenuItem.Enabled = false;
            EditToolStripButton.Enabled = false;
            fileBrowser.PopulateTreeView();
        }
Пример #11
0
        private void Delete(TreeView treeView)
        {
            if (treeView.SelectedNode.ImageIndex == 2)
            {
                var result = KryptonMessageBox.Show("Do you really want to delete the following configuration?  : \n\n                        " + treeView.SelectedNode.Text + "\n\nNote that this action is IRREVERSIBLE.", "Delete this file",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    File.Delete(treeView.SelectedNode.FullPath);

                    AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                    service.Delete_histo_configuration(treeView.SelectedNode.FullPath);
                    service.Close();

                    ((FileBrowser)FileBrowserNavigator.SelectedPage.Tag).PopulateTreeView();
                }

            }

            else if (treeView.SelectedNode.ImageIndex == 1)
            {
                var result = KryptonMessageBox.Show("Do you really want to delete the following Directory?  : \n\n                        " + treeView.SelectedNode.Text + "\n\nNote that this action is IRREVERSIBLE.", "Delete this folder",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    Directory.Delete(treeView.SelectedNode.FullPath, true);
                    ((FileBrowser)FileBrowserNavigator.SelectedPage.Tag).PopulateTreeView();
                }
            }
        }
Пример #12
0
        private void TreeView_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            TreeView treeView = ((TreeView)sender);
            _SourcePath = treeView.SelectedNode.FullPath;

            treeView.LabelEdit = false;

            if (e.Label == null || e.Label.Trim().Length == 0 || File.Exists(treeView.SelectedNode.Parent.FullPath + "\\" + e.Label.Trim()) || Directory.Exists(treeView.SelectedNode.Parent.FullPath + "\\" + e.Label.Trim()))
                //if (e.Label.Trim().Length == 0)
                e.CancelEdit = true;

            else
            {
                _TargetPath = treeView.SelectedNode.Parent.FullPath + "\\" + e.Label.Trim();
                if (treeView.SelectedNode != null && treeView.SelectedNode.ImageIndex == 2)
                {
                    File.Move(_SourcePath, _TargetPath);

                    // Check if config in db exists, else add config
                    try
                    {
                        AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                        int idConfig = session.Get_histo_id_config(_SourcePath);
                        if (idConfig == 0)
                        {
                            string[] splitResult = _SourcePath.Split(new string[] { "\\" }, StringSplitOptions.None);
                            session.Add_histo_config(splitResult[splitResult.Length-1].Replace(".xml",""), _SourcePath);
                        }
                        session.Close();
                    }
                    catch { }

                    // Update Config name in database
                    try
                    {
                        string[] splitResult = _SourcePath.Split(new string[] { "\\" }, StringSplitOptions.None);
                        string[] splitResult2 = _TargetPath.Split(new string[] { "\\" }, StringSplitOptions.None);
                        AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                        service.Update_histo_config_name(splitResult[splitResult.Length - 1].Replace(".xml", ""), splitResult2[splitResult.Length - 1].Replace(".xml", ""));
                        service.Close();
                    }
                    catch { }

                    // Consequently update Config path in database
                    try
                    {
                        AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                        service.Update_histo_config_path(_SourcePath,_TargetPath);
                        service.Close();
                    }
                    catch { }
                }
                else if (treeView.SelectedNode != null && treeView.SelectedNode.ImageIndex == 1)
                    Directory.Move(_SourcePath, _TargetPath);
            }
        }
Пример #13
0
        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeView treeView = ((TreeView)((ContextMenuStrip)(((ToolStripMenuItem)(sender)).Owner)).SourceControl);
            FileBrowser fileBrowser = ((FileBrowser)(((KryptonGroupBox)(((Panel)treeView.Parent).Parent)).Parent));
            if (treeView.SelectedNode.ImageIndex == 2)
            {
                if (File.Exists(treeView.SelectedNode.Parent.FullPath + "\\" + _PreviousNodeName + ".xml"))
                    _TargetPath = treeView.SelectedNode.Parent.FullPath + "\\" + _PreviousNodeName + "-COPY.xml";
                else _TargetPath = treeView.SelectedNode.Parent.FullPath + "\\" + _PreviousNodeName + ".xml";
            }

            else
            {
                if (File.Exists(treeView.SelectedNode.FullPath + "\\" + _PreviousNodeName + ".xml"))
                    _TargetPath = treeView.SelectedNode.FullPath + "\\" + _PreviousNodeName + "-COPY.xml";
                else _TargetPath = treeView.SelectedNode.FullPath + "\\" + _PreviousNodeName + ".xml";
            }

            if(_IsCopy)
                File.Copy(_SourcePath, _TargetPath,true);
            else if (!_IsCopy)
            {
                File.Move(_SourcePath, _TargetPath);

                // Check if config in db exists, else add config
                try
                {
                    AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                    int idConfig = session.Get_histo_id_config(_SourcePath);
                    if (idConfig == 0)
                        session.Add_histo_config(_PreviousNodeName.Replace(".xml", ""), _SourcePath);
                    session.Close();
                }
                catch { }

                // Update Config path in database
                try
                {
                    AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                    service.Update_histo_config_path(_SourcePath, _TargetPath);
                    service.Close();
                }
                catch { }
            }

            fileBrowser.PopulateTreeView();
            _FileBrowser.PasteToolStripMenuItem.Enabled = false;
            _LocalFileBrowser.PasteToolStripMenuItem.Enabled = false;
        }
Пример #14
0
        /***************************************************************************\
         * Update Chronicles                                                       *
         *    - Check if user exists, else create one. Get user ID.                *
         *    - Check if config exists, else create one. Get config ID.            *
         *    - Compute status ID.                                                 *
         *    - Transform arrays into one unique string (for config before/after). *
         *    - Add modif_per_config !                                             *
        \***************************************************************************/
        private void UpdateChronicles(string[] configBefore, string[] configAfter, int linesDeleted, int linesAdded)
        {
            string computer = null;
            int idUser = 0;
            int idConfig = 0;
            int idStatus = 0;
            System.DateTime dateOfModification = System.DateTime.Now;
            string dateOfModificationTreated = dateOfModification.ToString("yyyy-MM-dd HH':'mm':'ss");

            // Check if user exists, else create one. Get user ID.
            try
            {
                computer = System.Environment.MachineName;
                AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                idUser = session.Get_histo_id_user(computer);
                if (idUser == 0)
                {
                    session.Add_histo_user(computer);
                    idUser = session.Get_histo_id_user(computer);
                }
                session.Close();
            }
            catch (Exception ex) { KryptonMessageBox.Show(ex.ToString());}

            // Check if config exists, else create one. Get config ID.
            try
            {
                AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                idConfig = session.Get_histo_id_config(_Path);
                if (idConfig == 0)
                {
                    session.Add_histo_config(_Name, _Path);
                    idConfig = session.Get_histo_id_config(_Path);
                }
                session.Close();
            }
            catch (Exception ex) { KryptonMessageBox.Show(ex.ToString()); }

            // Compute status ID.
            if (_Path.Contains("Recettes"))
                idStatus = 2;
            else if (_Path.Contains("C:\\") || _Path.Contains("D:\\"))
                idStatus = 3;
            else idStatus = 1;

            // Transform arrays into one unique string (for config before/after)
            string before = null;
            string after = null;
            foreach (string line in configBefore)
                before = before + line + "\n";
            foreach (string line in configAfter)
                after = after + line + "\n";

            // Add modif_per_config
            try
            {
                AnalyticsWebService.AnalyticsSoapClient session = new AnalyticsWebService.AnalyticsSoapClient();
                session.Add_histo_modif_per_config(idStatus, idConfig, idUser, dateOfModificationTreated, linesDeleted, linesAdded, before, after, _Path);
                session.Close();
            }
            catch (Exception ex) { KryptonMessageBox.Show(ex.ToString()); }
        }
Пример #15
0
        private void UpdateUser(string oldUser, string newUser)
        {
            int accessTypeID=0;
            if (DataGridView.Rows[DataGridView.CurrentRow.Index].Cells[1].Value.Equals("user"))
                accessTypeID = 1;
            else if (DataGridView.Rows[DataGridView.CurrentRow.Index].Cells[1].Value.Equals("admin"))
                accessTypeID = 2;
            else if (DataGridView.Rows[DataGridView.CurrentRow.Index].Cells[1].Value.Equals("superadmin"))
                accessTypeID = 3;

            AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
            service.Update_User(oldUser, newUser, accessTypeID);
            service.Close();

            var result = KryptonMessageBox.Show("User modified !", "User modified",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
        }
Пример #16
0
        /***************\
         * Delete User *
        \***************/
        private void RemoveToolStripButton_Click(object sender, EventArgs e)
        {
            if (Navigator.SelectedPage.Text.Equals("Users"))
            {
                foreach (DataGridViewRow row in DataGridView.SelectedRows)
                {
                    if (row.Cells[0].Value.ToString().Equals("user") || row.Cells[0].Value.ToString().Equals("admin") || row.Cells[0].Value.ToString().Equals("superadmin"))
                    {
                        var result = KryptonMessageBox.Show("Cannot suppress " + row.Cells[0].Value.ToString(), "Error",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Stop);
                    }

                    else
                    {
                        AnalyticsWebService.AnalyticsSoapClient service = new AnalyticsWebService.AnalyticsSoapClient();
                        service.Delete_User(row.Cells[0].Value.ToString());
                        service.Close();

                        DataGridView.Rows.Remove(row);
                        var result = KryptonMessageBox.Show("User deleted !", "User deleted",
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Information);
                    }
                }
            }
        }