private string GenerateMemberDocId() { var sb = new StringBuilder(); // Get the full name from the type sb.Append(ParentType.ToString()); if (ParentType.IsArrayType) { sb.Append(ParentType.ArrayTypeInfo); } sb.Append("."); // Make sure that the member name is safe by replacing the unwanted characters. sb.Append(GetDocIdSafeMemberName(Name)); if (Kind == MemberKind.Method) { if (MethodSignature.GenericParameterCount > 0) { sb.Append($"``{MethodSignature.GenericParameterCount}"); } } // Add the method signature if (Kind == MemberKind.Method && MethodSignature.ParameterTypes.Count() > 0) { sb.Append("("); // Only required parameters should be listed explicitly Debug.Assert(MethodSignature.ParameterTypes.Count() >= MethodSignature.RequiredParameterCount, "More parameters were required than are available"); sb.Append(string.Join(",", MethodSignature.ParameterTypes.Select(m => m.ToString()).ToArray(), 0, MethodSignature.RequiredParameterCount)); // If the method is a varargs method, it should add an '__arglist' parameter if (MethodSignature.Header.CallingConvention.HasFlag(SignatureCallingConvention.VarArgs)) { sb.Append(",__arglist"); } sb.Append(")"); } else if (Kind == MemberKind.Method && MethodSignature.Header.CallingConvention.HasFlag(SignatureCallingConvention.VarArgs)) { // It's possible to have an __arglist without anything being passed to it sb.Append("(__arglist)"); } // Technically, we want to verify that these are marked as a special name along with the names op_Implicit or op_Explicit. However, // since we are just using member references, we don't have enought information to know if it is. For now, we will assume that it is // a special name if it only has one input parameter if (Kind == MemberKind.Method && MethodSignature.ParameterTypes.Length == 1 && (string.Equals(Name, "op_Implicit", StringComparison.Ordinal) || string.Equals(Name, "op_Explicit", StringComparison.Ordinal))) { sb.Append("~"); sb.Append(MethodSignature.ReturnType); } return(sb.ToString()); }
private int GetIdParentType(ParentType parentType) { int id = 0; try { sqlConnection = GetSqlConnection(); SqlCommand sql = new SqlCommand("SELECT ParentTypes.Id_Type from ParentTypes where(ParentTypes.[Name] = @ParentType)", sqlConnection); sqlConnection.Close(); sqlConnection.Open(); sql.Parameters.AddWithValue("@ParentType", parentType.ToString()); SqlDataReader sDR = sql.ExecuteReader(); if (sDR.HasRows) { while (sDR.Read()) { id = sDR.GetInt32(0); } } sqlConnection.Close(); } catch (System.Exception ex) { //DialogManager.showDialogError("Возможна ошибка базы данных! Проверьте!", "Внимание!"); Console.WriteLine(ex); } return(id); }
public List <Property> GetPropertyValues(ParentType parentType) { List <Property> list = new List <Property>(); try { sqlConnection = GetSqlConnection(); SqlCommand sql = new SqlCommand("SELECT Properties.Id_Property, [Values].Id_Parent, Id_Value, Properties.[Name], [Value], Properties.Unit from [Values] " + "left join ParentTypes on[Values].Id_ParentType = ParentTypes.Id_Type " + "left join Properties on[Values].Id_Property = Properties.Id_Property " + "WHERE (ParentTypes.[Name] = @ParentType)", sqlConnection); sqlConnection.Close(); sqlConnection.Open(); sql.Parameters.AddWithValue("@ParentType", parentType.ToString()); SqlDataReader sDR = sql.ExecuteReader(); if (sDR.HasRows) { while (sDR.Read()) { Property p = new Property(); p.Id = sDR.GetInt32(0); p.IdParent = sDR.GetInt32(1); p.Value.Id = sDR.GetInt32(2); p.Name = sDR.GetString(3); p.Value.value = sDR.GetDouble(4); p.Unit = sDR.GetString(5); list.Add(p); } } sqlConnection.Close(); } catch (System.Exception ex) { //DialogManager.showDialogError("Возможна ошибка базы данных! Проверьте!", "Внимание!"); Console.WriteLine(ex); } return(list); }
public override async Task <RepositoryResponse <FormPortalViewModel> > SaveModelAsync(bool isSaveSubModels = false, MixCmsContext _context = null, IDbContextTransaction _transaction = null) { UnitOfWorkHelper <MixCmsContext> .InitTransaction(_context, _transaction, out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot); try { var result = await base.SaveModelAsync(isSaveSubModels, context, transaction); if (result.IsSucceed && !string.IsNullOrEmpty(ParentId)) { var getNav = MixRelatedAttributeDatas.UpdateViewModel.Repository.CheckIsExists( m => m.DataId == Id && m.ParentId == ParentId && m.ParentType == ParentType.ToString() && m.Specificulture == Specificulture , context, transaction); if (!getNav) { var nav = new MixRelatedAttributeDatas.UpdateViewModel() { DataId = Id, Specificulture = Specificulture, AttributeSetId = AttributeSetId, AttributeSetName = AttributeSetName, ParentType = ParentType, ParentId = ParentId, Status = MixEnums.MixContentStatus.Published }; var saveResult = await nav.SaveModelAsync(false, context, transaction); if (!saveResult.IsSucceed) { result.IsSucceed = false; result.Exception = saveResult.Exception; result.Errors = saveResult.Errors; } } } UnitOfWorkHelper <MixCmsContext> .HandleTransaction(result.IsSucceed, isRoot, transaction); return(result); } catch (Exception ex) { return(UnitOfWorkHelper <MixCmsContext> .HandleException <FormPortalViewModel>(ex, isRoot, transaction)); } finally { if (isRoot) { ParseData(context, transaction); context.Dispose(); } } }
private void LoadComments() { CommentsDataSource ds = new CommentsDataSource(); Comments = new List <Comment>(CommentRepository.GetDatasetComments(DatasetId, ParentType.ToString(), Container)); }