Ejemplo n.º 1
0
        /// <summary>
        /// 将DataRedar转换为List
        /// </summary>
        private List <FoWoSoft.Data.Model.Guid_id> DataReaderToList(SqlDataReader dataReader)
        {
            List <FoWoSoft.Data.Model.Guid_id> List = new List <FoWoSoft.Data.Model.Guid_id>();

            FoWoSoft.Data.Model.Guid_id model = null;
            while (dataReader.Read())
            {
                model        = new FoWoSoft.Data.Model.Guid_id();
                model.id     = dataReader.GetInt32(0);
                model.GuidId = dataReader.GetGuid(1);
                model.useId  = dataReader.GetString(2);
                List.Add(model);
            }
            return(List);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加记录
        /// </summary>
        /// <param name="model">FoWoSoft.Data.Model.Guid_id实体类</param>
        /// <returns>操作所影响的行数</returns>
        public int Add(FoWoSoft.Data.Model.Guid_id model)
        {
            string sql = @" INSERT INTO Guid_id (GuidId, useId) VALUES( @GuidId, @useId)";

            SqlParameter[] parameters = new SqlParameter[] {
                new SqlParameter("@GuidId", SqlDbType.UniqueIdentifier, -1)
                {
                    Value = model.GuidId
                },
                new SqlParameter("@useId", SqlDbType.VarChar, 500)
                {
                    Value = model.useId
                },
            };
            return(dbHelper.Execute(sql, parameters));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 新增
 /// </summary>
 public int Add(FoWoSoft.Data.Model.Guid_id model)
 {
     return(dataGuid_id.Add(model));
 }
Ejemplo n.º 4
0
        //重建组织时用
        public void AddOrganize(DataSet ds)
        {
            FoWoSoft.Platform.Guid_id guidIdService = new FoWoSoft.Platform.Guid_id();
            var dt = ds.Tables[0];

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var dr = dt.Rows[i];
                #region 部门编号转换成GUID
                string id = dr["BMBH"].ToString();

                var  guidId = guidIdService.Get(id);
                Guid org1ID;
                if (guidId == null)
                {
                    org1ID = GetGuid(id);

                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["BMBH"] = org1ID;
                #endregion
                var orgrion = borganize.Get(org1ID);
                if (orgrion != null)
                {
                    continue;
                }
                #region 转上级编号为GUID
                id     = dr["SJBM"].ToString();
                guidId = guidIdService.Get(id);
                if (guidId == null)
                {
                    org1ID = GetGuid(id);
                    //插入对应表guid--id
                    FoWoSoft.Data.Model.Guid_id guidIdModel = new FoWoSoft.Data.Model.Guid_id()
                    {
                        GuidId = org1ID,
                        useId  = id
                    };
                    guidIdService.Add(guidIdModel);
                }
                else
                {
                    org1ID = guidId.GuidId;
                }
                dr["SJBM"] = org1ID;
                #endregion

                #region 插入组织结构
                FoWoSoft.Data.Model.Organize org = new FoWoSoft.Data.Model.Organize();

                org.ID       = Guid.Parse(dr["BMBH"].ToString());
                org.Name     = dr["BMMC"].ToString();
                org.Note     = null;
                org.Number   = ""; // org.Number + "," + org1ID.ToString().ToLower();
                org.ParentID = Guid.Parse(dr["SJBM"].ToString());
                org.Sort     = 0;  // borganize.GetMaxSort(org.ID);
                org.Status   = 0;
                org.Type     = 0;  // type.ToInt();
                org.Depth    = 0;  // org.Depth + 1;

                //using (System.Transactions.TransactionScope scope = new System.Transactions.TransactionScope())
                //  {

                borganize.Add(org);
                //更新父级[ChildsLength]字段
                //borganize.UpdateChildsLength(org.ID);
                // scope.Complete();
                // }
                #endregion
            }
        }