Exemplo n.º 1
0
        public ActionResult Add(ManualBackupServer msModel)
        {
            int result = -1;

            //session获取值
            if (Session["LoginId"] == null)
            {
                result = -99;
            }
            else
            {
                //保存
                try
                {
                    string dt = Common.CommonUtil.DateTimeNowToString();
                    msModel.DBServerIP = msModel.serverIP;
                    msModel.drive      = msModel.drive + ":";
                    msModel.creater    = Session["LoginId"].ToString();
                    msModel.createDate = dt;
                    msModel.deleteFlg  = 0;
                    msModel.updater    = Session["LoginId"].ToString();
                    msModel.updateDate = dt;
                    result             = msSerivice.InsertManualBackupServer(msModel);
                }
                catch (Exception ex)
                {
                    result = -10;
                    logger.Error(ex.Message);
                }
            }
            Response.Write(result);
            Response.End();
            return(null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// データ削除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Delete(int id)
        {
            int result = -1;

            if (Session["LoginId"] == null)
            {
                result = -99;
            }
            else
            {
                try
                {
                    ManualBackupServer model = msSerivice.GetManualBackupServerById(Convert.ToInt32(id));
                    if (model.id != "")
                    {
                        Common.NetworkConnection.Disconnect(model.drive);
                    }
                    result = msSerivice.DeleteManualBackupServer(id, Session["LoginId"].ToString());
                }
                catch (Exception ex)
                {
                    result = -10;
                    logger.Error(ex.Message);
                }
            }
            Response.Write(result);
            Response.End();
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// データ更新
        /// </summary>
        /// <param name="msModel"></param>
        /// <returns></returns>
        public ActionResult Update(ManualBackupServer msModel)
        {
            int result = -1;

            if (Session["LoginId"] == null)
            {
                result = -99;
            }
            else
            {
                try
                {
                    msModel.DBServerIP = msModel.serverIP;
                    msModel.updater    = Session["LoginId"].ToString();
                    msModel.updateDate = Common.CommonUtil.DateTimeNowToString();
                    result             = msSerivice.UpdateManualBackupServer(msModel);
                }
                catch (Exception ex)
                {
                    result = -10;
                    logger.Error(ex.Message);
                }
            }
            Response.Write(result);
            Response.End();
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="BackupServer"></param>
        /// <param name="conn"></param>
        /// <returns></returns>
        public int UpdateManualBackupServer(ManualBackupServer ManualBackupServer, OdbcConnection conn)
        {
            int    result = -1;
            string sql    = "UPDATE manualBackupServer SET "
                            + " DBServerIP = ?,"
                            + " serverIP = ?,"
                            + " account =?,"
                            + " password =?,"
                            + " startFile =?,"
                            + " drive =?,"
                            + " updater =?,"
                            + " updateDate =?"
                            + " WHERE id = ?";

            OdbcParameter[] para = new OdbcParameter[] {
                new OdbcParameter("@DBServerIP", ManualBackupServer.DBServerIP),
                new OdbcParameter("@backupServerIP", ManualBackupServer.serverIP),
                new OdbcParameter("@account", ManualBackupServer.account),
                new OdbcParameter("@password", ManualBackupServer.password),
                new OdbcParameter("@startFile", ManualBackupServer.startFile),
                new OdbcParameter("@drive", ManualBackupServer.drive),
                new OdbcParameter("@updater", ManualBackupServer.updater),
                new OdbcParameter("@updateDate", ManualBackupServer.updateDate),
                new OdbcParameter("@id", ManualBackupServer.id)
            };
            try
            {
                result = db.Udaquery(sql, conn, para);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(result);
        }
Exemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="BackupServer"></param>
 /// <param name="conn"></param>
 /// <returns></returns>
 public int InsertManualBackupServer(ManualBackupServer ManualBackupServer, OdbcConnection conn)
 {
     try
     {
         return(db.insert(ManualBackupServer, "manualBackupServer", conn));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Exemplo n.º 6
0
 public ActionResult Edit(int id)
 {
     try
     {
         ViewData["bkList"] = msSerivice.GetManualBackupServerById(id);
     }
     catch (Exception ex)
     {
         ViewData["bkList"] = new ManualBackupServer();
         logger.Error(ex.Message);
     }
     return(View());
 }
Exemplo n.º 7
0
        public int InsertManualBackupServer(ManualBackupServer ManualBackupServer)
        {
            OdbcConnection conn;
            int            count = 0;

            using (conn = OdbcHelper.CreateConntionAll())
            {
                conn.Open();
                count = ManualBackupServerDal.InsertManualBackupServer(ManualBackupServer, conn);
                conn.Close();
            }
            return(count);
        }
Exemplo n.º 8
0
        public ActionResult NetworkConnect(string id)
        {
            int Result = 0;

            try
            {
                ManualBackupServer model = msSerivice.GetManualBackupServerById(Convert.ToInt32(id));
                if (model.id != "")
                {
                    string ipMessage      = model.serverIP;
                    string stfileMessage  = model.startFile;
                    string monitorDriveP  = model.drive;
                    string accountMessage = model.account;
                    string passMessage    = model.password;
                    string localPath      = monitorDriveP;
                    if (System.IO.Directory.Exists(monitorDriveP))
                    {
                        Result = 1;
                    }
                    else
                    {
                        int status = Common.NetworkConnection.Connect(@"\\" + model.serverIP + @"\" + model.startFile.TrimStart('\\').Replace('/', '\\'), localPath, model.account, model.password);
                        if (status == (int)Common.ERROR_ID.ERROR_SUCCESS)
                        {
                            Result = 1;
                        }
                        else
                        {
                            Result = -1;
                        }
                    }
                }
                logger.Info("接続状態:" + Result.ToString());
            }
            catch (Exception ex)
            {
                Result = -10;
                logger.Error(ex.Message);
            }
            Response.Write(Result);
            Response.End();
            return(null);
        }