예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        internal static WaterUserCollection CreateLowLevelWaterUserCollection(int currentWaterUserID)
        {
            WaterUserCollection wuc = new WaterUserCollection();
            DataTable           tbl = WaterUserDBI.GetLowLevelWaterUserDataTable(currentWaterUserID);

            foreach (DataRow row in tbl.Rows)
            {
                WaterUserClass u = CreateWaterUser(row);
                wuc.Add(u);
            }
            return(wuc);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static WaterUserCollection CreateManagementWaterUserCollection()
        {
            WaterUserCollection wuc = new WaterUserCollection();
            DataTable           tbl = WaterUserDBI.GetManagementOrganization();

            foreach (DataRow row in tbl.Rows)
            {
                WaterUserClass wu = CreateWaterUser(row);
                wuc.Add(wu);
            }
            return(wuc);
        }
예제 #3
0
파일: WaterUser.cs 프로젝트: wwkkww1983/yh
        /// <summary>
        ///
        /// </summary>
        public void Save()
        {
            bool hasParent;
            int  parentID;

            GetParentID(out hasParent, out parentID);

            if (IsAdd())
            {
                WaterUserDBI.InsertWaterUser(
                    this.Name,
                    this.Remark,
                    this.WaterUserType.WaterUserTypeID,
                    // TODO: parentwater is null
                    //
                    hasParent,
                    parentID,
                    this.WaterUserLevel.WaterUserLevelID);

                this.WaterUserID = WaterUserDBI.GetWaterUserID(this.Name);
            }
            else
            {
                WaterUserDBI.UpdateWaterUser(this.WaterUserID,
                                             this.Name,
                                             this.Remark,
                                             this.WaterUserType.WaterUserTypeID,
                                             hasParent,
                                             parentID,
                                             //this.ParentWaterUser.WaterUserID,
                                             this.WaterUserLevel.WaterUserLevelID);
            }
            // add wateruser channel map
            //
            int[] channelIDs = this.ChannelCollection.GetChannelIDs();
            WaterUserChannelMapDBI.Associate(WaterUserID, channelIDs);

            // add wateruser in device
            //
            int[] inIDs = this.InDeviceCollection.GetDeviceIDs();
            WaterUserInDBI.AssociateWaterUserInDevice(this.WaterUserID, inIDs);

            // add wateruser out device
            //
            int[] outIDs = this.OutDeviceCollection.GetDeviceIDs();
            WaterUserOutDBI.AssociateWaterUserOutDevice(WaterUserID, outIDs);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="waterUserID"></param>
        /// <returns></returns>
        static public WaterUserClass CreateWaterUserByID(int waterUserID)
        {
            WaterUserClass wu = null;

            DataTable tbl = WaterUserDBI.GetWaterUserDataTable(waterUserID);

            if (tbl.Rows.Count > 0)
            {
                DataRow row = tbl.Rows[0];
                //int waterUserID = Convert.ToInt32(row["WaterUserID"]);
                wu = CreateWaterUser(row);
            }
            else
            {
                string err = string.Format("not find water user by id '{0}'", waterUserID);
                log.Error(err);
            }
            return(wu);
        }