Exemple #1
0
        public static void ExportGridToWord(GridView GridControl1, SplashScreenManager splashScreenManager1)
        {
            try
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.Filter       = "Files(*.RTF)|*.RTF";
                saveFileDialog.AddExtension = true;
                saveFileDialog.DefaultExt   = ".RTF";


                if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.CheckPathExists)
                {
                    if (splashScreenManager1 != null)
                    {
                        splashScreenManager1.ShowWaitForm();
                        splashScreenManager1.SetWaitFormDescription("Exporting..Please Wait");
                    }
                    GridControl1.ExportToRtf(saveFileDialog.FileName);

                    if (splashScreenManager1 != null)
                    {
                        splashScreenManager1.CloseWaitForm();
                    }

                    if (MessageBox.Show(@"Do you wish to open the RTF file now?", @"Export to RTF", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Process proc = new Process();
                        proc.StartInfo.FileName = saveFileDialog.FileName;
                        proc.Start();
                    }
                }
            }
            catch (Exception ex)
            {
                if (splashScreenManager1 != null && splashScreenManager1.IsSplashFormVisible)
                {
                    splashScreenManager1.CloseWaitForm();
                }


                MessageBox.Show(ex.ToString());
            }
        }
Exemple #2
0
 public static void FromRes(this DataTable dtDataTable, DataTable other, int cIndex, SplashScreenManager splashScreenManager)
 {
     for (int rIndex = 0; rIndex < other.Rows.Count; rIndex++)
     {
         DataRow[] arrDr = dtDataTable.Select(dtDataTable.Columns[0].ColumnName + "=" + other.Rows[rIndex][0]);
         if (arrDr.Length > 0)
         {
             if (cIndex < 0 || cIndex >= dtDataTable.Columns.Count)
             {
                 for (int i = 0; i < other.Columns.Count; i++)
                 {
                     arrDr[0][i] = other.Rows[rIndex][i];
                 }
             }
             else
             {
                 arrDr[0][cIndex] = other.Rows[rIndex][cIndex];
             }
         }
         splashScreenManager.SetWaitFormDescription((rIndex + 1) + "/" + other.Rows.Count);
         Application.DoEvents();
     }
 }
Exemple #3
0
        /// <summary>
        /// Backups the database.
        /// </summary>
        /// <returns></returns>
        public static bool BackupDatabase(SplashScreenManager splashScreenManager, string backupName, bool openBackupFolder)
        {
            try
            {
                var globalVariable = new GlobalVariable();
                if (splashScreenManager != null)
                {
                    splashScreenManager.ShowWaitForm();
                    splashScreenManager.SetWaitFormCaption("Đang sao lưu dữ liệu");
                    splashScreenManager.SetWaitFormDescription("Vui lòng đợi ..");
                }

                var databaseNameForBackup = RegistryHelper.GetValueByRegistryKey("DatabaseName");
                var databaseForBackup     = GlobalVariable.Server.Databases[databaseNameForBackup];
                var backup = new Backup
                {
                    //option for backup
                    Action = BackupActionType.Database,
                    BackupSetDescription = "Sao lưu CSDL, ngày " + DateTime.Now,
                    BackupSetName        = databaseNameForBackup + " Backup",
                    Database             = databaseForBackup.Name
                };

                //create backupdevice
                var folderBackup   = globalVariable.DailyBackupPath;
                var dateTimeString = "NG" + DateTime.Now.Day.ToString(CultureInfo.InvariantCulture) +
                                     "T" + DateTime.Now.Month.ToString(CultureInfo.InvariantCulture) +
                                     "N" + DateTime.Now.Year.ToString(CultureInfo.InvariantCulture) +
                                     "_" + DateTime.Now.Hour.ToString(CultureInfo.InvariantCulture) + "GI" +
                                     DateTime.Now.Minute.ToString(CultureInfo.InvariantCulture) + "P";

                var databaseName = databaseNameForBackup + "_" + (string.IsNullOrEmpty(backupName) ? "" : backupName) + "_" + dateTimeString + ".bak";

                //LINHMC kiem tra neu folder ko ton tai thi tao
                if (string.IsNullOrEmpty(folderBackup))
                {
                    DriveInfo[] allDrives = DriveInfo.GetDrives();
                    if (allDrives.Length > 1)
                    {
                        folderBackup = allDrives[1].Name + @"BACKUP_A_BIGTIME";
                    }
                    else
                    {
                        folderBackup = allDrives[0].Name + @"BACKUP_A_BIGTIME";
                    }
                }
                if (!Directory.Exists(folderBackup))
                {
                    Directory.CreateDirectory(folderBackup);
                }

                var fileBackup = folderBackup + @"\" + databaseName;
                if (File.Exists(fileBackup))
                {
                    XtraMessageBox.Show(ResourceHelper.GetResourceValueByName("ResFileBackupExits"),
                                        ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
                var backupDevice = new BackupDeviceItem(fileBackup, DeviceType.File);

                backup.Devices.Add(backupDevice);
                backup.Incremental = false;

                backup.SqlBackup(GlobalVariable.Server);

                //Cách nén file này chỉ dùng trong trường hợp hệ quản trị dữ liệu và chương trình cùng nằm trên 1 máy
                using (var zip = new ZipFile())
                {
                    zip.AddFile(fileBackup, "");
                    var zipFileName = fileBackup.Replace(".bak", ".zip");
                    zip.ParallelDeflateThreshold = -1;
                    zip.Save(zipFileName);
                    File.Delete(fileBackup);
                }
                if (splashScreenManager != null)
                {
                    splashScreenManager.CloseWaitForm();
                }

                if (openBackupFolder)
                {
                    Process.Start(folderBackup);
                }
                return(true);
            }
            catch (Exception ex)
            {
                if (splashScreenManager != null)
                {
                    splashScreenManager.CloseWaitForm();
                }
                XtraMessageBox.Show(ex.ToString(),
                                    ResourceHelper.GetResourceValueByName("ResExceptionCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 ///  显示进度条
 /// </summary>
 /// <param name="manager">进度条</param>
 /// <param name="caption">标题</param>
 /// <param name="description">描述</param>
 /// Author  : Napoleon
 /// Created : 2015-02-26 20:30:27
 protected void ShowManager(SplashScreenManager manager, string caption, string description)
 {
     manager.ShowWaitForm();
     manager.SetWaitFormCaption(caption);
     manager.SetWaitFormDescription(description);
 }
Exemple #5
0
 private void AddWaitStatus(string Text)
 {
     waitMng.SetWaitFormDescription(Text);
 }
Exemple #6
0
 /// <summary>
 ///  显示进度条
 /// </summary>
 /// <param name="manager">进度条</param>
 /// <param name="caption">标题</param>
 /// <param name="description">描述</param>
 /// Author  : Napoleon
 /// Created : 2015-02-26 20:30:27
 protected void ShowManager(SplashScreenManager manager, string caption, string description)
 {
     manager.ShowWaitForm();
     manager.SetWaitFormCaption(caption);
     manager.SetWaitFormDescription(description);
 }
 //TODO Comment
 public static bool CheckConnectTimeOutWait(SplashScreenManager splashScreenManager)
 {
     if (IsConnectedToInternet() == false)
     {
         splashScreenManager.ShowWaitForm();
         //TODO Set Constant
         splashScreenManager.SetWaitFormCaption("Checking the network connection!");
         splashScreenManager.SetWaitFormDescription(SEDConst.SET_PLEASE_WAIT);
         Thread.Sleep(7000);
         splashScreenManager.CloseWaitForm();
         if (IsConnectedToInternet() == false)
         {
             //TODO Set Constant
             XtraMessageBox.Show("Connect Timout. Checking the network connection...!",
                 SEDConst.MESSAGE_WARNING_DISCONNECTED);
             return false;
         }
         return true;
     }
     return true;
 }
Exemple #8
0
        /// <summary>
        /// 导入全部数据
        /// </summary>
        private void AddAllData()
        {
            string path = string.Empty;
            FolderBrowserDialog browserDialog = new FolderBrowserDialog();

            browserDialog.ShowNewFolderButton = false;
            if (browserDialog.ShowDialog() == DialogResult.OK)
            {
                path = browserDialog.SelectedPath;
            }
            if (string.IsNullOrEmpty(path))
            {
                MessageBox.Show(this, "未选择导入文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DirectoryInfo directory = new DirectoryInfo(path);

            FileInfo[] files = directory.GetFiles();
            if (files == null || files.Count() == 0)
            {
                MessageBox.Show(this, string.Format(directory.Name + "文件夹中没有文件,无法导入!"), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            bool boo = true;

            using (var ssm = new SplashScreenManager(this, typeof(SysWaitForm), true, true))
            {
                ssm.ShowWaitForm();
                ssm.SetWaitFormDescription("正在导入...");
                //遍历所有文件
                try
                {
                    foreach (var file in files)
                    {
                        if (file.Length == 0)
                        {
                            continue;
                        }
                        if (file.Name.Contains("Command"))
                        {
                            var personFileList = FormatterSerializerBll <Command> .ImportData(file.FullName);

                            var commandList = DbFactory.CommandBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = commandList.Where(p => p.Cmd.Equals(o.Cmd) || p.Cmd.StartsWith(o.Cmd + "(")).ToList().Count();
                                o.Cmd = oCount == 0 ? o.Cmd : o.Cmd + "(" + oCount + ")";
                                o.Id  = null;
                                DbFactory.CommandBll.Insert(o);
                            }
                            continue;
                        }
                        else if (file.Name.Contains("Dut"))
                        {
                            var personFileList = FormatterSerializerBll <Dut> .ImportData(file.FullName);

                            var DutList = DbFactory.DutBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = DutList.Where(p => p.Name.Equals(o.Name) || p.Name.StartsWith(o.Name + "(")).ToList().Count();
                                o.Name = oCount == 0 ? o.Name : o.Name + "(" + oCount + ")";
                                o.Id   = null;
                                DbFactory.DutBll.Insert(o);
                            }
                            continue;
                        }

                        else if (file.Name.Contains("Project"))
                        {
                            var personFileList = FormatterSerializerBll <Project> .ImportData(file.FullName);

                            var ProjectList = DbFactory.ProjectBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = ProjectList.Where(p => p.Name.Equals(o.Name) || p.Name.StartsWith(o.Name + "(")).ToList().Count();
                                o.Name = oCount == 0 ? o.Name : o.Name + "(" + oCount + ")";

                                o.Id = null;
                                DbFactory.ProjectBll.Insert(o);
                            }
                            continue;
                        }
                        else if (file.Name.Contains("TestCase"))
                        {
                            var personFileList = FormatterSerializerBll <TestCase> .ImportData(file.FullName);

                            var TestCaseList = DbFactory.TestCaseBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = TestCaseList.Where(p => p.Name.Equals(o.Name) || p.Name.StartsWith(o.Name + "(")).ToList().Count();
                                o.Name = oCount == 0 ? o.Name : o.Name + "(" + oCount + ")";

                                o.Id = null;
                                DbFactory.TestCaseBll.Insert(o);
                            }
                            continue;
                        }
                        else if (file.Name.Contains("TestDevice"))
                        {
                            var personFileList = FormatterSerializerBll <TestDevice> .ImportData(file.FullName);

                            var TestDeviceList = DbFactory.TestDeviceBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = TestDeviceList.Where(p => p.DeviceCode.Equals(o.DeviceCode) || p.DeviceCode.StartsWith(o.DeviceCode + "(")).ToList().Count();
                                o.DeviceCode = oCount == 0 ? o.DeviceCode : o.DeviceCode + "(" + oCount + ")";
                                o.Id         = null;
                                DbFactory.TestDeviceBll.Insert(o);
                            }
                            continue;
                        }
                        else if (file.Name.Contains("TestParams"))
                        {
                            var personFileList = FormatterSerializerBll <TestParams> .ImportData(file.FullName);

                            var TestParamsList = DbFactory.TestParamsBll.SelectAll();
                            foreach (var o in personFileList)
                            {
                                var oCount = TestParamsList.Where(p => p.Name.Equals(o.Name) || p.Name.StartsWith(o.Name + "(")).ToList().Count();
                                o.Name = oCount == 0 ? o.Name : o.Name + "(" + oCount + ")";
                                o.Id   = null;
                                DbFactory.TestParamsBll.Insert(o);
                            }
                            continue;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    if (boo == true)
                    {
                        ssm.CloseWaitForm();
                        MessageBox.Show(this, "数据导入完毕!", "提示", MessageBoxButtons.OK);
                    }
                }
                catch (Exception)
                {
                    ssm.CloseWaitForm();
                    MessageBox.Show(this, "导入的数据格式不正确!", "提示", MessageBoxButtons.OK);
                    boo = false;
                }
            }
        }
 /// <summary>
 ///     [EN] ShowWaitForm
 ///     Create By: ManhNV1 -Date:02/25/2016
 ///     Descripton: ShowWaitForm
 /// </summary>
 /// <param name="frmWaitForm">Form Used</param>
 /// <param name="strCaption">
 ///     Title WaitForm:
 ///     if strCaption = null => Value = Please Wait
 ///     else => Value = strCaption
 /// </param>
 /// <param name="strDescription">Description WaitForm</param>
 /// <returns>SplashScreenManager Type</returns>
 public static SplashScreenManager ShowWaitForm(Form frmWaitForm, string strCaption
     , string strDescription)
 {
     var splashScreenManager = new SplashScreenManager(frmWaitForm
         , typeof (WaitFormPlease), true, true);
     splashScreenManager.ShowWaitForm();
     if (strCaption == null)
         splashScreenManager.SetWaitFormCaption(SEDConst.SET_PLEASE_WAIT);
     else splashScreenManager.SetWaitFormCaption(strCaption);
     // Nếu Null thì dùng strDescription không thì  Set_Loading
     splashScreenManager.SetWaitFormDescription(strDescription ?? SEDConst.SET_LOADING);
     return splashScreenManager;
 }