Esempio n. 1
0
        /// <summary>
        /// 获取命令行
        /// </summary>
        /// <param name="vSchedulerEmailBackupObj">vSchedulerEmailBackup对象</param>
        /// <param name="KeyId">主键值</param>
        /// <returns></returns>
        public string GetJobCommandString(vSchedulerEmailBackup vSchedulerEmailBackupObj, string KeyId, Job jb)
        {
            string     JobCommandString = string.Empty;
            UTPCommand comm             = new UTPCommand();

            try
            {
                //获取UTP命令行
                comm = this.UTPCommands(vSchedulerEmailBackupObj, jb);

                //UTP命令赋值
                UTPCommandBuilder builder = new UTPCommandBuilder(comm);
                JobCommandString = builder.JobCommandString;

                //删除数据
                this.LogicDelete(KeyId);

                //插入数据
                this.InsertCommand(builder, KeyId);
                return(JobCommandString);
            }
            catch (Exception)
            {
                return("");
            }
        }
        /// <summary>
        /// 根据属性值生成字符串
        /// </summary>
        /// <remarks>根据当前类的属性设置值生成命令行字符串,此方法为私有方法。</remarks>
        /// <param name="Command">命令行构建参数</param>
        private string BuilderCommandString(UTPCommand Command)
        {
            string tmpCommandString;

            try
            {
                //生成命令头
                tmpCommandString = " -s";

                //构建操作类型部分
                switch (Command.ActiveType)
                {
                case ActionType.Backup:
                    tmpCommandString = tmpCommandString + " category:backup";
                    break;

                case ActionType.Billing:
                    tmpCommandString = tmpCommandString + " category:billing";
                    break;

                case ActionType.Pastdue:
                    tmpCommandString = tmpCommandString + " category:snapshot";
                    break;

                case ActionType.Snapshot:
                    tmpCommandString = tmpCommandString + " category:pastdue";
                    break;
                }

                //构建公司信息部分
                tmpCommandString = tmpCommandString + " company:" + Command.Company;

                //构建算费周期部分
                tmpCommandString = tmpCommandString + " cycles:" + Command.Cycle;

                if (Command.Status != "All")
                {
                    //构建账户状态部分
                    tmpCommandString = tmpCommandString + " status:" + Command.Status;
                }
                //构建算费镜像部分
                tmpCommandString = tmpCommandString + " copy:" + (Command.ShadowCopies == BillingShadowCopies.Yes ? "y" : "n");

                //构建自动计算用量部分
                tmpCommandString = tmpCommandString + " calc:" + (Command.AutoCalc == CalcUsageBeforeBillingRegister.Yes ? "y" : "n");

                //构建日志部分
                //tmpCommandString = tmpCommandString + " trace:" + (Command.Trace == Trace.Yes ? "y" : "n");
                tmpCommandString = tmpCommandString + " trace:y";
                if (Command.Trace == Trace.Yes)
                {
                    switch (Command.TraceType)
                    {
                    case TraceType.File:
                        tmpCommandString = tmpCommandString + " file " + Command.TraceFilePath;
                        break;

                    case TraceType.Table:
                        tmpCommandString = tmpCommandString + " table " + Command.TraceDBConnectionString;
                        break;
                    }
                }
                tmpCommandString = tmpCommandString + " table " + "\"" + "\"";
                //构建计划信息
                tmpCommandString = tmpCommandString + " sid:" + Command.SID.ToString();

                //构建用户信息
                tmpCommandString = tmpCommandString + " -u " + "\"" + Command.UTPUsername + "\"";

                //构建口令信息
                tmpCommandString = tmpCommandString + " -p " + "\"" + Command.UTPPassword + "\"";

                return(tmpCommandString);
            }
            catch (Exception)
            {
                return(string.Empty);
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <remarks>根据参数值生成命令行字符串。</remarks>
 /// <param name="Command">命令行构建参数。</param>
 public UTPCommandBuilder(UTPCommand Command)
 {
     _CommandString    = BuilderCommandString(Command);
     _CommandID        = Guid.NewGuid().ToString();
     _JobCommandString = Command.UTPPath + " -COMMAND luid:" + Command.GUID;
 }
Esempio n. 4
0
        public UTPCommand UTPCommands(vSchedulerEmailBackup vSchedulerEmailBackupObj, Job jb)
        {
            UTPCommand comm = new UTPCommand();

            //操作类型
            switch (vSchedulerEmailBackupObj.Action)
            {
            case "Billing":
                comm.ActiveType = ActionType.Billing;
                break;
            }

            //自动计算用量
            switch (vSchedulerEmailBackupObj.Calc)
            {
            case "True":
                comm.AutoCalc = CalcUsageBeforeBillingRegister.Yes;
                break;

            case "False":
                comm.AutoCalc = CalcUsageBeforeBillingRegister.No;
                break;
            }

            //公司标识
            comm.Company = vSchedulerEmailBackupObj.Company;

            //算费周期范围
            comm.Cycle = vSchedulerEmailBackupObj.Cycle;

            //镜像复制
            switch (vSchedulerEmailBackupObj.Copy)
            {
            case "True":
                comm.ShadowCopies = BillingShadowCopies.Yes;
                break;

            case "False":
                comm.ShadowCopies = BillingShadowCopies.No;
                break;
            }

            //账户状态
            if (vSchedulerEmailBackupObj.Status != "All")
            {
                comm.Status = vSchedulerEmailBackupObj.Status;
            }
            //日志
            switch (vSchedulerEmailBackupObj.Trace)
            {
            case "True":
                comm.Trace = Trace.Yes;
                break;

            case "False":
                comm.Trace = Trace.Yes;
                break;
            }

            //日志数据库连接字符串
            comm.TraceDBConnectionString = vSchedulerEmailBackupObj.TraceTable;

            //日志文件保存路径
            //comm.TraceFilePath=vSchedulerEmailBackupObj.trace

            //日志类型
            switch (vSchedulerEmailBackupObj.TraceType)
            {
            case "File":
                comm.TraceType = TraceType.File;
                break;

            case "Table":
                comm.TraceType = TraceType.Table;
                break;

            case "None":
                comm.TraceType = TraceType.None;
                break;
            }

            //口令
            comm.UTPPassword = vSchedulerEmailBackupObj.UTPPwd;

            //用户名
            comm.UTPUsername = vSchedulerEmailBackupObj.UTPUser;

            //计划标识
            comm.GUID = vSchedulerEmailBackupObj.ScheduleID.ToString();

            //UTP程序路径,保存了UTP EXE文件所在的应用程序路径,此属性值要求包含Utility.exe的全路径。
            comm.UTPPath = "*" + this.GetConfig("UTPPath") + "*";

            //计划标识符
            comm.SID = vSchedulerEmailBackupObj.ScheduleID;


            return(comm);
        }