示例#1
0
        private void SetPathArhive(PathArhive oldpath)
        {
            try
            {
                if (!SystemArgs.Request.PathArhiveExist(Order.PathArhive))
                {
                    SystemArgs.Request.InsertPathArhive(Order.PathArhive);
                }

                Order.PathArhive = SystemArgs.Request.GetPathArhive(Order.PathArhive);

                SystemArgs.Request.SetPathArhiveAllOrder(Order);

                if (SystemArgs.Request.CheckedNeedRemovePathArhive(oldpath))
                {
                    SystemArgs.Request.DeletePathArhive(oldpath);
                }

                var updateOrders = SystemArgs.Orders.FindAll(p => p.Number == Order.Number);

                foreach (var order in updateOrders)
                {
                    order.PathArhive = Order.PathArhive;
                }
            }
            catch (Exception Ex)
            {
                throw new Exception(Ex.Message, Ex);
            }
        }
示例#2
0
        private void ChangePathArhive_B_Click(object sender, EventArgs e)
        {
            try
            {
                if (Order.PathArhive.Path == PathArhive_TB.Text)
                {
                    FolderBrowserDialog dialog = new FolderBrowserDialog();

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        PathArhive oldpath = Order.PathArhive;

                        string ModelPath = dialog.SelectedPath;

                        if (ModelPath.Substring(0, 2) != @"\\")
                        {
                            using (var managementObject = new ManagementObject())
                            {
                                managementObject.Path = new ManagementPath($"Win32_LogicalDisk='{ModelPath.Substring(0, 2)}'");
                                var driveType   = (DriveType)(uint)managementObject["DriveType"];
                                var networkPath = Convert.ToString(managementObject["ProviderName"]);

                                ModelPath = networkPath + ModelPath.Remove(0, 2);
                            }
                        }

                        ModelPath = ModelPath.Replace("tekla-fs", "10.0.7.249");

                        Order.PathArhive = new PathArhive {
                            DateCreate = DateTime.Now, Path = ModelPath
                        };

                        SetPathArhive(oldpath);

                        PathArhive_TB.Text = ModelPath;

                        MessageBox.Show("Путь успешно изменен!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (!Directory.Exists(PathArhive_TB.Text))
                    {
                        throw new Exception("Не найдена папка");
                    }

                    PathArhive oldpath = Order.PathArhive;

                    string ModelPath = PathArhive_TB.Text;

                    if (ModelPath.Substring(0, 2) != @"\\")
                    {
                        using (var managementObject = new ManagementObject())
                        {
                            managementObject.Path = new ManagementPath($"Win32_LogicalDisk='{ModelPath.Substring(0, 2)}'");
                            var driveType   = (DriveType)(uint)managementObject["DriveType"];
                            var networkPath = Convert.ToString(managementObject["ProviderName"]);

                            ModelPath = networkPath + ModelPath.Remove(0, 2);
                        }
                    }

                    ModelPath = ModelPath.Replace("tekla-fs", "10.0.7.249");

                    Order.PathArhive = new PathArhive {
                        DateCreate = DateTime.Now, Path = ModelPath
                    };

                    SetPathArhive(oldpath);

                    PathArhive_TB.Text = ModelPath;

                    MessageBox.Show("Путь успешно изменен!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception E)
            {
                SystemArgs.PrintLog(E.ToString());
                MessageBox.Show(E.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }