Exemplo n.º 1
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            var sdr = new SqlDataRecord(
                new SqlMetaData("FormFieldId", SqlDbType.BigInt),
                new SqlMetaData("SortOrder", SqlDbType.Int),
                new SqlMetaData("FormFieldType", SqlDbType.Int),
                new SqlMetaData("Label", SqlDbType.NVarChar, 100),
                new SqlMetaData("Required", SqlDbType.Bit)
                );

            foreach (FormElementField field in this)
            {
                if (field.FormFieldId != 0)
                {
                    sdr.SetInt64(0, field.FormFieldId);
                }
                else
                {
                    sdr.SetDBNull(0);
                }
                sdr.SetInt32(1, field.SortOrder);
                sdr.SetInt32(2, (int)field.FieldType);
                sdr.SetString(3, field.Label);
                sdr.SetBoolean(4, field.Required);
                yield return(sdr);
            }
        }
Exemplo n.º 2
0
 public static SqlDataRecord Convert(TeamLevelReport report, DataSourceNames name)
 {
     var record = new SqlDataRecord(Constants.Structures[name]);
     for (var index = 0; index < Constants.Structures[name].Length; index++)
     {
         switch (Constants.Structures[name][index].Name)
         {
             case "Monthly":
                 record.SetStringIfNullOrEmpty(index, report.Monthly);
                 break;
             case "Weekly":
                 record.SetStringIfNullOrEmpty(index, report.Weekly);
                 break;
             case "IsTotalLine":
                 record.SetBoolean(index, report.IsTotalLine);
                 break;
             case "BatchJobId":
                 record.SetStringIfNullOrEmpty(index, report.BatchJob);
                 break;
             case "Metadata":
                 record.SetStringIfNullOrEmpty(index, report.Metadata);
                 break;
         }
     }
     return record;
 }
Exemplo n.º 3
0
 public static SqlDataRecord ConvertforTeamLevel(ExcelSignleRow row, DataSourceNames name)
 {
     var record = new SqlDataRecord(Constants.Structures[name]);
     for (var index = 0; index < Constants.Structures[name].Length; index++)
     {
         var month = row.JMetadata.TryGetValue<string>("$.Month");
         var week = row.JMetadata.TryGetValue<string>("$.Week");
         if (month == null && lastMonth != string.Empty)
             month = lastMonth;
         if (month != null && month.IndexOf("Grand Total") >= 0) return null;
         if (string.IsNullOrEmpty(week))
             week = "Week 1";
         switch (Constants.Structures[name][index].Name)
         {
             case "Monthly":
                 record.SetStringIfNullOrEmpty(index, month);
                 break;
             case "Weekly":
                 record.SetStringIfNullOrEmpty(index, week);
                 break;
             case "IsTotalLine":
                 record.SetBoolean(index, month.IndexOf("Total") >= 0);
                 break;
             case "BatchJobId":
                 record.SetStringIfNullOrEmpty(index, row.BatchJob?.Id);
                 break;
             case "Metadata":
                 record.SetStringIfNullOrEmpty(index, row.JMetadata?.ToString());
                 break;
         }
         if (month != null)
             lastMonth = month;
     }
     return record;
 }
Exemplo n.º 4
0
    public static int ListsUnsubscribe(SqlString apikey, SqlString list_id, SqlString email, SqlString euid, SqlString leid, SqlBoolean delete_member, SqlBoolean send_goodbye, SqlBoolean send_notify)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            EmailParameter emailParam = new EmailParameter
            {
                Email = email.ToString(),
                EUId  = euid.ToString(),
                LEId  = leid.ToString()
            };

            UnsubscribeResult result = mc.Unsubscribe(list_id.ToString(), emailParam, delete_member.IsTrue, send_goodbye.IsTrue, send_notify.IsTrue);

            SqlDataRecord record = new SqlDataRecord(CompleteResultsMetaData);
            record.SetBoolean(0, result.Complete);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            return(1);
        }
        return(0);
    }
Exemplo n.º 5
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            SqlDataRecord ret = new SqlDataRecord(
                new SqlMetaData("DireccionesAnexasId", SqlDbType.Int),
                new SqlMetaData("EmpresaId", SqlDbType.Int),
                new SqlMetaData("DepartamentoId", SqlDbType.Int),
                new SqlMetaData("ProvinciaId", SqlDbType.Int),
                new SqlMetaData("DistritoId", SqlDbType.Int),
                new SqlMetaData("Direccion", SqlDbType.NVarChar, 100),
                new SqlMetaData("Riesgo", SqlDbType.Bit),
                new SqlMetaData("CreatedDate", SqlDbType.DateTime),
                new SqlMetaData("CreatedBy", SqlDbType.Int),
                new SqlMetaData("LastUpdateDate", SqlDbType.DateTime),
                new SqlMetaData("LastUpdateBy", SqlDbType.Int),
                new SqlMetaData("Estado", SqlDbType.Int)
                );

            foreach (clsAddressesRisk data in this)
            {
                ret.SetInt32(0, data.ID);
                ret.SetInt32(1, data.EmpresaId);
                ret.SetInt32(2, data.DepartamentoId);
                ret.SetInt32(3, data.ProvinciaId);
                ret.SetInt32(4, data.DistritoId);
                ret.SetString(5, data.Direccion);
                ret.SetBoolean(6, data.Riesgo);
                ret.SetDateTime(7, data.CreationDate);
                ret.SetInt32(8, data.Createdby);
                ret.SetDateTime(9, data.UpdateDate);
                ret.SetInt32(10, data.Updatedby);
                ret.SetInt32(11, data.Estado);
                yield return(ret);
            }
        }
Exemplo n.º 6
0
        private static IEnumerable <SqlDataRecord> BindDishRows(IEnumerable <DishEntity> dishesToUpdate)
        {
            foreach (var dish in dishesToUpdate)
            {
                SqlDataRecord record = new SqlDataRecord(typ_DishTable);

                record.SetInt64(0, dish.DishId);
                record.SetInt64(1, dish.ProviderId);
                record.SetInt32(2, (int)dish.DishType);
                record.SetString(3, dish.DishName);
                record.SetString(4, dish.Description);
                record.SetString(5, dish.Ingredients);
                record.SetDecimal(6, dish.Price);
                record.SetInt32(7, dish.WaitingTimeInMins);
                if (!dish.ThumbNailPictureKey.HasValue)
                {
                    record.SetDBNull(8);
                }
                else
                {
                    record.SetGuid(8, dish.ThumbNailPictureKey.Value);
                }
                record.SetBoolean(9, dish.Available);

                yield return(record);
            }
        }
    public static void UserExistsInAD(SqlString Users, SqlString Domain)
    {
        string[] UserArr = Users.Value.Split(',');

        string ADdomain = Domain.IsNull ? ProcessOneDWDomainName : Domain.Value;

        using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain, ADdomain))
        {
            // Create the record and specify the metadata for the columns.
            SqlDataRecord record = new SqlDataRecord(
                new SqlMetaData("UserName", SqlDbType.NVarChar, 50),
                new SqlMetaData("DoesExist", SqlDbType.Bit));

            // Mark the begining of the result-set.
            SqlContext.Pipe.SendResultsStart(record);

            foreach (string UserName in UserArr)
            {
                UserPrincipal DoesExist = UserPrincipal.FindByIdentity(domainContext, IdentityType.SamAccountName, UserName);
                // Set values for each column in the row.
                record.SetString(0, UserName);
                record.SetBoolean(1, DoesExist != null ? true : false);

                // Send the row back to the client.
                SqlContext.Pipe.SendResultsRow(record);
            }

            // Mark the end of the result-set.
            SqlContext.Pipe.SendResultsEnd();
        }
    }
Exemplo n.º 8
0
        /// <summary>
        ///     Set property value to sql record.
        /// </summary>
        /// <param name="dataRecord">
        ///     Instance of sql data record.
        /// </param>
        /// <param name="databaseType">
        ///     Type of database column.
        /// </param>
        /// <param name="propValue">
        ///     Value to be inserted.
        /// </param>
        /// <param name="ordinal">
        ///     The zero based ordinal of the data record column.
        /// </param>
        private void SetDataRecordValue(SqlDataRecord dataRecord, DbType databaseType, object propValue, int ordinal)
        {
            switch (databaseType)
            {
            case DbType.String:
                dataRecord.SetString(ordinal, propValue.ToString());
                break;

            case DbType.Int32:
                dataRecord.SetInt32(ordinal, Convert.ToInt32(propValue));
                break;

            case DbType.DateTime:
                dataRecord.SetDateTime(ordinal, Convert.ToDateTime(propValue));
                break;

            case DbType.Boolean:
                dataRecord.SetBoolean(ordinal, Convert.ToBoolean(propValue));
                break;

            default:
                dataRecord.SetString(ordinal, propValue.ToString());
                break;
            }
        }
Exemplo n.º 9
0
    public static int ListsMergeVarAdd(SqlString apikey, SqlString list_id, SqlString tag, SqlString name, SqlString opt_field_type, SqlBoolean opt_req,
                                       SqlBoolean opt_public, SqlBoolean opt_show, SqlInt32 opt_order, SqlString opt_default_value, SqlString opt_helptext, SqlString opt_choices,
                                       SqlString opt_dateformat, SqlString opt_phoneformat, SqlString opt_defaultcountry)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            MergeVarItemResult result = mc.AddMergeVar(list_id.ToString(), tag.ToString(), name.ToString(), new MergeVarOptions
            {
                FieldType      = opt_field_type.ToString(),
                Required       = opt_req.IsTrue,
                Public         = opt_public.IsTrue,
                Show           = opt_show.IsTrue,
                Order          = opt_order.Value,
                DefaultValue   = opt_default_value.ToString(),
                HelpText       = opt_helptext.ToString(),
                Choices        = opt_choices.ToString().Split(','),
                DateFormat     = opt_dateformat.ToString(),
                PhoneFormat    = opt_phoneformat.ToString(),
                DefaultCountry = opt_defaultcountry.ToString()
            });

            SqlDataRecord record = new SqlDataRecord(MergeVarResultsMetaData);
            record.SetString(0, result.Name);
            record.SetBoolean(1, result.Required);
            record.SetString(2, result.FieldType);
            record.SetBoolean(3, result.Public);
            record.SetBoolean(4, result.Show);
            record.SetInt32(5, result.Order);
            record.SetString(6, result.DefaultValue);
            record.SetString(7, result.HelpText);
            record.SetString(8, (result.Choices == null) ? string.Empty : string.Join(",", result.Choices));
            record.SetString(9, result.Size);
            record.SetString(10, result.Tag);
            record.SetInt32(11, result.Id);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            SqlContext.Pipe.Send(ex.StackTrace);
            return(1);
        }
        return(0);
    }
        /// <summary>
        /// Sets the boolean.
        /// </summary>
        /// <param name="record">The record.</param>
        /// <param name="fieldName">Name of the field.</param>
        /// <param name="value">if set to <c>true</c> [value].</param>
        public static void SetBoolean(this SqlDataRecord record, string fieldName, bool?value)
        {
            int ordinal = GetOrdinal(record, fieldName);

            if (value.HasValue)
            {
                record.SetBoolean(ordinal, value.Value);
            }
        }
Exemplo n.º 11
0
        internal static SqlDataRecord MapToTvp(this LogCallingMethodParameter message)
        {
            var recrod = new SqlDataRecord(Constants.CallingMethodIOData);

            recrod.SetGuid(0, message.OwnerLog.LogUUID);
            recrod.SetBoolean(1, message.IsInput);
            recrod.SetString(2, message.ParameterName);
            recrod.SetString(3, message.Value);

            return(recrod);
        }
Exemplo n.º 12
0
 internal override void SetDataRecordValue(SqlDataRecord record, int ordinal)
 {
     if (InputValue == null)
     {
         record.SetDBNull(ordinal);
     }
     else
     {
         record.SetBoolean(ordinal, InputValue.Value);
     }
 }
Exemplo n.º 13
0
 public override void Set(SqlDataRecord record, int ordinal, bool?value)
 {
     if (value.HasValue)
     {
         record.SetBoolean(ordinal, value.Value);
     }
     else
     {
         record.SetDBNull(ordinal);
     }
 }
 public static void SetBoolean(this SqlDataRecord record, int ordinal, bool?value)
 {
     if (value != null)
     {
         record.SetBoolean(ordinal, (bool)value);
     }
     else
     {
         record.SetDBNull(ordinal);
     }
 }
Exemplo n.º 15
0
 public static void SetNullableBoolean(this SqlDataRecord sqlDataRecord, int ordinal, bool?value)
 {
     if (value.HasValue)
     {
         sqlDataRecord.SetBoolean(ordinal, value.Value);
     }
     else
     {
         sqlDataRecord.SetDBNull(ordinal);
     }
 }
Exemplo n.º 16
0
            IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
            {
                SqlDataRecord sdr = new SqlDataRecord(
                    new SqlMetaData("KeyField", SqlDbType.SmallInt),
                    new SqlMetaData("Description", SqlDbType.VarChar, 20),
                    new SqlMetaData("DisplayOrder", SqlDbType.SmallInt),
                    new SqlMetaData("OKToDelete", SqlDbType.Bit),
                    new SqlMetaData("UpdateYN", SqlDbType.Bit),
                    new SqlMetaData("DeletedYN", SqlDbType.Bit));

                foreach (EnrollmentType i in this)
                {
                    sdr.SetSqlInt16(0, i.KeyField);
                    sdr.SetString(1, i.Description);
                    sdr.SetSqlNullableInt16(2, i.DisplayOrder);
                    sdr.SetBoolean(3, i.OKToDelete);
                    sdr.SetBoolean(4, i.UpdateYN);
                    sdr.SetBoolean(5, i.DeleteYN);
                    yield return(sdr);
                }
            }
Exemplo n.º 17
0
            IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
            {
                SqlDataRecord sdr = new SqlDataRecord(
                    new SqlMetaData("KeyField", SqlDbType.SmallInt),
                    new SqlMetaData("description", SqlDbType.VarChar, 30),
                    new SqlMetaData("MaxStudents", SqlDbType.Int),
                    new SqlMetaData("DeletedYN", SqlDbType.Bit),
                    new SqlMetaData("UpdateYN", SqlDbType.Bit),
                    new SqlMetaData("OKToDelete", SqlDbType.Bit));

                foreach (Room i in this)
                {
                    sdr.SetSqlInt16(0, i.KeyField);
                    sdr.SetString(1, i.description);
                    sdr.SetSqlNullableInt32(2, i.MaxStudents);
                    sdr.SetBoolean(3, i.DeleteYN);
                    sdr.SetBoolean(4, i.UpdateYN);
                    sdr.SetBoolean(5, i.OKToDelete);
                    yield return(sdr);
                }
            }
        public override void Set(SqlDataRecord record, int ordinal, bool?value)
        {
            EnsureArg.IsNotNull(record, nameof(record));

            if (value.HasValue)
            {
                record.SetBoolean(ordinal, value.Value);
            }
            else
            {
                record.SetDBNull(ordinal);
            }
        }
Exemplo n.º 19
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            var row     = new SqlDataRecord(new SqlMetaData("order_id", SqlDbType.Int), new SqlMetaData("value1", SqlDbType.Int), new SqlMetaData("value2", SqlDbType.Bit));
            int ordinal = 0;

            foreach (KeyValuePair <int, bool> kv in this)
            {
                row.SetInt32(0, ordinal++);
                row.SetInt32(1, kv.Key);
                row.SetBoolean(2, kv.Value);
                yield return(row);
            }
        }
Exemplo n.º 20
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            var sdr = new SqlDataRecord(
                new[]
            {
                new SqlMetaData("ID", SqlDbType.VarChar, 36),
                new SqlMetaData("USERID", SqlDbType.VarChar, 50),
                new SqlMetaData("ASSIGNMENTID", SqlDbType.VarChar, 36),
                new SqlMetaData("ACTIVITYSTATE", SqlDbType.Int),
                new SqlMetaData("ACTIVITYTYPE", SqlDbType.Int),
                new SqlMetaData("DESCRIPTION", SqlDbType.VarChar, 200),
                new SqlMetaData("STARTDATE", SqlDbType.DateTime),
                new SqlMetaData("ENDDATE", SqlDbType.DateTime),
                new SqlMetaData("DURATION", SqlDbType.Time),
                new SqlMetaData("ACTIVE", SqlDbType.Bit),
                new SqlMetaData("DAY", SqlDbType.Bit),
                new SqlMetaData("ONLINE", SqlDbType.Bit)
            });

            foreach (var activity in this)
            {
                sdr.SetString(0, activity.Id);
                sdr.SetString(1, activity.UserId);
                sdr.SetString(2, activity.AssignmentId);
                sdr.SetInt32(3, (int)activity.ActivityState);
                sdr.SetInt32(4, (int)activity.ActivityType);
                sdr.SetString(5, activity.Description);
                sdr.SetDateTime(6, activity.StartDate);
                Common.SqlDataRecordExtensions.SetNullableDateTime(sdr, 7, activity.EndDate);
                //sdr.SetDateTime(7, activity.EndDate.HasValue ? activity.EndDate);// ANTONIODATE
                sdr.SetTimeSpan(8, activity.DurationEnd);
                sdr.SetBoolean(9, activity.Active);
                sdr.SetBoolean(10, activity.Day);
                sdr.SetBoolean(11, activity.Online);
                yield return(sdr);
            }
        }
Exemplo n.º 21
0
        private static SqlDataRecord CreateBooleanRecord(bool?value)
        {
            var record = new SqlDataRecord(new SqlMetaData("Value", SqlDbType.Bit));

            if (value.HasValue)
            {
                record.SetBoolean(0, value.Value);
            }
            else
            {
                record.SetDBNull(0);
            }

            return(record);
        }
        public static IEnumerable <SqlDataRecord> TSqlDataRecord(List <Menu> ListaMenu)
        {
            List <SqlDataRecord> listaSqlDataRecord = new List <SqlDataRecord>();

            foreach (Menu oMenu in ListaMenu)
            {
                SqlDataRecord oSqlDataRecord = new SqlDataRecord(
                    new SqlMetaData[] { new SqlMetaData("nMenuId", SqlDbType.Int),
                                        new SqlMetaData("nValor", SqlDbType.Bit) });

                oSqlDataRecord.SetInt32(0, oMenu.nMenuId);
                oSqlDataRecord.SetBoolean(1, oMenu.bEstado);
                listaSqlDataRecord.Add(oSqlDataRecord);
            }

            return(listaSqlDataRecord);
        }
Exemplo n.º 23
0
        public static IEnumerable <SqlDataRecord> TSqlDataRecord(List <Permiso> ListaPermiso)
        {
            List <SqlDataRecord> listaSqlDataRecord = new List <SqlDataRecord>();

            foreach (Permiso oPermiso in ListaPermiso)
            {
                SqlDataRecord oSqlDataRecord = new SqlDataRecord(
                    new SqlMetaData[] { new SqlMetaData("nModId", SqlDbType.Int),
                                        new SqlMetaData("nPermId", SqlDbType.Int),
                                        new SqlMetaData("nValor", SqlDbType.Bit) });

                oSqlDataRecord.SetInt32(0, oPermiso.nModId);
                oSqlDataRecord.SetInt32(1, oPermiso.nPermId);
                oSqlDataRecord.SetBoolean(2, oPermiso.bEstado);
                listaSqlDataRecord.Add(oSqlDataRecord);
            }

            return(listaSqlDataRecord);
        }
Exemplo n.º 24
0
        static IEnumerable <SqlDataRecord> ToHistoryEventsParameter(
            IEnumerable <HistoryEvent> historyEvents,
            OrchestrationInstance instance,
            int nextSequenceNumber,
            EventPayloadMap eventPayloadMap)
        {
            var record = new SqlDataRecord(HistoryEventSchema);

            foreach (HistoryEvent e in historyEvents)
            {
                record.SetSqlInt64(ColumnOrdinals.SequenceNumber, nextSequenceNumber++);
                record.SetSqlString(ColumnOrdinals.InstanceID, instance.InstanceId);
                record.SetSqlString(ColumnOrdinals.ExecutionID, instance.ExecutionId);
                record.SetSqlString(ColumnOrdinals.EventType, e.EventType.ToString());
                record.SetSqlString(ColumnOrdinals.Name, SqlUtils.GetName(e));
                record.SetSqlString(ColumnOrdinals.RuntimeStatus, SqlUtils.GetRuntimeStatus(e));
                record.SetSqlInt32(ColumnOrdinals.TaskID, SqlUtils.GetTaskId(e));
                record.SetDateTime(ColumnOrdinals.Timestamp, e.Timestamp);
                record.SetBoolean(ColumnOrdinals.IsPlayed, e.IsPlayed);
                record.SetDateTime(ColumnOrdinals.VisibleTime, SqlUtils.GetVisibleTime(e));

                if (eventPayloadMap.TryGetPayloadId(e, out Guid existingPayloadId))
                {
                    // We already have a payload saved in the DB for this event. Send only the payload ID.
                    record.SetSqlString(ColumnOrdinals.Reason, SqlString.Null);
                    record.SetSqlString(ColumnOrdinals.PayloadText, SqlString.Null);
                    record.SetSqlGuid(ColumnOrdinals.PayloadID, existingPayloadId);
                }
                else
                {
                    // This path is expected for ExecutionCompleted, possibly others?
                    SqlString reason = SqlUtils.GetReason(e);
                    record.SetSqlString(ColumnOrdinals.Reason, reason);
                    SqlString payload = SqlUtils.GetPayloadText(e);
                    record.SetSqlString(ColumnOrdinals.PayloadText, payload);
                    SqlGuid newPayloadId = reason.IsNull && payload.IsNull ? SqlGuid.Null : new SqlGuid(Guid.NewGuid());
                    record.SetSqlGuid(ColumnOrdinals.PayloadID, newPayloadId);
                }

                yield return(record);
            }
        }
Exemplo n.º 25
0
    public static int ListsMergeVarSet(SqlString apikey, SqlString list_id, SqlString tag, SqlString value)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            CompleteResult result = mc.SetMergeVar(list_id.ToString(), tag.ToString(), value.ToString());

            SqlDataRecord record = new SqlDataRecord(CompleteResultsMetaData);
            record.SetBoolean(0, result.Complete);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            return(1);
        }
        return(0);
    }
Exemplo n.º 26
0
    public static int ListsInterestGroupingUpdate(SqlString apikey, SqlString list_id, SqlInt32 grouping_id, SqlString name, SqlString value)
    {
        try
        {
            MailChimpManager mc = new MailChimpManager(apikey.ToString());

            CompleteResult result = mc.UpdateListInterestGrouping(list_id.ToString(), grouping_id.Value, name.ToString(), value.ToString());

            SqlDataRecord record = new SqlDataRecord(CompleteResultsMetaData);
            record.SetBoolean(0, result.Complete);

            SqlContext.Pipe.Send(record);
        }
        catch (Exception ex)
        {
            SqlContext.Pipe.Send(ex.Message);
            return(1);
        }
        return(0);
    }
Exemplo n.º 27
0
 public override void Set(SqlDataRecord record, int ordinal, bool value)
 {
     record.SetBoolean(ordinal, value);
 }
Exemplo n.º 28
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            SqlDataRecord ret = new SqlDataRecord(
                new SqlMetaData("EmailVerificationID", SqlDbType.Int),
                new SqlMetaData("VerficationCode", SqlDbType.VarChar, -1),
                new SqlMetaData("ExpiryDate", SqlDbType.DateTime),
                new SqlMetaData("MemberId", SqlDbType.Int),
                new SqlMetaData("Isused", SqlDbType.Bit),
                new SqlMetaData("ProfileType", SqlDbType.VarChar, -1)
                );

            foreach (Email_Verification data in this)
            {
                if (CheckNullOrEmpty(data.EmailVerificationID))
                {
                    ret.SetDBNull(0);
                }

                else
                {
                    ret.SetInt32(0, data.EmailVerificationID);
                }


                if (CheckNullOrEmpty(data.VerficationCode))
                {
                    ret.SetDBNull(1);
                }

                else
                {
                    ret.SetString(1, data.VerficationCode);
                }


                if (CheckNullOrEmpty(data.ExpiryDate))
                {
                    ret.SetDBNull(2);
                }

                else
                {
                    ret.SetDateTime(2, data.ExpiryDate);
                }


                if (CheckNullOrEmpty(data.MemberId))
                {
                    ret.SetDBNull(3);
                }

                else
                {
                    ret.SetInt32(3, data.MemberId);
                }


                if (CheckNullOrEmpty(data.Isused))
                {
                    ret.SetDBNull(4);
                }

                else
                {
                    ret.SetBoolean(4, data.Isused);
                }


                if (CheckNullOrEmpty(data.ProfileType))
                {
                    ret.SetDBNull(5);
                }

                else
                {
                    ret.SetString(5, data.ProfileType);
                }

                yield return(ret);
            }
        }
        public void SqlRecordFillTest()
        {
            SqlMetaData[] metaData = new SqlMetaData[]
            {
                new SqlMetaData("col1", SqlDbType.Bit),
                new SqlMetaData("col2", SqlDbType.TinyInt),
                new SqlMetaData("col3", SqlDbType.VarBinary, 1000),
                new SqlMetaData("col4", SqlDbType.NVarChar, 1000),
                new SqlMetaData("col5", SqlDbType.DateTime),
                new SqlMetaData("col6", SqlDbType.Float),
                new SqlMetaData("col7", SqlDbType.UniqueIdentifier),
                new SqlMetaData("col8", SqlDbType.SmallInt),
                new SqlMetaData("col9", SqlDbType.Int),
                new SqlMetaData("col10", SqlDbType.BigInt),
                new SqlMetaData("col11", SqlDbType.Real),
                new SqlMetaData("col12", SqlDbType.Decimal),
                new SqlMetaData("col13", SqlDbType.Money),
                new SqlMetaData("col14", SqlDbType.Variant)
            };

            SqlDataRecord record = new SqlDataRecord(metaData);

            for (int i = 0; i < record.FieldCount; i++)
            {
                Assert.Equal($"col{i + 1}", record.GetName(i));
            }

            record.SetBoolean(0, true);
            Assert.Equal(true, record.GetBoolean(0));

            record.SetByte(1, 1);
            Assert.Equal(1, record.GetByte(1));

            byte[] bb1 = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            byte[] bb2 = new byte[5];
            record.SetSqlBinary(2, new SqlBinary(new byte[0]));
            record.SetBytes(2, 0, bb1, 0, 3);
            record.SetBytes(2, 2, bb1, 6, 3);

            // Verify the length of the byte array
            Assert.Equal(5, record.GetBytes(2, 0, bb2, 0, 5));

            Assert.Equal(5, record.GetBytes(2, 0, null, 0, 0));

            byte[] expected = new byte[] { 1, 2, 7, 8, 9 };
            Assert.Equal <byte>(expected, bb2);

            char[] cb1 = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
            char[] cb2 = new char[5];
            record.SetChars(3, 0, cb1, 0, 3);
            record.SetChars(3, 2, cb1, 4, 3);

            char[] expectedValue = new char[] { 'a', 'b', 'e', 'f', 'g' };
            Assert.Equal(expectedValue.Length, record.GetChars(3, 0, cb2, 0, 5));
            Assert.Equal <char>(expectedValue, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)));

            record.SetString(3, "");
            string xyz = "xyz";

            record.SetString(3, "xyz");
            Assert.Equal(xyz, record.GetString(3));
            Assert.Equal(xyz.Length, record.GetChars(3, 0, cb2, 0, 5));
            Assert.Equal(xyz, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)));

            record.SetChars(3, 2, cb1, 4, 3);
            Assert.Equal(5, record.GetChars(3, 0, cb2, 0, 5));

            string interleavedResult = "xyefg";

            Assert.Equal(interleavedResult, new string(cb2, 0, (int)record.GetChars(3, 0, null, 0, 0)));
            Assert.Equal(interleavedResult, record.GetString(3));

            record.SetSqlDateTime(4, SqlDateTime.MaxValue);
            Assert.Equal(SqlDateTime.MaxValue, record.GetSqlDateTime(4));

            record.SetSqlDouble(5, SqlDouble.MaxValue);
            Assert.Equal(SqlDouble.MaxValue, record.GetSqlDouble(5));

            SqlGuid guid = new SqlGuid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4");

            record.SetSqlGuid(6, guid);
            Assert.Equal(guid, record.GetSqlGuid(6));

            record.SetSqlInt16(7, SqlInt16.MaxValue);
            Assert.Equal(SqlInt16.MaxValue, record.GetSqlInt16(7));

            record.SetSqlInt32(8, SqlInt32.MaxValue);
            Assert.Equal(SqlInt32.MaxValue, record.GetSqlInt32(8));

            record.SetSqlInt64(9, SqlInt64.MaxValue);
            Assert.Equal(SqlInt64.MaxValue, record.GetSqlInt64(9));

            record.SetSqlSingle(10, SqlSingle.MinValue);
            Assert.Equal(SqlSingle.MinValue, record.GetSqlSingle(10));

            record.SetSqlDecimal(11, SqlDecimal.Null);
            record.SetSqlDecimal(11, SqlDecimal.MaxValue);
            Assert.Equal(SqlDecimal.MaxValue, record.GetSqlDecimal(11));

            record.SetSqlMoney(12, SqlMoney.MaxValue);
            Assert.Equal(SqlMoney.MaxValue, record.GetSqlMoney(12));


            // Try adding different values to SqlVariant type
            for (int i = 0; i < record.FieldCount - 1; ++i)
            {
                object valueToSet = record.GetSqlValue(i);
                record.SetValue(record.FieldCount - 1, valueToSet);
                object o = record.GetSqlValue(record.FieldCount - 1);

                if (o is SqlBinary)
                {
                    Assert.Equal <byte>(((SqlBinary)valueToSet).Value, ((SqlBinary)o).Value);
                }
                else
                {
                    Assert.Equal(valueToSet, o);
                }

                record.SetDBNull(record.FieldCount - 1);
                Assert.Equal(DBNull.Value, record.GetSqlValue(record.FieldCount - 1));

                record.SetDBNull(i);
                Assert.Equal(DBNull.Value, record.GetValue(i));
            }
        }
Exemplo n.º 30
0
        IEnumerator <SqlDataRecord> IEnumerable <SqlDataRecord> .GetEnumerator()
        {
            SqlDataRecord ret = new SqlDataRecord(
                new SqlMetaData("Hall_ID", SqlDbType.Int),
                new SqlMetaData("Hall_Name", SqlDbType.VarChar, -1),
                new SqlMetaData("Username", SqlDbType.VarChar, -1),
                new SqlMetaData("Password", SqlDbType.VarChar, -1),
                new SqlMetaData("Email", SqlDbType.VarChar, -1),
                new SqlMetaData("Country", SqlDbType.VarChar, -1),
                new SqlMetaData("City", SqlDbType.VarChar, -1),
                new SqlMetaData("Capacity", SqlDbType.VarChar, -1),
                new SqlMetaData("Amount", SqlDbType.VarChar, -1),
                new SqlMetaData("Type", SqlDbType.VarChar, -1),
                new SqlMetaData("Office_Contact", SqlDbType.VarChar, -1),
                new SqlMetaData("Office_Hours_From", SqlDbType.VarChar, -1),
                new SqlMetaData("Office_Hours_To", SqlDbType.VarChar, -1),
                new SqlMetaData("Website_Url", SqlDbType.VarChar, -1),
                new SqlMetaData("Facebook_Page", SqlDbType.VarChar, -1),
                new SqlMetaData("Longitude", SqlDbType.VarChar, -1),
                new SqlMetaData("Latitude", SqlDbType.VarChar, -1),
                new SqlMetaData("Img1", SqlDbType.VarChar, -1),
                new SqlMetaData("Img2", SqlDbType.VarChar, -1),
                new SqlMetaData("Img3", SqlDbType.VarChar, -1),
                new SqlMetaData("Img4", SqlDbType.VarChar, -1),
                new SqlMetaData("Img5", SqlDbType.VarChar, -1),
                new SqlMetaData("Isactive", SqlDbType.Bit),
                new SqlMetaData("IsAdminAproved", SqlDbType.Bit)
                );

            foreach (Hall data in this)
            {
                if (CheckNullOrEmpty(data.Hall_ID))
                {
                    ret.SetDBNull(0);
                }

                else
                {
                    ret.SetInt32(0, data.Hall_ID);
                }


                if (CheckNullOrEmpty(data.Hall_Name))
                {
                    ret.SetDBNull(1);
                }

                else
                {
                    ret.SetString(1, data.Hall_Name);
                }


                if (CheckNullOrEmpty(data.Username))
                {
                    ret.SetDBNull(2);
                }

                else
                {
                    ret.SetString(2, data.Username);
                }


                if (CheckNullOrEmpty(data.Password))
                {
                    ret.SetDBNull(3);
                }

                else
                {
                    ret.SetString(3, data.Password);
                }


                if (CheckNullOrEmpty(data.Email))
                {
                    ret.SetDBNull(4);
                }

                else
                {
                    ret.SetString(4, data.Email);
                }


                if (CheckNullOrEmpty(data.Country))
                {
                    ret.SetDBNull(5);
                }

                else
                {
                    ret.SetString(5, data.Country);
                }


                if (CheckNullOrEmpty(data.City))
                {
                    ret.SetDBNull(6);
                }

                else
                {
                    ret.SetString(6, data.City);
                }


                if (CheckNullOrEmpty(data.Capacity))
                {
                    ret.SetDBNull(7);
                }

                else
                {
                    ret.SetString(7, data.Capacity);
                }


                if (CheckNullOrEmpty(data.Amount))
                {
                    ret.SetDBNull(8);
                }

                else
                {
                    ret.SetString(8, data.Amount);
                }


                if (CheckNullOrEmpty(data.Type))
                {
                    ret.SetDBNull(9);
                }

                else
                {
                    ret.SetString(9, data.Type);
                }


                if (CheckNullOrEmpty(data.Office_Contact))
                {
                    ret.SetDBNull(10);
                }

                else
                {
                    ret.SetString(10, data.Office_Contact);
                }


                if (CheckNullOrEmpty(data.Office_Hours_From))
                {
                    ret.SetDBNull(11);
                }

                else
                {
                    ret.SetString(11, data.Office_Hours_From);
                }


                if (CheckNullOrEmpty(data.Office_Hours_To))
                {
                    ret.SetDBNull(12);
                }

                else
                {
                    ret.SetString(12, data.Office_Hours_To);
                }


                if (CheckNullOrEmpty(data.Website_Url))
                {
                    ret.SetDBNull(13);
                }

                else
                {
                    ret.SetString(13, data.Website_Url);
                }


                if (CheckNullOrEmpty(data.Facebook_Page))
                {
                    ret.SetDBNull(14);
                }

                else
                {
                    ret.SetString(14, data.Facebook_Page);
                }


                if (CheckNullOrEmpty(data.Longitude))
                {
                    ret.SetDBNull(15);
                }

                else
                {
                    ret.SetString(15, data.Longitude);
                }


                if (CheckNullOrEmpty(data.Latitude))
                {
                    ret.SetDBNull(16);
                }

                else
                {
                    ret.SetString(16, data.Latitude);
                }


                if (CheckNullOrEmpty(data.Img1))
                {
                    ret.SetDBNull(17);
                }

                else
                {
                    ret.SetString(17, data.Img1);
                }


                if (CheckNullOrEmpty(data.Img2))
                {
                    ret.SetDBNull(18);
                }

                else
                {
                    ret.SetString(18, data.Img2);
                }


                if (CheckNullOrEmpty(data.Img3))
                {
                    ret.SetDBNull(19);
                }

                else
                {
                    ret.SetString(19, data.Img3);
                }


                if (CheckNullOrEmpty(data.Img4))
                {
                    ret.SetDBNull(20);
                }

                else
                {
                    ret.SetString(20, data.Img4);
                }


                if (CheckNullOrEmpty(data.Img5))
                {
                    ret.SetDBNull(21);
                }

                else
                {
                    ret.SetString(21, data.Img5);
                }


                if (CheckNullOrEmpty(data.Isactive))
                {
                    ret.SetDBNull(22);
                }

                else
                {
                    ret.SetBoolean(22, (Boolean)data.Isactive);
                }


                if (CheckNullOrEmpty(data.IsAdminAproved))
                {
                    ret.SetDBNull(23);
                }

                else
                {
                    ret.SetBoolean(23, (Boolean)data.IsAdminAproved);
                }

                yield return(ret);
            }
        }