Пример #1
0
        public MainPage()
        {
            this.InitializeComponent();

            //Set IoT Hub & Azure Storage connection string from container for app settings
            IoTHubConnTextBox.Text  = App.IOTHUBCONNSTRING;
            StorageConnTextBox.Text = App.STORAGECONNSTRING;
            if (App.IOTHUBCONNSTRING.Length > 0)
            {
                ListDevices();
                SettingsGrid.Visibility = Visibility.Collapsed;
            }

            //Set root MainPage for all User Controls
            DeviceInfo.SetMainPage(this);
            Applications.SetMainPage(this);
            WindowsTelemetry.SetMainPage(this);
            WindowsUpdate.SetMainPage(this);
            Reboot.SetMainPage(this);
            TimeSettings.SetMainPage(this);
            Certificates.SetMainPage(this);
            DiagnosticLogs.SetMainPage(this);
            FactoryReset.SetMainPage(this);
            Wifi.SetMainPage(this);
            DHA.SetMainPage(this);
        }
 /// <summary>
 /// Create  Zip for database back up
 /// </summary>
 /// <returns>int 0 -not success, 1- success </returns>
 public int CreateDBZip(FactoryReset oFactoryResetEntity)
 {
     if (oFactoryResetEntity.iSeverity == 9)
     {
         return(ZipDatabseFile(oFactoryResetEntity.strBackupFileName, oFactoryResetEntity.strZipFileName, oFactoryResetEntity.iSeverity));
     }
     else
     {
         return(ZipDatabseFile(oFactoryResetEntity.strBackupFileName, oFactoryResetEntity.strZipFileName, oFactoryResetEntity.iSeverity));
     }
 }
Пример #3
0
 public int CreateDBZip(FactoryReset objFactoryReset)
 {
     return(FactoryResetDataAccess.CreateDBZip(objFactoryReset));
 }
Пример #4
0
 public int CreateSqlDatabaseBackUp(FactoryReset objFactoryReset)
 {
     return(FactoryResetDataAccess.CreateSqlDatabaseBackUp(objFactoryReset));
 }
Пример #5
0
 public int CreateDBZip(FactoryReset objFactoryReset)
 {
     return(oFactoryResetBusiness.CreateDBZip(objFactoryReset));
 }
Пример #6
0
 public int CreateSqlDatabaseBackUp(FactoryReset objFactoryReset)
 {
     return(oFactoryResetBusiness.CreateSqlDatabaseBackUp(objFactoryReset));
 }
        /// <summary>
        /// Create database back up in Zip format and kept in path
        /// </summary>
        /// <returns>int 0 -not success, 1- success, 2 - already backkup available</returns>
        public int CreateSqlDatabaseBackUp(FactoryReset oFactoryResetEntity)
        {
            SqlConnection    SqlConn = null;
            ServerConnection svrConnServerConnection = null;
            Server           SqlSever = null;
            Backup           bak      = null;
            BackupDeviceItem bkpitem  = null;
            DateTime         dt       = DateTime.Now;
            int iResult = 0;

            String[] format      = { "ddMMMyyyyHHmm" };
            string   bkpFileName = "";
            string   Backuppath  = "";
            string   date        = "";
            string   zipFileName = "";

            try
            {
                date        = dt.ToString(format[0], DateTimeFormatInfo.InvariantInfo);
                Backuppath  = oFactoryResetEntity.strBackupPath;
                bkpFileName = Backuppath + "\\" + "[" + date + "]" + "_BAK_" + "[" +
                              CommonDataAccess.GetSettingValue("TICKET_LOCATION_CODE") + "]" +
                              "[" + BMC.Transport.Settings.SiteName + "]" + "_" +
                              oFactoryResetEntity.BackUpDataBase + ".BAK";
                oFactoryResetEntity.strBackupFileName = bkpFileName;
                if (Directory.Exists(Backuppath))
                {
                    if (File.Exists(bkpFileName) == false)
                    {
                        try
                        {
                            SqlConn = new SqlConnection(CommonDataAccess.ExchangeConnectionString);
                            svrConnServerConnection = new ServerConnection(SqlConn);
                            SqlSever = new Server(svrConnServerConnection);

                            if (SqlSever != null)
                            {
                                bak        = new Microsoft.SqlServer.Management.Smo.Backup();
                                bak.Action = BackupActionType.Database;
                                bkpitem    = new BackupDeviceItem(bkpFileName, DeviceType.File);
                                bak.Devices.Add(bkpitem);
                                bak.Database = oFactoryResetEntity.BackUpDataBase;
                                bak.SqlBackup(SqlSever);
                            }
                        }
                        catch (SqlException sqlex)
                        {
                            ExceptionManager.Publish(sqlex);
                            iResult = 0;
                        }
                        catch (TimeoutException tex)
                        {
                            ExceptionManager.Publish(tex);
                            iResult = 0;
                        }

                        zipFileName = Backuppath + "\\" + "bkp" + oFactoryResetEntity.BackUpDataBase + date + ".ZIP";
                        zipFileName = Backuppath + "\\" + "[" + date + "]" + "_BAK_" + "[" +
                                      CommonDataAccess.GetSettingValue("TICKET_LOCATION_CODE") + "]" +
                                      "[" + BMC.Transport.Settings.SiteName + "]" + "_" +
                                      oFactoryResetEntity.BackUpDataBase + ".ZIP";
                        oFactoryResetEntity.strZipFileName = zipFileName;
                        iResult = 1;
                    }
                    else
                    {
                        iResult = 2;
                    }
                }
                else
                {
                    Directory.CreateDirectory(Backuppath);
                    try
                    {
                        SqlConn = new SqlConnection(CommonDataAccess.ExchangeConnectionString);
                        svrConnServerConnection = new ServerConnection(SqlConn);
                        SqlSever = new Server(svrConnServerConnection);

                        if (SqlSever != null)
                        {
                            bak        = new Microsoft.SqlServer.Management.Smo.Backup();
                            bak.Action = BackupActionType.Database;
                            bkpitem    = new BackupDeviceItem(bkpFileName, DeviceType.File);
                            bak.Devices.Add(bkpitem);
                            bak.Database = oFactoryResetEntity.BackUpDataBase;
                            bak.SqlBackup(SqlSever);
                        }
                    }
                    catch (SqlException sqlex)
                    {
                        ExceptionManager.Publish(sqlex);
                        iResult = 0;
                    }
                    catch (TimeoutException tex)
                    {
                        ExceptionManager.Publish(tex);
                        iResult = 0;
                    }
                    zipFileName = Backuppath + "bkp" + oFactoryResetEntity.BackUpDataBase + date + ".zip";
                    oFactoryResetEntity.strZipFileName = zipFileName;
                    iResult = 1;
                }
            }
            catch (FileNotFoundException fex)
            {
                ExceptionManager.Publish(fex);
                iResult = 0;
            }
            catch (FileLoadException flx)
            {
                ExceptionManager.Publish(flx);
                iResult = 0;
            }
            catch (Exception ex)
            {
                ExceptionManager.Publish(ex);
                iResult = 0;
            }
            return(iResult);
        }