Exemplo n.º 1
0
        private void btnAddDevFilter_Click(object sender, EventArgs e)
        {
            BaseDataServicePresenter presenter = new BaseDataServicePresenter();
            var list = presenter.GetObjectTypeList().ToList();
            UCItemListSelect <ObjecttypeDto> ucObjTypeSelect;

            ucObjTypeSelect = new UCItemListSelect <ObjecttypeDto>(list);
            List <ColumnDescriptor> columnDescriptor = new List <ColumnDescriptor>();

            columnDescriptor.Add(new ColumnDescriptor()
            {
                Name = AssemblyReflector.GetMemberName((ObjecttypeDto m) => m.ObjecttypeDesc), Caption = "نام", Width = 150
            });
            ucObjTypeSelect.AddColumnDescriptor(columnDescriptor);
            ISE.UILibrary.Utils.UIUtils.SetFrmTrans(ucObjTypeSelect, "انتخاب نوع تجهیز", FormBorderStyle.FixedDialog);
            if (ucObjTypeSelect.HasSelected)
            {
                var selected = ucObjTypeSelect.SelectedItems.FirstOrDefault();
                selected.State       = Framework.Common.CommonBase.DtoObjectState.Updated;
                txtDeviceFilter.Text = selected.ObjecttypeDesc;
                txtDeviceFilter.Tag  = selected;
                if (mode == TransMode.EditRecord)
                {
                    fcat = new SdFilterCategoryDto()
                    {
                        Objecttypeid     = ((ObjecttypeDto)selected).ObjecttypeId,
                        Servicecaegoryid = service.ServiceCatId,
                        State            = Framework.Common.CommonBase.DtoObjectState.Updated
                    };
                }
            }
        }
Exemplo n.º 2
0
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            if (this.gridUsers.CurrentRow != null)
            {
                var           user      = (UserDto)this.gridUsers.CurrentRow.DataRow;
                RolePresenter presenter = new RolePresenter();

                var       roleList = presenter.GetAll().RoleDtoList;
                var       tbl      = DataTableHelper.ConvertToDatatable <RoleDto>(roleList);
                ILov      lovActionOrder;
                LovFields lfActionOrder;
                lfActionOrder = new LovFields();
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((RoleDto m) => m.CondidateRoleName), "عنوان نقش", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((RoleDto m) => m.AppDomainName), "حوزه", 100, true);

                lovActionOrder = new ILov(this.btnAddRole, "ليست نقش ها", tbl, lfActionOrder);
                var row = lovActionOrder.ShowDialog() as DataRow;
                if (row != null)
                {
                    var    roleId       = row.Field <int>(AssemblyReflector.GetMemberName((RoleDto m) => m.RoleId));
                    var    selectedRole = roleList.Where(it => it.RoleId == roleId).FirstOrDefault();
                    string message      = string.Format("آیا از انتساب نقش {0} به {1} مطمئن هستید؟", selectedRole.CondidateRoleName, user.FullName);
                    if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK)
                    {
                        return;
                    }
                    view.AssignToRoles(user, selectedRole);
                }
            }
        }
Exemplo n.º 3
0
        private void btnAddGrp_Click(object sender, EventArgs e)
        {
            if (this.iGridEX1.CurrentRow != null)
            {
                var role = (RoleDto)this.iGridEX1.CurrentRow.DataRow;
                SecurityGroupPresenter presenter = new SecurityGroupPresenter();
                var       groups = presenter.GetAll().SecurityGroupDtoList;
                var       tbl    = DataTableHelper.ConvertToDatatable <SecurityGroupDto>(groups);
                ILov      lovActionOrder;
                LovFields lfActionOrder;
                lfActionOrder = new LovFields();
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.GroupName), "نام", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.AppDomainName), "نام خانوادگی", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.DisplayName), "نام نمایشی", 100, true);


                lovActionOrder = new ILov(this.btnAddGrp, "ليست گروه ها", tbl, lfActionOrder);
                var row = lovActionOrder.ShowDialog() as DataRow;
                if (row != null)
                {
                    var    grpId         = row.Field <int>(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.SecurityGroupId));
                    var    selectedGroup = groups.Where(it => it.SecurityGroupId == grpId).FirstOrDefault();
                    string message       = string.Format("آیا از عضویت نقش {0} در {1} مطمئن هستید؟", role.RoleName, selectedGroup.DisplayName);
                    if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK)
                    {
                        return;
                    }
                    view.AssignToGroup(role, selectedGroup);
                }
            }
        }
Exemplo n.º 4
0
        private void btnCompany_Click(object sender, EventArgs e)
        {
            var       result = view.LoadCompanies();
            var       tbl    = DataTableHelper.ConvertToDatatable <CompanyDto>(result);
            ILov      lovActionOrder;
            LovFields lfActionOrder;

            lfActionOrder = new LovFields();
            lfActionOrder.AddItem(AssemblyReflector.GetMemberName((CompanyDto m) => m.Name), "نام شرکت", 200, true);
            lfActionOrder.AddItem(AssemblyReflector.GetMemberName((CompanyDto m) => m.NationalNo), "کد شناسایی ملی", 100, true);

            lovActionOrder = new ILov(this.btnCompany, "ليست شرکت ها", tbl, lfActionOrder);
            var row = lovActionOrder.ShowDialog() as DataRow;

            if (row != null)
            {
                var companId        = row.Field <int>(AssemblyReflector.GetMemberName((CompanyDto m) => m.CompanyId));
                var selectedCompany = result.Where(it => it.CompanyId == companId).FirstOrDefault();
                if (selectedCompany != null)
                {
                    txtCompany.Text = selectedCompany.Name;
                    txtCompany.Tag  = selectedCompany;
                }
            }
        }
Exemplo n.º 5
0
        private void btnAddRole_Click(object sender, EventArgs e)
        {
            if (this.iGridEXGroup.CurrentRow != null)
            {
                var           group     = (SecurityGroupDto)this.iGridEXGroup.CurrentRow.DataRow;
                RolePresenter presenter = new RolePresenter();
                var           roles     = presenter.GetAll().RoleDtoList;
                var           tbl       = DataTableHelper.ConvertToDatatable <RoleDto>(roles);
                ILov          lovActionOrder;
                LovFields     lfActionOrder;
                lfActionOrder = new LovFields();
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((RoleDto m) => m.RoleName), "نام", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((RoleDto m) => m.AppDomainName), "نام حوزه", 100, true);


                lovActionOrder = new ILov(this.btnAddRole, "ليست نقش ها", tbl, lfActionOrder);
                var row = lovActionOrder.ShowDialog() as DataRow;
                if (row != null)
                {
                    var    roleId       = row.Field <int>(AssemblyReflector.GetMemberName((RoleDto m) => m.RoleId));
                    var    selectedRole = roles.Where(it => it.RoleId == roleId).FirstOrDefault();
                    string message      = string.Format("آیا از انتساب گروه {0} به  نفش {1} مطمئن هستید؟", group.DisplayName, selectedRole.RoleName);
                    if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK)
                    {
                        return;
                    }
                    view.AssignRole(group, selectedRole);
                }
            }
        }
Exemplo n.º 6
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            if (this.iGridEXGroup.CurrentRow != null)
            {
                var group = (SecurityGroupDto)this.iGridEXGroup.CurrentRow.DataRow;
                SecurityUserPresenter presenter = new SecurityUserPresenter();
                var       users = presenter.GetAll().UserDtoList;
                var       tbl   = DataTableHelper.ConvertToDatatable <UserDto>(users);
                ILov      lovActionOrder;
                LovFields lfActionOrder;
                lfActionOrder = new LovFields();
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.FirstName), "نام", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.LastName), "نام خانوادگی", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.PersonelCode), "کد پرسنلی", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((UserDto m) => m.NationalNo), "کد ملی", 100, true);

                lovActionOrder = new ILov(this.btnAddUser, "ليست کاربران", tbl, lfActionOrder);
                var row = lovActionOrder.ShowDialog() as DataRow;
                if (row != null)
                {
                    var    userId       = row.Field <long>(AssemblyReflector.GetMemberName((UserDto m) => m.UserId));
                    var    selectedUser = users.Where(it => it.UserId == userId).FirstOrDefault();
                    string message      = string.Format("آیا از انتساب گروه {0} به {1} مطمئن هستید؟", group.DisplayName, selectedUser.FullName);
                    if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK)
                    {
                        return;
                    }
                    view.AssignUser(group, selectedUser);
                }
            }
        }
Exemplo n.º 7
0
        public virtual void Update(TEntityDto entityDto)
        {
            if (WcfCurrentContext.IsAuthenticated)
            {
                UserIdentity currentUser = WcfCurrentContext.CurrentUser;
                var          perId       = int.Parse(currentUser.UserId);
                AssemblyReflector.SetValue(entityDto, "UpdatePerId", perId);
            }

            AssemblyReflector.SetValue(entityDto, "UpdateDate", DateTime.Now);
            if (entityDto.State == DtoObjectState.Updated || entityDto.State == DtoObjectState.Ignore || entityDto.State == DtoObjectState.Persisted)
            {
                try
                {
                    CurrentRepository.UpdateOrCreate(entityDto);
                    CurrentRepository.SaveChanges();
                    entityDto.State = DtoObjectState.Updated;
                }
                catch (Exception ex)
                {
                    entityDto.State = DtoObjectState.Ignore;
                    entityDto.Response.AddBusinessException(new Framework.Common.Service.Message.BusinessExceptionDto(Framework.Common.Service.Message.BusinessExceptionEnum.Operational, "در ویرایش اطلاعات از دیتابیس مشکل بوجود آمد!", ex.Message, ex.StackTrace));
                    ex.Data.Add("type", "db");
                    throw ex;
                }
            }
        }
Exemplo n.º 8
0
        public virtual void Insert(TEntityDto entityDto)
        {
            try
            {
                if (WcfCurrentContext.IsAuthenticated)
                {
                    UserIdentity currentUser = WcfCurrentContext.CurrentUser;
                    var          perId       = int.Parse(currentUser.UserId);
                    AssemblyReflector.SetValue(entityDto, "InsertPerId", perId);
                }
                AssemblyReflector.SetValue(entityDto, "InsertDate", DateTime.Now);
                TEntity entity = CurrentRepository.Create(entityDto);
                CurrentRepository.SaveChanges();

                object id = AssemblyReflector.GetValue(entity, entityDto.PrimaryKeyName);
                AssemblyReflector.SetValue(entityDto, entityDto.PrimaryKeyName, id);
                entityDto.State = DtoObjectState.Inserted;
            }
            catch (Exception ex)
            {
                entityDto.State = DtoObjectState.Ignore;
                entityDto.Response.AddBusinessException(new Framework.Common.Service.Message.BusinessExceptionDto(Framework.Common.Service.Message.BusinessExceptionEnum.Operational, "در ورود اطلاعات به دیتابیس مشکل بوجود آمد!", ex.Message, ex.StackTrace));
                ex.Data.Add("type", "db");
                throw ex;
            }
        }
Exemplo n.º 9
0
        private void btnAddGrp_Click(object sender, EventArgs e)
        {
            if (this.gridUsers.CurrentRow != null)
            {
                var user = (UserDto)this.gridUsers.CurrentRow.DataRow;
                SecurityGroupPresenter presenter = new SecurityGroupPresenter();
                var       group = presenter.GetAll().SecurityGroupDtoList;
                var       tbl   = DataTableHelper.ConvertToDatatable <SecurityGroupDto>(group);
                ILov      lovActionOrder;
                LovFields lfActionOrder;
                lfActionOrder = new LovFields();
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.DisplayName), "عنوان گروه", 100, true);
                lfActionOrder.AddItem(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.AppDomainName), "حوزه", 100, true);

                lovActionOrder = new ILov(this.btnAddGrp, "ليست نقش ها", tbl, lfActionOrder);
                var row = lovActionOrder.ShowDialog() as DataRow;
                if (row != null)
                {
                    var    groupId       = row.Field <int>(AssemblyReflector.GetMemberName((SecurityGroupDto m) => m.SecurityGroupId));
                    var    selectedGroup = group.Where(it => it.SecurityGroupId == groupId).FirstOrDefault();
                    string message       = string.Format("آیا از انتساب گروه {0} به {1} مطمئن هستید؟", selectedGroup.DisplayName, user.FullName);
                    if (ISE.Framework.Client.Win.Viewer.MessageViewer.ShowAlert(message) != DialogResult.OK)
                    {
                        return;
                    }
                    view.AssignToGroups(user, selectedGroup);
                }
            }
        }
Exemplo n.º 10
0
        private void ViewAllServiceJobs()
        {
            var jobList = jobView.LoadServiceJobs(-1);

            lstJobs.Items.Clear();
            lstJobs.Items.AddRange(jobList.ToArray());
            lstJobs.DisplayMember = AssemblyReflector.GetMemberName((SdServiceJobDto c) => c.Title);
        }
Exemplo n.º 11
0
        public void LoadAppDomains()
        {
            AppDomainPresenter appDomainPresenter = new AppDomainPresenter();
            var lst = appDomainPresenter.GetAppDomainList();

            cmbDomain.DataSource    = lst;
            cmbDomain.DisplayMember = AssemblyReflector.GetMemberName((ApplicationDomainDto m) => m.Title);
            cmbDomain.ValueMember   = AssemblyReflector.GetMemberName((ApplicationDomainDto m) => m.ApplicationDomainId);
        }
 public void SetUp()
 {
     _mocks = new MockRepository();
     _accessTypeReflectorMock   = _mocks.StrictMock <IAccessTypeReflector> ();
     _classReflectorMock        = _mocks.StrictMock <IClassReflector> ();
     _abstractRoleReflectorMock = _mocks.StrictMock <IAbstractRoleReflector> ();
     _assemblyReflector         = new AssemblyReflector(_accessTypeReflectorMock, _classReflectorMock, _abstractRoleReflectorMock);
     _cache = new MetadataCache();
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            AssemblyReflector reflector = new AssemblyReflector();

            reflector.RegisterTypeToDatatype(typeof(bool), new BoolType().Datatype);
            reflector.RegisterTypeToDatatype(typeof(bool?), new NullableBoolType().Datatype);
            reflector.RegisterTypeToDatatype(typeof(Int32?), new NullableInt32Type().Datatype);
            reflector.RegisterTypeToDatatype(typeof(Int32), new Int32Type().Datatype);
            reflector.RegisterTypeToDatatype(typeof(String), new StringType().Datatype);
            reflector.RegisterTypeToDatatype(typeof(List <>), new ListType().Datatype);
            reflector.RegisterTypeToDatatype(typeof(Dictionary <,>), new DictionaryType().Datatype);

            reflector.LoadSchemaAssembly(@"C:\Users\jeremy.lothian\OneDrive\Projects\Anvyl\Anvyl.Experimental.Library\bin\Debug\netcoreapp2.0\Anvyl.Experimental.Library.dll");


            var settings = new JsonSerializerSettings
            {
                ContractResolver = ShouldSerializeContractResolver.Instance,
                Formatting       = Formatting.Indented
            };
            StringBuilder sb = new StringBuilder();

            foreach (DataField df in reflector.FieldsForType)
            {
                Console.WriteLine(df.ToJson());
                sb.AppendLine(df.ToJson().TrimEnd() + ",");
            }
            File.WriteAllText("output.json", "{" + sb.ToString().TrimEnd().TrimEnd(',') + "}");
            //string serialized = JsonConvert.SerializeObject(reflector.FieldsForType, settings);
            //Console.WriteLine(serialized);
            //List<DataField> df = JsonConvert.DeserializeObject<List<DataField>>(serialized);
            //string serialized2 = JsonConvert.SerializeObject(df, settings);
            //if(serialized == serialized2)
            {
                //    Console.WriteLine("Sussesses!");
            }

            IConfigurationBuilder configurationBuilder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory());

            configurationBuilder.AddJsonFile("xpconfig.json");

            var configuration = configurationBuilder.Build();
            var asettings     = configuration.GetSection("Accufiguration").Get <AccufigurationSettings>();


            //validation
            var Validation = new ConfigurationValidationManager();

            Validation.RegisterValidator(new TestValidatorNullableInt32());

            var isValid = Validation.Validate(configuration.GetSection("Accufiguration"), reflector.FieldsForType[0]);

            //JsonExConfigurationProvider jsonProv = new JsonExConfigurationProvider(new JsonConfigurationSource());
            //jsonProv.Save(configuration, configuration, reflector.rootDataField, "**********[MARKED_FOR_DELETE]**********", "outNew.txt");
        }
Exemplo n.º 14
0
        public UCAppDomainEntry(ResourceView view)
        {
            this.view    = view;
            DialogResult = System.Windows.Forms.DialogResult.None;
            InitializeComponent();
            var loginTypes = view.GetLoginTypes();

            cmbLoginType.DataSource    = loginTypes;
            cmbLoginType.DisplayMember = AssemblyReflector.GetMemberName((LoginTypeDto m) => m.Title);
            cmbLoginType.ValueMember   = AssemblyReflector.GetMemberName((LoginTypeDto m) => m.LoginTypeId);
        }
Exemplo n.º 15
0
        public void ShouldLookTypesByName()
        {
            using (var assembly = new AssemblyReflector(@"NuDocTests.exe", new Mock <ILog>().Object))
            {
                Assert.That(assembly.LookupType("System.Guid"), Is.Null, "Lookup of a type which isn't in the assembly returns null.");

                var class1 = assembly.LookupType("TestData.Xyz.Foo.TestClass");
                Assert.That(class1, Is.Not.Null, "TestClass lookup succeeds.");

                var genericClass = assembly.LookupType("TestData.Xyz.Foo.TestGeneric`2");
                Assert.That(genericClass, Is.Not.Null, "Generic class lookup succeeds.");
            }
        }
Exemplo n.º 16
0
        private void treeServices_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var            node     = (TreeView)sender;
            ServiceJobView jobView  = new ServiceJobView();
            var            selected = (SdServiceCategoryDto)node.SelectedNode.Tag;

            if (selected != null)
            {
                var jobList = jobView.LoadServiceJobs(selected.ServiceCatId);
                lstJobs.DataSource    = jobList;
                lstJobs.DisplayMember = AssemblyReflector.GetMemberName((SdServiceJobDto c) => c.Title);
            }
        }
Exemplo n.º 17
0
        private void treeServices_AfterSelect(object sender, TreeViewEventArgs e)
        {
            var node = (TreeView)sender;

            var selected = (SdServiceCategoryDto)node.SelectedNode.Tag;

            if (selected != null)
            {
                lstJobs.Items.Clear();
                var jobList = jobView.LoadServiceJobs(selected.ServiceCatId);
                lstJobs.Items.AddRange(jobList.ToArray());
                lstJobs.DisplayMember = AssemblyReflector.GetMemberName((SdServiceJobDto c) => c.Title);
            }
        }
Exemplo n.º 18
0
        private void LoadData()
        {
            SdRequestStateDto all = new SdRequestStateDto()
            {
                StateTitle   = "همه",
                SdReqStateId = -1
            };
            var stateList = myView.bPresenter.GetStateList();

            stateList.Add(all);
            cmbState.DataSource    = stateList;
            cmbState.DisplayMember = AssemblyReflector.GetMemberName((SdRequestStateDto c) => c.StateTitle);
            cmbState.ValueMember   = AssemblyReflector.GetMemberName((SdRequestStateDto c) => c.SdReqStateId);
            LoadUserRequests();
        }
Exemplo n.º 19
0
        private void iGridToolBar1_NewRecord(object sender, EventArgs e)
        {
            BaseDataServicePresenter presenter = new BaseDataServicePresenter();

            var personels = presenter.getPersonelListByInd(22852); // چارت مدیریت آی تی


            ucExpertSelect = new UCItemListSelect <VwPersonelDto>(personels);
            List <ColumnDescriptor> column = new List <ColumnDescriptor>();

            column.Add(new ColumnDescriptor()
            {
                Name = AssemblyReflector.GetMemberName((VwPersonelDto m) => m.PerNo), Caption = "شماره پرسنلی "
            });
            column.Add(new ColumnDescriptor()
            {
                Name = AssemblyReflector.GetMemberName((VwPersonelDto m) => m.NationalNo), Caption = "کد ملی "
            });
            column.Add(new ColumnDescriptor()
            {
                Name = AssemblyReflector.GetMemberName((VwPersonelDto m) => m.PerFname), Caption = "نام "
            });
            column.Add(new ColumnDescriptor()
            {
                Name = AssemblyReflector.GetMemberName((VwPersonelDto m) => m.PerLname), Caption = "نام خانوادگی "
            });

            ucExpertSelect.AddColumnDescriptor(column);


            ISE.UILibrary.Utils.UIUtils.SetFrmTrans(ucExpertSelect, "فرم انتخاب کارشناس", FormBorderStyle.FixedDialog);
            if (ucExpertSelect.HasSelected)
            {
                var           selected = ucExpertSelect.SelectedItems.FirstOrDefault();
                SdItExpertDto expert   = new SdItExpertDto()
                {
                    Officeid  = cmbOffices.SelectedIndex + 1,
                    Userid    = selected.PerId,
                    Personel  = selected,
                    IsEnabled = true
                };
                if (officePresenter.AddExpert(expert))
                {
                    expBList.Add(expert);
                }
            }
        }
Exemplo n.º 20
0
        public virtual void Insert(List <TEntityDto> entityDtoList)
        {
            //   using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
            {
                try
                {
                    List <TEntity> insertedList = new List <TEntity>();
                    foreach (var entityDto in entityDtoList)
                    {
                        if (WcfCurrentContext.IsAuthenticated)
                        {
                            UserIdentity currentUser = WcfCurrentContext.CurrentUser;
                            var          perId       = int.Parse(currentUser.UserId);
                            AssemblyReflector.SetValue(entityDto, "InsertPerId", perId);
                        }
                        AssemblyReflector.SetValue(entityDto, "InsertDate", DateTime.Now);
                        TEntity entity = CurrentRepository.Create(entityDto);
                        insertedList.Add(entity);
                    }
                    CurrentRepository.SaveChanges();
                    //  scope.Complete();

                    if (insertedList.Count == entityDtoList.Count)
                    {
                        int index = 0;
                        foreach (var entityDto in entityDtoList)
                        {
                            var    entity = insertedList[index++];
                            object id     = AssemblyReflector.GetValue(entity, entityDto.PrimaryKeyName);
                            AssemblyReflector.SetValue(entityDto, entityDto.PrimaryKeyName, id);

                            entityDto.State = DtoObjectState.Inserted;
                        }
                    }
                }
                catch (Exception ex)
                {
                    foreach (var entityDto in entityDtoList)
                    {
                        entityDto.State = DtoObjectState.Ignore;
                        entityDto.Response.AddBusinessException(new Framework.Common.Service.Message.BusinessExceptionDto(Framework.Common.Service.Message.BusinessExceptionEnum.Operational, "در ورود اطلاعات به دیتابیس مشکل بوجود آمد!", ex.Message, ex.StackTrace));
                    }
                    ex.Data.Add("type", "db");
                    throw ex;
                }
            }
        }
Exemplo n.º 21
0
        public void ShouldGenerateSlashdocForPublicTypesAndMembersOnly()
        {
            var fileName = @"slashdoc.xml";

            File.Delete(fileName);

            using (var assembly = new AssemblyReflector(@"NuDocTests.exe", new Mock <ILog>().Object))
            {
                using (var slashdocStream = new FileStream(@"NuDocTests.xml", FileMode.Open, FileAccess.Read))
                {
                    SlashdocProcessor.WritePublicApiSlashdoc(assembly, slashdocStream, fileName);
                }
            }

            using (var xmlReader = XmlReader.Create(new FileStream(fileName, FileMode.Open, FileAccess.Read)))
            {
                var doc       = new XPathDocument(xmlReader);
                var navigator = doc.CreateNavigator();
                Assert.That(navigator.SelectSingleNode("/doc"), Is.Not.Null);
                Assert.That(navigator.SelectSingleNode("/doc/assembly/name/text()").Value, Is.EqualTo("NuDocTests"), "assembly name is preserved.");

                Assert.That(
                    InnerXmlWithoutWhitespace(navigator.SelectSingleNode("/doc/members/member[@name='T:TestData.Xyz.Foo.SlashdocTestClass']")),
                    Is.EqualTo("<summary>Aclass.</summary>"),
                    "slashdoc for the public type SlashdocTestClass is preserved.");
                Assert.That(
                    InnerXmlWithoutWhitespace(navigator.SelectSingleNode("/doc/members/member[@name='M:TestData.Xyz.Foo.SlashdocTestClass.DoSomething(System.DateTime)']")),
                    Is.EqualTo("<summary>IfIcouldonlyrememberwhat.</summary><paramname=\"when\">Andwhen.</param>"),
                    "slashdoc for the public member SlashdocTestClass.DoSomething is preserved.");
                Assert.That(
                    navigator.SelectSingleNode("/doc/members/member[@name='M:TestData.Xyz.Foo.SlashdocTestClass.PrivateMethod']"),
                    Is.Null,
                    "slashdoc for the private member SlashdocTestClass.PrivateMethod is NOT preserved.");

                Assert.That(
                    navigator.SelectSingleNode("/doc/members/member[@name='T:TestData.Xyz.Foo.InternalClass']"),
                    Is.Null,
                    "slashdoc for the non-public type InternalClass is NOT preserved.");

                Assert.That(navigator.SelectSingleNode("/doc/members/member[@name='T:No.Such.Type']"), Is.Null);
            }
        }
Exemplo n.º 22
0
        public void TestWrongUsage()
        {
            var extm = typeof(List <int>).GetExtensionsMethods(AssemblyReflector.GetLoadedAssemblies()).ToList();
            var enumerableSumMethod = extm.Where(x => x.Name == "Sum" && !x.IsGenericMethod).FirstOrDefault();
            var builder             = new MethodInvokerLambdaBuilder();

            //Assert.Throws<ArgumentNullException>(() => MethodInvokerBuilder<object>.BuildGenericInvoker(null));
            Assert.Throws <ArgumentNullException>(() => builder.BuildFromTypes(null));

            Assert.Throws <ArgumentException>(() => builder.BuildGenericStatic(typeof(TestTargetClass).GetMethod("VoidFoo")));
            //Assert.Throws<ArgumentException>(() => builder.BuildGenericExtension(typeof(TestTargetClass).GetMethod("Foo")));
            Assert.Throws <ArgumentException>(() => builder.BuildGenericStatic(typeof(TestTargetClass).GetMethod("Foo")));
            //Assert.Throws<ArgumentException>(() => builder.BuildGenericInstance(typeof(TestTargetClass).GetMethod("StaticFoo")));
            //Assert.Throws<ArgumentException>(() => MethodInvokerBuilder<object>.BuildInvoker(typeof(TestTargetClass).GetMethod("Foo"), true));

            //Assert.Throws<ArgumentException>(() => builder.BuildTypedInvokerExpression(typeof(TestTargetClass).GetMethod("Foo")));
            //Assert.Throws<ArgumentException>(() => builder.BuildTypedInvokerExpression(typeof(TestTargetClass).GetMethod("VoidFoo"),typeof(TestTargetClass),new[] { typeof(int), typeof(int) }, typeof(int))); //<Func<TestTargetClass, int, int, int>>
            //Assert.Throws<ArgumentException>(() => builder.BuildTypedInvokerExpression(enumerableSumMethod,null,new[] { typeof(int), typeof(int) }, typeof(bool))); //Func<int, int, bool>
            //Assert.Throws<ArgumentException>(() => builder.BuildTypedInvokerExpression(typeof(TestTargetClass).GetMethod("StaticFoo"), typeof(IEnumerable<int>),new[] { typeof(int) })); //Func<IEnumerable<int>, int>
        }
Exemplo n.º 23
0
        private void AddSubJob()
        {
            UCServiceJob frm = new UCServiceJob(jobView);

            ISE.UILibrary.Utils.UIUtils.SetFrmTrans(frm, "ایجاد زیر خدمت", FormBorderStyle.FixedDialog);
            if (frm.Result == DialogResult.OK)
            {
                if (frm.serviceJobList.Count > 0)
                {
                    var node = (TreeView)treeServices;

                    var selected = (SdServiceCategoryDto)node.SelectedNode.Tag;
                    if (selected != null)
                    {
                        lstJobs.Items.AddRange(frm.serviceJobList.ToArray());
                        lstJobs.DisplayMember = AssemblyReflector.GetMemberName((SdServiceJobDto c) => c.Title);
                    }
                }
            }
        }
Exemplo n.º 24
0
 public UCServiceCatJob(SdServiceCategoryJobDto serviceCatJob)
 {
     view = new ServiceCategoryJobView();
     InitializeComponent();
     cmbRoles.DataSource    = view.LoadRoles();
     cmbRoles.DisplayMember = AssemblyReflector.GetMemberName((SdItRoleDto c) => c.Title);
     cmbRoles.ValueMember   = AssemblyReflector.GetMemberName((SdItRoleDto c) => c.RoleId);
     this.serviceCatJob     = serviceCatJob;
     if (serviceCatJob != null)
     {
         txtActionId.Text       = serviceCatJob.Actionid.ToString();
         txtEstimateTime.Text   = serviceCatJob.Estimatetimecost.ToString();
         chkAttch.Checked       = serviceCatJob.HasAttachments;
         chkCreditDate.Checked  = serviceCatJob.HasCreditdates;
         chkDesc.Checked        = serviceCatJob.HasDescriptions;
         chkMulti.Checked       = serviceCatJob.IsMultipleReq;
         cmbRoles.SelectedValue = serviceCatJob.Roleid ?? 1;
         chkEnabled.Checked     = serviceCatJob.Enabled > 0;
         chkIsInserter.Checked  = serviceCatJob.IsInserters;
     }
 }
Exemplo n.º 25
0
        public UCAppDomainEntry(TransMode mode, ApplicationDomainDto appDomain, ResourceView view)
        {
            DialogResult = System.Windows.Forms.DialogResult.None;
            this.view    = view;
            InitializeComponent();
            this.mode = mode;
            this.ApplicationDomain = appDomain;
            var loginTypes = view.GetLoginTypes();

            cmbLoginType.DataSource    = loginTypes;
            cmbLoginType.DisplayMember = AssemblyReflector.GetMemberName((LoginTypeDto m) => m.Title);
            cmbLoginType.ValueMember   = AssemblyReflector.GetMemberName((LoginTypeDto m) => m.LoginTypeId);
            if (mode == TransMode.EditRecord || mode == TransMode.ViewRecord)
            {
                txtTitle.Text     = appDomain.Title;
                chkEnable.Checked = appDomain.IsEnabled;
                chkLock.Checked   = appDomain.IsLocked;
                if (appDomain.LoginTypeId != null)
                {
                    cmbLoginType.SelectedValue = appDomain.LoginTypeId;
                }
            }
        }
Exemplo n.º 26
0
        public static void MapProperty(TSource entity, TDestination destination, string propertyName)
        {
            var value = AssemblyReflector.GetValue(entity, propertyName);

            AssemblyReflector.SetValue(destination, propertyName, value);
        }
Exemplo n.º 27
0
        private void treeServices_AfterSelect(object sender, TreeViewEventArgs e)
        {
            string s = "";

            try
            {
                grpOwner.Enabled = false;
                var node = (TreeView)sender;
                if (node != null)
                {
                    var selected = (SdServiceCategoryDto)node.SelectedNode.Tag;
                    if (selected != null)
                    {
                        var jobList = jobView.LoadServiceJobs(selected.ServiceCatId, true);

                        lstJobs.DataSource = jobList;

                        lstJobs.DisplayMember = AssemblyReflector.GetMemberName((SdServiceJobDto c) => c.Title);

                        grpDeviceList.Enabled = selected.HasDevices;

                        btnSelectMenu.Enabled = selected.HasMenus;

                        txtMenu.Enabled = selected.HasMenus;

                        var filter = myView.baseDataPresenter.GetFilter(selected.ServiceCatId);

                        var job = (SdServiceJobDto)lstJobs.SelectedItem;
                        if (job != null)
                        {
                            var catJob = myView.cjPresenter.GetServiceCategoryJob(job.ServiceJobId, selected.ServiceCatId);

                            if (selected.HasDevices)
                            {
                                int objTypeId = -1;
                                if (filter != null)
                                {
                                    objTypeId = filter.Objecttypeid ?? -1;
                                }
                                //if (userInfo.ActionId == (int)RequestAction.All)
                                //{
                                //    LoadChartDevice(person.IndependentId.Value, objTypeId);
                                //}
                                //else
                                //{
                                //    LoadPersonDevice(userInfo.PerId, objTypeId);
                                //}
                                LoadPersonDevice(userInfo.PerId, objTypeId);
                            }
                            else
                            {
                                grpDeviceList.Visible = false;
                            }

                            if (!(catJob.IsInserter > 0))
                            {
                                grpDeviceList.Visible = false;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 28
0
        public static void Generate(string fileName, string namespaceToSearch, string directoryName, bool forceAttribute)
        {
            string[] files = Directory.GetFiles(Path.GetDirectoryName(fileName), "*.dll");

            string targetPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            foreach (string file in files)
            {
                if (!File.Exists(Path.Combine(targetPath, Path.GetFileName(file))))
                {
                    File.Copy(file, Path.Combine(targetPath, Path.GetFileName(file)));
                }
            }

            Assembly      assembly = Assembly.LoadFile(fileName);
            List <string> classes  = AssemblyReflector.ListClasses(assembly);

            Console.WriteLine("Directory is " + directoryName);

            // Search for this namespace
            string regexFind = "^" + namespaceToSearch.Replace(".", @"\.") + @"\.\w+$";

            foreach (string orgClassName in classes)
            {
                try
                {
                    // Ignore classes that doesn't exist in the given namespace
                    if (!Regex.Match(orgClassName, regexFind).Success)
                    {
                        Console.WriteLine(" Skip " + orgClassName); // togr

                        continue;
                    }

                    Type  orgType      = assembly.GetType(orgClassName);
                    Class reflectClass = ClassReflector.ReflectType(orgType, forceAttribute);

                    if (reflectClass == null)
                    {
                        Console.WriteLine(" Skip2 " + orgClassName); // togr
                        continue;
                    }

                    Console.WriteLine(" Generate " + orgClassName); // togr

                    string hibernateMap = HibernateMapGenerator.Generate(reflectClass);

                    string shortFileName  = string.Format(@"{0}.hbm.xml", reflectClass.Type.Name);
                    string outputFileName = string.Format(@"{0}\{1}", directoryName, shortFileName);

                    bool writeFile = true;

                    Console.WriteLine("file is " + outputFileName);

                    // Check if outputfile exist
                    if (File.Exists(outputFileName))
                    {
                        // Read contents
                        string existingContent = File.ReadAllText(outputFileName, Encoding.UTF8);

                        // Check if contents have changed
                        if (existingContent == hibernateMap)
                        {
                            writeFile = false;
                        }
                    }

                    if (writeFile)
                    {
                        try
                        {
                            if (File.Exists(outputFileName))
                            {
                                // Set attributes to Archive because file could be readonly
                                File.SetAttributes(outputFileName, FileAttributes.Archive);
                            }

                            // Write the file to disc
                            StreamWriter w = new StreamWriter(outputFileName, false, Encoding.UTF8);
                            w.Write(hibernateMap);
                            w.Close();
                            Console.WriteLine("Created file {0}", shortFileName);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Failed to create file {0} with exception {1}", shortFileName, ex);
                        }
                    }
                }
                catch (Exception outerEx)
                {
                    Console.WriteLine("Failed to generate code for class {0} with exception {1}", orgClassName, outerEx);
                }
            }
            Console.WriteLine("Done!");
        }
Exemplo n.º 29
0
        public void TestNonGenericMethodBuilders()
        {
            var extm = typeof(List <int>).GetExtensionsMethods(AssemblyReflector.GetLoadedAssemblies()).ToList();
            var enumerableSumMethod = extm.Where(x => x.Name == "Sum" && !x.IsGenericMethod).FirstOrDefault();
            var enumerableAddMethod = extm.Where(x => x.Name == "Add").FirstOrDefault();
            var l = new List <int>()
            {
                1, 2, 3
            };

            var extmethods    = typeof(TestTargetClass).GetExtensionsMethods();
            var extmethod     = extmethods.Where(x => x.Name == nameof(TargetTestClassExtensions.StaticExtensionFoo)).FirstOrDefault();
            var extmethodvoid = extmethods.Where(x => x.Name == nameof(TargetTestClassExtensions.StaticExtensionFooVoid)).FirstOrDefault();


            //var m1 = MethodInvokerBuilder.BuildInstanceInvoker(typeof(TestTargetClass).GetMethod("VoidFoo"));
            //var m2 = MethodInvokerBuilder.BuildInstanceInvoker(typeof(TestTargetClass).GetMethod("Foo"));
            //var m3 = MethodInvokerBuilder.BuildStaticInvoker(typeof(TestTargetClass).GetMethod("StaticFoo"));
            //var m4 = MethodInvokerBuilder.BuildExtensionAsInstanceInvoker(extmethod);
            //var m5 = MethodInvokerBuilder.BuildStaticInvoker(extmethod);
            //var m6 = MethodInvokerBuilder.BuildStaticInvoker(extmethodvoid);
            //var m7 = MethodInvokerBuilder.BuildExtensionAsInstanceInvoker(extmethodvoid);

            var builder = new MethodInvokerLambdaBuilder();
            var m1      = (GenericInstanceInvoker)builder.BuildGenericInstance(typeof(TestTargetClass).GetMethod("VoidFoo")).Compile();
            var m2      = (GenericInstanceInvoker)builder.BuildGenericInstance(typeof(TestTargetClass).GetMethod("Foo")).Compile();
            var m3      = (GenericStaticInvoker)builder.BuildGenericStatic(typeof(TestTargetClass).GetMethod("StaticFoo")).Compile();
            var m3b     = (GenericInstanceInvoker)builder.BuildGenericInstance(typeof(TestTargetClass).GetMethod("StaticFoo")).Compile();
            var m4      = (GenericInstanceInvoker)builder.BuildGenericInstance(extmethod).Compile();
            var m5      = (GenericStaticInvoker)builder.BuildGenericStatic(extmethod).Compile();
            var m6      = (GenericStaticInvoker)builder.BuildGenericStatic(extmethodvoid).Compile();
            var m7      = (GenericInstanceInvoker)builder.BuildGenericInstance(extmethodvoid).Compile();

            var e8 = builder.BuildGenericInstance(extmethodvoid);
            var d1 = (GenericInstanceInvoker)e8.CompileCached();
            var d2 = (GenericInstanceInvoker)e8.CompileCached();
            var d3 = (GenericInstanceInvoker)e8.CompileCached();
            var d4 = (GenericInstanceInvoker)e8.Compile();

            Assert.IsTrue((d1 == d2) && (d2 == d3));
            Assert.IsTrue(d4 != d1);


            var o         = new TestTargetClass();
            var nameValue = "Jim";
            var dateValue = DateTime.Now;
            var r1        = m1.Invoke(o, nameValue, dateValue);

            Assert.IsTrue(r1 == null && o.FirstName == nameValue && o.DOB == dateValue);

            var r2 = m2.Invoke(o, 2, 3);

            Assert.IsTrue(r2.GetType() == typeof(int) && (int)r2 == 5);

            var r3 = m3.Invoke(2, 2);

            Assert.IsTrue(r3 != null && r3.Equals(true));
            var r3b = m3b.Invoke(null, 3, 3);

            Assert.IsTrue(r3b != null && r3b.Equals(true));

            var r4 = m4.Invoke(o, nameValue);

            Assert.IsTrue(r4 != null && r4.Equals(true));

            var r5 = m5.Invoke(o, nameValue);

            Assert.IsTrue(r5 != null && r5.Equals(true));

            o.FirstName = "";
            var r6 = m6.Invoke(o, nameValue);

            Assert.IsTrue(r6 == null && o.FirstName.Equals(nameValue));

            o.FirstName = "";
            var r7 = m7.Invoke(o, nameValue);

            Assert.IsTrue(r7 == null && o.FirstName.Equals(nameValue));


            var m1t = builder.BuildFromDelegate <Action <TestTargetClass, string, DateTime> >(typeof(TestTargetClass).GetMethod("VoidFoo")).Compile();
            var m2t = builder.BuildFuncInstance <TestTargetClass, int, int, int>(typeof(TestTargetClass).GetMethod("Foo")).Compile();
            var m3t = builder.BuildFromDelegate <Func <int, int, bool> >(typeof(TestTargetClass).GetMethod("StaticFoo")).Compile();
            //var m4t = builder.BuildFuncInstance<IEnumerable<int>, int>(enumerableSumMethod).Compile();
            var m4t = builder.BuildFuncStatic <IEnumerable <int>, int>(enumerableSumMethod).Compile();

            var m2td = builder.BuildFromTypes(typeof(TestTargetClass).GetMethod("Foo")).Compile();
            var m3td = builder.BuildFromTypes(typeof(TestTargetClass).GetMethod("StaticFoo")).Compile();

            o = new TestTargetClass();
            var r1t = m1.Invoke(o, nameValue, dateValue);

            Assert.IsTrue(o.FirstName == nameValue && o.DOB == dateValue);

            var r2t = m2t.Invoke(o, 2, 3);

            Assert.IsTrue(r2t == 5);

            var r3t = m3t.Invoke(2, 2);

            Assert.IsTrue(r3t);

            var r4t = m4t.Invoke(l);

            Assert.IsTrue(r4t == 6);

            var r2td = m2td.DynamicInvoke(o, 2, 3);

            Assert.IsTrue((int)r2td == 5);

            var r3td = m3td.DynamicInvoke(2, 2);

            Assert.IsTrue((bool)r3td);

            var ctorBuilder = new ConstructorInvokerLambdaBuilder();
            var ctors       = typeof(TestTargetClass).GetConstructors();
            var ctor1       = ctors.First();
            var ctor2       = ctors.Skip(1).First();

            var c1 = ((Expression <Func <TestTargetClass> >)ctorBuilder.BuildFromTypes(ctor1)).Compile().Invoke();

            Assert.True(c1 != null && c1.GetType() == typeof(TestTargetClass));

            var c2 = ((Expression <Func <string, TestTargetClass> >)ctorBuilder.BuildFromTypes(ctor2)).Compile().Invoke("test");

            Assert.True(c2 != null && c2.GetType() == typeof(TestTargetClass) && c2.FirstName == "test");

            var ctorBuilder2 = new ConstructorInvokerLambdaBuilder();
            var ctors2       = typeof(TestTargetClass).GetConstructors();
            var ctor12       = ctors2.First();
            var m11          = ctorBuilder.BuildFromTypes(ctor12);
        }
Exemplo n.º 30
0
 private void InitUi()
 {
     cmbWork.DataSource    = basePresenter.GetWorkListByServiceCatJob(request.Servicecategoryjobid.Value, true);
     cmbWork.DisplayMember = AssemblyReflector.GetMemberName((SdWorkDto m) => m.Title);
     cmbWork.ValueMember   = AssemblyReflector.GetMemberName((SdWorkDto m) => m.WorkId);
 }