Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="row"></param>
        /// <returns></returns>
        private static WaterUserClass CreateWaterUser(DataRow row)
        {
            int    waterUserID      = Convert.ToInt32(row["WaterUserID"]);
            int    waterUserLevelID = Convert.ToInt32(row["WaterUserLevelID"]);
            int    wuTypeID         = Convert.ToInt32(row["WaterUserTypeID"]);
            string name             = row["WaterUserName"].ToString();
            string remark           = row["remark"].ToString();
            float  unitPrice        = GetUnitPriceFromDataRow(row);


            // TODO: 2011-04-08
            // parent wateruser, wulevel, indevice ...
            // init at get property
            //
            // 2. dead loop
            //
            //WaterUserClass parentWaterUser = null;
            //object parentObject = row["ParentWaterUserID"];
            //if (parentObject != DBNull.Value)
            //{
            //    int parentID = Convert.ToInt32(row["ParentWaterUserID"]);
            //    if (parentID != waterUserID)
            //    {
            //        parentWaterUser = CreateWaterUserByID(parentID);
            //    }
            //}
            //wu.ParentWaterUser = CreateWaterUserByID(parentID);
            //wu.ParentWaterUser = parentWaterUser;

            WaterUserLevel wuLevel = WaterUserLevelFactory.CreateWaterUserLevelByID(waterUserLevelID);
            //WaterUserType
            WaterUserType wuType = WaterUserTypeFactory.CreateWaterUserTypeByID(wuTypeID);

            WaterUserClass wu = new WaterUserClass();

            wu.Name           = name;
            wu.WaterUserID    = waterUserID;
            wu.WaterUserLevel = wuLevel;
            wu.WaterUserType  = wuType;
            wu.Remark         = remark;
            wu.UnitPrice      = unitPrice;


            wu.ChannelCollection = ChannelFactory.CreateChannelCollection(waterUserID);

            //wu.InStationCollection
            //wu.InDeviceCollection = CreateInDevice
            //wu.OutStationCollection

            //wu.InDeviceCollection = DeviceFactory.CreateInDeviceCollection(waterUserID);
            //wu.OutDeviceCollection = DeviceFactory.CreateOutDeviceCollection(waterUserID);

            return(wu);
        }
Exemplo n.º 2
0
        //#region CreateJu
        ///// <summary>
        /////
        ///// </summary>
        ///// <returns></returns>
        //static public WaterUser CreateJu()
        //{
        //    // TODO:
        //    //
        //    return new WaterUser(null);
        //}
        //#endregion //CreateJu

        // TODO:
        // chu
        //


        #region CreateWaterUser
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        static public WaterUserClass CreateWaterUser(WaterUserLevel level)
        {
            if (level == null)
            {
                throw new ArgumentNullException("level");
            }

            WaterUserClass wu = new WaterUserClass();

            wu.WaterUserLevel = level;
            //wu.WaterUserType = WaterUserTypeFactory.CreateDefaultWaterUserType(level);
            //WaterUserType.GetManagerWaterUserType
            wu.WaterUserType = WaterUserTypeFactory.GetDefaultWaterUserType(level);
            return(wu);
        }