Example #1
0
        public IOperationResult CreateTemplate(Template template)
        {
            if (GetTemplate(template.TemplateId.ToString()) != null)
                return new OperationResult() { Result = false, Message = "template id already exist!", Data = new List<object> { template.TemplateId } };

            if (GetTemplateByName(template.Name) != null)
                return new OperationResult() { Result = false, Message = "template name already exist!", Data = new List<object> { template.Name } };

            // Get param
            template.Params = GetParam(template);

            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.CreateTemplate(template, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { template.TemplateId } };
        }
Example #2
0
        internal static Template FillTemplateFromReader(IDataReader reader)
        {
            var template = new Template();

            if (reader != null && !reader.IsClosed)
            {
                DataTable dt = reader.GetSchemaTable();

                if (dt.Select("ColumnName='" + "CommandId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandId")))
                        template.TemplateId = reader.GetInt16(reader.GetOrdinal("CommandId"));
                if (dt.Select("ColumnName='" + "Name" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Name")))
                        template.Name = reader.GetString(reader.GetOrdinal("Name"));
                if (dt.Select("ColumnName='" + "Description" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Description")))
                        template.Description = reader.GetString(reader.GetOrdinal("Description"));
                if (dt.Select("ColumnName='" + "CannedCommand" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CannedCommand")))
                        template.CannedCommand = reader.GetByte(reader.GetOrdinal("CannedCommand"));
                if (dt.Select("ColumnName='" + "AppName" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("AppName")))
                        template.AppName = reader.GetString(reader.GetOrdinal("AppName"));
                if (dt.Select("ColumnName='" + "Params" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("Params")))
                        template.Params = reader.GetString(reader.GetOrdinal("Params"));
                if (dt.Select("ColumnName='" + "UseCommandShell" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("UseCommandShell")))
                        template.UseCommandShell = reader.GetByte(reader.GetOrdinal("UseCommandShell"));
                if (dt.Select("ColumnName='" + "TimeoutDurationSecs" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("TimeoutDurationSecs")))
                        template.TimeoutDurationSecs = reader.GetInt16(reader.GetOrdinal("TimeoutDurationSecs"));
                if (dt.Select("ColumnName='" + "UserId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("UserId")))
                        template.UserId = reader.GetInt16(reader.GetOrdinal("UserId"));
                if (dt.Select("ColumnName='" + "WaitInterval" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("WaitInterval")))
                        template.WaitInterval = reader.GetInt16(reader.GetOrdinal("WaitInterval"));
                if (dt.Select("ColumnName='" + "InvokeCategory" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("InvokeCategory")))
                        template.InvokeCategory = reader.GetString(reader.GetOrdinal("InvokeCategory"));
                if (dt.Select("ColumnName='" + "InvokeItemName" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("InvokeItemName")))
                        template.InvokeItemName = reader.GetString(reader.GetOrdinal("InvokeItemName"));
                if (dt.Select("ColumnName='" + "CommandResultTestPatternText" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternText")))
                        template.CommandResultTestPatternText = reader.GetString(reader.GetOrdinal("CommandResultTestPatternText"));
                if (dt.Select("ColumnName='" + "CommandResultTestPatternType" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandResultTestPatternType")))
                        template.CommandResultTestPatternType = reader.GetInt16(reader.GetOrdinal("CommandResultTestPatternType"));
                if (dt.Select("ColumnName='" + "CommandMenuGroupId" + "'").Length > 0)
                    if (!reader.IsDBNull(reader.GetOrdinal("CommandMenuGroupId")))
                        template.CommandMenuGroupId = reader.GetInt16(reader.GetOrdinal("CommandMenuGroupId"));

            }

            return template;
        }
        public IWebOperationResult CreateTemplate(Template template)
        {
            template.UserId = user.UserId;
            var result = cdManager.CreateTemplate(template);

            return new WebOperationResult(result.Result, result.Result
                                                                   ? "Template created successfully"
                                                                   : result.Message,"", result.ResultCode);
        }
        public IWebOperationResult UpdateTemplateByName(string templateName, Template template)
        {
            var result = cdManager.UpdateTemplateByName(templateName, template);

            return new WebOperationResult(result.Result, result.Result
                                                                      ? "Template updated successfully"
                                                                      : result.Message, result.Data, result.ResultCode);
        }
Example #5
0
        private string GetParam(Template template)
        {
            bool isOverRide = template.IsOverride ? true : false;

            string atmPath = template.TemplatePath;
            atmPath = (atmPath.EndsWith("/") || atmPath.EndsWith("\\")) && (!atmPath.EndsWith(":\\") && !atmPath.EndsWith(":/"))
                ? atmPath.Substring(0, atmPath.Length - 1).Trim() : atmPath;

            string strParams = string.Empty;
            string strPutFileParts = "<cmd type=" + '"' + "put-file-part" + '"'
                 + " name=" + '"' + "%" + Config.ATMFileTransferSourceURLParamName + "%"
                 + '"' + " ipaddress=" + '"' + Config.FileUploadIPAddressSubstitutionParamString + '"'
                 + " port=" + '"' + Config.ATMFileTransferPortNumber + '"' + " param1=" + '"' + atmPath
                 + '"' + " param2=" + '"' + isOverRide + '"'
                 + " timeout=" + '"' + Config.ATMFileTransferTimeout + '"' + " filepartsize=" + '"' + template.FilePartSize + '"' + "/>";

            string strPutFile = "<cmd type=" + '"' + "put-file" + '"'
               + " name=" + '"' + "%" + Config.ATMFileTransferSourceURLParamName + "%"
               + '"' + " ipaddress=" + '"' + Config.FileUploadIPAddressSubstitutionParamString + '"'
               + " port=" + '"' + Config.ATMFileTransferPortNumber + '"' + " param1=" + '"' + atmPath
               + '"' + " param2=" + '"' + isOverRide + '"'
               + " timeout=" + '"' + Config.ATMFileTransferTimeout + '"' + "/>";

            strParams = template.IsOverride ? strPutFileParts : strPutFile;

            return strParams;
        }
Example #6
0
        public IOperationResult UpdateTemplateByName(string templateName, Template template)
        {
            if (GetTemplateByName(templateName) == null)
                return new OperationResult() { Result = false, Message = "template Name does not exist!", Data = new List<object> { template.Name } };

            template.Params = GetParam(template);
            bool result;

            using (var transactionContext = new TransactionContext())
            {
                result = cdDataProvider.UpdateTemplateByName(templateName, template, transactionContext);

                if (result)
                {
                    transactionContext.Commit();
                }
            }

            return new OperationResult() { Result = result, Data = new List<object> { template.Name } };
        }
Example #7
0
 public WebOperationResult CreateTemplate(Template template)
 {
     return (WebOperationResult)webMessageHandler.CreateTemplate(template);
 }
Example #8
0
 public WebOperationResult UpdateTemplateByName(string templateName, Template template)
 {
     return (WebOperationResult)webMessageHandler.UpdateTemplateByName(templateName, template);
 }