Exemple #1
0
	public static int Main ()
	{
		Guid Id = Guid.NewGuid ();
		DC dc = new DC (Id);
		Console.WriteLine ("id: {0} default: {1}", Id, default (Guid));
		if (dc.Id.Equals (default (Guid)))
			return 1;

		return 0;
	}
Exemple #2
0
    public static void Main()
    {
        BC b;
        b = new BC();
        b.Display();
        Console.WriteLine("BC");

        b = new DC();
        b.Display();
        Console.WriteLine("DC");
        Console.Read();
        Console.WriteLine("Press Enter to terminate...");
        Console.Read();
    }
    static void Main()
    {
        Console.WriteLine("Overloading");
        Foo(105);
        Foo(18039932103);

        //Overriding
        Console.WriteLine("");
        Console.WriteLine("Overriding");
        BC b;
        b = new BC();
        b.Display();

        b = new DC();
        b.Display();

        b = new TC();
        b.Display();
        Console.Read();
    }
Exemple #4
0
 public ActionResult GetFrameworkGroups()
 {
     return(Ok(DC.Set <FrameworkGroup>().GetSelectListItems(Wtm, x => x.GroupName)));
 }
Exemple #5
0
        private void DoEditPrepare(bool updateAllFields)
        {
            if (typeof(TModel).GetTypeInfo().IsSubclassOf(typeof(BasePoco)))
            {
                BasePoco ent = Entity as BasePoco;
                if (ent.UpdateTime == null)
                {
                    ent.UpdateTime = DateTime.Now;
                }
                if (string.IsNullOrEmpty(ent.UpdateBy))
                {
                    ent.UpdateBy = LoginUserInfo?.ITCode;
                }
            }
            var pros = typeof(TModel).GetProperties();

            #region 更新子表
            foreach (var pro in pros)
            {
                //找到类型为List<xxx>的字段
                if (pro.PropertyType.GenericTypeArguments.Count() > 0)
                {
                    //获取xxx的类型
                    var ftype = pro.PropertyType.GenericTypeArguments.First();
                    //如果xxx继承自TopBasePoco
                    if (ftype.IsSubclassOf(typeof(TopBasePoco)))
                    {
                        //界面传过来的子表数据

                        if (pro.GetValue(Entity) is IEnumerable <TopBasePoco> list && list.Count() > 0)
                        {
                            //获取外键字段名称
                            string         fkname   = DC.GetFKName <TModel>(pro.Name);
                            PropertyInfo[] itemPros = ftype.GetProperties();

                            bool found = false;
                            foreach (var newitem in list)
                            {
                                var subtype = newitem.GetType();
                                if (subtype.IsSubclassOf(typeof(BasePoco)))
                                {
                                    BasePoco ent = newitem as BasePoco;
                                    if (ent.UpdateTime == null)
                                    {
                                        ent.UpdateTime = DateTime.Now;
                                    }
                                    if (string.IsNullOrEmpty(ent.UpdateBy))
                                    {
                                        ent.UpdateBy = LoginUserInfo?.ITCode;
                                    }
                                }
                                //循环页面传过来的子表数据,将关联到TopBasePoco的字段设为null,并且把外键字段的值设定为主表ID
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(newitem, null);
                                    }
                                    if (!string.IsNullOrEmpty(fkname))
                                    {
                                        if (itempro.Name.ToLower() == fkname.ToLower())
                                        {
                                            itempro.SetValue(newitem, Entity.GetID());
                                            found = true;
                                        }
                                    }
                                }
                            }
                            //如果没有找到相应的外建字段,则可能是多对多的关系,或者做了特殊的设定,这种情况框架无法支持,直接退出本次循环
                            if (found == false)
                            {
                                continue;
                            }


                            TModel _entity = null;
                            //打开新的数据库联接,获取数据库中的主表和子表数据
                            using (var ndc = DC.CreateNew())
                            {
                                _entity = ndc.Set <TModel>().Include(pro.Name).AsNoTracking().CheckID(Entity.GetID()).FirstOrDefault();
                            }
                            //比较子表原数据和新数据的区别
                            IEnumerable <TopBasePoco> toadd    = null;
                            IEnumerable <TopBasePoco> toremove = null;
                            IEnumerable <TopBasePoco> data     = _entity.GetType().GetProperty(pro.Name).GetValue(_entity) as IEnumerable <TopBasePoco>;
                            Utils.CheckDifference(data, list, out toremove, out toadd);
                            //设定子表应该更新的字段
                            List <string> setnames = new List <string>();
                            foreach (var field in FC.Keys)
                            {
                                if (field.StartsWith("Entity." + pro.Name + "[0]."))
                                {
                                    string name = field.Replace("Entity." + pro.Name + "[0].", "");
                                    setnames.Add(name);
                                }
                            }

                            //前台传过来的数据
                            foreach (var newitem in list)
                            {
                                //数据库中的数据
                                foreach (var item in data)
                                {
                                    //需要更新的数据
                                    if (newitem.GetID().ToString() == item.GetID().ToString())
                                    {
                                        dynamic i           = newitem;
                                        var     newitemType = item.GetType();
                                        foreach (var itempro in itemPros)
                                        {
                                            if (!itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)) && (updateAllFields == true || setnames.Contains(itempro.Name)))
                                            {
                                                var notmapped = itempro.GetCustomAttribute <NotMappedAttribute>();
                                                if (itempro.Name != "ID" && notmapped == null && itempro.PropertyType.IsList() == false)
                                                {
                                                    DC.UpdateProperty(i, itempro.Name);
                                                }
                                            }
                                        }
                                        if (item.GetType().IsSubclassOf(typeof(BasePoco)))
                                        {
                                            DC.UpdateProperty(i, "UpdateTime");
                                            DC.UpdateProperty(i, "UpdateBy");
                                        }
                                    }
                                }
                            }
                            //需要删除的数据
                            foreach (var item in toremove)
                            {
                                //如果是PersistPoco,则把IsValid设为false,并不进行物理删除
                                if (ftype.IsSubclassOf(typeof(PersistPoco)))
                                {
                                    (item as PersistPoco).IsValid    = false;
                                    (item as PersistPoco).UpdateTime = DateTime.Now;
                                    (item as PersistPoco).UpdateBy   = LoginUserInfo?.ITCode;
                                    dynamic i = item;
                                    DC.UpdateEntity(i);
                                }
                                else
                                {
                                    foreach (var itempro in itemPros)
                                    {
                                        if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                        {
                                            itempro.SetValue(item, null);
                                        }
                                    }
                                    dynamic i = item;
                                    DC.DeleteEntity(i);
                                }
                            }
                            //需要添加的数据
                            foreach (var item in toadd)
                            {
                                if (item.GetType().IsSubclassOf(typeof(BasePoco)))
                                {
                                    BasePoco ent = item as BasePoco;
                                    if (ent.CreateTime == null)
                                    {
                                        ent.CreateTime = DateTime.Now;
                                    }
                                    if (string.IsNullOrEmpty(ent.CreateBy))
                                    {
                                        ent.CreateBy = LoginUserInfo?.ITCode;
                                    }
                                }
                                DC.AddEntity(item);
                            }
                        }
                        else if (FC.Keys.Contains("Entity." + pro.Name + ".DONOTUSECLEAR") || (pro.GetValue(Entity) is IEnumerable <TopBasePoco> list2 && list2?.Count() == 0))
                        {
                            PropertyInfo[] itemPros = ftype.GetProperties();
                            var            _entity  = DC.Set <TModel>().Include(pro.Name).AsNoTracking().CheckID(Entity.GetID()).FirstOrDefault();
                            if (_entity != null)
                            {
                                IEnumerable <TopBasePoco> removeData = _entity.GetType().GetProperty(pro.Name).GetValue(_entity) as IEnumerable <TopBasePoco>;
                                //如果是PersistPoco,则把IsValid设为false,并不进行物理删除
                                if (removeData is IEnumerable <PersistPoco> removePersistPocoData)
                                {
                                    foreach (var item in removePersistPocoData)
                                    {
                                        (item as PersistPoco).IsValid    = false;
                                        (item as PersistPoco).UpdateTime = DateTime.Now;
                                        (item as PersistPoco).UpdateBy   = LoginUserInfo?.ITCode;
                                        dynamic i = item;
                                        DC.UpdateEntity(i);
                                    }
                                }
                                else
                                {
                                    foreach (var item in removeData)
                                    {
                                        foreach (var itempro in itemPros)
                                        {
                                            if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                            {
                                                itempro.SetValue(item, null);
                                            }
                                        }
                                        dynamic i = item;
                                        DC.DeleteEntity(i);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion


            if (updateAllFields == false)
            {
                foreach (var field in FC.Keys)
                {
                    if (field.StartsWith("Entity.") && !field.Contains("["))
                    {
                        string name = field.Replace("Entity.", "");
                        try
                        {
                            DC.UpdateProperty(Entity, name);
                        }
                        catch (Exception ea)
                        {
                        }
                    }
                }
                if (typeof(TModel).GetTypeInfo().IsSubclassOf(typeof(BasePoco)))
                {
                    try
                    {
                        DC.UpdateProperty(Entity, "UpdateTime");
                        DC.UpdateProperty(Entity, "UpdateBy");
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            else
            {
                DC.UpdateEntity(Entity);
            }
        }
Exemple #6
0
 public void ReflectToView()
 {
     DC.PushToView();
 }
Exemple #7
0
 public ActionResult GetMajorInfos()
 {
     return(Ok(DC.Set <MajorInfo>().GetSelectListItems(Wtm, x => x.Name)));
 }
Exemple #8
0
 public IQueryable <TModel> GetBaseQuery()
 {
     return(DC.Set <TModel>());
 }
Exemple #9
0
        /// 添加一个T类型的实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool AddEntity(T entity)
        {
            CurrentDal.AddEntity(entity);

            return(DC.SaveChange() > 0);
        }
Exemple #10
0
 public bool UpdateEntity(T entity)
 {
     CurrentDal.UpdateEntity(entity);
     return(DC.SaveChange() > 0);
 }
        public static string InsertDC(string DCName, int IsActive)
        {
            DCManagementBLL objRoleManagementBLL = null;
            string outResult = string.Empty;
               // bool isFlag = false;
            try
            {
                DC dc = new DC();
                dc.DCName = DCName;
                dc.IsActive = IsActive;
                objRoleManagementBLL = new DCManagementBLL();
                dc.CreatedBy = GetCurrentUserName();
                outResult = objRoleManagementBLL.InsertDC(dc);

            }
            catch (Exception ex)
            {
                // Log the error to a text file in the Error folder
                Common.WriteError(ex);
            }
            finally
            {
                objRoleManagementBLL = null;
            }

            return outResult;
        }
        public ActionResult GetUserById(string keywords)
        {
            var users = DC.Set <FrameworkUserBase>().Where(x => x.ITCode.ToLower().StartsWith(keywords.ToLower())).GetSelectListItems(LoginUserInfo.DataPrivileges, null, x => x.CodeAndName, x => x.ITCode);

            return(Json(users));
        }
        public string UpdateDC(DC roledetail)
        {
            ObjSqlHelper = new SqlHelper.SqlHelper();

            string proc_name = ConstantsDLL.USP_UPDATEDC;
            SqlParameter[] param = new SqlParameter[5];

            param[0] = new SqlParameter("@DCId", roledetail.DCID);
            param[1] = new SqlParameter("@IsActive", roledetail.IsActive);
            param[2] = new SqlParameter("@ModifyBy", roledetail.ModifiedBy);
            param[3] = new SqlParameter("@DCName", roledetail.DCName);
            string Result = "";
            param[4] = new SqlParameter("@Result", SqlDbType.VarChar, 50, Result);
            param[4].Direction = ParameterDirection.Output;

            using (SqlHelper.SqlHelper db = new SqlHelper.SqlHelper())
              //  ObjSqlHelper.ExecNonQueryProc(proc_name, param);

            {
                db.ExecNonQueryProc(proc_name, param);
            }
            Result = Convert.ToString(param[4].Value);
            return Result;

               // return true;
        }
Exemple #14
0
 public ActionResult GetFrameworkRoles()
 {
     return(Ok(DC.Set <FrameworkRole>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, x => x.RoleName)));
 }
        public string InsertDC(DC roledetail)
        {
            string outResult = string.Empty;
            ObjSqlHelper = new SqlHelper.SqlHelper();

            string proc_name = ConstantsDLL.USP_INSERTDC;
            SqlParameter[] param = new SqlParameter[4];

            param[0] = new SqlParameter("@DCName", roledetail.DCName);
            param[1] = new SqlParameter("@IsActive", roledetail.IsActive);
            param[2] = new SqlParameter("@CreatedBy", roledetail.CreatedBy);
            param[3] = new SqlParameter("@Result", outResult);
            param[3].Direction = ParameterDirection.Output;
            ObjSqlHelper.ExecNonQueryProc(proc_name, param);
            outResult = Convert.ToString(param[3].Value);

               // ObjSqlHelper.ExecNonQueryProc(proc_name, param);

            return outResult;
        }
        public static string UpdateDC(DC roledetail)
        {
            string isFlag = string.Empty;
            DCManagementBLL objRoleManagementBLL = null;
              //  bool isFlag = false;
            try
            {
                objRoleManagementBLL = new DCManagementBLL();
                roledetail.ModifiedBy = GetCurrentUserName();

                isFlag = objRoleManagementBLL.UpdateDC(roledetail);

            }
            catch (Exception ex)
            {
                // Log the error to a text file in the Error folder
                Common.WriteError(ex);
            }
            finally
            {
                objRoleManagementBLL = null;
            }

            return isFlag;
        }
        /// <summary>
        /// Method to Update DC
        /// </summary>
        /// <returns></returns>
        public string UpdateDC(DC roledetail)
        {
            string isFlag = string.Empty;
              //  bool isFlag = false;
            DCManagementDLL objrolemanagement = null;
            try
            {
                objrolemanagement = new DCManagementDLL();
                isFlag = objrolemanagement.UpdateDC(roledetail);
                return isFlag;

            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                objrolemanagement = null;

            }
        }
        /// <summary>
        /// Method to Insert DC
        /// </summary>
        /// <returns></returns>
        public string InsertDC(DC roledetail)
        {
            //bool isFlag = false;
            string outResult = string.Empty;
            DCManagementDLL objrolemanagement = null;

            try
            {
                objrolemanagement = new DCManagementDLL();
                outResult = objrolemanagement.InsertDC(roledetail);
                return outResult;

            }
            catch (Exception e)
            {
                throw;
            }
            finally
            {
                objrolemanagement = null;

            }
        }
Exemple #19
0
 public bool BitBlt(int x, int y, int nWidth, int nHeight, DC hSrcDC, int xSrc, int ySrc, int dwRop)
 {
     return NativeMethods.BitBlt(this.IntPtr, x, y, nWidth, nHeight, hSrcDC.IntPtr, xSrc, ySrc, dwRop);
 }
 public SeperateSaveData(string loc, string name, DC.SaveMethod save, DC.LoadMethod load)
     : base(save, load)
 {
     SaveLocation = loc;
     SaveName = name;
     CustomSaving.AddSeperateSave(this);
 }
Exemple #21
0
        public override void DoEdit(bool updateAllFields = false)
        {
            if (Entity.IsInside == false)
            {
                if (Entity.Url != null && Entity.Url != "")
                {
                    if (Entity.DomainId == null)
                    {
                        if (Entity.Url.ToLower().StartsWith("http://") == false && Entity.Url.ToLower().StartsWith("https://") == false)
                        {
                            Entity.Url = "http://" + Entity.Url;
                        }
                    }
                    else
                    {
                        if (Entity.Url.StartsWith("/") == false)
                        {
                            Entity.Url = "/" + Entity.Url;
                        }
                    }
                }
            }
            else
            {
                if (string.IsNullOrEmpty(SelectedModule) == true && Entity.FolderOnly == false)
                {
                    MSD.AddModelError("SelectedModule", "请选择一个模块");
                    return;
                }
                if (string.IsNullOrEmpty(SelectedModule) == false && Entity.FolderOnly == false)
                {
                    var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule;
                    List <FrameworkAction> otherActions = null;
                    var mainAction = modules.Where(x => x.FullName == this.SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName == "Index").SingleOrDefault();
                    if (mainAction == null && Entity.ShowOnMenu == true)
                    {
                        MSD.AddModelError("Entity.ModuleId", "模块中没有找到Index页面");
                        return;
                    }
                    if (mainAction == null && Entity.ShowOnMenu == false)
                    {
                        var model = modules.Where(x => x.FullName == this.SelectedModule).FirstOrDefault();
                        mainAction            = new FrameworkAction();
                        mainAction.Module     = model;
                        mainAction.MethodName = "Index";
                    }
                    var ndc    = DC.ReCreate();
                    var oldIDs = ndc.Set <FrameworkMenu>().Where(x => x.ParentId == Entity.ID).Select(x => x.ID).ToList();
                    foreach (var oldid in oldIDs)
                    {
                        try
                        {
                            FrameworkMenu fp = new FrameworkMenu {
                                ID = oldid
                            };
                            ndc.Set <FrameworkMenu>().Attach(fp);
                            ndc.DeleteEntity(fp);
                        }
                        catch { }
                    }
                    ndc.SaveChanges();

                    Entity.Url        = mainAction.Url;
                    Entity.ModuleName = mainAction.Module.ModuleName;
                    Entity.ClassName  = mainAction.Module.ClassName;
                    Entity.MethodName = "Index";

                    otherActions = modules.Where(x => x.FullName == this.SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index").ToList();
                    int order = 1;
                    foreach (var action in otherActions)
                    {
                        if (SelectedActionIDs != null && SelectedActionIDs.Contains(action.Url))
                        {
                            FrameworkMenu menu = new FrameworkMenu();
                            menu.FolderOnly   = false;
                            menu.IsPublic     = false;
                            menu.Parent       = Entity;
                            menu.ShowOnMenu   = false;
                            menu.DisplayOrder = order++;
                            menu.Privileges   = new List <FunctionPrivilege>();
                            menu.CreateBy     = LoginUserInfo.ITCode;
                            menu.CreateTime   = DateTime.Now;
                            menu.IsInside     = true;
                            menu.DomainId     = Entity.DomainId;
                            menu.PageName     = action.ActionName;
                            menu.ModuleName   = action.Module.ModuleName;
                            menu.ActionName   = action.ActionName;
                            menu.Url          = action.Url;
                            Entity.Children.Add(menu);
                        }
                    }
                }

                else
                {
                    Entity.Children = null;
                    Entity.Url      = null;
                }
            }
            base.DoEdit();
            List <Guid> guids = new List <Guid>();

            guids.Add(Entity.ID);
            if (Entity.Children != null)
            {
                guids.AddRange(Entity.Children?.Select(x => x.ID).ToList());
            }
            AddPrivilege(guids);
        }
Exemple #22
0
 protected override void InitVM()
 {
     AllLocations = DC.Set <City>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, y => y.Name);
 }
        /// <summary>
        /// 修改,进行默认的修改操作。子类如有自定义操作应重载本函数
        /// </summary>
        public virtual void DoEdit(bool updateAllFields = false)
        {
            //自动设定修改日期和修改人
            if (typeof(TModel).GetTypeInfo().IsSubclassOf(typeof(BasePoco)))
            {
                BasePoco ent = Entity as BasePoco;
                if (ent.UpdateTime == null)
                {
                    ent.UpdateTime = DateTime.Now;
                }
                if (string.IsNullOrEmpty(ent.UpdateBy))
                {
                    ent.UpdateBy = LoginUserInfo?.ITCode;
                }
            }
            var pros = typeof(TModel).GetProperties();

            #region 更新子表
            foreach (var pro in pros)
            {
                //找到类型为List<xxx>的字段
                if (pro.PropertyType.GenericTypeArguments.Count() > 0)
                {
                    //获取xxx的类型
                    var ftype = pro.PropertyType.GenericTypeArguments.First();
                    //如果xxx继承自TopBasePoco
                    if (ftype.IsSubclassOf(typeof(TopBasePoco)))
                    {
                        //界面传过来的子表数据

                        if (pro.GetValue(Entity) is IEnumerable <TopBasePoco> list && list.Count() > 0)
                        {
                            //获取外键字段名称
                            string         fkname   = DC.GetFKName <TModel>(pro.Name);
                            PropertyInfo[] itemPros = ftype.GetProperties();

                            bool found = false;
                            foreach (var newitem in list)
                            {
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(newitem, null);
                                    }
                                    if (!string.IsNullOrEmpty(fkname))
                                    {
                                        if (itempro.Name.ToLower() == fkname.ToLower())
                                        {
                                            itempro.SetValue(newitem, Entity.ID);
                                            found = true;
                                        }
                                    }
                                }
                            }
                            //如果没有找到相应的外建字段,则可能是多对多的关系,或者做了特殊的设定,这种情况框架无法支持,直接退出本次循环
                            if (found == false)
                            {
                                continue;
                            }


                            //循环页面传过来的子表数据,将关联到TopBasePoco的字段设为null,并且把外键字段的值设定为主表ID
                            foreach (var newitem in list)
                            {
                                var subtype = newitem.GetType();
                                if (subtype.IsSubclassOf(typeof(BasePoco)))
                                {
                                    BasePoco ent = newitem as BasePoco;
                                    if (ent.UpdateTime == null)
                                    {
                                        ent.UpdateTime = DateTime.Now;
                                    }
                                    if (string.IsNullOrEmpty(ent.UpdateBy))
                                    {
                                        ent.UpdateBy = LoginUserInfo.ITCode;
                                    }
                                }
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(newitem, null);
                                    }
                                    if (!string.IsNullOrEmpty(fkname))
                                    {
                                        if (itempro.Name.ToLower() == fkname.ToLower())
                                        {
                                            itempro.SetValue(newitem, Entity.ID);
                                            found = true;
                                        }
                                    }
                                }
                            }
                            TModel _entity = null;
                            //打开新的数据库联接,获取数据库中的主表和子表数据
                            using (var ndc = DC.CreateNew())
                            {
                                _entity = ndc.Set <TModel>().Include(pro.Name).AsNoTracking().Where(x => x.ID == Entity.ID).FirstOrDefault();
                            }
                            //比较子表原数据和新数据的区别
                            IEnumerable <TopBasePoco> toadd    = null;
                            IEnumerable <TopBasePoco> toremove = null;
                            IEnumerable <TopBasePoco> data     = _entity.GetType().GetProperty(pro.Name).GetValue(_entity) as IEnumerable <TopBasePoco>;
                            Utils.CheckDifference(data, list, out toremove, out toadd);
                            //设定子表应该更新的字段
                            List <string> setnames = new List <string>();
                            foreach (var field in FC.Keys)
                            {
                                if (field.StartsWith("Entity." + pro.Name + "[0]."))
                                {
                                    string name = field.Replace("Entity." + pro.Name + "[0].", "");
                                    if (name != "UpdateTime" && name != "UpdateBy")
                                    {
                                        setnames.Add(name);
                                    }
                                }
                            }

                            //前台传过来的数据
                            foreach (var newitem in list)
                            {
                                //数据库中的数据
                                foreach (var item in data)
                                {
                                    //需要更新的数据
                                    if (newitem.ID == item.ID)
                                    {
                                        dynamic i           = newitem;
                                        var     newitemType = item.GetType();
                                        foreach (var itempro in itemPros)
                                        {
                                            if (!itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)) && setnames.Contains(itempro.Name))
                                            {
                                                if (itempro.Name != "ID")
                                                {
                                                    DC.UpdateProperty(i, itempro.Name);
                                                }
                                            }
                                        }

                                        DC.UpdateProperty(i, "UpdateTime");
                                        DC.UpdateProperty(i, "UpdateBy");
                                    }
                                }
                            }
                            //需要删除的数据
                            foreach (var item in toremove)
                            {
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(item, null);
                                    }
                                }
                                dynamic i = item;
                                DC.DeleteEntity(i);
                            }
                            //需要添加的数据
                            foreach (var item in toadd)
                            {
                                if (item.GetType().IsSubclassOf(typeof(BasePoco)))
                                {
                                    BasePoco ent = item as BasePoco;
                                    if (ent.CreateTime == null)
                                    {
                                        ent.CreateTime = DateTime.Now;
                                    }
                                    if (string.IsNullOrEmpty(ent.CreateBy))
                                    {
                                        ent.CreateBy = LoginUserInfo?.ITCode;
                                    }
                                }
                                DC.AddEntity(item);
                            }
                        }
                        else if (FC.Keys.Contains("Entity." + pro.Name + ".DONOTUSECLEAR"))
                        {
                            PropertyInfo[]            itemPros   = ftype.GetProperties();
                            var                       _entity    = DC.Set <TModel>().Include(pro.Name).AsNoTracking().Where(x => x.ID == Entity.ID).FirstOrDefault();
                            IEnumerable <TopBasePoco> removeData = _entity.GetType().GetProperty(pro.Name).GetValue(_entity) as IEnumerable <TopBasePoco>;
                            foreach (var item in removeData)
                            {
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(item, null);
                                    }
                                }
                                dynamic i = item;
                                DC.DeleteEntity(i);
                            }
                        }
                    }
                }
            }
            #endregion


            if (updateAllFields == false)
            {
                foreach (var field in FC.Keys)
                {
                    if (field.StartsWith("Entity.") && !field.Contains("["))
                    {
                        string name = field.Replace("Entity.", "");
                        if (name != "UpdateTime" && name != "UpdateBy")
                        {
                            try
                            {
                                DC.UpdateProperty(Entity, name);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
            else
            {
                DC.UpdateEntity(Entity);
            }

            DC.SaveChanges();
            //删除不需要的附件
            if (DeletedFileIds != null)
            {
                foreach (var item in DeletedFileIds)
                {
                    FileAttachmentVM ofa = new FileAttachmentVM();
                    ofa.CopyContext(this);
                    ofa.SetEntityById(item);
                    ofa.DoDelete();
                }
            }
        }
Exemple #24
0
 public ActionResult GetCitys()
 {
     return(Ok(DC.Set <City>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, x => x.Name)));
 }
Exemple #25
0
 protected override void InitVM()
 {
     Customer_Excel.DataType  = ColumnDataType.ComboBox;
     Customer_Excel.ListItems = DC.Set <VOS_Customer>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, y => y.cust_name);
 }
Exemple #26
0
 public bool DeleteEntity(T entity)
 {
     CurrentDal.DeleteEntity(entity);
     return(DC.SaveChange() > 0);
 }
        public virtual void UpdateEntityList(bool updateAllFields = false)
        {
            if (EntityList != null)
            {
                var ftype    = EntityList.GetType().GenericTypeArguments.First();
                var itemPros = ftype.GetAllProperties();

                foreach (var newitem in EntityList)
                {
                    var subtype = newitem.GetType();
                    if (subtype.IsSubclassOf(typeof(BasePoco)))
                    {
                        BasePoco ent = newitem as BasePoco;
                        if (ent.UpdateTime == null)
                        {
                            ent.UpdateTime = DateTime.Now;
                        }
                        if (string.IsNullOrEmpty(ent.UpdateBy))
                        {
                            ent.UpdateBy = LoginUserInfo?.ITCode;
                        }
                    }
                    //循环页面传过来的子表数据,将关联到TopBasePoco的字段设为null,并且把外键字段的值设定为主表ID
                    foreach (var itempro in itemPros)
                    {
                        if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                        {
                            itempro.SetValue(newitem, null);
                        }
                    }
                }

                IEnumerable <TopBasePoco> data = null;
                //打开新的数据库联接,获取数据库中的主表和子表数据
                using (var ndc = DC.CreateNew())
                {
                    var ids = EntityList.Select(x => x.GetID().ToString()).ToList();
                    data = ndc.Set <TModel>().AsNoTracking().Where(ids.GetContainIdExpression <TModel>()).ToList();
                }
                //比较子表原数据和新数据的区别
                IEnumerable <TopBasePoco> toadd    = null;
                IEnumerable <TopBasePoco> toremove = null;
                Utils.CheckDifference(data, EntityList, out toremove, out toadd);
                //设定子表应该更新的字段
                List <string> setnames = new List <string>();
                foreach (var field in FC.Keys)
                {
                    if (field.StartsWith("EntityList[0]."))
                    {
                        string name = field.Replace("EntityList[0].", "");
                        setnames.Add(name);
                    }
                }

                //前台传过来的数据
                foreach (var newitem in EntityList)
                {
                    //数据库中的数据
                    foreach (var item in data)
                    {
                        //需要更新的数据
                        if (newitem.GetID().ToString() == item.GetID().ToString())
                        {
                            dynamic i           = newitem;
                            var     newitemType = item.GetType();
                            foreach (var itempro in itemPros)
                            {
                                if (!itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)) && (updateAllFields == true || setnames.Contains(itempro.Name)))
                                {
                                    var notmapped = itempro.GetCustomAttribute <NotMappedAttribute>();
                                    if (itempro.Name != "ID" && notmapped == null && itempro.PropertyType.IsList() == false)
                                    {
                                        DC.UpdateProperty(i, itempro.Name);
                                    }
                                }
                            }
                            if (item.GetType().IsSubclassOf(typeof(BasePoco)))
                            {
                                DC.UpdateProperty(i, "UpdateTime");
                                DC.UpdateProperty(i, "UpdateBy");
                            }
                        }
                    }
                }
                //需要删除的数据
                foreach (var item in toremove)
                {
                    //如果是PersistPoco,则把IsValid设为false,并不进行物理删除
                    if (ftype.IsSubclassOf(typeof(PersistPoco)))
                    {
                        (item as PersistPoco).IsValid    = false;
                        (item as PersistPoco).UpdateTime = DateTime.Now;
                        (item as PersistPoco).UpdateBy   = LoginUserInfo?.ITCode;
                        dynamic i = item;
                        DC.UpdateEntity(i);
                    }
                    else
                    {
                        foreach (var itempro in itemPros)
                        {
                            if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                            {
                                itempro.SetValue(item, null);
                            }
                        }
                        dynamic i = item;
                        DC.DeleteEntity(i);
                    }
                }
                //需要添加的数据
                foreach (var item in toadd)
                {
                    if (item.GetType().IsSubclassOf(typeof(BasePoco)))
                    {
                        BasePoco ent = item as BasePoco;
                        if (ent.CreateTime == null)
                        {
                            ent.CreateTime = DateTime.Now;
                        }
                        if (string.IsNullOrEmpty(ent.CreateBy))
                        {
                            ent.CreateBy = LoginUserInfo?.ITCode;
                        }
                    }
                    DC.AddEntity(item);
                }

                DC.SaveChanges();
            }
        }
Exemple #28
0
 public ActionResult GetSchoolInfos()
 {
     return(Ok(DC.Set <SchoolInfo>().GetSelectListItems(Wtm, x => x.EnglishName)));
 }
        private void ProcessCommand(DbCommand cmd)
        {
            object total;

            if (Searcher.Page <= 0)
            {
                Searcher.Page = 1;
            }
            if (DC.Database.IsMySql())
            {
                List <MySqlParameter> parms = new List <MySqlParameter>();
                foreach (MySqlParameter item in cmd.Parameters)
                {
                    parms.Add(new MySqlParameter(string.Format("@{0}", item.ParameterName), item.Value));
                }
                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    parms.Add(new MySqlParameter("@SearchMode", Enum.GetName(typeof(ListVMSearchModeEnum), SearcherMode)));
                    parms.Add(new MySqlParameter("@NeedPage", (NeedPage && Searcher.Limit != -1)));
                    parms.Add(new MySqlParameter("@CurrentPage", Searcher.Page));
                    parms.Add(new MySqlParameter("@RecordsPerPage", Searcher.Limit));
                    parms.Add(new MySqlParameter("@Sort", Searcher.SortInfo?.Property));
                    parms.Add(new MySqlParameter("@SortDir", Searcher.SortInfo?.Direction));
                    parms.Add(new MySqlParameter("@IDs", Ids == null ? "" : Ids.ToSepratedString()));

                    MySqlParameter outp = new MySqlParameter("@TotalRecords", MySqlDbType.Int64)
                    {
                        Value     = 0,
                        Direction = ParameterDirection.Output
                    };
                    parms.Add(outp);
                }
                var pa = parms.ToArray();

                EntityList = DC.Run <TModel>(cmd.CommandText, cmd.CommandType, pa).ToList();
                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    total = pa.Last().Value;
                }
                else
                {
                    total = EntityList.Count;
                }
            }
            else if (DC.Database.IsNpgsql())
            {
                List <NpgsqlParameter> parms = new List <NpgsqlParameter>();
                foreach (NpgsqlParameter item in cmd.Parameters)
                {
                    parms.Add(new NpgsqlParameter(string.Format("@{0}", item.ParameterName), item.Value));
                }

                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    parms.Add(new NpgsqlParameter("@SearchMode", Enum.GetName(typeof(ListVMSearchModeEnum), SearcherMode)));
                    parms.Add(new NpgsqlParameter("@NeedPage", (NeedPage && Searcher.Limit != -1)));
                    parms.Add(new NpgsqlParameter("@CurrentPage", Searcher.Page));
                    parms.Add(new NpgsqlParameter("@RecordsPerPage", Searcher.Limit));
                    parms.Add(new NpgsqlParameter("@Sort", Searcher.SortInfo?.Property));
                    parms.Add(new NpgsqlParameter("@SortDir", Searcher.SortInfo?.Direction));
                    parms.Add(new NpgsqlParameter("@IDs", Ids == null ? "" : Ids.ToSepratedString()));

                    NpgsqlParameter outp = new NpgsqlParameter("@TotalRecords", NpgsqlDbType.Bigint)
                    {
                        Value     = 0,
                        Direction = ParameterDirection.Output
                    };
                    parms.Add(outp);
                }
                var pa = parms.ToArray();

                EntityList = DC.Run <TModel>(cmd.CommandText, cmd.CommandType, pa).ToList();
                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    total = pa.Last().Value;
                }
                else
                {
                    total = EntityList.Count;
                }
            }
            else
            {
                List <SqlParameter> parms = new List <SqlParameter>();
                foreach (SqlParameter item in cmd.Parameters)
                {
                    parms.Add(new SqlParameter(string.Format("@{0}", item.ParameterName), item.Value));
                }
                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    parms.Add(new SqlParameter("@SearchMode", Enum.GetName(typeof(ListVMSearchModeEnum), SearcherMode)));
                    parms.Add(new SqlParameter("@NeedPage", (NeedPage && Searcher.Limit != -1)));
                    parms.Add(new SqlParameter("@CurrentPage", Searcher.Page));
                    parms.Add(new SqlParameter("@RecordsPerPage", Searcher.Limit));
                    parms.Add(new SqlParameter("@Sort", Searcher.SortInfo?.Property));
                    parms.Add(new SqlParameter("@SortDir", Searcher.SortInfo?.Direction));
                    parms.Add(new SqlParameter("@IDs", Ids == null ? "" : Ids.ToSepratedString()));

                    SqlParameter outp = new SqlParameter("@TotalRecords", 0)
                    {
                        Direction = ParameterDirection.Output
                    };
                    parms.Add(outp);
                }
                var pa = parms.ToArray();

                EntityList = DC.Run <TModel>(cmd.CommandText, cmd.CommandType, pa).ToList();
                if (cmd.CommandType == CommandType.StoredProcedure)
                {
                    total = pa.Last().Value;
                }
                else
                {
                    total = EntityList.Count;
                }
            }
            if (NeedPage && Searcher.Limit != -1)
            {
                if (total != null)
                {
                    try
                    {
                        Searcher.Count     = long.Parse(total.ToString());
                        Searcher.PageCount = (int)((Searcher.Count - 1) / Searcher.Limit + 1);
                    }
                    catch { }
                }
            }
            else
            {
                Searcher.PageCount = EntityList.Count;
            }
        }
Exemple #30
0
 public ActionResult GetGradeClassInfos()
 {
     return(Ok(DC.Set <GradeClassInfo>().GetSelectListItems(Wtm, x => x.Name)));
 }
Exemple #31
0
 protected override void InitVM()
 {
     AllAreas = DC.Set <Area>().GetTreeSelectListItems(Wtm, x => x.Name);
 }
Exemple #32
0
        private void DoAddPrepare()
        {
            var pros = typeof(TModel).GetProperties();

            //将所有TopBasePoco的属性赋空值,防止添加关联的重复内容
            if (typeof(TModel) != typeof(FileAttachment))
            {
                foreach (var pro in pros)
                {
                    if (pro.PropertyType.GetTypeInfo().IsSubclassOf(typeof(TopBasePoco)))
                    {
                        pro.SetValue(Entity, null);
                    }
                }
            }
            //自动设定添加日期和添加人
            if (typeof(TModel).GetTypeInfo().IsSubclassOf(typeof(BasePoco)))
            {
                BasePoco ent = Entity as BasePoco;
                if (ent.CreateTime == null)
                {
                    ent.CreateTime = DateTime.Now;
                }
                if (string.IsNullOrEmpty(ent.CreateBy))
                {
                    ent.CreateBy = LoginUserInfo?.ITCode;
                }
            }

            if (typeof(TModel).GetTypeInfo().IsSubclassOf(typeof(PersistPoco)))
            {
                (Entity as PersistPoco).IsValid = true;
            }

            #region 更新子表
            foreach (var pro in pros)
            {
                //找到类型为List<xxx>的字段
                if (pro.PropertyType.GenericTypeArguments.Count() > 0)
                {
                    //获取xxx的类型
                    var ftype = pro.PropertyType.GenericTypeArguments.First();
                    //如果xxx继承自TopBasePoco
                    if (ftype.IsSubclassOf(typeof(TopBasePoco)))
                    {
                        //界面传过来的子表数据
                        IEnumerable <TopBasePoco> list = pro.GetValue(Entity) as IEnumerable <BasePoco>;
                        if (list != null && list.Count() > 0)
                        {
                            string         fkname   = DC.GetFKName <TModel>(pro.Name);
                            PropertyInfo[] itemPros = ftype.GetProperties();

                            bool found = false;
                            foreach (var newitem in list)
                            {
                                foreach (var itempro in itemPros)
                                {
                                    if (itempro.PropertyType.IsSubclassOf(typeof(TopBasePoco)))
                                    {
                                        itempro.SetValue(newitem, null);
                                    }
                                    if (!string.IsNullOrEmpty(fkname))
                                    {
                                        if (itempro.Name.ToLower() == fkname.ToLower())
                                        {
                                            itempro.SetValue(newitem, Entity.GetID());
                                            found = true;
                                        }
                                    }
                                }
                            }
                            //如果没有找到相应的外建字段,则可能是多对多的关系,或者做了特殊的设定,这种情况框架无法支持,直接退出本次循环
                            if (found == false)
                            {
                                continue;
                            }
                            //循环页面传过来的子表数据,自动设定添加日期和添加人
                            foreach (var newitem in list)
                            {
                                var      subtype = newitem.GetType();
                                BasePoco ent     = newitem as BasePoco;
                                if (ent.CreateTime == null)
                                {
                                    ent.CreateTime = DateTime.Now;
                                }
                                if (string.IsNullOrEmpty(ent.CreateBy))
                                {
                                    ent.CreateBy = LoginUserInfo?.ITCode;
                                }
                            }
                        }
                    }
                }
            }
            #endregion


            //添加数据
            DC.Set <TModel>().Add(Entity);
        }
Exemple #33
0
 public ActionResult GetDepotss()
 {
     return(Ok(DC.Set <Depots>().GetSelectListItems(Wtm, x => x.DepotName)));
 }
Exemple #34
0
        /// <summary>
        /// 验证重复数据
        /// </summary>
        protected void ValidateDuplicateData()
        {
            //获取设定的重复字段信息
            var checkCondition = SetDuplicatedCheck();

            if (checkCondition != null && checkCondition.Groups.Count > 0)
            {
                //生成基础Query
                var baseExp              = DC.Set <TModel>().AsQueryable();
                var modelType            = typeof(TModel);
                ParameterExpression para = Expression.Parameter(modelType, "tm");
                //循环所有重复字段组
                foreach (var group in checkCondition.Groups)
                {
                    List <Expression> conditions = new List <Expression>();
                    //生成一个表达式,类似于 x=>x.Id != id,这是为了当修改数据时验证重复性的时候,排除当前正在修改的数据
                    var idproperty                = typeof(TModel).GetProperties().Where(x => x.Name.ToLower() == "id").FirstOrDefault();
                    MemberExpression   idLeft     = Expression.Property(para, idproperty);
                    ConstantExpression idRight    = Expression.Constant(Entity.GetID());
                    BinaryExpression   idNotEqual = Expression.NotEqual(idLeft, idRight);
                    conditions.Add(idNotEqual);
                    List <PropertyInfo> props = new List <PropertyInfo>();
                    //在每个组中循环所有字段
                    foreach (var field in group.Fields)
                    {
                        Expression exp = field.GetExpression(Entity, para);
                        if (exp != null)
                        {
                            conditions.Add(exp);
                        }
                        //将字段名保存,为后面生成错误信息作准备
                        props.AddRange(field.GetProperties());
                    }
                    //如果要求判断id不重复,则去掉id不相等的判断,加入id相等的判断
                    if (props.Any(x => x.Name.ToLower() == "id"))
                    {
                        conditions.RemoveAt(0);
                        BinaryExpression idEqual = Expression.Equal(idLeft, idRight);
                        conditions.Insert(0, idEqual);
                    }
                    int count = 0;
                    if (conditions.Count > 1)
                    {
                        //循环添加条件并生成Where语句
                        Expression conExp = conditions[0];
                        for (int i = 1; i < conditions.Count; i++)
                        {
                            conExp = Expression.And(conExp, conditions[i]);
                        }

                        MethodCallExpression whereCallExpression = Expression.Call(
                            typeof(Queryable),
                            "Where",
                            new Type[] { modelType },
                            baseExp.Expression,
                            Expression.Lambda <Func <TModel, bool> >(conExp, new ParameterExpression[] { para }));
                        var result = baseExp.Provider.CreateQuery(whereCallExpression);

                        foreach (var res in result)
                        {
                            count++;
                        }
                    }
                    if (count > 0)
                    {
                        //循环拼接所有字段名
                        string AllName = "";
                        foreach (var prop in props)
                        {
                            string name = PropertyHelper.GetPropertyDisplayName(prop);
                            AllName += name + ",";
                        }
                        if (AllName.EndsWith(","))
                        {
                            AllName = AllName.Remove(AllName.Length - 1);
                        }
                        //如果只有一个字段重复,则拼接形成 xxx字段重复 这种提示
                        if (props.Count == 1)
                        {
                            MSD.AddModelError(GetValidationFieldName(props[0])[0], Program._localizer["DuplicateError", AllName]);
                        }
                        //如果多个字段重复,则拼接形成 xx,yy,zz组合字段重复 这种提示
                        else if (props.Count > 1)
                        {
                            MSD.AddModelError(GetValidationFieldName(props.First())[0], Program._localizer["DuplicateGroupError", AllName]);
                        }
                    }
                }
            }
        }
Exemple #35
0
        public ActionResult GetFolders()
        {
            var m = DC.Set <FrameworkMenu>().Where(x => x.FolderOnly == true).OrderBy(x => x.DisplayOrder).GetSelectListItems(LoginUserInfo.DataPrivileges, null, x => x.PageName);

            return(Ok(m));
        }
Exemple #36
0
 public ActionResult GetFrameworkRoles()
 {
     return(Ok(DC.Set <FrameworkRole>().GetSelectListItems(Wtm, x => x.RoleName)));
 }
Exemple #37
0
 protected override void InitVM()
 {
     AllSuppliers  = DC.Set <Supplier>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, y => y.SupplierName);
     AllGoodsInfos = DC.Set <GoodsInfo>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, y => y.GoodsName + "   " + y.Specification + "   " + GetStoreName(y.StoreHouseId));
 }
 protected override void InitVM()
 {
     AllProducts = DC.Set <Product>().GetSelectListItems(LoginUserInfo?.DataPrivileges, null, y => y.Name);
 }
 /// <summary>
 /// 设定搜索语句,继承的类应该重载这个函数来指定自己的搜索语句
 /// </summary>
 /// <returns>搜索语句</returns>
 public virtual IOrderedQueryable <TModel> GetSearchQuery()
 {
     return(DC.Set <TModel>().OrderByDescending(x => x.ID));
 }
 public SaveData(DC.SaveMethod save, DC.LoadMethod load)
 {
     SaveMethod = save;
     LoadMethod = load;
 }
        private void ProcessCommand(DbCommand cmd)
        {
            object total;

            if (DC.Database.IsMySql())
            {
                List <MySqlParameter> parms = new List <MySqlParameter>();
                foreach (MySqlParameter item in cmd.Parameters)
                {
                    parms.Add(new MySqlParameter(string.Format("@{0}", item.ParameterName), item.Value));
                }

                parms.Add(new MySqlParameter("@SearchMode", Enum.GetName(typeof(ListVMSearchModeEnum), SearcherMode)));
                parms.Add(new MySqlParameter("@NeedPage", (NeedPage && Searcher.Limit != -1)));
                parms.Add(new MySqlParameter("@CurrentPage", Searcher.Page));
                parms.Add(new MySqlParameter("@RecordsPerPage", Searcher.Limit));
                parms.Add(new MySqlParameter("@IDs", Ids == null ? "" : Ids.ToSpratedString()));

                MySqlParameter outp = new MySqlParameter("@TotalRecords", MySqlDbType.Int64);
                outp.Value     = 0;
                outp.Direction = System.Data.ParameterDirection.Output;
                parms.Add(outp);

                var pa = parms.ToArray();

                EntityDataTable = DC.RunSP(cmd.CommandText, pa);
                total           = outp.Value;
            }
            else
            {
                List <SqlParameter> parms = new List <SqlParameter>();
                foreach (SqlParameter item in cmd.Parameters)
                {
                    parms.Add(new SqlParameter(string.Format("@{0}", item.ParameterName), item.Value));
                }

                parms.Add(new SqlParameter("@SearchMode", Enum.GetName(typeof(ListVMSearchModeEnum), SearcherMode)));
                parms.Add(new SqlParameter("@NeedPage", (NeedPage && Searcher.Limit != -1)));
                parms.Add(new SqlParameter("@CurrentPage", Searcher.Page));
                parms.Add(new SqlParameter("@RecordsPerPage", Searcher.Limit));
                parms.Add(new SqlParameter("@IDs", Ids == null ? "" : Ids.ToSpratedString()));

                SqlParameter outp = new SqlParameter("@TotalRecords", 0);
                outp.Direction = System.Data.ParameterDirection.Output;
                parms.Add(outp);
                var pa = parms.ToArray();

                EntityDataTable = DC.RunSP(cmd.CommandText, pa);
                total           = outp.Value;
            }
            if (NeedPage && Searcher.Limit != -1)
            {
                if (total != null)
                {
                    try
                    {
                        Searcher.Count     = (long)total;
                        Searcher.PageCount = (int)((Searcher.Count - 1) / Searcher.Limit + 1);
                    }
                    catch { }
                }
            }
            else
            {
                Searcher.PageCount = EntityDataTable.Rows.Count;
            }
        }
Exemple #42
0
        public void When_MOS1DC_Expect_Spice3f5Reference()
        {
            /*
             * Mosfet biased by voltage sources
             * Current is expected to behave like the reference. Reference is from Spice 3f5.
             * The model is part from the ntd20n06 (OnSemi) device.
             */
            // Create circuit
            var ckt = new Circuit(
                new VoltageSource("V1", "g", "0", 0.0),
                new VoltageSource("V2", "d", "0", 0),
                new VoltageSource("V3", "b", "0", -5.0),
                CreateMOS1("M1", "d", "g", "0", "b", "MM"),
                CreateMOS1Model("MM", "IS=1e-32 VTO=3.03646 LAMBDA=0 KP=5.28747 CGSO=6.5761e-06 CGDO=1e-11")
                );

            // Create simulation
            var dc = new DC("dc", new[] {
                new SweepConfiguration("V2", -5, 5, 0.5),
                new SweepConfiguration("V1", -5, 5, 0.5)
            });

            // Create exports
            Export <double>[] exports = { new RealPropertyExport(dc, "V2", "i") };

            // Create references
            var references = new double[1][];

            references[0] = new[]
            {
                0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00,
                0.000000000000000e+00, 0.000000000000000e+00, 0.000000000000000e+00, 5.680575723775245e-01,
                2.454468244277527e+00, 5.662746416177523e+00, 1.019289208807752e+01, 1.604490525997753e+01,
                2.321878593187752e+01, 3.171453410377752e+01, 4.153214977567750e+01, 5.267163294757751e+01,
                6.513298361947750e+01, 7.834814421900002e+01, 9.156681921900000e+01, 1.047854942190000e+02,
                1.180041692190000e+02, -4.999999999999999e-13, -4.999999999999999e-13, -4.999999999999999e-13,
                -4.999999999999999e-13, -4.999999999999999e-13, -4.999999999999999e-13, -4.999999999999999e-13,
                -4.999999999999999e-13, 5.680575723770240e-01, 2.454468244277025e+00, 5.662746416177022e+00,
                1.019289208807702e+01, 1.604490525997703e+01, 2.321878593187702e+01, 3.171453410377702e+01,
                4.153214977567701e+01, 5.267163294757702e+01, 6.456492604709950e+01, 7.646173354709953e+01,
                8.835854104709949e+01, 1.002553485470995e+02, -9.999999999999998e-13, -9.999999999999998e-13,
                -9.999999999999998e-13, -9.999999999999998e-13, -9.999999999999998e-13, -9.999999999999998e-13,
                -9.999999999999998e-13, -9.999999999999998e-13, -9.999999999999998e-13, 5.680575723765238e-01,
                2.454468244276526e+00, 5.662746416176525e+00, 1.019289208807652e+01, 1.604490525997653e+01,
                2.321878593187651e+01, 3.171453410377652e+01, 4.153214977567652e+01, 5.210357537519901e+01,
                6.267851537519901e+01, 7.325345537519900e+01, 8.382839537519902e+01, -1.500000000000000e-12,
                -1.500000000000000e-12, -1.500000000000000e-12, -1.500000000000000e-12, -1.500000000000000e-12,
                -1.500000000000000e-12, -1.500000000000000e-12, -1.500000000000000e-12, -1.500000000000000e-12,
                -1.500000000000000e-12, 5.680575723760235e-01, 2.454468244276028e+00, 5.662746416176023e+00,
                1.019289208807602e+01, 1.604490525997603e+01, 2.321878593187601e+01, 3.171453410377602e+01,
                4.096409220329851e+01, 5.021716470329851e+01, 5.947023720329851e+01, 6.872330970329853e+01,
                -2.000000000000000e-12, -2.000000000000000e-12, -2.000000000000000e-12, -2.000000000000000e-12,
                -2.000000000000000e-12, -2.000000000000000e-12, -2.000000000000000e-12, -2.000000000000000e-12,
                -2.000000000000000e-12, -2.000000000000000e-12, -2.000000000000000e-12, 5.680575723755232e-01,
                2.454468244275526e+00, 5.662746416175525e+00, 1.019289208807552e+01, 1.604490525997553e+01,
                2.321878593187552e+01, 3.114647653139799e+01, 3.907768153139800e+01, 4.700888653139801e+01,
                5.494009153139801e+01, -2.500000000000000e-12, -2.500000000000000e-12, -2.500000000000000e-12,
                -2.500000000000000e-12, -2.500000000000000e-12, -2.500000000000000e-12, -2.500000000000000e-12,
                -2.500000000000000e-12, -2.500000000000000e-12, -2.500000000000000e-12, -2.500000000000000e-12,
                -2.500000000000000e-12, 5.680575723750239e-01, 2.454468244275026e+00, 5.662746416175024e+00,
                1.019289208807502e+01, 1.604490525997503e+01, 2.265072835949751e+01, 2.926006585949749e+01,
                3.586940335949749e+01, 4.247874085949751e+01, -3.000000000000000e-12, -3.000000000000000e-12,
                -3.000000000000000e-12, -3.000000000000000e-12, -3.000000000000000e-12, -3.000000000000000e-12,
                -3.000000000000000e-12, -3.000000000000000e-12, -3.000000000000000e-12, -3.000000000000000e-12,
                -3.000000000000000e-12, -3.000000000000000e-12, -3.000000000000000e-12, 5.680575723745234e-01,
                2.454468244274526e+00, 5.662746416174523e+00, 1.019289208807452e+01, 1.547684768759700e+01,
                2.076431768759700e+01, 2.605178768759699e+01, 3.133925768759698e+01, -3.500000000000000e-12,
                -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12,
                -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12,
                -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12, -3.500000000000000e-12,
                -3.500000000000000e-12, 5.680575723740233e-01, 2.454468244274027e+00, 5.662746416174024e+00,
                9.624834515696499e+00, 1.359043701569650e+01, 1.755603951569650e+01, 2.152164201569649e+01,
                -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12,
                -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12,
                -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12,
                -4.000000000000000e-12, -4.000000000000000e-12, -4.000000000000000e-12, 5.680575723735242e-01,
                2.454468244273526e+00, 5.094688843796002e+00, 7.738423843796001e+00, 1.038215884379600e+01,
                1.302589384379600e+01, -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12,
                -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12,
                -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12,
                -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12, -4.500000000000000e-12,
                -4.500000000000000e-12, 5.680575723730232e-01, 1.886410671895499e+00, 3.208278171895499e+00,
                4.530145671895499e+00, 5.852013171895498e+00, -5.000000000000000e-12, -5.000000000000000e-12,
                -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12,
                -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12,
                -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12,
                -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12,
                -5.000000000000000e-12, -5.000000000000000e-12, -5.000000000000000e-12, -5.500000000000000e-12,
                -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12,
                -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12,
                -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12,
                -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12, -5.500000000000000e-12,
                -5.680575723830241e-01, -1.886410671905500e+00, -3.208278171905500e+00, -4.530145671905499e+00,
                -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12,
                -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12,
                -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12,
                -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12, -5.999999999999999e-12,
                -5.999999999999999e-12, -5.680575723835251e-01, -2.454468244283522e+00, -5.094688843805997e+00,
                -7.738423843805997e+00, -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12,
                -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12,
                -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12,
                -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12, -6.500000000000000e-12,
                -6.500000000000000e-12, -6.500000000000000e-12, -5.680575723840242e-01, -2.454468244284023e+00,
                -5.662746416184021e+00, -9.624834515706503e+00, -7.000000000000000e-12, -7.000000000000000e-12,
                -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12,
                -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12,
                -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12,
                -7.000000000000000e-12, -7.000000000000000e-12, -7.000000000000000e-12, -5.680575723845251e-01,
                -2.454468244284524e+00, -5.662746416184522e+00, -1.019289208808452e+01, -7.500000000000000e-12,
                -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12,
                -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12,
                -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12,
                -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12, -7.500000000000000e-12,
                -5.680575723850243e-01, -2.454468244285025e+00, -5.662746416185023e+00, -1.019289208808502e+01,
                -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12,
                -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12,
                -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12,
                -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12, -8.000000000000000e-12,
                -8.000000000000000e-12, -5.680575723855252e-01, -2.454468244285522e+00, -5.662746416185520e+00,
                -1.019289208808552e+01, -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12,
                -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12,
                -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12,
                -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12, -8.500000000000000e-12,
                -8.500000000000000e-12, -8.500000000000000e-12, -5.680575723860244e-01, -2.454468244286023e+00,
                -5.662746416186021e+00, -1.019289208808603e+01, -9.000000000000000e-12, -9.000000000000000e-12,
                -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12,
                -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12,
                -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12,
                -9.000000000000000e-12, -9.000000000000000e-12, -9.000000000000000e-12, -5.680575723865253e-01,
                -2.454468244286524e+00, -5.662746416186522e+00, -1.019289208808652e+01, -9.500000000000000e-12,
                -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12,
                -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12,
                -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12,
                -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12, -9.500000000000000e-12,
                -5.680575723870245e-01, -2.454468244287025e+00, -5.662746416187023e+00, -1.019289208808702e+01,
                -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12,
                -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12,
                -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12,
                -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12, -9.999999999999999e-12,
                -9.999999999999999e-12, -5.680575723875254e-01, -2.454468244287522e+00, -5.662746416187520e+00,
                -1.019289208808753e+01
            };

            // Run simulation
            AnalyzeDC(dc, ckt, exports, references);
        }
Exemple #43
0
 public static void Prc_QLTQCT_KhoiTao_MoiTruong(string p_short_name, DC.Forms.Frm_QLCD p_frm_qlcd)
 {
     string _query = null;
     using (CLS_DBASE.ORA _ora = new CLS_DBASE.ORA(GlobalVar.gl_connTKTQ))
     {
         _ora.TransStart();
         _query = "call PCK_MOI_TRUONG.prc_set_glview('" + p_short_name + "')";
         _ora.TransExecute(_query);
         _query = "call PCK_MOI_TRUONG.prc_cre_dblink(userenv('client_info'))";
         _ora.TransExecute(_query);
         _query = "call PCK_MOI_TRUONG.prc_ktao(userenv('client_info'))";
         _ora.TransExecute(_query);
         _ora.TransCommit();
     }
 }