/// <summary>
 /// 根据条件以及排序规则,获取对象集
 /// </summary>
 /// <param name="SearchStr">查询条件</param>
 /// <param name="orderby">排序规则</param>
 /// <returns>符合条件的对象集</returns>
 public ObjectQuery<vBackupAndEmailSetting> GetBackupAndEmailSetting(string SearchStr, string orderby)
 {
     string StrWhere = " it.BackupID is not null " + SearchStr;
     ObjectQuery<vBackupAndEmailSetting> query = null;
     try
     {
         ServiceDirectDB = new ServiceDirectDBEntities();
         query = ServiceDirectDB.vBackupAndEmailSetting.Top("1").Where(StrWhere).OrderBy(orderby);
     }
     catch (EntitySqlException)
     {
         throw;
     }
     return query;
 }
Beispiel #2
0
        /// <summary>
        /// 根据Company对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">Company的ID</param>
        /// <returns>返回对象</returns>
        public virtual vUTPCycle FindFirstCycleByCompanyId(string KeyId, string orderby)
        {
            vUTPCycle CycleObj;

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                CycleObj = ServiceDirectDB.vUTPCycle.OrderBy(orderby).First(t => t.CompanyID == KeyId);
            }
            catch (EntityException)
            {
                throw;
            }
            return CycleObj;
        }
Beispiel #3
0
 /// <summary>
 /// 调用存储过程,创建发送的Email
 /// </summary>
 /// <param name="EmailID">EmailID</param>
 /// <returns></returns>
 public int CreateEmail(string EmailID)
 {
     int counts = 0;
     ServiceDirectDBEntities objDB;
     try
     {
         objDB = new ServiceDirectDBEntities();
         counts = objDB.PrJobEmail(EmailID);
         return counts;
     }
     catch (Exception)
     {
         return counts;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 根据对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">对象的ID</param>
        /// <returns>返回对象</returns>
        public virtual tblBackup FindBackupById(string KeyId)
        {
            tblBackup BackupObj;
            System.Guid KeyIdGuid = new Guid(KeyId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                BackupObj = ServiceDirectDB.tblBackup.FirstOrDefault(t => t.BackupID == KeyIdGuid);
            }
            catch (EntityException)
            {
                throw;
            }
            return BackupObj;
        }
Beispiel #5
0
        /// <summary>
        /// 根据jobID查询job对象
        /// </summary>
        /// <param name="jobId">jobId</param>
        /// <returns>job对象</returns>
        public vOnlySysJobs FindVOnlyJobByJobId(string jobId)
        {
            vOnlySysJobs VOnlyJobObj = null;
            System.Guid KeyIdGuid = new Guid(jobId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                VOnlyJobObj = ServiceDirectDB.vOnlySysJobs.FirstOrDefault(t => t.job_id == KeyIdGuid);
            }
            catch (EntitySqlException)
            {
                throw;
            }
            return VOnlyJobObj;
        }
Beispiel #6
0
        /// <summary>
        /// 根据对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">对象的ID</param>
        /// <returns>返回对象</returns>
        public virtual tblEmail FindEmailById(string KeyId)
        {
            tblEmail EmailObj;
            System.Guid KeyIdGuid = new Guid(KeyId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                EmailObj = ServiceDirectDB.tblEmail.First(t => t.EmailID == KeyIdGuid);
            }
            catch (EntityException)
            {
                throw;
            }
            return EmailObj;
        }
Beispiel #7
0
        /// <summary>
        /// 查询所有job的结果信息
        /// </summary>
        /// <param name="SearchStr">查询条件</param>
        /// <param name="orderby">倒序排列</param>
        /// <returns></returns>
        public virtual ObjectQuery<vUTPScheduleMessager> FindJobResult(string SearchStr, string orderby)
        {
            ObjectQuery<vUTPScheduleMessager> ScheduleLogObjs;
            string StrWhere = " it.PID is not null " + SearchStr;

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                ScheduleLogObjs = ServiceDirectDB.vUTPScheduleMessager.Where(StrWhere).OrderBy(orderby);
            }
            catch (EntitySqlException)
            {
                throw;
            }

            return ScheduleLogObjs;
        }
Beispiel #8
0
        /// <summary>
        /// 根据对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">对象的ID</param>
        /// <returns>是否存在对象</returns>
        public virtual Boolean ExistFindBackupById(string KeyId)
        {
            tblBackup BackupObj;
            System.Guid KeyIdGuid = new Guid(KeyId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                BackupObj = ServiceDirectDB.tblBackup.FirstOrDefault(t => t.BackupID == KeyIdGuid);
            }
            catch (EntityException)
            {
                throw;
            }
            if (BackupObj!=null)
            {
                return true;
            }
            return false;
        }
Beispiel #9
0
        /// <summary>
        /// 根据TasksId查询job对象
        /// </summary>
        /// <param name="TasksId">TasksId</param>
        /// <returns>job对象</returns>
        public vSchedulerTasks FindTaskSchedulerByTaskId(string TasksId)
        {
            vSchedulerTasks vSchedulerTasksObj = null;
            System.Guid KeyIdGuid = new Guid(TasksId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                vSchedulerTasksObj = ServiceDirectDB.vSchedulerTasks.First(t => t.ScheduleID == KeyIdGuid);
            }
            catch (EntitySqlException)
            {
                throw;
            }
            catch(InvalidOperationException)
            {
                return null;
            }
            return vSchedulerTasksObj;
        }
Beispiel #10
0
        /// <summary>
        /// 根据对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">对象的ID</param>
        /// <returns>返回对象</returns>
        public virtual tblScheduler FindSchedulerById(string KeyId)
        {
            tblScheduler SchedulerObj;
            System.Guid KeyIdGuid = new Guid(KeyId);

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                SchedulerObj = ServiceDirectDB.tblScheduler.First(t => t.ScheduleID == KeyIdGuid);
            }
            catch (EntityException)
            {
                throw;
            }
            catch (NullReferenceException)
            {
                return null;
            }
            return SchedulerObj;
        }
Beispiel #11
0
        /// <summary>
        /// 根据Company对象的ID查询数据
        /// </summary>
        /// <param name="KeyId">Company的ID</param>
        /// <returns>返回对象</returns>
        public virtual vUTPCycle FindLastCycleByCompanyId(string KeyId, string orderby)
        {
            vUTPCycle CycleObj;

            string SearchStr = " and it.CompanyID='" + KeyId + "'";
            string StrWhere = " it.CycleID is not null " + SearchStr;
            List<vUTPCycle> query = null;
            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                query = ServiceDirectDB.vUTPCycle.Where(StrWhere).OrderBy(orderby).ToList();
                CycleObj = query.Last();
            }
            catch (EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }
            return CycleObj;
        }
Beispiel #12
0
        /// <summary>
        /// 根据Schedele的id查询job的执行消息,消息大于1个则说明job执行失败
        /// </summary>
        /// <param name="KeyId">Schedele的ID</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns></returns>
        public virtual string FindJobResultByScheduleId(string KeyId, string startTime, string endTime)
        {
            ObjectQuery<vUTPScheduleMessager> ScheduleLogObjs;
            string orderBy;
            string StrWhere;
            string strTemp;

            StrWhere = "it.PID is not null and it.SID='" + KeyId + "' and it.SDT>=cast('" + startTime + "' as System.DateTime) and it.SDT<=cast('" + endTime + "' as System.DateTime)";
            orderBy = "it.GDT desc";
            string str = HttpContext.GetGlobalResourceObject("WebResource", "ScheduleTasksForm_JobResult_value").ToString();

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                ScheduleLogObjs = ServiceDirectDB.vUTPScheduleMessager.Where(StrWhere).OrderBy(orderBy);
            }
            catch (EntityException)
            {
                throw;
            }
            if (ScheduleLogObjs.Count() > 0)
            {
                foreach (vUTPScheduleMessager item in ScheduleLogObjs)
                {
                    strTemp = item.SMessage;
                    if (strTemp.IndexOf("Successfully") > 0)
                    {
                        return str = HttpContext.GetGlobalResourceObject("WebResource", "ScheduleTasksForm_JobResult_SuccessValue").ToString();
                    }
                    else
                    {
                        return str = HttpContext.GetGlobalResourceObject("WebResource", "ScheduleTasksForm_JobResult_FailValue").ToString();
                    }
                }
            }
            return str;
        }
Beispiel #13
0
 /// <summary>
 /// 根据条件以及排序规则,获取对象集
 /// </summary>
 /// <param name="SearchStr">查询条件</param>
 /// <param name="orderby">排序规则</param>
 /// <returns>符合条件的对象集</returns>
 public ObjectQuery<vOnlySysJobs> GetVOnlyJobs(string SearchStr, string orderby)
 {
     string StrWhere = " it.job_id is not null " + SearchStr;
     ObjectQuery<vOnlySysJobs> query = null;
     try
     {
         ServiceDirectDB = new ServiceDirectDBEntities();
         query = ServiceDirectDB.vOnlySysJobs.Where(StrWhere).OrderBy(orderby);
     }
     catch (EntitySqlException)
     {
         throw;
     }
     return query;
 }
Beispiel #14
0
        /// <summary>
        /// 插入的对象
        /// </summary>
        /// <param name="BackupObj">需要插入的对象</param>
        /// <returns>受影响的行数</returns>
        public virtual string Insert(tblBackup BackupObj)
        {
            int counts = 0;//影响行数标记
            string strErrorMessage = "InsertError";

            //插入数据
            try
            {
                ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities();
                ServiceDirectDBEntitieAdd.tblBackup.AddObject(BackupObj);
                counts = ServiceDirectDBEntitieAdd.SaveChanges();
            }
            catch (EntitySqlException)
            {
                throw;
            }
            if (counts>0)
            {
                return BackupObj.BackupID.ToString();
            }
            return strErrorMessage;
        }
Beispiel #15
0
 /// <summary>
 /// 根据对象的ID查询数据
 /// </summary>
 /// <param name="KeyId">对象ID</param>
 /// <returns>返回对象</returns>
 public virtual vSchedulerEmailBackup FindvSchedulerEmailBackupById(string KeyId)
 {
     ServiceDirectDBEntities objDB;
     vSchedulerEmailBackup vSchedulerEmailBackupObj;
     System.Guid KeyIdGuid = new Guid(KeyId);
     try
     {
         objDB = new ServiceDirectDBEntities();
         vSchedulerEmailBackupObj = objDB.vSchedulerEmailBackup.FirstOrDefault(s => s.ScheduleID == KeyIdGuid);
     }
     catch (EntityException)
     {
         return null;
     }
     return vSchedulerEmailBackupObj;
 }
Beispiel #16
0
        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="SchedulerObj">需要更新的对象</param>
        /// <returns>返回受影响的行数</returns>
        public virtual string UpdateInTaskDetailForm(tblScheduler SchedulerObj)
        {
            tblScheduler SchedulerObjUpdate;//需要跟新的对象

            string strMessage = "UpdateError";
            int counts = 0;//影响行数标记

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                SchedulerObjUpdate = ServiceDirectDB.tblScheduler.First(t => t.ScheduleID == SchedulerObj.ScheduleID);
            }
            catch (EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }

            //对象进行赋值,准备更新

            SchedulerObjUpdate.Action = SchedulerObj.Action;
            SchedulerObjUpdate.TraceType = SchedulerObj.TraceType;
            SchedulerObjUpdate.PostAction = SchedulerObj.PostAction;
            SchedulerObjUpdate.ScheduleType = SchedulerObj.ScheduleType;
            SchedulerObjUpdate.StartTime = SchedulerObj.StartTime;
            SchedulerObjUpdate.TaskName = SchedulerObj.TaskName;
            SchedulerObjUpdate.RunOnly = SchedulerObj.RunOnly;
            SchedulerObjUpdate.RunOnlyStart = SchedulerObj.RunOnlyStart;
            SchedulerObjUpdate.RunOnlyEnd = SchedulerObj.RunOnlyEnd;
            SchedulerObjUpdate.BackupID = SchedulerObj.BackupID;

            SchedulerObjUpdate.Trace = SchedulerObj.Trace;
            SchedulerObjUpdate.TraceTable = SchedulerObj.TraceTable;

            //SchedulerObjUpdate.Status = SchedulerObj.Status;
            //SchedulerObjUpdate.UTPPwd = SchedulerObj.UTPPwd;
            //SchedulerObjUpdate.UTPUser = SchedulerObj.UTPUser;
            //SchedulerObjUpdate.Cycle = SchedulerObj.Cycle;
            //SchedulerObjUpdate.Calc = SchedulerObj.Calc;
            //SchedulerObjUpdate.Company = SchedulerObj.Company;
            //SchedulerObjUpdate.Copy = SchedulerObj.Copy;
            try
            {
                counts = ServiceDirectDB.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            if (counts > 0)
            {
                strMessage = "Update success";
                return strMessage;
            }

            return strMessage;
        }
Beispiel #17
0
 /// <summary>
 /// 根据对象的ID查询数据
 /// </summary>
 /// <param name="KeyId">对象ID</param>
 /// <returns>返回对象</returns>
 public virtual vSchedulerTasks FindvSchedulerTasksById(string jobID)
 {
     ServiceDirectDBEntities objDB;
     vSchedulerTasks vSchedulerTasksObj;
     System.Guid KeyIdGuid = new Guid(jobID);
     try
     {
         objDB = new ServiceDirectDBEntities();
         vSchedulerTasksObj = objDB.vSchedulerTasks.FirstOrDefault(s => s.JobID == KeyIdGuid);
     }
     catch (EntityException)
     {
         return null;
     }
     return vSchedulerTasksObj;
 }
Beispiel #18
0
 /// <summary>
 /// 根据条件以及排序规则,获取对象集
 /// </summary>
 /// <param name="SearchStr">查询条件</param>
 /// <param name="orderby">排序规则</param>
 /// <returns>符合条件的对象集</returns>
 public ObjectQuery<vUTPCompany> GetUTPCompanys(string SearchStr, string orderby)
 {
     string StrWhere = " it.CompanyID is not null " + SearchStr;
     ObjectQuery<vUTPCompany> query = null;
     try
     {
         ServiceDirectDB = new ServiceDirectDBEntities();
         query = ServiceDirectDB.vUTPCompany.Where(StrWhere).OrderBy(orderby);
     }
     catch (EntitySqlException)
     {
         throw;
     }
     return query;
 }
Beispiel #19
0
        public void InsertCommand(UTPCommandBuilder builder, string RelateID)
        {
            ServiceDirectDBEntities objDB;
            vUTPCommand vUTPCommandObj;

            //影响行数标记
            int counts = 0;

            //插入数据
            try
            {
                objDB = new ServiceDirectDBEntities();
                vUTPCommandObj = new vUTPCommand();
                vUTPCommandObj.CommandID = builder.CommandID;
                vUTPCommandObj.CommandLine = builder.CommandString;
                vUTPCommandObj.RelateID = RelateID;
                vUTPCommandObj.Sequence = 1;
                objDB.vUTPCommand.AddObject(vUTPCommandObj);
                counts = objDB.SaveChanges();
            }
            catch (EntitySqlException)
            {
                throw;
            }
        }
Beispiel #20
0
        /// <summary>
        /// 创建包含步骤和计划的作业,返回 string  jobid, Kill的JOB
        /// </summary>
        /// <param name="KeyId">对象ID</param>
        /// <returns>返回 string</returns>
        public string Create(string KeyId, string JobType)
        {
            try
            {

                #region 定义变量

                //数据库名称
                string strDatabaseName = string.Empty;

                //作业名称
                string strJobName = string.Empty;

                //作业ID
                string strJobID = string.Empty;

                //作业说明
                string strDescription = string.Empty;

                //开始时间
                DateTime dtStartDate = System.DateTime.Now;

                //计划频率,Daily:每天、Weekly:每周、Monthly:每月、Run Once:只运行一次
                FrequencyTypes FrequencyType = FrequencyTypes.Daily;

                //开始运行时间 如:10:30:00
                string strRunStartDate = string.Empty;

                //结束运行时间,如:11:05:00
                string strRunEndDate = string.Empty;

                //数据库服务名
                string strSQLServer = string.Empty;

                //数据库登录用户
                string strUser = string.Empty;

                //数据库登录密码
                string strPassword = string.Empty;

                //时
                int hours = 0;

                //分
                int minutes = 0;

                //秒
                int seconds = 0;

                //命令行
                string JobCommandString = string.Empty;
                vSchedulerEmailBackup vSchedulerEmailBackupObj = null;

                #endregion

                //返回vSchedulerEmailBackup 对象,根据id查询
                vSchedulerEmailBackupObj = this.FindvSchedulerEmailBackupById(KeyId);
                if (vSchedulerEmailBackupObj != null)
                {
                    #region 变量赋值

                    //strDatabaseName = "ServiceDirectDB";
                    strDatabaseName = this.GetConfig("strDatabaseName");
                    string[] strJobNames = vSchedulerEmailBackupObj.TaskName.Split('-');
                    strJobName = strJobNames[0].ToString() + "-Kill";

                    if (vSchedulerEmailBackupObj.JobID != null)
                    {
                        strJobID = vSchedulerEmailBackupObj.JobID.ToString();
                    }
                    strDescription = "KillUTP";
                    dtStartDate = Convert.ToDateTime(vSchedulerEmailBackupObj.RunOnlyEnd);
                    switch (vSchedulerEmailBackupObj.ScheduleType)
                    {
                        case "Daily":
                            FrequencyType = FrequencyTypes.Daily;
                            break;
                        case "Run Once":
                            FrequencyType = FrequencyTypes.OneTime;
                            break;
                    }
                    DateTime dtRunOnlyStart = Convert.ToDateTime(vSchedulerEmailBackupObj.RunOnlyStart);
                    DateTime dtRunOnlyEnd = Convert.ToDateTime(vSchedulerEmailBackupObj.RunOnlyEnd);
                    strRunStartDate = dtRunOnlyStart.ToLongTimeString();
                    strRunEndDate = dtRunOnlyEnd.ToLongTimeString();

                    //开始运行时间 时:分:秒:
                    hours = dtRunOnlyEnd.Hour;
                    //结束时间减去5分钟之后在运行Kill的JOB
                    minutes = dtRunOnlyEnd.Minute - 5;
                    seconds = dtRunOnlyEnd.Second;

                    //获取自定义config的值
                    strSQLServer = this.GetConfig("strSQLServer");
                    strUser = this.GetConfig("strUser");
                    strPassword = this.GetConfig("strPassword");
                    #endregion
                    #region 创建作业

                    ServiceDirectDBEntities objDB = new ServiceDirectDBEntities();

                    //获取数据库名
                    string strdatabase = objDB.Connection.Database;

                    //获取数据库服务器名
                    string strDataSource = objDB.Connection.DataSource;
                    ServerConnection conn = null;
                    Server myServer = null;
                    conn = new ServerConnection(strSQLServer, strUser, strPassword);
                    myServer = new Server(conn);

                    string KillID = string.Empty;

                    //调用删除job方法,传入job名称
                    //DeleteJob(KillID);
                    DeleteJob(strJobID);

                    Job jb = new Job(myServer.JobServer, strJobName);
                    jb.Description = strDescription;

                    //更改JOB状态
                    if (JobType == "enable")
                    {
                        jb.IsEnabled = true;
                    }
                    switch (JobType)
                    {
                        case "enable":
                            jb.IsEnabled = true;
                            break;
                        case "disable":
                            jb.IsEnabled = false;
                            break;
                        case "Insert":
                            jb.IsEnabled = true;
                            break;
                    }

                    //创建JOB
                    jb.Create();
                    #endregion 创建作业

                    #region 作业步骤

                    Steps steps = new Steps();

                    //创建步骤
                    steps.CreateStepKill(jb, strDatabaseName, KeyId);

                    #endregion 作业步骤

                    #region 作业计划属性

                    JobSchedule jbsch = new JobSchedule(jb, "ScheduleKill");

                    //计划频率,每几天一次
                    jbsch.FrequencyTypes = FrequencyType;
                    if (vSchedulerEmailBackupObj.ScheduleType.Equals("Daily"))
                    {
                        //执行间隔 (天)
                        jbsch.FrequencyInterval = 1;

                        //当天只执行一次
                        jbsch.FrequencySubDayTypes = FrequencySubDayTypes.Once;
                    }
                    if (strRunStartDate != string.Empty)
                    {
                        //开始执行时间
                        jbsch.ActiveStartTimeOfDay = new TimeSpan(hours, minutes, seconds);
                    }

                    //持续时间
                    if (dtStartDate != null)
                    {
                        //开始时间
                        jbsch.ActiveStartDate = dtStartDate;
                    }
                    else
                    {
                        jbsch.ActiveStartDate = DateTime.Now;
                    }

                    //创建SQL代理实例的作业调度
                    jbsch.Create();
                    jb.ApplyToTargetServer(myServer.JobServer.Name);

                    //创建成功后立刻执行一次开始
                    //jb.Start();

                    //创建成功后立刻执行一次结束
                    #endregion 作业计划属性

                    string KillJobID = jb.JobID.ToString();
                    string BillinJobID = string.Empty;
                    BillinJobID = this.CreateBilling(KeyId, JobType, KillJobID);
                    //返回作业GUID
                    return BillinJobID;
                }
                else
                {
                    return "";
                }

            }
            catch (Exception)
            {
                return "";
            }
        }
Beispiel #21
0
        /// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="KeyId">需要删除对象的ID</param>
        /// <returns>返回受影响的行数</returns>
        public virtual int LogicDelete(string KeyId)
        {
            int counts = 0;//影响行数标记
            System.Guid KeyIdGuid = new Guid(KeyId);//转换成Guid类型
            tblBackup BackupObjDelete;//需要跟新的对象

            try
            {
                ServiceDirectDBEntitiesDelete = new ServiceDirectDBEntities();
                BackupObjDelete = ServiceDirectDBEntitiesDelete.tblBackup.First(t => t.BackupID == KeyIdGuid);
                ServiceDirectDBEntitiesDelete.DeleteObject(BackupObjDelete);
                counts = ServiceDirectDBEntitiesDelete.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            return counts;
        }
Beispiel #22
0
        /// <summary>
        /// 根据ScheduleId查询UserName信息
        /// </summary>
        /// <param name="ScheduleId"></param>
        /// <returns></returns>
        public vUTPScheduleMessager FindUserNameByScheduleId(string ScheduleId)
        {
            vUTPScheduleMessager ScheduleLogObj = null;

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                ScheduleLogObj = ServiceDirectDB.vUTPScheduleMessager.FirstOrDefault(t => t.SID == ScheduleId);
            }
            catch (EntitySqlException)
            {
                throw;
            }
            return ScheduleLogObj;
        }
Beispiel #23
0
        /// <summary>
        /// 插入的对象
        /// </summary>
        /// <param name="SchedulerObj">需要插入的对象</param>
        /// <returns>受影响的行数</returns>
        public virtual string Insert(tblScheduler SchedulerObj)
        {
            int counts;//影响行数标记
            string strScheduleID;//插入对象的ID
            string strErrorMessage="InsertError";

            SchedulerObj.ScheduleID = System.Guid.NewGuid();

            //插入数据
            try
            {
                ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities();
                ServiceDirectDBEntitieAdd.tblScheduler.AddObject(SchedulerObj);
                counts = ServiceDirectDBEntitieAdd.SaveChanges();
            }
            catch (EntitySqlException)
            {
                throw;
            }
            if(counts>0)
            {
                strScheduleID = SchedulerObj.ScheduleID.ToString();
                return strScheduleID;
            }
            return strErrorMessage;
        }
Beispiel #24
0
        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="EmailObj">需要更新的对象</param>
        /// <returns>返回受影响的行数</returns>
        public virtual string Update(tblEmail EmailObj)
        {
            tblEmail EmailObjUpdate;//需要跟新的对象

            string strMessage = "InsertError";
            int counts = 0;//影响行数标记

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                EmailObjUpdate = ServiceDirectDB.tblEmail.First(t => t.EmailID == EmailObj.EmailID);
            }catch(EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }

            //对象进行赋值,准备更新
            EmailObjUpdate.EmailFrom = EmailObj.EmailFrom;
            //EmailObjUpdate.EmailTo = EmailObj.EmailTo;
            EmailObjUpdate.EmailPort = EmailObj.EmailPort;
            EmailObjUpdate.EmailSSL = EmailObj.EmailSSL;

            EmailObjUpdate.SMTPHost = EmailObj.SMTPHost;
            EmailObjUpdate.SMTPUsername = EmailObj.SMTPUsername;
            EmailObjUpdate.SMTPPassword = EmailObj.SMTPPassword;

            try
            {
                counts = ServiceDirectDB.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            if (counts > 0)
            {
                strMessage = "update success";
                return strMessage;
            }

            return strMessage;
        }
Beispiel #25
0
 /// <summary>
 /// 物理删除
 /// </summary>
 /// <param name="KeyId">需要删除对象的ID</param>
 /// <returns>返回受影响的行数</returns>
 public virtual int LogicDelete(string KeyId)
 {
     int counts = 0;//影响行数标记
     ServiceDirectDBEntities objDB;
     vUTPCommand vUTPCommandObj;
     try
     {
         objDB = new ServiceDirectDBEntities();
         vUTPCommandObj = objDB.vUTPCommand.FirstOrDefault(c => c.RelateID == KeyId);
         if (vUTPCommandObj != null)
         {
             if (vUTPCommandObj.RelateID != null && vUTPCommandObj.RelateID != string.Empty)
             {
                 objDB.DeleteObject(vUTPCommandObj);
                 counts = objDB.SaveChanges();
             }
         }
     }
     catch (EntityException)
     {
         throw;
     }
     return counts;
 }
Beispiel #26
0
        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="BackupObj">需要更新的对象</param>
        /// <returns>返回受影响的行数</returns>
        public virtual string Update(tblBackup BackupObj)
        {
            tblBackup SchedulerObjUpdate;//需要跟新的对象

            string strMessage = "InsertError";
            int counts = 0;//影响行数标记

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                SchedulerObjUpdate = ServiceDirectDB.tblBackup.FirstOrDefault(t => t.BackupID == BackupObj.BackupID);
            }catch(EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }

            if (SchedulerObjUpdate != null)//如果为空则进行插入
            {
                //对象进行赋值,准备更新
                SchedulerObjUpdate.BackupFloder = BackupObj.BackupFloder;
                SchedulerObjUpdate.BackupDatabase = BackupObj.BackupDatabase;
                SchedulerObjUpdate.DeleteBackupOlder = BackupObj.DeleteBackupOlder;
                SchedulerObjUpdate.BackupServer = BackupObj.BackupServer;

                SchedulerObjUpdate.BackupUser = BackupObj.BackupUser;
                SchedulerObjUpdate.BackupPassword = BackupObj.BackupPassword;

                try
                {
                    counts = ServiceDirectDB.SaveChanges();
                }
                catch (EntityException)
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    ServiceDirectDBEntitieAdd = new ServiceDirectDBEntities();
                    ServiceDirectDBEntitieAdd.tblBackup.AddObject(BackupObj);
                    counts = ServiceDirectDBEntitieAdd.SaveChanges();
                }
                catch (EntityException)
                {

                    throw;
                }
            }

            if (counts > 0)
            {
                strMessage = "update success";
                return strMessage;
            }
            return strMessage;
        }
Beispiel #27
0
        /// <summary>
        /// 物理删除
        /// </summary>
        /// <param name="KeyId">需要删除对象的ID</param>
        /// <returns>返回受影响的行数</returns>
        public virtual string LogicDelete(string KeyId)
        {
            int counts = 0;//影响行数标记
            string strMessage = "InsertError";

            System.Guid KeyIdGuid = new Guid(KeyId);//转换成Guid类型
            tblScheduler SchedulerObjDelete;//需要跟新的对象

            try
            {
                ServiceDirectDBEntitiesDelete = new ServiceDirectDBEntities();
                SchedulerObjDelete = ServiceDirectDBEntitiesDelete.tblScheduler.First(t => t.ScheduleID == KeyIdGuid);
                ServiceDirectDBEntitiesDelete.DeleteObject(SchedulerObjDelete);
                counts = ServiceDirectDBEntitiesDelete.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            if (counts > 0)
            {
                strMessage = "update success";
                return strMessage;
            }
            return strMessage;
        }
Beispiel #28
0
        /// <summary>
        /// 更新对象
        /// </summary>
        /// <param name="SchedulerObj">需要更新的对象</param>
        /// <returns>返回受影响的行数</returns>
        public virtual Boolean UpdateInTaskView(tblScheduler SchedulerObj)
        {
            tblScheduler SchedulerObjUpdate;//需要跟新的对象

            Boolean flagSuccess = false;
            int counts = 0;//影响行数标记

            try
            {
                ServiceDirectDB = new ServiceDirectDBEntities();
                SchedulerObjUpdate = ServiceDirectDB.tblScheduler.First(t => t.ScheduleID == SchedulerObj.ScheduleID);
            }
            catch (EntitySqlException)
            {
                throw;
            }
            catch (EntityException)
            {
                throw;
            }

            //对象进行赋值,准备更新

            //SchedulerObjUpdate.Action = SchedulerObj.Action;
            //SchedulerObjUpdate.TraceType = SchedulerObj.TraceType;
            //SchedulerObjUpdate.PostAction = SchedulerObj.PostAction;
            //SchedulerObjUpdate.ScheduleType = SchedulerObj.ScheduleType;
            //SchedulerObjUpdate.StartTime = SchedulerObj.StartTime;
            //SchedulerObjUpdate.TaskName = SchedulerObj.TaskName;
            //SchedulerObjUpdate.RunOnly = SchedulerObj.RunOnly;
            //SchedulerObjUpdate.RunOnlyStart = SchedulerObj.RunOnlyStart;
            //SchedulerObjUpdate.RunOnlyEnd = SchedulerObj.RunOnlyEnd;

            SchedulerObjUpdate.Trace = SchedulerObj.Trace;
            SchedulerObjUpdate.TraceTable = SchedulerObj.TraceTable;
            SchedulerObjUpdate.JobID = SchedulerObj.JobID;

            //SchedulerObjUpdate.Status = SchedulerObj.Status;
            //SchedulerObjUpdate.UTPPwd = SchedulerObj.UTPPwd;
            //SchedulerObjUpdate.UTPUser = SchedulerObj.UTPUser;
            //SchedulerObjUpdate.Cycle = SchedulerObj.Cycle;
            //SchedulerObjUpdate.Calc = SchedulerObj.Calc;
            //SchedulerObjUpdate.Company = SchedulerObj.Company;
            //SchedulerObjUpdate.Copy = SchedulerObj.Copy;
            try
            {
                counts = ServiceDirectDB.SaveChanges();
            }
            catch (EntityException)
            {
                throw;
            }
            if (counts > 0)
            {
                flagSuccess = true;
                return flagSuccess;
            }

            return flagSuccess;
        }
Beispiel #29
0
 /// <summary>
 /// 根据条件以及排序规则,获取对象集
 /// </summary>
 /// <param name="SearchStr">查询条件</param>
 /// <param name="orderby">排序规则</param>
 /// <returns>符合条件的对象集</returns>
 public ObjectQuery<tblScheduler> GetSchedulers(string SearchStr, string orderby)
 {
     string StrWhere = " it.ScheduleID is not null " + SearchStr;
     ObjectQuery<tblScheduler> query = null;
     try
     {
         ServiceDirectDB = new ServiceDirectDBEntities();
         query = ServiceDirectDB.tblScheduler.Where(StrWhere).OrderBy(orderby);
     }
     catch (EntitySqlException)
     {
         throw;
     }
     return query;
 }