Example #1
0
        /// <summary>
        ///  Map a DataRow to a UserGroup Entity.
        /// </summary>
        /// <returns></returns>
        public static UserGroup Row2Entity(System.Data.DataRow row)
        {
            if (row == null) return null;

            UserGroup entity = new UserGroup();

            if (!row.IsNull("Group_ID"))
                entity._groupId = (int)(row["Group_ID"]);
            if (!row.IsNull("Parent_ID"))
                entity._parentId = (int)(row["Parent_ID"]);
            if (!row.IsNull("Name"))
                entity._name = (string)(row["Name"]);
            if (!row.IsNull("Description"))
                entity._description = (string)(row["Description"]);
            if (!row.IsNull("Group_Type"))
                entity._groupType = (UserGroupType)Enum.Parse(typeof(UserGroupType),(row["Group_Type"]).ToString());
            if (!row.IsNull("Group_Level"))
                entity._groupLevel = (short)(row["Group_Level"]);
            if (!row.IsNull("Create_Time"))
                entity._createTime = (DateTime)(row["Create_Time"]);
            if (!row.IsNull("Modify_Time"))
                entity._modifyTime = (DateTime)(row["Modify_Time"]);
            if (!row.IsNull("Create_By"))
                entity._createBy = (int)(row["Create_By"]);
            if (!row.IsNull("Modify_By"))
                entity._modifyBy = (int)(row["Modify_By"]);

            return entity;
        }
Example #2
0
        /// <summary>
        /// Creates the text for the "Last Post" information on a forum listing.
        /// Detects user permissions and disables links if they have none.
        /// </summary>
        /// <param name="row">Current data row</param>
        /// <returns>Formatted "Last Post" text</returns>
        protected string FormatLastPost( System.Data.DataRow row )
        {
            if ( row ["RemoteURL"] != DBNull.Value )
                return "-";

            int ForumID = Convert.ToInt32( row ["ForumID"] );
            // defaults to "no posts" text
            string strTemp = ForumPage.GetText( "NO_POSTS" );

            if ( !row.IsNull( "LastPosted" ) )
            {
                strTemp = ForumPage.GetThemeContents( "ICONS", ( DateTime.Parse( Convert.ToString( row ["LastPosted"] ) ) > Mession.LastVisit ) ? "ICON_NEWEST" : "ICON_LATEST" );

                if ( int.Parse( row ["ReadAccess"].ToString() ) > 0 )
                {
                    strTemp = String.Format( "{0}<br/>{1}<br/>{2}&nbsp;<a title=\"{4}\" href=\"{5}\"><img src=\"{3}\"></a>",
                            ForumPage.FormatDateTimeTopic( ( DateTime ) row ["LastPosted"] ),
                            String.Format( ForumPage.GetText( "in" ), String.Format( "<a href=\"{0}\">{1}</a>", Forum.GetLink( Pages.posts, "t={0}", row ["LastTopicID"] ), Truncate( Utils.BadWordReplace( row ["LastTopicName"].ToString() ), 50 ) ) ),
                            String.Format( ForumPage.GetText( "by" ), String.Format( "<a href=\"{0}\">{1}</a>", Forum.GetLink( Pages.profile, "u={0}", row ["LastUserID"] ), BBCode.EncodeHTML( row ["LastUser"].ToString() ) ) ),
                            strTemp,
                            ForumPage.GetText( "GO_LAST_POST" ),
                            Forum.GetLink( Pages.posts, "m={0}#{0}", row ["LastMessageID"] )
                        );
                }
                else
                {
                    // no access to this forum... disable links
                    strTemp = String.Format("{0}<br/>{1}<br/>{2}",
                            ForumPage.FormatDateTimeTopic((DateTime)row["LastPosted"]),
                            String.Format(ForumPage.GetText("in"), String.Format("{0}", Truncate(row["LastTopicName"].ToString(), 50))),
                            String.Format(ForumPage.GetText("by"), String.Format("<a href=\"{0}\">{1}</a>", Forum.GetLink(Pages.profile, "u={0}", row["LastUserID"]), BBCode.EncodeHTML(row["LastUser"].ToString())))
                        );
                }
            }

            return strTemp;
        }
Example #3
0
        private object GetFieldValue(AutoGeneratedFieldProperties property, object obj, ModelField field, System.Data.DataRow dataRow, out bool notFound)
        {
            notFound = false;
            if (field != null && field.ServerMapping.IsNotEmpty())
            {
                string[] mapping = field.ServerMapping.Split('.');

                if (mapping.Length > 1)
                {
                    for (int i = 0; i < mapping.Length; i++)
                    {
                        if (dataRow != null && dataRow.IsNull(mapping[i]))
                        {
                            return null;
                        }

                        PropertyInfo p = obj.GetType().GetProperty(mapping[i]);
                        if (p == null)
                        {
                            notFound = true;
                            return null;
                        }

                        obj = p.GetValue(obj, null);

                        if (obj == null)
                        {
                            return null;
                        }
                    }

                    return obj;
                }
            }

            if (dataRow == null)
            {
                var prop = TypeDescriptor.GetProperties(obj).Find(property.DataField, true);
                if (prop != null)
                {
                    return prop.GetValue(obj);
                }
            }
            else if(!dataRow.IsNull(property.DataField))
            {
                return dataRow[property.DataField];
            }
            
            notFound = true;
            return null;
        }        
Example #4
0
        /// <summary>
        ///  Map a DataRow to a Operation Entity.
        /// </summary>
        /// <returns></returns>
        public static Operation Row2Entity(System.Data.DataRow row)
        {
            if(row == null) return null;

            Operation entity = new Operation();

            if(!row.IsNull("OPT_ID"))
                    entity._operationId= (int)(row["OPT_ID"]);
            if(!row.IsNull("PARENT_ID"))
                    entity._parentId= (int)(row["PARENT_ID"]);
            if(!row.IsNull("OPT_NAME"))
                    entity._name= (string)(row["OPT_NAME"]);
            if(!row.IsNull("OPT_TYPE"))
                    entity._type= (OperationType)Enum.Parse(typeof(OperationType),(row["OPT_TYPE"]).ToString());
            if(!row.IsNull("OPT_DESC"))
                    entity._description= (string)(row["OPT_DESC"]);
            if (!row.IsNull("OPT_ENTRY"))
                entity._entry = Cast.String(row["OPT_ENTRY"]);
            entity._seqNo = Cast.Int(row["OPT_SEQNUM"]);
            entity._image = Cast.String(row["OPT_IMAGE"]);
            entity._level = Cast.Int(row["OPT_LEVEL"]);

               return entity;
        }
Example #5
0
        /// <summary>
        ///  Map a DataRow to a Permission Entity.
        /// </summary>
        /// <returns></returns>
        public static Permission Row2Entity(System.Data.DataRow row)
        {
            if(row == null) return null;

            Permission entity = new Permission();

            if(!row.IsNull("PERM_ID"))
                    entity._permissionId= (int)(row["PERM_ID"]);
            if(!row.IsNull("OPT_ID"))
                    entity._operationId= (int)(row["OPT_ID"]);
            if(!row.IsNull("PERM_TYPE"))
                    entity._type= (PermissionType)Enum.Parse(typeof(PermissionType),(row["PERM_TYPE"]).ToString());
            if(!row.IsNull("USR_ID"))
                    entity._userId= (int)(row["USR_ID"]);
            if(!row.IsNull("UGP_ID"))
                    entity._groupId= (int)(row["UGP_ID"]);
            if(!row.IsNull("PERM_ALLOW"))
                    entity._isAllow= (bool)(row["PERM_ALLOW"]);
            if(!row.IsNull("CREATE_TIME"))
                    entity._createTime= (DateTime)(row["CREATE_TIME"]);
            if(!row.IsNull("CREATE_BY"))
                    entity._createBy= (int)(row["CREATE_BY"]);

               return entity;
        }
 private FixedSummServiceView Load(System.Data.DataRow row)
 {
     return new FixedSummServiceView { CanBeIncluded = System.Convert.ToBoolean(row.get_Item("canBeIncluded")), Include = false, FlatNumber = row.IsNull("flatNumber") ? string.Empty : ((string) ((string) row.get_Item("flatNumber"))), ApartmentNumber = row.IsNull("apartmentNumber") ? string.Empty : ((string) ((string) row.get_Item("apartmentNumber"))), Abonent = row.IsNull("accountOwner") ? string.Empty : ((string) ((string) row.get_Item("accountOwner"))), OwnershipType = row.IsNull("ownershipTypeName") ? string.Empty : ((string) ((string) row.get_Item("ownershipTypeName"))), MonthCount = row.IsNull("monthCount") ? ((int) 0) : ((int) ((int) row.get_Item("monthCount"))), ChargeSumm = (decimal) row.get_Item("chargeSumm"), IsNew = System.Convert.ToBoolean(row.get_Item("isNew")), AccountId = (long) ((long) row.get_Item("accountId")), FromDate = row.IsNull("fromDate") ? Constants.NullDate : ((System.DateTime) row.get_Item("fromDate")), AccountServiceId = row.IsNull("accountServiceId") ? ((long) 0L) : ((long) ((long) row.get_Item("accountServiceId"))) };
 }
Example #7
0
        private void FillDeadline(System.Data.DataRow row)
        {
            FillEventsComboBox();

            if (!row.IsNull("deadline_id"))
            {
                long deadlineID = (long) row["deadline_id"];

                using (var automatic = new AutomaticOpenClose(connection))
                {
                    var command = new System.Data.SQLite.SQLiteCommand("SELECT deadlines.deadline, events.ID FROM deadlines LEFT JOIN events ON deadlines.ID=events.deadline_id WHERE [email protected]", connection);
                    command.Parameters.Add(new System.Data.SQLite.SQLiteParameter("@id", deadlineID));

                    var reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        DeadlineDatePicker.SelectedDate = reader.GetDateTime(0);
                        if (reader.IsDBNull(1))
                        {
                            DeadlineIsSelectedDateRadioButton.IsChecked = true;
                        }
                        else
                        {
                            DeadlineIsEventRadioButton.IsChecked = true;
                            EventsComboBox.SelectedValue = reader.GetInt64(1);
                        }
                    }
                }
            }
        }
Example #8
0
        protected string FormatLastPost( System.Data.DataRow row )
        {
            if ( !row.IsNull( "LastPosted" ) )
            {
                string minipost;
                if ( DateTime.Parse( row ["LastPosted"].ToString() ) > Mession.LastVisit )
                    minipost = GetThemeContents( "ICONS", "ICON_NEWEST" );
                else
                    minipost = GetThemeContents( "ICONS", "ICON_LATEST" );

                return String.Format( "{0}<br/>{1}<br/>{2}&nbsp;<a title=\"{4}\" href=\"{5}\"><img src='{3}'></a>",
                    FormatDateTimeTopic( Convert.ToDateTime( row ["LastPosted"] ) ),
                    String.Format( GetText( "in" ), String.Format( "<a href=\"{0}\">{1}</a>", Forum.GetLink( Pages.posts, "t={0}", row ["LastTopicID"] ), row ["LastTopicName"] ) ),
                    String.Format( GetText( "by" ), String.Format( "<a href=\"{0}\">{1}</a>", Forum.GetLink( Pages.profile, "u={0}", row ["LastUserID"] ), row ["LastUser"] ) ),
                    minipost,
                    GetText( "GO_LAST_POST" ),
                    Forum.GetLink( Pages.posts, "m={0}#{0}", row ["LastMessageID"] )
                    );
            }
            else
                return GetText( "NO_POSTS" );
        }
Example #9
0
 public void Load(System.Data.DataRow row, Role owid)
 {
     owid.Id = row.IsNull("id") ? ((int) 0) : ((int) ((int) row.get_Item("id")));
     owid.Right = row.IsNull("name") ? string.Empty : ((string) ((string) row.get_Item("name")));
     owid.TypeRight = row.IsNull("name") ? RightTypesEnum.Пусто : ((RightTypesEnum) ((int) row.get_Item("TypeId")));
 }
Example #10
0
        private object GetFieldValue(AutoGeneratedFieldProperties property, object obj, RecordField field, System.Data.DataRow dataRow)
        {
            if (field != null && field.ServerMapping.IsNotEmpty())
            {
                string[] mapping = field.ServerMapping.Split('.');

                if (mapping.Length > 1)
                {
                    for (int i = 0; i < mapping.Length; i++)
                    {
                        if (dataRow != null && dataRow.IsNull(mapping[i]))
                        {
                            return null;
                        }
                        
                        PropertyInfo p = obj.GetType().GetProperty(mapping[i]);
                        try
                        {
                            obj = p.GetValue(obj, null);
                        }
                        catch (NullReferenceException e)
                        {
                            throw new NullReferenceException(String.Format("Mapped property '{0}' doesn't exist", mapping[i]));
                        }
                        
                        if (obj == null)
                        {
                            return null;
                        }
                    }

                    return obj;
                }
            }

            return (dataRow != null && dataRow.IsNull(property.DataField)) ? null : DataBinder.GetPropertyValue(obj, property.DataField);
        }
Example #11
0
        private void FillDeadline(System.Data.DataRow row)
        {
            if (!row.IsNull("deadline_id"))
            {
                long deadlineID = (long)row["deadline_id"];

                using (var automatic = new AutomaticOpenClose(connection))
                {
                    var command = new System.Data.SQLite.SQLiteCommand("SELECT deadlines.deadline, events.ID FROM deadlines LEFT JOIN events ON deadlines.ID=events.deadline_id WHERE [email protected]", connection);
                    command.Parameters.Add(new System.Data.SQLite.SQLiteParameter("@id", deadlineID));

                    var reader = command.ExecuteReader();

                    if (reader.Read())
                    {
                        DeadlineDatePicker.SelectedDate = reader.GetDateTime(0);
                    }
                }
            }
        }
Example #12
0
        /// <summary>
        ///  Map a DataRow to a User Entity.
        /// </summary>
        /// <returns></returns>
        public static User Row2Entity(System.Data.DataRow row)
        {
            if (row == null) return null;

            User entity = new User();

            if (!row.IsNull("USR_ID"))
                entity._userId = (int)(row["USR_ID"]);
            if (!row.IsNull("USR_LOGIN_ID"))
                entity._userName = (string)(row["USR_LOGIN_ID"]);
            if (!row.IsNull("USR_PSW"))
                entity._password = (string)(row["USR_PSW"]);
            if (!row.IsNull("USR_NAME"))
                entity._fullName = (string)(row["USR_NAME"]);
            if (!row.IsNull("USR_TYPE"))
                entity._userType =(OrgType)Enum.Parse(typeof(OrgType),(row["USR_TYPE"]).ToString());
            if (!row.IsNull("USR_EMAIL"))
                entity._email = (string)(row["USR_EMAIL"]);
            if (!row.IsNull("USR_GENDER"))
                entity._gender = (bool)(row["USR_GENDER"]);
            if (!row.IsNull("USR_WORK_NUM"))
                entity._employeeNo = (string)(row["USR_WORK_NUM"]);
            if (!row.IsNull("USR_EXT"))
                entity._ext = (string)(row["USR_EXT"]);
            if (!row.IsNull("USR_MOBILE"))
                entity._mobile = (string)(row["USR_MOBILE"]);
            if (!row.IsNull("USR_HOME_PHONE"))
                entity._homePhone = (string)(row["USR_HOME_PHONE"]);
            if (!row.IsNull("USR_HOME_ADDR"))
                entity._homeAddress = (string)(row["USR_HOME_ADDR"]);
            if (!row.IsNull("USR_BIRTHDAY"))
                entity._birthday = (DateTime)(row["USR_BIRTHDAY"]);
            if (!row.IsNull("USR_NOTE"))
                entity._note = (string)(row["USR_NOTE"]);
            if (!row.IsNull("USR_STATUS"))
                entity._status = (UserStatus)Enum.Parse(typeof(UserStatus),(row["USR_STATUS"]).ToString());
            if (!row.IsNull("ORG_ID"))
                entity._orgId = (int)(row["ORG_ID"]);
            if (!row.IsNull("LAST_LOGIN"))
                entity._lastLogonTime = (DateTime)(row["LAST_LOGIN"]);
            if (!row.IsNull("CREATE_TIME"))
                entity._createTime = (DateTime)(row["CREATE_TIME"]);
            if (!row.IsNull("CREATE_BY"))
                entity._createBy = (int)(row["CREATE_BY"]);
            if (!row.IsNull("MODIFY_BY"))
                entity._modifyBy = (int)(row["MODIFY_BY"]);
            if (!row.IsNull("MODIFY_TIME"))
                entity._modifyTime = (DateTime)(row["MODIFY_TIME"]);

            return entity;
        }
Example #13
0
 private Faset Load(System.Data.DataRow row)
 {
     return new Faset { Id = System.Convert.ToInt32(row.get_Item("id")), Name = row.get_Item("name").ToString(), IsSystem = row.IsNull("isSystem") ? ((bool) false) : ((bool) ((bool) row.get_Item("isSystem"))), Type = row.IsNull("type") ? string.Empty : ((string) ((string) row.get_Item("type"))) };
 }