Beispiel #1
0
        public static ScheduleTask UpdateItem(ScheduleTask model)
        {
            String result = String.Empty;

            using (var reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ScheduleTask_Update", CreateSqlParameter(model)))
            {
                while (reader.Read())
                {
                    result = (String)reader[0];
                }
            }
            return(GetItemByID(model.Id, model.CompanyID));
        }
Beispiel #2
0
        public static ScheduleTaskCollection Search(SearchFilter SearchKey)
        {
            ScheduleTaskCollection collection = new ScheduleTaskCollection();

            using (var reader = SqlHelper.ExecuteReader("ScheduleTask_Search", SearchFilterManager.SqlSearchParam(SearchKey)))
            {
                while (reader.Read())
                {
                    ScheduleTask obj = new ScheduleTask();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Beispiel #3
0
        //public static ScheduleTask GetbyType(string Type, int CompanyID)
        //{
        //    ScheduleTaskCollection collection = new ScheduleTaskCollection();
        //    ScheduleTask obj;
        //    var sqlParams = new SqlParameter[]
        //      {
        //                    new SqlParameter("@Type", Type),
        //                    new SqlParameter("@CompanyID", CompanyID),
        //      };
        //    using (var reader = SqlHelper.ExecuteReader("ScheduleTask_GetAll_byType", sqlParams))
        //    {
        //        while (reader.Read())
        //        {
        //            obj = GetItemFromReader(reader);
        //            collection.Add(obj);
        //        }
        //    }
        //    return collection;
        //}
        public static ScheduleTask GetbyType(string Type, int CompanyID)
        {
            ScheduleTask item      = new ScheduleTask();
            var          sqlParams = new SqlParameter[]
            {
                new SqlParameter("@Type", Type),
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("ScheduleTask_GetAll_byType", sqlParams))
            {
                while (reader.Read())
                {
                    item = GetItemFromReader(reader);
                }
            }
            return(item);
        }
Beispiel #4
0
        public static ScheduleTask GetItemByID(int Id, int CompanyID)
        {
            ScheduleTask item      = new ScheduleTask();
            var          sqlParams = new SqlParameter[]
            {
                new SqlParameter("@Id", Id),
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("ScheduleTask_GetByID", sqlParams))
            {
                while (reader.Read())
                {
                    item = GetItemFromReader(reader);
                }
            }
            return(item);
        }
Beispiel #5
0
        public static ScheduleTask AddItem(ScheduleTask model)
        {
            int result = 0;

            try
            {
                using (var reader = SqlHelper.ExecuteReader(CommandType.StoredProcedure, "ScheduleTask_Add", CreateSqlParameter(model)))
                {
                    while (reader.Read())
                    {
                        result = (int)reader[0];
                    }
                }
            }
            catch (Exception ObjEx)
            {
            }
            return(GetItemByID(result, model.CompanyID));
        }
Beispiel #6
0
        public static ScheduleTaskCollection GetAllItem(int CompanyID)
        {
            ScheduleTaskCollection collection = new ScheduleTaskCollection();

            var sqlParams = new SqlParameter[]
            {
                new SqlParameter("@CompanyID", CompanyID),
            };

            using (var reader = SqlHelper.ExecuteReader("ScheduleTask_GetAll", sqlParams))
            {
                while (reader.Read())
                {
                    ScheduleTask obj = new ScheduleTask();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Beispiel #7
0
        private static ScheduleTask GetItemFromReader(IDataReader dataReader)
        {
            ScheduleTask objItem = new ScheduleTask();

            objItem.CompanyID = SqlHelper.GetInt(dataReader, "CompanyID");

            objItem.Id = SqlHelper.GetInt(dataReader, "Id");

            objItem.Name = SqlHelper.GetString(dataReader, "Name");

            objItem.Seconds = SqlHelper.GetInt(dataReader, "Seconds");

            objItem.Type = SqlHelper.GetString(dataReader, "Type");

            objItem.Enabled = SqlHelper.GetBoolean(dataReader, "Enabled");

            objItem.StopOnError = SqlHelper.GetBoolean(dataReader, "StopOnError");

            objItem.LeasedByMachineName = SqlHelper.GetString(dataReader, "LeasedByMachineName");

            objItem.LeasedUntilUtc = SqlHelper.GetDateTime(dataReader, "LeasedUntilUtc");

            objItem.LastStartUtc = SqlHelper.GetDateTime(dataReader, "LastStartUtc");

            objItem.LastEndUtc = SqlHelper.GetDateTime(dataReader, "LastEndUtc");

            objItem.LastSuccessUtc = SqlHelper.GetDateTime(dataReader, "LastSuccessUtc");

            objItem.CreatedDate = SqlHelper.GetDateTime(dataReader, "CreatedDate");

            objItem.CreatedUser = SqlHelper.GetInt(dataReader, "CreatedUser");

            objItem.ScreenID = SqlHelper.GetString(dataReader, "ScreenID");

            if (SqlHelper.ColumnExists(dataReader, "TotalRecord"))
            {
                objItem.TotalRecord = SqlHelper.GetInt(dataReader, "TotalRecord");
            }

            return(objItem);
        }
Beispiel #8
0
 private static SqlParameter[] CreateSqlParameter(ScheduleTask model)
 {
     return(new SqlParameter[]
     {
         new SqlParameter("@CompanyID", model.CompanyID),
         new SqlParameter("@Id", model.Id),
         new SqlParameter("@Name", model.Name),
         new SqlParameter("@Seconds", model.Seconds),
         new SqlParameter("@Type", model.Type),
         new SqlParameter("@Enabled", model.Enabled),
         new SqlParameter("@StopOnError", model.StopOnError),
         new SqlParameter("@LeasedByMachineName", model.LeasedByMachineName),
         new SqlParameter("@LeasedUntilUtc", model.LeasedUntilUtc),
         new SqlParameter("@LastStartUtc", model.LastStartUtc),
         new SqlParameter("@LastEndUtc", model.LastEndUtc),
         new SqlParameter("@LastSuccessUtc", model.LastSuccessUtc),
         new SqlParameter("@CreatedDate", model.CreatedDate),
         new SqlParameter("@CreatedUser", model.CreatedUser),
         new SqlParameter("@ScreenID", model.ScreenID),
     });
 }